ludic.wildlife: a climb is judged over half a metre ahead, not one frame's step

17.10 found almost every animal turn-back was for a climb, where the navmesh (40-45 degrees) is stricter than the step's 1.2 per metre. So the frame-sized test was refusing a few centimetres of steep ground: a pebble a walker steps across. It also refused sooner the faster the frame rate. wl_climb takes the ground half a metre ahead along the way the step actually goes. climb_test holds it at 60 and 240 Hz: a pebble is crossed and a wall is not. Both tests fail under the old rule. wildlife 24/24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 23:52:49 +03:00
parent 74006849b5
commit b1fff7c921
2 changed files with 82 additions and 1 deletions

View file

@ -20,6 +20,16 @@ export function wildlife_turned(wildlife_st: WildlifeState) -> int { return wild
export function wildlife_turned_wet(wildlife_st: WildlifeState) -> int { return wildlife_st.wl_turned_wet }
export function wildlife_turned_steep(wildlife_st: WildlifeState) -> int { return wildlife_st.wl_turned_steep }
# a climb is judged over half a metre ahead, not one frame's step: a few centimetres of the drawn
# ground rise steeply over a pebble a walker steps across, and a frame's step shrinks with the rate
const WL_LOOK: float = 0.5
function wl_climb(a: WildAnimal, nx: float, nz: float) -> float {
let dx = nx - a.x
let dz = nz - a.z
let l = Math.sqrt(dx * dx + dz * dz)
return WildlifeWorld.ground(a.x + dx / l * WL_LOOK, a.z + dz / l * WL_LOOK) - a.y
}
function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bool {
let d = a.speed * dt
if d < 0.0001 { return false }
@ -33,7 +43,7 @@ function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bo
let nh = WildlifeWorld.ground(nx, nz)
let moved = Math.abs(nx - a.x) + Math.abs(nz - a.z)
let wet = nh < WildlifeWorld.water(nx, nz) + 0.6
let steep = nh - a.y > d * 1.2
let steep = moved > 0.0001 and wl_climb(a, nx, nz) > WL_LOOK * 1.2
if wet or steep or moved < d * 0.2 {
if wet { wildlife_st.wl_turned_wet += 1 } else if steep { wildlife_st.wl_turned_steep += 1 }
a.yaw = a.yaw + Math.deg_to_rad(75.0)