From a7cd916ae4ce5a1cdd3ba9a877856220fb4d3bd9 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 25 Dec 2007 08:36:36 +0000 Subject: [PATCH] don't call SV_CheckWaterTransition on MOVETYPE_STEP entities unless the 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 | 5 +++++ sv_phys.c | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/progs.h b/progs.h index 69560224..5993d20d 100644 --- 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; diff --git a/sv_phys.c b/sv_phys.c index 6c6fd13a..8777ea00 100644 --- 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); + } } //============================================================================ -- 2.39.2