This version of documentation is OUTDATED! Please switch to the latest one.

# BodyFracture Class

This class is used to simulate destructable fracture bodies. There are three patterns of the fracturing:

New surfces that are created when fracturing occurs are assigned their own material and properties.
Notice
Fracture body can be used with meshes in form of a simple primitive: boxes, spheres, capsules, cylinders, etc. Complex meshes cannot be fractured procedurally.

Fracture body is, per se, a rigid body and moves according to the rigid bodies dynamics.

## BodyFracture ()

Constructor. Creates a fracture body with default properties.

## BodyFracture (const Ptr<Object> & object)

Constructor. Creates a fracture body with default properties for a given object.

### Arguments

• const Ptr<Object> & object - Object represented with the new fracture body.

## voidaddWorldForce (const Math::Vec3 & point, const Math::vec3 & force)

Applies a force to the given point of the body, that is specified in world coordinates. Integrated forces are applied after calling the update.

### Arguments

• const Math::Vec3 & point - Point of the body in world coordinates.
• const Math::vec3 & force - Amount of force to apply.

## floatgetAngularDamping ()

Returns the current damping of the body angular velocity.

### Return value

Angular damping value.

## intcreateSlicePieces (const Math::Vec3 & point, const Math::vec3 & normal)

Breaks the object into two slices, slitting the body according to the normal of the specified point.

### Arguments

• const Math::Vec3 & point - Point of contact.
• const Math::vec3 & normal - Normal of the contact point.

### Return value

Positive number if the object was successfully broken; otherwise, 0.

## voidaddForce (const Math::vec3 & force)

Applies a force to the given point of the body, that is specified in local coordinates. Integrated forces are applied after calling the update.

### Arguments

• const Math::vec3 & force - Radius vector starting in the body's center of mass in local coordinates. Its end is the point of force application.

## const char *getPropertyName ()

Returns the property for fractured verge surfaces appearing after breaking the body.

### Return value

Property name for the fractured verges.

## floatgetLinearDamping ()

Returns the current damping of the body linear velocity.

### Return value

Linear damping value.

## voidsetMaxAngularVelocity (float velocity)

Sets the maximum possible linear velocity for the body. If the value is lower than the engine.physics.setMaxAngularVelocity one, it is overridden.

### Arguments

• float velocity - Maximum possible angular velocity.

## voidsetLinearDamping (float damping)

Sets the damping of the body linear velocity.

### Arguments

• float damping - Linear damping value.

## voidsetMaxLinearVelocity (float velocity)

Sets the maximum possible linear velocity for the body. If the value is lower than the engine.physics.setMaxLinearVelocity one, it is overridden.

### Arguments

• float velocity - Maximum possible linear velocity.

## floatgetFriction ()

Returns the current friction of the body against other surfaces.

Friction value.

## voidsetDensity (float density)

Sets density of a body. Changing the density influences the mass, that is computed by multiplying body volume by density.

### Arguments

• float density - Density of the body.

Sets a collision bit mask for the body. Two objects collide, if they both have matching masks. See also details on additional collision exclusion mask.

### Arguments

• int mask - Integer, each bit of which is a mask.

## voidaddForce (const Math::vec3 & radius, const Math::vec3 & force)

Applies a force to the given point of the body, that is specified in local coordinates. Integrated forces are applied after calling the update.

### Arguments

• const Math::vec3 & radius - Radius vector starting in the body's center of mass in local coordinates. Its end is the point of force application.
• const Math::vec3 & force - Amount of force to apply.

## floatgetDensity ()

Returns the current density of the body.

### Return value

Density of the body.

## const char *getMaterialName ()

Returns the material for fractured verge surfaces appearing after breaking the body.

### Return value

Material name for the fractured verges.

## voidsetMass (float mass)

Sets a mass of the body. Changing the mass influences the density, that is computed by dividing the mass by body volume.

### Arguments

• float mass - Mass of the body.

## voidsetError (float error)

Sets approximation error permissible by creating convex shape for the mesh.

### Arguments

• float error - Approximation error. If a negative value is provided, 0 will be used instead.

## voidsetBroken (int broken)

Sets a value indicating if the object is broken or remains its solid state.

### Arguments

• int broken - Positive number to indicate the object as broken; 0 for it to remain solid.

## voidsetProperty (const char * name)

Sets the property for cracked verge surfaces appearing after breaking the body.

### Arguments

• const char * name - Property name for the fractured verges.

Returns the collision bit mask for the body. Two objects collide, if they both have matching masks. See also details on additional collision exclusion mask.

### Return value

Integer, each bit of which is a mask.

## voidsetMaterial (const char * name)

Sets the material for fractured verge surfaces appearing after breaking the body.

### Arguments

• const char * name - Material name for the fractured verges.

## floatgetMaxLinearVelocity ()

Returns the current maximum possible linear velocity for the body. If the value is lower than the engine.physics.setMaxLinearVelocity one, it is overridden.

### Return value

Maximum possible linear velocity.

## floatgetMaxAngularVelocity ()

Returns the current maximum possible angular velocity for the body. If the value is lower than the engine.physics.setMaxAngularVelocity one, it is overridden.

### Return value

Maximum possible angular velocity.

## Math::vec3getWorldVelocity (const Math::Vec3 & point)

Returns the total linear velocity in the point specified in world coordinates.

### Arguments

• const Math::Vec3 & point - Point of the body in world coordinates.

### Return value

Total linear velocity in the given point.

## floatgetThreshold ()

Returns the current minimum volume threshold for breaking. If the piece volume is less than the threshold value, it cannot be fractured further.

### Return value

Volume threshold.

