PhysicsWorldContinuous world,enabled
Parameters
|
world - live explicit physics world enabled - True enables native continuous collision (default), False disables it |
Description
|
Enables or disables a world's continuous collision detection. Controls the world's native continuous-collision stage, including the stage used by bullet bodies. Disabling it allows fast bodies to tunnel through thin geometry; it does not change any per-body bullet flags or replace ordinary discrete collision. The setting is independent of maximum speed and the fast-rotation constructor. Changing it does not wake bodies; its effect is observed during subsequent physics steps. The mutation is recorded and affects only this world. 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. Requires Extended mode. See also: PhysicsWorldIsContinuousEnabled, PhysicsBodyBullet, CreatePhysicsFastBody, PhysicsWorldMaxSpeed. |
Example
; PhysicsWorldContinuous Example ; ------------------------------ ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() Const PHYSICS_STATIC=0 Const PHYSICS_DYNAMIC=2 camera=CreateCamera() PositionEntity camera,7,2,-1 RotateEntity camera,5,80,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) ; A thin glass pane, only 4 cm thick pane=CreateCube() ScaleEntity pane,1.5,1.5,0.02 PositionEntity pane,0,1.5,0 EntityColor pane,150,220,255 EntityAlpha pane,0.6 pane_body=CreatePhysicsBody(world,pane,PHYSICS_STATIC) pane_shape=PhysicsBodyBox(pane_body,3,3,0.04) ; A small ball that ignores gravity ball=CreateSphere(8) ScaleEntity ball,0.1,0.1,0.1 EntityColor ball,255,120,70 ball_body=CreatePhysicsBody(world,ball,PHYSICS_DYNAMIC) ball_shape=PhysicsBodySphere(ball_body,0.2) PhysicsBodyGravityScale ball_body,0 ResetPhysicsBody ball_body,0,1.5,-4,0,0,0 While Not KeyDown(1) ; Space fires the ball at the pane at 100 m/s If KeyHit(57) ResetPhysicsBody ball_body,0,1.5,-4,0,0,0 PhysicsBodyVelocity ball_body,0,0,100 EndIf ; C switches continuous collision; without it the fast ball can pass through If KeyHit(46) continuous=Not PhysicsWorldIsContinuousEnabled(world) PhysicsWorldContinuous world,continuous 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: fire C: continuous Esc: exit" Text 0,20,"PhysicsWorldContinuous world,"+PhysicsWorldIsContinuousEnabled(world) Text 0,40,"Ball Z: "+EntityZ(ball)+" (the pane is at Z 0; above 0 means it went through)" Flip Wend FreePhysicsWorld world End
Index