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
|
|
@ -4,6 +4,11 @@ import "ludic.physics"
|
|||
import "ludic.base"
|
||||
program HullShapeTest {
|
||||
numbers float
|
||||
function ray(physics_st: mut PhysicsState, ox: float, oy: float, oz: float, dx: float, dy: float, dz: float, mask: int) -> PhysHit {
|
||||
let h = new PhysHit
|
||||
phys_ray(physics_st, ox, oy, oz, dx, dy, dz, mask, h)
|
||||
return h
|
||||
}
|
||||
|
||||
# a cube two metres across, its centre two metres along x from its origin
|
||||
function cube(physics_st: mut PhysicsState) -> int {
|
||||
|
|
@ -15,7 +20,7 @@ program HullShapeTest {
|
|||
}
|
||||
return phys_convex(physics_st, v, 8)
|
||||
}
|
||||
function down(physics_st: mut PhysicsState, x: float, z: float) -> PhysHit { return phys_ray(physics_st, x, 10.0, z, 0.0, -20.0, 0.0, PHYS_M_ALL) }
|
||||
function down(physics_st: mut PhysicsState, x: float, z: float) -> PhysHit { return ray(physics_st, x, 10.0, z, 0.0, -20.0, 0.0, PHYS_M_ALL) }
|
||||
|
||||
test "a hull stands where its points are, and too few points are no shape" (physics_st: mut PhysicsState) {
|
||||
expect(phys_open(physics_st, 16, 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue