]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/csqcmodel_hooks.qc
player model LOD: fix origin, actually work
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / csqcmodel_hooks.qc
index 7204981bd4f3ee8d83806688af7c04fe97b3c74c..27fb70d86461ea1cee14ad79ac5fd8ee8a51afe1 100644 (file)
@@ -53,8 +53,8 @@ void CSQCPlayer_LOD_Apply(void)
        }
        else
        {
-               float distance = vlen(self.origin - other.origin);
-               float f = (distance + 100.0) * autocvar_cl_playerdetailreduction;
+               float distance = vlen(self.origin - view_origin);
+               float f = (distance * current_viewzoom + 100.0) * autocvar_cl_playerdetailreduction;
                f *= 1.0 / bound(0.01, view_quality, 1);
                if(f > autocvar_cl_loddistance2)
                        self.modelindex = self.lodmodelindex2;
@@ -117,6 +117,7 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer)
        {
                entity e;
                e = spawn();
+               precache_model(cvar_defstring("_cl_playermodel"));
                setmodel(e, cvar_defstring("_cl_playermodel"));
                forceplayermodels_goodmodel = e.model;
                forceplayermodels_goodmodelindex = e.modelindex;
@@ -207,8 +208,6 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer)
 .float csqcmodel_saveframe4;
 .float csqcmodel_framecount;
 
-.float csqcmodel_isdead; // for utility code
-
 #define IS_DEAD_FRAME(f) ((f) == 0 || (f) == 1)
 void CSQCPlayer_FallbackFrame_PreUpdate(void)
 {
@@ -229,7 +228,7 @@ void CSQCPlayer_FallbackFrame_PostUpdate(float isnew)
        if(isnew)
        {
 #define FIX_FRAMETIME(f,ft) \
-               if(IS_DEAD_FRAME(self.f)) \
+               if(IS_DEAD_FRAME(self.f) && self.ft != 0 && self.death_time != 0) \
                { \
                        self.ft = self.death_time; \
                }
@@ -244,6 +243,8 @@ float CSQCPlayer_FallbackFrame(float f)
 {
        if(frameduration(self.modelindex, f) > 0)
                return f; // goooooood
+       if(frameduration(self.modelindex, 1) <= 0)
+               return f; // this is a static model. We can't fix it if we wanted to
        switch(f)
        {
                case 23: return 11; // anim_melee -> anim_shoot
@@ -465,8 +466,9 @@ void CSQCPlayer_GlowMod_Apply(void)
                {
                        self.glowmod = self.glowmod * bound(0, 1 - (time - self.death_time) / autocvar_cl_deathglow, 1);
                        // prevent the zero vector
-                       if(self.glowmod_x == 0)
-                               self.glowmod_x = -1;
+                       self.glowmod_x = max(self.glowmod_x, 0.0001);
+                       self.glowmod_y = max(self.glowmod_y, 0.0001);
+                       self.glowmod_z = max(self.glowmod_z, 0.0001);
                }
 }