From: havoc Date: Fri, 25 Nov 2005 01:34:12 +0000 (+0000) Subject: SOLID_NOT is now linked into the areagrid, which fixed the bugs with corpses not... X-Git-Tag: xonotic-v0.1.0preview~4456 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=80bf4ebf5beea6eba76f5dd4f13c41d28241688c;p=xonotic%2Fdarkplaces.git SOLID_NOT is now linked into the areagrid, which fixed the bugs with corpses not riding lifts, and also means that findradius will find SOLID_NOT entities more often like the sv_gameplayfix_blowupfallenzombies was intended to reorganized and optimized the TOSS/FLY/BOUNCE/STEP physics for better handling of sv_gameplayfix_noairborncorpse git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5828 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/sv_phys.c b/sv_phys.c index 31f1e491..9873eb28 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -1200,22 +1200,25 @@ void SV_Physics_Toss (prvm_edict_t *ent) trace_t trace; vec3_t move; - // don't stick to ground if onground and moving upward - if (ent->fields.server->velocity[2] >= (1.0 / 32.0) && ((int)ent->fields.server->flags & FL_ONGROUND)) - ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND; - // if onground, return without moving if ((int)ent->fields.server->flags & FL_ONGROUND) { - if (ent->fields.server->groundentity == 0 || sv_gameplayfix_noairborncorpse.integer) - return; - // if ent was supported by a brush model on previous frame, - // and groundentity is now freed, set groundentity to 0 (floating) - if (ent->priv.server->suspendedinairflag && PRVM_PROG_TO_EDICT(ent->fields.server->groundentity)->priv.server->free) + // don't stick to ground if onground and moving upward + if (ent->fields.server->velocity[2] >= (1.0 / 32.0)) + ent->fields.server->flags -= FL_ONGROUND; + else { - // leave it suspended in the air - ent->fields.server->groundentity = 0; - return; + prvm_edict_t *ground = PRVM_PROG_TO_EDICT(ent->fields.server->groundentity); + if (ground->fields.server->solid == SOLID_BSP || !sv_gameplayfix_noairborncorpse.integer) + return; + // if ent was supported by a brush model on previous frame, + // and groundentity is now freed, set groundentity to 0 (floating) + if (ent->priv.server->suspendedinairflag && ground->priv.server->free) + { + // leave it suspended in the air + ent->fields.server->groundentity = 0; + return; + } } } ent->priv.server->suspendedinairflag = false; @@ -1315,23 +1318,38 @@ will fall if the floor is pulled out from under them. */ void SV_Physics_Step (prvm_edict_t *ent) { - // don't stick to ground if onground and moving upward - if (ent->fields.server->velocity[2] >= (1.0 / 32.0) && ((int)ent->fields.server->flags & FL_ONGROUND)) - ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND; - - // freefall if not onground/fly/swim - if (!((int)ent->fields.server->flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) + int flags = (int)ent->fields.server->flags; + // don't fall at all if fly/swim + if (!(flags & (FL_FLY | FL_SWIM))) { - int hitsound = ent->fields.server->velocity[2] < sv_gravity.value * -0.1; + if (flags & FL_ONGROUND) + { + // freefall if onground and moving upward + // freefall if not standing on a world surface (it may be a lift) + prvm_edict_t *ground = PRVM_PROG_TO_EDICT(ent->fields.server->groundentity); + if (ent->fields.server->velocity[2] >= (1.0 / 32.0) || (ground->fields.server->solid != SOLID_BSP && sv_gameplayfix_noairborncorpse.integer)) + { + ent->fields.server->flags -= FL_ONGROUND; + SV_AddGravity(ent); + SV_CheckVelocity(ent); + SV_FlyMove(ent, sv.frametime, NULL); + SV_LinkEdict(ent, true); + } + } + else + { + // freefall if not onground + int hitsound = ent->fields.server->velocity[2] < sv_gravity.value * -0.1; - SV_AddGravity(ent); - SV_CheckVelocity(ent); - SV_FlyMove(ent, sv.frametime, NULL); - SV_LinkEdict(ent, true); + SV_AddGravity(ent); + SV_CheckVelocity(ent); + SV_FlyMove(ent, sv.frametime, NULL); + SV_LinkEdict(ent, true); - // just hit ground - if (hitsound && (int)ent->fields.server->flags & FL_ONGROUND && gamemode != GAME_NEXUIZ) - SV_StartSound(ent, 0, "demon/dland2.wav", 255, 1); + // just hit ground + if (hitsound && (int)ent->fields.server->flags & FL_ONGROUND && gamemode != GAME_NEXUIZ) + SV_StartSound(ent, 0, "demon/dland2.wav", 255, 1); + } } // regular thinking diff --git a/world.c b/world.c index b367221d..0a9a5861 100644 --- a/world.c +++ b/world.c @@ -168,11 +168,11 @@ int SV_EntitiesInBox(vec3_t mins, vec3_t maxs, int maxlist, prvm_edict_t **list) sv_areagrid_stats_calls++; sv_areagrid_marknumber++; - igridmins[0] = (int) ((mins[0] + sv_areagrid_bias[0]) * sv_areagrid_scale[0]); - igridmins[1] = (int) ((mins[1] + sv_areagrid_bias[1]) * sv_areagrid_scale[1]); + igridmins[0] = (int) floor((mins[0] + sv_areagrid_bias[0]) * sv_areagrid_scale[0]); + igridmins[1] = (int) floor((mins[1] + sv_areagrid_bias[1]) * sv_areagrid_scale[1]); //igridmins[2] = (int) ((mins[2] + sv_areagrid_bias[2]) * sv_areagrid_scale[2]); - igridmaxs[0] = (int) ((maxs[0] + sv_areagrid_bias[0]) * sv_areagrid_scale[0]) + 1; - igridmaxs[1] = (int) ((maxs[1] + sv_areagrid_bias[1]) * sv_areagrid_scale[1]) + 1; + igridmaxs[0] = (int) floor((maxs[0] + sv_areagrid_bias[0]) * sv_areagrid_scale[0]) + 1; + igridmaxs[1] = (int) floor((maxs[1] + sv_areagrid_bias[1]) * sv_areagrid_scale[1]) + 1; //igridmaxs[2] = (int) ((maxs[2] + sv_areagrid_bias[2]) * sv_areagrid_scale[2]) + 1; igridmins[0] = max(0, igridmins[0]); igridmins[1] = max(0, igridmins[1]); @@ -222,6 +222,7 @@ int SV_EntitiesInBox(vec3_t mins, vec3_t maxs, int maxlist, prvm_edict_t **list) list[numlist] = ent; numlist++; } + // Con_Printf("%d %f %f %f %f %f %f : %d : %f %f %f %f %f %f\n", BoxesOverlap(mins, maxs, ent->fields.server->absmin, ent->fields.server->absmax), ent->fields.server->absmin[0], ent->fields.server->absmin[1], ent->fields.server->absmin[2], ent->fields.server->absmax[0], ent->fields.server->absmax[1], ent->fields.server->absmax[2], PRVM_NUM_FOR_EDICT(ent), mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2]); } sv_areagrid_stats_entitychecks++; } @@ -274,11 +275,11 @@ void SV_LinkEdict_AreaGrid(prvm_edict_t *ent) return; } - igridmins[0] = (int) ((ent->fields.server->absmin[0] + sv_areagrid_bias[0]) * sv_areagrid_scale[0]); - igridmins[1] = (int) ((ent->fields.server->absmin[1] + sv_areagrid_bias[1]) * sv_areagrid_scale[1]); + igridmins[0] = (int) floor((ent->fields.server->absmin[0] + sv_areagrid_bias[0]) * sv_areagrid_scale[0]); + igridmins[1] = (int) floor((ent->fields.server->absmin[1] + sv_areagrid_bias[1]) * sv_areagrid_scale[1]); //igridmins[2] = (int) ((ent->fields.server->absmin[2] + sv_areagrid_bias[2]) * sv_areagrid_scale[2]); - igridmaxs[0] = (int) ((ent->fields.server->absmax[0] + sv_areagrid_bias[0]) * sv_areagrid_scale[0]) + 1; - igridmaxs[1] = (int) ((ent->fields.server->absmax[1] + sv_areagrid_bias[1]) * sv_areagrid_scale[1]) + 1; + igridmaxs[0] = (int) floor((ent->fields.server->absmax[0] + sv_areagrid_bias[0]) * sv_areagrid_scale[0]) + 1; + igridmaxs[1] = (int) floor((ent->fields.server->absmax[1] + sv_areagrid_bias[1]) * sv_areagrid_scale[1]) + 1; //igridmaxs[2] = (int) ((ent->fields.server->absmax[2] + sv_areagrid_bias[2]) * sv_areagrid_scale[2]) + 1; if (igridmins[0] < 0 || igridmaxs[0] > AREA_GRID || igridmins[1] < 0 || igridmaxs[1] > AREA_GRID || ((igridmaxs[0] - igridmins[0]) * (igridmaxs[1] - igridmins[1])) > ENTITYGRIDAREAS) { @@ -385,8 +386,8 @@ void SV_LinkEdict (prvm_edict_t *ent, qboolean touch_triggers) ent->fields.server->absmax[2] += 1; } - if (ent->fields.server->solid == SOLID_NOT) - return; + //if (ent->fields.server->solid == SOLID_NOT) + // return; SV_LinkEdict_AreaGrid(ent);