]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_subs.qc
Merge branch 'master' of git://de.git.xonotic.org/xonotic/xonotic-data.pk3dir
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_subs.qc
index 500240d6ce4aee4c96220ee9dc9d4bec52ebf5e2..8ba71e4655822bc988c645cf0e354dd51a3d06ff 100644 (file)
@@ -698,6 +698,33 @@ void LODmodel_attach()
                        SetCustomizer(self, LOD_customize, LOD_uncustomize);
 }
 
+void ApplyMinMaxScaleAngles(entity e)
+{
+       if(e.angles_x != 0 || e.angles_z != 0 || self.avelocity_x != 0 || self.avelocity_z != 0) // "weird" rotation
+       {
+               e.maxs = '1 1 1' * vlen(
+                       '1 0 0' * max(-e.mins_x, e.maxs_x) +
+                       '0 1 0' * max(-e.mins_y, e.maxs_y) +
+                       '0 0 1' * max(-e.mins_z, e.maxs_z)
+               );
+               e.mins = -e.maxs;
+       }
+       else if(e.angles_y != 0 || self.avelocity_y != 0) // yaw only is a bit better
+       {
+               e.maxs_x = vlen(
+                       '1 0 0' * max(-e.mins_x, e.maxs_x) +
+                       '0 1 0' * max(-e.mins_y, e.maxs_y)
+               );
+               e.maxs_y = e.maxs_x;
+               e.mins_x = -e.maxs_x;
+               e.mins_y = -e.maxs_x;
+       }
+       if(e.scale)
+               setsize(e, e.mins * e.scale, e.maxs * e.scale);
+       else
+               setsize(e, e.mins, e.maxs);
+}
+
 void SetBrushEntityModel()
 {
        if(self.model != "")
@@ -707,10 +734,7 @@ void SetBrushEntityModel()
                InitializeEntity(self, LODmodel_attach, INITPRIO_FINDTARGET);
        }
        setorigin(self, self.origin);
-       if(self.scale)
-               setsize(self, self.mins * self.scale, self.maxs * self.scale);
-       else
-               setsize(self, self.mins, self.maxs);
+       ApplyMinMaxScaleAngles(self);
 }
 
 void SetBrushEntityModelNoLOD()
@@ -721,10 +745,7 @@ void SetBrushEntityModelNoLOD()
                setmodel(self, self.model); // no precision needed
        }
        setorigin(self, self.origin);
-       if(self.scale)
-               setsize(self, self.mins * self.scale, self.maxs * self.scale);
-       else
-               setsize(self, self.mins, self.maxs);
+       ApplyMinMaxScaleAngles(self);
 }
 
 /*
@@ -750,9 +771,7 @@ void InitTrigger()
 {
 // 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.
-       if (self.movedir == '0 0 0')
-       if (self.angles != '0 0 0')
-               SetMovedir ();
+       SetMovedir ();
        self.solid = SOLID_TRIGGER;
        SetBrushEntityModel();
        self.movetype = MOVETYPE_NONE;
@@ -764,9 +783,7 @@ void InitSolidBSPTrigger()
 {
 // 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.
-       if (self.movedir == '0 0 0')
-       if (self.angles != '0 0 0')
-               SetMovedir ();
+       SetMovedir ();
        self.solid = SOLID_BSP;
        SetBrushEntityModel();
        self.movetype = MOVETYPE_NONE; // why was this PUSH? -div0