Physics in Nu - bryanedds/Nu GitHub Wiki
NOTE: mention how center of mass offsets are non-existent in Nu's 3D due to this issue: https://github.com/bryanedds/Nu/issues/575
TODO: basic content.
Nu has two physics engines, AetherPhysics for 2D and Bullet Physics for 3D.
The most recent manual for Bullet Physics I've found is here -
https://github.com/bulletphysics/bullet3/blob/master/docs/Bullet_User_Manual.pdf
Fast Imperative Physics Behind a Purely Functional API?
This might seem impossible, but with a technique we developed, it is actually entirely possible to wrap any imperative representation behind a purely functional API so long as it can support certain operations -
TODO: more detail.
Collision Events are Opt-In
If you want to be able to handle an entity's collision events, you must set its Observable property to true. The reason that this is opt-in is purely for efficiency - the engine doesn't want to publish any collision events that the user won't utilize. So if you're not getting the collision events you're expecting, make sure that the entity's Observable property is set to true!
Collision Message Filtering by BodyIndex
Bodies that are created with BodyIndex = -1 (Constants.Physics.InternalIndex) will NOT produce physics messages / event when collided with another body with BodyIndex = -1. This is an optimization and is true by default for all of the out-of-the-box physics entities. So if you need to build a new dispatcher that needs custom physics behavior, be sure to define its BodyIndex property like -
computed Entity.BodyId (fun (entity : Entity) _ -> { BodySource = entity; BodyIndex = 0 }) None
where BodyIndex is 0 or higher.
HOWEVER, when you use a BodyIndex <> -1, then you will also need to handle physics transform events yourself, as the engine must assume that it cannot do so itself.
Synchronized or Manual Physics Motion
You can set the PhysicsMotion
property of a physics-based entity to ManualMotion
to prevent changes to the entity's transformation properties from being automatically synchronized with the physics backend. However, enabling ManualMotion
also means that whenever you need to change the physical transformation of such an entity, you must do so via a function call such as World.setBodyCenter
. Changing an entity's transformation via its transform property will have no effect on its physical representation when in ManualMotion.
TODO: more detail.