Creates Jolt HeightFieldShape physics for terrain (optimized for terrain collision, much faster than mesh).
Takes entity (terrain entity handle).
Returns physics body handle (0 if failed).
3D Graphics
Parameters & Returns
Parameters
entityInt
Returns
Int
Quick Summary
Creates Jolt HeightFieldShape physics for terrain (optimized for terrain collision, much faster than mesh).
Takes entity (terrain entity handle).
Returns physics body handle (0 if failed).
Technical Exegesis...
Creates Jolt HeightFieldShape physics for terrain (optimized for terrain collision, much faster than mesh). Takes entity (terrain entity handle). Returns physics body handle (0 if failed). Creates HeightFieldShape from heightmap data (width x height samples, spatial acceleration), creates static body (EMotionType::Static, layer 0 NON_MOVING), adds to Jolt system. Use for character walking on terrain, vehicle collision, object placement, or raycasting against terrain.
Creates Jolt HeightFieldShape physics for terrain (optimized for terrain collision, much faster than mesh). Takes entity (terrain entity handle). Returns physics body handle (0 if failed). Creates HeightFieldShape from heightmap data (width x height samples, spatial acceleration), creates static body (EMotionType::Static, layer 0 NON_MOVING), adds to Jolt system. Use for character walking on terrain, vehicle collision, object placement, or raycasting against terrain. HeightFieldShape optimized for terrain (O(log N) queries vs O(N) mesh, spatial grid acceleration), handles large heightmaps efficiently (millions of height samples, fast collision). Height data processing: inverts heightmap (1.0 - height, matches GPU shader), negates Y (converts Y- up internal to Y+ up physics), applies entity scale (scaleY multiplies height, scaleX/Z define sample spacing). Sample spacing: scaleX / (width - 1) for X spacing (world units between samples), scaleZ / (height - 1) for Z spacing, closer samples = higher precision collision. Static body: terrain doesn't move (fixed position, EActivation::DontActivate), layer 0 (static NON_MOVING layer, collides with dynamic objects), positioned at entity.position (terrain origin in world space). Use cases: character controllers walk on terrain, vehicles drive on terrain, physics objects rest on terrain, raycasts query terrain height. Performance: O(log N) collision queries (spatial grid acceleration, very fast), supports large terrains (1024x1024 or larger, negligible cost), much faster than MeshShape (optimized specifically for height fields). Validation: returns 0 if entity not terrain (invalid handle or wrong type), returns 0 if physics system not initialized (g_physicsSystem null), silent failure. Related: b3dCreateTerrain creates terrain entity (call first, then add physics), b3dTerrainHeight queries height (CPU-side height query, complements physics collision), b3dCreatePhysicsBody creates mesh physics (alternative for non-terrain meshes).