Jolt's Allocate/Reallocate/Free/AlignedAllocate/AlignedFree go to libc's malloc with the size in a 16-byte header, and atomic counters keep live bytes, the peak and the blocks asked for (its job threads allocate too). The fence reads the three exports extern_weak to judge Jolt by its plateau. jolt_heap_test: a ground in and out 1100 times holds 46,482,514 bytes after the first 100 and after all of them, the peak does not move, and a closed world gives back every byte it took. The macOS library is rebuilt; the Windows DLL still has to be rebuilt on the PC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
5.5 KiB
Text
54 lines
5.5 KiB
Text
# native.ludic - the shim's symbols (native/shim/jph_shim.cpp). A world and a shape are handles
|
|
# the package keeps; a body is an int id. None of this is exported.
|
|
extern function jph_world_new(max_bodies: int, threads: int) -> pointer = "jph_world_new"
|
|
extern function jph_world_free(w: pointer) -> void = "jph_world_free"
|
|
extern function jph_world_gravity(w: pointer, y: float) -> void = "jph_world_gravity"
|
|
extern function jph_world_step(w: pointer, dt: float, sub: int) -> int = "jph_world_step"
|
|
extern function jph_world_optimize(w: pointer) -> void = "jph_world_optimize"
|
|
extern function jph_world_bodies(w: pointer) -> int = "jph_world_bodies"
|
|
extern function jph_contacts_drain(w: pointer, ids: pointer, vals: pointer, cap: int) -> int = "jph_contacts_drain"
|
|
extern function jph_contacts_lost(w: pointer) -> int = "jph_contacts_lost"
|
|
extern function jph_shape_box(hx: float, hy: float, hz: float) -> pointer = "jph_shape_box"
|
|
extern function jph_shape_sphere(r: float) -> pointer = "jph_shape_sphere"
|
|
extern function jph_shape_capsule(half_h: float, r: float) -> pointer = "jph_shape_capsule"
|
|
extern function jph_shape_cylinder(half_h: float, r: float) -> pointer = "jph_shape_cylinder"
|
|
extern function jph_shape_dome(r: float, h: float) -> pointer = "jph_shape_dome"
|
|
extern function jph_shape_offset(s: pointer, x: float, y: float, z: float, yaw: float) -> pointer = "jph_shape_offset"
|
|
extern function jph_shape_convex(v: pointer, n: int, radius: float) -> pointer = "jph_shape_convex"
|
|
extern function jph_shape_scaled(s: pointer, k: float) -> pointer = "jph_shape_scaled"
|
|
extern function jph_shape_heightfield(h: pointer, n: int, ox: float, oz: float, cell: float) -> pointer = "jph_shape_heightfield"
|
|
extern function jph_shape_mesh(v: pointer, nv: int, tri: pointer, nt: int) -> pointer = "jph_shape_mesh"
|
|
extern function jph_shape_free(s: pointer) -> void = "jph_shape_free"
|
|
extern function jph_body_add(w: pointer, s: pointer, x: float, y: float, z: float, yaw: float, motion: int, layer: int, mass: float, friction: float, bounce: float) -> int = "jph_body_add"
|
|
extern function jph_body_remove(w: pointer, id: int) -> void = "jph_body_remove"
|
|
extern function jph_body_read(w: pointer, id: int, out: pointer) -> int = "jph_body_read"
|
|
extern function jph_body_place(w: pointer, id: int, x: float, y: float, z: float, yaw: float) -> void = "jph_body_place"
|
|
extern function jph_body_impulse(w: pointer, id: int, x: float, y: float, z: float) -> void = "jph_body_impulse"
|
|
extern function jph_body_velocity(w: pointer, id: int, x: float, y: float, z: float) -> void = "jph_body_velocity"
|
|
extern function jph_body_target(w: pointer, id: int, x: float, y: float, z: float, yaw: float, dt: float) -> void = "jph_body_target"
|
|
extern function jph_body_awake(w: pointer, id: int) -> int = "jph_body_awake"
|
|
extern function jph_body_buoyancy(w: pointer, id: int, sy: float, nx: float, ny: float, nz: float, buoy: float, lin: float, ang: float, cx: float, cz: float, dt: float) -> int = "jph_body_buoyancy"
|
|
extern function jph_ray(w: pointer, ox: float, oy: float, oz: float, dx: float, dy: float, dz: float, mask: int, out: pointer) -> int = "jph_ray"
|
|
extern function jph_top_at(w: pointer, x: float, z: float, r: float, from_y: float, depth: float, mask: int) -> float = "jph_top_at"
|
|
extern function jph_overlap(w: pointer, x: float, y: float, z: float, r: float, mask: int, ids: pointer, cap: int) -> int = "jph_overlap"
|
|
extern function jph_push(w: pointer, x: float, z: float, r: float, y0: float, y1: float, mask: int, out: pointer) -> int = "jph_push"
|
|
extern function jph_step_top(w: pointer, x: float, z: float, r: float, feet: float, reach: float, mask: int) -> float = "jph_step_top"
|
|
extern function jph_char_new(w: pointer, r: float, h: float, x: float, y: float, z: float, max_slope: float, mass: float) -> pointer = "jph_char_new"
|
|
extern function jph_char_free(k: pointer) -> void = "jph_char_free"
|
|
extern function jph_char_limits(k: pointer, step_up: float, stick: float, max_slope: float) -> void = "jph_char_limits"
|
|
extern function jph_char_step(w: pointer, k: pointer, dt: float, vx: float, vz: float, jump: float) -> int = "jph_char_step"
|
|
extern function jph_char_read(k: pointer, out: pointer) -> void = "jph_char_read"
|
|
extern function jph_char_place(w: pointer, k: pointer, x: float, y: float, z: float) -> void = "jph_char_place"
|
|
extern function jph_body_force(w: pointer, id: int, x: float, y: float, z: float) -> void = "jph_body_force"
|
|
extern function jph_body_torque(w: pointer, id: int, x: float, y: float, z: float) -> void = "jph_body_torque"
|
|
extern function jph_body_angular_impulse(w: pointer, id: int, x: float, y: float, z: float) -> void = "jph_body_angular_impulse"
|
|
extern function jph_body_spin(w: pointer, id: int, out: pointer) -> void = "jph_body_spin"
|
|
extern function jph_body_set_pose(w: pointer, id: int, x: float, y: float, z: float, qx: float, qy: float, qz: float, qw: float, vx: float, vy: float, vz: float) -> void = "jph_body_set_pose"
|
|
extern function jph_shape_heightfield_bspline(tex: pointer, n: int, ox: float, oz: float, cell: float) -> pointer = "jph_shape_heightfield_bspline"
|
|
extern function jph_heap_bytes() -> long = "jph_heap_bytes"
|
|
extern function jph_heap_peak() -> long = "jph_heap_peak"
|
|
extern function jph_heap_allocs() -> long = "jph_heap_allocs"
|
|
# what Jolt holds now, the most it has held, and the blocks it has asked for (counted in the shim)
|
|
export function phys_heap_bytes() -> long { return jph_heap_bytes() }
|
|
export function phys_heap_peak() -> long { return jph_heap_peak() }
|
|
export function phys_heap_allocs() -> long { return jph_heap_allocs() }
|