ludic.physics: queries fill a record the caller keeps, and allocate nothing
phys_pose, phys_ray, phys_push and phys_walker_pose each made a new record per call, some several times a frame, and Ludic never gives one back. They now fill the caller's PhysPose / PhysHit / PhysPush / PhysWalk and return whether they found anything. phys_overlap returns a count; phys_overlap_id(i) reads each id back. The package's own uses (phys_resolve, phys_row, phys_walker_move) read the values buffer directly. Tests take small allocating helpers. physics 20, character 15, vehicles 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b6c4d703a2
commit
f048ffb6ac
11 changed files with 140 additions and 87 deletions
|
|
@ -7,6 +7,11 @@ import "ludic.base"
|
|||
import "ludic.physics"
|
||||
program CharacterTest {
|
||||
numbers float
|
||||
function wpose(physics_st: mut PhysicsState, id: int) -> PhysWalk {
|
||||
let p = new PhysWalk
|
||||
if not phys_walker_pose(physics_st, id, p) { return null }
|
||||
return p
|
||||
}
|
||||
|
||||
# the world: x in 4..8 is a deck 45 cm up; z < -10 a cliff; z > 10 a gentle rise; x > 20 the lake
|
||||
function fk_height(x: float, z: float) -> float {
|
||||
|
|
@ -87,7 +92,7 @@ program CharacterTest {
|
|||
function fk_walk(physics_st: mut PhysicsState, character_test_st: mut CharacterTestState, x: float, y: float, z: float, vx: float, vz: float, jump: float, step: float, slope: float, dt: float) -> int {
|
||||
if character_test_st.walker < 0 { character_test_st.walker = fk_jolt(physics_st) }
|
||||
let g = phys_walker_move(physics_st, character_test_st.walker, x, y, z, vx, vz, jump, step, slope, dt)
|
||||
let p = phys_walker_pose(physics_st, character_test_st.walker)
|
||||
let p = wpose(physics_st, character_test_st.walker)
|
||||
character_test_st.wx = p.x
|
||||
character_test_st.wy = p.y
|
||||
character_test_st.wz = p.z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue