Destroys physics body attached to an entity.
Takes entityHandle (entity with physics body from b3dCreatePhysicsBody).
Returns nothing.
3D Graphics
Parameters & Returns
Parameters
entityHandleInt
Returns
Void
Quick Summary
Destroys physics body attached to an entity.
Takes entityHandle (entity with physics body from b3dCreatePhysicsBody).
Returns nothing.
Technical Exegesis...
Destroys physics body attached to an entity, removing it from physics simulation. Takes entityHandle (entity handle from b3dLoadMesh/b3dCreateBox/etc that has physics body attached via b3dCreatePhysicsBody). Returns nothing. Removes Jolt physics body from physics world, freeing physics resources while keeping visual entity intact.
Destroys physics body attached to an entity, removing it from physics simulation. Takes entityHandle (entity handle from b3dLoadMesh/b3dCreateBox/etc that has physics body attached via b3dCreatePhysicsBody). Returns nothing. Removes Jolt physics body from physics world, freeing physics resources while keeping visual entity intact.
Physics body destruction: removes body from Jolt PhysicsSystem (no longer participates in collision detection, no longer affected by gravity/forces, no longer updates position/rotation), frees Jolt body memory (releases BodyID, removes from body storage), entity visual remains (entity still renderable, position/rotation manually controlled after destruction, no automatic physics updates). Use when physics no longer needed (deactivate physics for distant objects, convert from dynamic to kinematic via destruction and manual control).
Use cases: (1) LOD physics (destroy physics bodies for distant objects to improve performance, recreate when objects come close), (2) Cutscene mode (destroy physics to manually animate entity during cutscene, recreate physics when gameplay resumes), (3) Cleanup (destroy physics when entity no longer interactive, e.g. debris settling), (4) Conversion (destroy to switch from physics-based to script-based movement). Common patterns: destroy distant bodies (if distanceFromPlayer > 100 then b3dDestroyPhysicsBody), destroy settled debris (if velocity near zero for extended time then destroy physics).
Entity vs physics: entity and physics separate (destroying physics doesn't destroy entity, entity remains visible and renderable, physics only affects automatic position/rotation updates), recreate physics if needed (call b3dCreatePhysicsBody again to re-enable physics on same entity). Performance: reduces physics simulation cost (fewer bodies = faster PhysicsSystem::Update, typical gain 0.1-0.5ms per 100 bodies removed), reduces memory (frees Jolt body storage, BodyID returned to pool).
Validation: silently returns if entityHandle invalid (entity not found in g_entityMap), silently returns if entity has no physics body (no-op if physics never created or already destroyed), safe to call multiple times (subsequent calls no-op). Cleanup: automatically removes body from all physics structures (body handles, collision maps, simulation lists), no manual cleanup required.
Related: b3dCreatePhysicsBody creates physics body (inverse operation, re-enables physics on entity), b3dDisablePhysicsBody temporarily disables physics (alternative to destruction, physics body remains but inactive), b3dEnablePhysicsBody re-enables disabled physics body.
Example
Example.bam
; Create physics body
box = b3dCreateBox()
b3dCreatePhysicsBody(box, 1, 10.0, 0, 0, 0)
; Later, destroy physics when no longer needed
b3dDestroyPhysicsBody(box)
; LOD system - destroy distant physics bodiesFor i = 0To lastEntity
entity = entityList(i)
distance = EntityDistance(player, entity)
If distance > lodDistance Then
b3dDestroyPhysicsBody(entity)
EndIfNext; Cleanup settled debris after some timeIf debrisSettled And MilliSecs() > debrisTime + 5000Then
b3dDestroyPhysicsBody(debrisEntity)
EndIf