From 7c82443dc33d8bca7b904e131033bb312c800d1a Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Sat, 15 Jul 2023 22:27:42 +1000 Subject: [PATCH] NudgeOutOfSolid: fix "random" failures on slightly inclined planes History: This epsilon value was first added to the nudge distance in 31e7715cffcebfd400b8473f3b2d3dc80937fc5a and was replaced with bbox expansion in 25c09ca585e81bf9eb236a339ae5dcd64f63b679 With the expansion approach we need to compare to separation to make "good location" detection reliable, partly to avoid float precision problems, partly to avoid compatibility problems with normal TraceBox. For example: we drop an entity to floor successfully with TraceBox, but then NudgeOutOfSolid decides it's in solid. Also updated the startsolid conditions to suit the 2-pass approach. Signed-off-by: bones_was_here --- phys.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phys.c b/phys.c index 1e602a1f..bf6c525d 100644 --- a/phys.c +++ b/phys.c @@ -55,7 +55,10 @@ int PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent) else stucktrace = CL_TraceBox(stuckorigin, stuckmins, stuckmaxs, stuckorigin, pass ? MOVE_WORLDONLY : MOVE_NOMONSTERS, ent, SV_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value, pass ? false : true, false, NULL, false); - if (!stucktrace.bmodelstartsolid || stucktrace.startdepth >= 0) + // Separation compared here to ensure a good location will be recognised reliably. + if (-stucktrace.startdepth <= separation + || (!stucktrace.bmodelstartsolid && !stucktrace.worldstartsolid) + || (pass && !stucktrace.worldstartsolid)) { // found a good location, use it VectorCopy(stuckorigin, PRVM_serveredictvector(ent, origin)); -- 2.39.2