]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
don't call SV_CheckWaterTransition on MOVETYPE_STEP entities unless the
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 25 Dec 2007 08:36:36 +0000 (08:36 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 25 Dec 2007 08:36:36 +0000 (08:36 +0000)
entity moves (or a pusher moves through the area)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7860 d7cf8633-e32d-0410-b094-e92efae38249

progs.h
sv_phys.c

diff --git a/progs.h b/progs.h
index 695602240e62557d5c71badd9014a763d82e4d84..5993d20d36a07b8f147e4a763cfb7002f7c4f475 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -55,6 +55,11 @@ typedef struct edict_engineprivate_s
 
        // LordHavoc: gross hack to make floating items still work
        int suspendedinairflag;
+
+       // cached position to avoid redundant SV_CheckWaterTransition calls on monsters
+       qboolean waterposition_forceupdate; // force an update on this entity (set by SV_PushMove code for moving water entities)
+       vec3_t waterposition_origin; // updates whenever this changes
+
        // used by PushMove to keep track of where objects were before they were
        // moved, in case they need to be moved back
        vec3_t moved_from;
index 6c6fd13aa29487a5f9370b481bece079d61b85d0..8777ea00a34a7ece5d9e6a822877a5b9bad05f82 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -1191,6 +1191,9 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
                 || check->fields.server->movetype == MOVETYPE_FAKEPUSH)
                        continue;
 
+               // tell any MOVETYPE_STEP entity that it may need to check for water transitions
+               check->priv.server->waterposition_forceupdate = true;
+
                // if the entity is standing on the pusher, it will definitely be moved
                // if the entity is not standing on the pusher, but is in the pusher's
                // final position, move it
@@ -1973,6 +1976,7 @@ void SV_Physics_Step (prvm_edict_t *ent)
                                SV_CheckVelocity(ent);
                                SV_FlyMove(ent, sv.frametime, NULL, SV_GenericHitSuperContentsMask(ent));
                                SV_LinkEdict(ent, true);
+                               ent->priv.server->waterposition_forceupdate = true;
                        }
                }
                else
@@ -1988,13 +1992,20 @@ void SV_Physics_Step (prvm_edict_t *ent)
                        // just hit ground
                        if (hitsound && (int)ent->fields.server->flags & FL_ONGROUND && sv_sound_land.string)
                                SV_StartSound(ent, 0, sv_sound_land.string, 255, 1);
+                       ent->priv.server->waterposition_forceupdate = true;
                }
        }
 
 // regular thinking
-       SV_RunThink(ent);
+       if (!SV_RunThink(ent))
+               return;
 
-       SV_CheckWaterTransition(ent);
+       if (ent->priv.server->waterposition_forceupdate || !VectorCompare(ent->fields.server->origin, ent->priv.server->waterposition_origin))
+       {
+               ent->priv.server->waterposition_forceupdate = false;
+               VectorCopy(ent->fields.server->origin, ent->priv.server->waterposition_origin);
+               SV_CheckWaterTransition(ent);
+       }
 }
 
 //============================================================================