|
world - live explicit physics world entity - entity with no existing explicit or classic physics owner Pending EntityPhysics or backend-1 Collisions participation also reserves the entity; remove those claims first. body_type (optional) - 0 static, 1 kinematic, 2 dynamic (default) |
|
Creates a body that allows fast rotation, and returns its handle. Creates and returns an entity-owned body with the native allowFastRotation creation flag enabled. Otherwise ownership, entity synchronisation, collider authoring, body modes and teardown follow CreatePhysicsBody. Existing CreatePhysicsBody behaviour and its required body_type argument are unchanged. The native solver normally caps angular displacement to π/4 radians per whole StepPhysics interval; at 1/60 s this is about 47.12 rad/s. This constructor opts out of that angular-speed cap. It does not change the world linear-speed cap, forces, inertia, damping, motion locks or bullet setting. Use this for circular shapes such as rapidly spinning wheels. Fast rotation of non-circular colliders is not guaranteed to have accurate continuous collision. Collision and solver constraints may still change angular velocity. Kinematic bodies retain the existing entity-target driving policy. This flag cannot be changed on a live body in the pinned library. It survives reset, disable/re-enable and body-type changes. To choose a different policy, explicitly destroy/recreate the body and its dependent resources. The native flag is included in recordings; render entities and script data are not. Ordinary world/body arguments must be live handles of the correct kind; invalid or stale handles raise a runtime error. Mutations are rejected while the owning world is stepping. See also: CreatePhysicsBody, PhysicsBodyAllowsFastRotation, PhysicsBodyBullet, PhysicsWorldMaxSpeed. |
; CreatePhysicsFastBody Example
; -----------------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
Const PHYSICS_STATIC=0
Const PHYSICS_DYNAMIC=2
camera=CreateCamera()
PositionEntity camera,0,3,-7
RotateEntity camera,20,0,0
light=CreateLight()
RotateEntity light,45,-30,0
AmbientLight 60,60,60
; An independent Box3D world with standard gravity
world=CreatePhysicsWorld()
; Blue static floor
ground=CreateCube()
ScaleEntity ground,6,0.5,6
PositionEntity ground,0,-0.5,0
EntityColor ground,80,160,255
ground_body=CreatePhysicsBody(world,ground,PHYSICS_STATIC)
ground_shape=PhysicsBodyBox(ground_body,12,1,12)
; Two floating rotors: an ordinary body, and a fast-rotation body
slow=CreateCube()
ScaleEntity slow,1.5,0.05,0.2
PositionEntity slow,-2,2,0
EntityColor slow,120,200,140
slow_body=CreatePhysicsBody(world,slow,PHYSICS_DYNAMIC)
fast=CreateCube()
ScaleEntity fast,1.5,0.05,0.2
PositionEntity fast,2,2,0
EntityColor fast,255,120,70
; CreatePhysicsFastBody lifts the solver's cap on turning per step
fast_body=CreatePhysicsFastBody(world,fast,PHYSICS_DYNAMIC)
PhysicsBodyGravityScale slow_body,0
PhysicsBodyGravityScale fast_body,0
slow_shape=PhysicsBodyBox(slow_body,3,0.1,0.4)
fast_shape=PhysicsBodyBox(fast_body,3,0.1,0.4)
While Not KeyDown(1)
; Space asks both rotors to spin at 300 radians per second
If KeyHit(57)
PhysicsBodyAngularVelocity slow_body,0,300,0
PhysicsBodyAngularVelocity fast_body,0,300,0
EndIf
StepPhysics world,1.0/60.0,4
; Arrow keys move the camera
If KeyDown(200) Then MoveEntity camera,0,0,0.1
If KeyDown(208) Then MoveEntity camera,0,0,-0.1
If KeyDown(203) Then TurnEntity camera,0,1,0
If KeyDown(205) Then TurnEntity camera,0,-1,0
RenderWorld
Text 0,0,"Arrow keys: move camera Space: spin Esc: exit"
Text 0,20,"Green, ordinary body: "+PhysicsBodyAngularVelocityY(slow_body)+" rad/s"
Text 0,40,"Orange, fast body: "+PhysicsBodyAngularVelocityY(fast_body)+" rad/s"
Flip
Wend
FreePhysicsWorld world
End