A rigid body. To add a rigid body to a physics world, create a RigidBody instance, create and add shapes via RigidBody.addShape, and add the rigid body to the physics world through World.addRigidBody. Rigid bodies have three motion types: dynamic, static, and kinematic. See RigidBodyType for details of motion types.

Constructor

new(config:RigidBodyConfig)

Creates a new rigid body by configuration config.

Variables

userData:Any

Extra field that users can use for their own purposes.

Methods

inlineaddAngularVelocity(angularVelocityChange:Vec3):Void

Adds angularVelocityChange to the angular velcity of the rigid body.

inlineaddLinearVelocity(linearVelocityChange:Vec3):Void

Adds linearVelocityChange to the linear velcity of the rigid body.

addShape(shape:Shape):Void

Adds the shape to the rigid body.

applyAngularImpulse(impulse:Vec3):Void

Applies the angular impulse impulse to the rigid body.

This does not change the linear velocity.

applyForce(force:Vec3, positionInWorld:Vec3):Void

Applies the force force to positionInWorld in world position.

applyForceToCenter(force:Vec3):Void

Applies the force force to the center of mass.

applyImpulse(impulse:Vec3, positionInWorld:Vec3):Void

Applies the impulse impulse to the rigid body at positionInWorld in world position.

This changes both the linear velocity and the angular velocity.

applyLinearImpulse(impulse:Vec3):Void

Applies the linear impulse impulse to the rigid body.

This does not change the angular velocity.

applyTorque(torque:Vec3):Void

Applies the torque torque.

inlinegetAngularContactImpulse():Vec3

Returns the total angular impulse applied by contact constraints.

inlinegetAngularContactImpulseTo(angularContactImpulse:Vec3):Void

Sets angularContactImpulse to the total angular impulse applied by contact constraints.

This does not create a new instance of Vec3.

inlinegetAngularDamping():Float

Returns the angular damping.

inlinegetAngularVelocity():Vec3

Returns the angular velocity of the rigid body.

inlinegetAngularVelocityTo(angularVelocity:Vec3):Void

Sets angularVelocity to the angular velocity of the rigid body.

This does not create a new intrance of Vec3.

inlinegetContactLinkList():ContactLink

Returns the list of the contact links the rigid body is involved.

inlinegetGravityScale():Float

Returns the gravity scaling factor of the rigid body.

inlinegetJointLinkList():JointLink

Returns the list of the joint links the rigid body is attached.

inlinegetLinearContactImpulse():Vec3

Returns the total linear impulse applied by contact constraints.

inlinegetLinearContactImpulseTo(linearContactImpulse:Vec3):Void

Sets linearContactImpulse to the total linear impulse applied by contact constraints.

This does not create a new instance of Vec3.

inlinegetLinearDamping():Float

Returns the linear damping.

inlinegetLinearVelocity():Vec3

Returns the linear velocity of the rigid body.

inlinegetLinearVelocityTo(linearVelocity:Vec3):Void

Sets linearVelocity to the linear velocity of the rigid body.

This does not create a new intrance of Vec3.

inlinegetLocalInertia():Mat3

Returns the moment of inertia tensor in local space.

inlinegetLocalInertiaTo(inertia:Mat3):Void

Sets inertia to the moment of inertia tensor in local space.

This does not create a new instance of Mat3

inlinegetLocalPoint(worldPoint:Vec3):Vec3

Returns the local coordinates of the point worldPoint in world coodinates.

inlinegetLocalPointTo(worldPoint:Vec3, localPoint:Vec3):Void

Sets localPoint to the local coordinates of the point worldPoint in world coodinates.

This does not create a new instance of Vec3.

inlinegetLocalVector(worldVector:Vec3):Vec3

Returns the local coordinates of the vector worldVector in world coodinates.

inlinegetLocalVectorTo(worldVector:Vec3, localVector:Vec3):Void

Sets localVector to the local coordinates of the vector worldVector in world coodinates.

This does not create a new instance of Vec3.

inlinegetMass():Float

Returns the mass of the rigid body.

If the rigid body has infinite mass, 0 will be returned.

inlinegetMassData():MassData

Returns the mass data of the rigid body.

inlinegetMassDataTo(massData:MassData):Void

Sets massData to the mass data of the rigid body.

This does not create a new instance of MassData.

inlinegetNext():RigidBody

Returns the next rigid body in the world.

If the next one does not exist, null will be returned.

inlinegetNumContactLinks():Int

Returns the number of the contact lists the rigid body is involved.

inlinegetNumJointLinks():Int

Returns the number of the joint links the rigid body is attached.

inlinegetNumShapes():Int

Returns the number of the shapes added.

inlinegetOrientation():Quat