Returns the bit mask that prevents collisions of the body with other ones. This mask is independent of the collision mask. For bodies with matching collision masks not to collide, at least one bit of their exclusion mask should match.

### Return value

Integer, each bit of which is a mask.

## voidsetThreshold (float threshold)

Sets the minimum volume threshold for breaking. If the piece volume is less than the threshold value, it cannot be fractured further.

### Arguments

• float threshold - Volume threshold. If a negative value is provided, 0 will be used instead.

## intcreateShatterPieces (int num_pieces)

Breaks the object into arbitrary shattered pieces.

### Arguments

• int num_pieces - The number of shattered pieces.

### Return value

Positive number if the object was successfully broken; otherwise, 0.

## voidaddWorldTorque (const Math::Vec3 & point, const Math::vec3 & torque)

Applies a torque to the given point of the body, that is specified in world coordinates.

### Arguments

• const Math::Vec3 & point - Point of the body in world coordinates.
• const Math::vec3 & torque - Amount of torque to apply.

## intisBroken ()

Returns a value indicating if the object is broken or remains its solid state.

### Return value

Positive number if the object is already broken; 0 if it is still solid.

## voidaddTorque (const Math::vec3 & torque)

Applies a torque to the given point of the body, that is specified in local coordinates.

### Arguments

• const Math::vec3 & torque - Radius vector starting in the body's center of mass in local coordinates. Its end is the point of torque application.

## voidsetFrozenAngularVelocity (float velocity)

Sets angular velocity threshold for freezing body simulation. If body angular velocity remains lower than this threshold during the number of Frozen frames (together with linear one), it stops to be updated.

### Arguments

Sets an bit mask to prevent collisions of the body with other ones. This mask is independent of the collision mask. For bodies with matching collision masks not to collide, at least one bit of their exclusion mask should match. 0 is to collide with all bodies with a matching collision mask.

### Arguments

• int mask - Integer, each bit of which is a mask.

## voidsetAngularDamping (float damping)

Sets the damping of the body angular velocity.

### Arguments

• float damping - Angular damping value.

## voidsetFrozenLinearVelocity (float velocity)

Sets linear velocity threshold for freezing body simulation. If body linear velocity remains lower than this threshold during the number of Frozen frames (together with angular one), it stops to be updated.

## Ptr<BodyRigid>getBodyRigid ()

Returns an internal body rigid body that represents fracture body until it is broken.

### Return value

Internal body rigid.

## voidsetFriction (float friction)

Sets friction of the body against other surfaces.

### Arguments

• float friction - Friction value.

## Math::vec3getVelocity (const Math::vec3 & radius)

Returns the total linear velocity in the point specified in local coordinates.

### Arguments

• const Math::vec3 & radius - Radius vector starting in the body's center of mass.

### Return value

Total linear velocity in the given point.

## floatgetFrozenLinearVelocity ()

Returns the current linear velocity threshold for freezing body simulation. If body linear velocity remains lower than this threshold during the number of Frozen frames (together with angular one), it stops to be updated.

### Return value

"Freeze" linear velocity.

## voidaddWorldImpulse (const Math::Vec3 & point, const Math::vec3 & impulse)

Applies an impulse to the given point of the body, that is specified in world coordinates. Impulses immediately affect the body velocity.

### Arguments

• const Math::Vec3 & point - Point of the body in world coordinates.
• const Math::vec3 & impulse - Amount of impulse to apply.

## voidaddImpulse (const Math::vec3 & radius, const Math::vec3 & impulse)

Applies an impulse to the given point of the body, that is specified in local coordinates. Impulses immediately affect the body velocity.

### Arguments

• const Math::vec3 & radius - Radius vector starting in the body's center of mass in local coordinates. Its end is the point of impulse application.
• const Math::vec3 & impulse - Amount of impulse to apply.

## floatgetMass ()

Returns the current mass of the body.

### Return value

Mass of the body.

## intcreateCrackPieces (const Math::Vec3 & point, const Math::vec3 & normal, int num_cuts, int num_rings, float step)

Breakes the object into radial cracks combined with concentric splits. If the first concentric split is rendered further than the specified step distance, decrease the volume threshold value.

### Arguments

• const Math::Vec3 & point - Point of contact.
• const Math::vec3 & normal - Normal of the contact point.
• int num_cuts - Number of radial cuts that are represented as rays coming from the center of contact point.
• int num_rings - Number of rings that form concentric splits. The number of rings that is will be actually rendered depends on the step value.
• float step - Distance between concentric splits.

### Return value

Positive number if the object was successfully broken; otherwise, 0.

## floatgetFrozenAngularVelocity ()

Returns the current angular velocity threshold for freezing body simulation. If body angular velocity remains lower than this threshold during the number of Frozen frames (together with linear one), it stops to be updated.

### Return value

"Freeze" angular velocity.

Returns the intersection bit mask for the body.

### Return value

Integer, each bit of which is a mask.

## floatgetRestitution ()

Returns the current restitution that determines body bouncing off the surfaces.

### Return value

Restitution value.

## voidaddTorque (const Math::vec3 & radius, const Math::vec3 & torque)

Applies a torque to the given point of the body, that is specified in local coordinates.

### Arguments

• const Math::vec3 & radius - Radius vector starting in the body's center of mass in local coordinates. Its end is the point of torque application.
• const Math::vec3 & torque - Amount of torque to apply.

Sets an intersection bit mask for the body.

### Arguments

• int mask - Integer, each bit of which is a mask.

## floatgetError ()

Returns the current approximation error permissible by creating convex shape for the mesh.

### Return value

Approximation error.

## voidsetRestitution (float restitution)

Sets the restitution that determines body bouncing off the surfaces.

### Arguments

• float restitution - Restitution value.
Last update: 2017-07-03