From: Mario Date: Sat, 28 Dec 2019 18:22:29 +0000 (+1000) Subject: Rotate .obj entity models 180 degrees around the Y axis, workaround for an engine bug X-Git-Tag: xonotic-v0.8.5~1173 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9e00d155e29b6312fdb98326d55bce9f50c81103;p=xonotic%2Fxonotic-data.pk3dir.git Rotate .obj entity models 180 degrees around the Y axis, workaround for an engine bug --- diff --git a/qcsrc/common/mapobjects/func/breakable.qc b/qcsrc/common/mapobjects/func/breakable.qc index 32926d490..e92af677c 100644 --- a/qcsrc/common/mapobjects/func/breakable.qc +++ b/qcsrc/common/mapobjects/func/breakable.qc @@ -343,7 +343,7 @@ spawnfunc(func_breakable) this.dmg_force = 200; this.mdl = this.model; - SetBrushEntityModel(this); + SetBrushEntityModel(this, true); if(this.spawnflags & BREAKABLE_NODAMAGE) this.use = func_breakable_destroy; diff --git a/qcsrc/common/mapobjects/func/rainsnow.qc b/qcsrc/common/mapobjects/func/rainsnow.qc index c765a4293..644194c35 100644 --- a/qcsrc/common/mapobjects/func/rainsnow.qc +++ b/qcsrc/common/mapobjects/func/rainsnow.qc @@ -36,7 +36,7 @@ spawnfunc(func_rain) this.angles = '0 0 0'; set_movetype(this, MOVETYPE_NONE); this.solid = SOLID_NOT; - SetBrushEntityModel(this); + SetBrushEntityModel(this, true); if (!this.cnt) { this.cnt = 12; @@ -76,7 +76,7 @@ spawnfunc(func_snow) this.angles = '0 0 0'; set_movetype(this, MOVETYPE_NONE); this.solid = SOLID_NOT; - SetBrushEntityModel(this); + SetBrushEntityModel(this, true); if (!this.cnt) { this.cnt = 12; diff --git a/qcsrc/common/mapobjects/models.qc b/qcsrc/common/mapobjects/models.qc index 44a13522a..18d033663 100644 --- a/qcsrc/common/mapobjects/models.qc +++ b/qcsrc/common/mapobjects/models.qc @@ -168,7 +168,7 @@ bool g_clientmodel_genericsendentity(entity this, entity to, int sf) #define G_MODEL_INIT(ent,sol) \ if(ent.geomtype && autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS); \ if(!ent.scale) ent.scale = ent.modelscale; \ - SetBrushEntityModel(ent); \ + SetBrushEntityModel(ent,true); \ ent.use = g_model_setcolormaptoactivator; \ InitializeEntity(ent, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \ if(!ent.solid) ent.solid = (sol); \ @@ -177,7 +177,7 @@ bool g_clientmodel_genericsendentity(entity this, entity to, int sf) #define G_CLIENTMODEL_INIT(ent,sol) \ if(ent.geomtype && autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS); \ if(!ent.scale) ent.scale = ent.modelscale; \ - SetBrushEntityModel(ent); \ + SetBrushEntityModel(ent,true); \ ent.use = g_clientmodel_use; \ InitializeEntity(ent, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \ if(!ent.solid) ent.solid = (sol); \ diff --git a/qcsrc/common/mapobjects/subs.qc b/qcsrc/common/mapobjects/subs.qc index f9e50dcf8..9adccb492 100644 --- a/qcsrc/common/mapobjects/subs.qc +++ b/qcsrc/common/mapobjects/subs.qc @@ -398,7 +398,7 @@ void ApplyMinMaxScaleAngles(entity e) setsize(e, e.mins, e.maxs); } -void SetBrushEntityModel(entity this) +void SetBrushEntityModel(entity this, bool with_lod) { if(this.model != "") { @@ -412,26 +412,11 @@ void SetBrushEntityModel(entity this) } else _setmodel(this, this.model); // no precision needed - InitializeEntity(this, LODmodel_attach, INITPRIO_FINDTARGET); - } - setorigin(this, this.origin); - ApplyMinMaxScaleAngles(this); -} + if(with_lod) + InitializeEntity(this, LODmodel_attach, INITPRIO_FINDTARGET); -void SetBrushEntityModelNoLOD(entity this) -{ - if(this.model != "") - { - precache_model(this.model); - if(this.mins != '0 0 0' || this.maxs != '0 0 0') - { - vector mi = this.mins; - vector ma = this.maxs; - _setmodel(this, this.model); // no precision needed - setsize(this, mi, ma); - } - else - _setmodel(this, this.model); // no precision needed + if(endsWith(this.model, ".obj")) // WORKAROUND: darkplaces currently rotates .obj models on entities incorrectly, we need to add 180 degrees to the Y axis + this.angles_y = anglemods(this.angles_y - 180); } setorigin(this, this.origin); ApplyMinMaxScaleAngles(this); @@ -553,7 +538,7 @@ void InitTrigger(entity this) // to mean no restrictions, so use a yaw of 360 instead. SetMovedir(this); this.solid = SOLID_TRIGGER; - SetBrushEntityModelNoLOD(this); + SetBrushEntityModel(this, false); set_movetype(this, MOVETYPE_NONE); this.modelindex = 0; this.model = ""; @@ -565,7 +550,7 @@ void InitSolidBSPTrigger(entity this) // to mean no restrictions, so use a yaw of 360 instead. SetMovedir(this); this.solid = SOLID_BSP; - SetBrushEntityModelNoLOD(this); + SetBrushEntityModel(this, false); set_movetype(this, MOVETYPE_NONE); // why was this PUSH? -div0 // this.modelindex = 0; this.model = ""; @@ -576,7 +561,7 @@ bool InitMovingBrushTrigger(entity this) // trigger angles are used for one-way touches. An angle of 0 is assumed // to mean no restrictions, so use a yaw of 360 instead. this.solid = SOLID_BSP; - SetBrushEntityModel(this); + SetBrushEntityModel(this, true); set_movetype(this, MOVETYPE_PUSH); if(this.modelindex == 0) { diff --git a/qcsrc/common/mapobjects/subs.qh b/qcsrc/common/mapobjects/subs.qh index 861d73e72..c1d4d06e5 100644 --- a/qcsrc/common/mapobjects/subs.qh +++ b/qcsrc/common/mapobjects/subs.qh @@ -115,9 +115,7 @@ void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, #ifdef SVQC void ApplyMinMaxScaleAngles(entity e); -void SetBrushEntityModel(entity this); - -void SetBrushEntityModelNoLOD(entity this); +void SetBrushEntityModel(entity this, bool with_lod); int autocvar_loddebug; .string lodtarget1;