Returns the rotation of the rigid body as a quaternion.

inlinegetOrientationTo(orientation:Quat):Void

Sets orientation to the rotation quaternion of the rigid body.

This does not create a new instance of Quat.

inlinegetPosition():Vec3

Returns the world position of the rigid body.

inlinegetPositionTo(position:Vec3):Void

Sets position to the world position of the rigid body.

This does not create a new instance of Vec3.

inlinegetPrev():RigidBody

Returns the previous rigid body in the world.

If the previous one does not exist, null will be returned.

inlinegetRotation():Mat3

Returns the rotation matrix of the rigid body.

inlinegetRotationFactor():Vec3

Returns the rotation factor of the rigid body.

inlinegetRotationTo(rotation:Mat3):Void

Sets rotation to the rotation matrix of the rigid body.

This does not create a new instance of Mat3.

inlinegetShapeList():Shape

Returns the list of the shapes of the rigid body.

inlinegetSleepTime():Float

Returns how long the rigid body is stopping moving. This returns 0 if the body has already slept.

inlinegetTransform():Transform

Returns the transform of the rigid body.

inlinegetTransformTo(transform:Transform):Void

Sets transform to the transform of the rigid body.

This does not create a new instance of Transform.

inlinegetType():Int

Returns the rigid body's type of behaviour.

See RigidBodyType class for details.

inlinegetWorldPoint(localPoint:Vec3):Vec3

Returns the world coordinates of the point localPoint in local coodinates.

inlinegetWorldPointTo(localPoint:Vec3, worldPoint:Vec3):Void

Sets worldPoint to the world coordinates of the point localPoint in local coodinates.

This does not create a new instance of Vec3.

inlinegetWorldVector(localVector:Vec3):Vec3

Returns the world coordinates of the vector localVector in local coodinates.

inlinegetWorldVectorTo(localVector:Vec3, worldVector:Vec3):Void

Sets worldVector to the world coordinates of the vector localVector in local coodinates.

This does not create a new instance of Vec3.

inlineisSleeping():Bool

Returns whether the rigid body is sleeping.

removeShape(shape:Shape):Void

Removes the shape from the rigid body.

inlinerotate(rotation:Mat3):Void

Rotates the rigid body by the rotation matrix rotation.

inlinerotateXyz(eulerAngles:Vec3):Void

Rotates the rigid body by Euler angles eulerAngles in radians.

inlinesetAngularDamping(damping:Float):Void

Sets the angular damping to damping.

inlinesetAngularVelocity(angularVelocity:Vec3):Void

Sets the angular velocity of the rigid body.

inlinesetAutoSleep(autoSleepEnabled:Bool):Void

Sets the rigid body's auto sleep flag.

If auto sleep is enabled, the rigid body will automatically sleep when needed.

inlinesetGravityScale(gravityScale:Float):Void

Sets the gravity scaling factor of the rigid body to gravityScale.

If 0 is set, the rigid body will not be affected by gravity.

inlinesetLinearDamping(damping:Float):Void

Sets the linear damping to damping.

inlinesetLinearVelocity(linearVelocity:Vec3):Void

Sets the linear velocity of the rigid body.

inlinesetMassData(massData:MassData):Void

Sets the mass and moment of inertia of the rigid body by the mass data massData. The properties set by this will be overwritten when

  • some shapes are added or removed
  • the type of the rigid body is changed

inlinesetOrientation(quaternion:Quat):Void

Sets the rotation of the rigid body from a quaternion quaternion.

inlinesetPosition(position:Vec3):Void

Sets the world position of the rigid body to position.

inlinesetRotation(rotation:Mat3):Void

Sets the rotation matrix of the rigid body to rotation.

inlinesetRotationFactor(rotationFactor:Vec3):Void

Sets the rotation factor of the rigid body to rotationFactor.

This changes moment of inertia internally, so that the change of angular velocity in global space along X, Y and Z axis will scale by rotationFactor.x, rotationFactor.y and rotationFactor.z times respectively.

inlinesetRotationXyz(eulerAngles:Vec3):Void

Sets the rotation of the rigid body by Euler angles eulerAngles in radians.

inlinesetTransform(transform:Transform):Void

Sets the transform of the rigid body to transform.

This does not keep any references to transform.

setType(type:Int):Void

Sets the rigid body's type of behaviour.

See RigidBodyType class for details.

inlinesleep():Void

Sets the rigid body's sleep flag true.

This also resets the sleeping timer of the rigid body.

inlinetranslate(translation:Vec3):Void

Translates the position of the rigid body by translation.

inlinewakeUp():Void

Sets the rigid body's sleep flag false.

This also resets the sleeping timer of the rigid body.