DinoFracture 2.11.1
A Dynamic Fracture Library
Loading...
Searching...
No Matches

DinoFracture.FractureGeometry Class Referenceabstract

This is the base class for the PreFractureGeometry and RuntimeFractureGeometry components. As such, it is not intended to be directly added to any game object even though fracture initiator components rely on it. More...

Inheritance diagram for DinoFracture.FractureGeometry:
[legend]
Collaboration diagram for DinoFracture.FractureGeometry:
[legend]

Classes

class  OnFractureEvent
 OnFracture() Unity event wrapper. More...
 
struct  SizeSerializable
 Unity cannot handle the serializable attribute on types defined in dlls. This wraps a DinoFracture.Size type. More...
 
struct  SlicePlaneSerializable
 Unity cannot handle the serializable attribute on types defined in dlls. So, we have to duplicate the SlicePlane structure here in order to save it. More...
 
struct  UVBoundsSerializable
 Unity cannot handle the serializable attribute on types defined in dlls. This wraps a DinoFracture.UVBounds type. More...
 

Public Member Functions

void FractureAndForget ()
 Initiate a fracture at the origin and does not return a handle to the async operation.
 
void FractureAndForget (Vector3 localPos)
 Initiate a fracture at the specified position relative to this object and does not return a handle to the async operation.
 
AsyncFractureResult Fracture ()
 Initiate a fracture at the origin.
 
AsyncFractureResult Fracture (Vector3 localPos)
 Initiate a fracture at the specified position relative to this object.
 
OnFractureEventArgs CreateEmptyFractureEventArgs ()
 Creates an empty set of OnFractureEventArgs that can be used to manually fracture completed handler in the event that calling Fracture() returns no async fracture result to attach to.
 
MeshTopologyError CheckMeshValidity ()
 This is called automatically when viewing the component in the inspector. However, it should be called whenever the mesh changes through other means.
 
void ForceValidGeometry ()
 This will force the geometry to pass all validity checks.
 
List< EdgeErrorGetMeshEdgeErrors ()
 Returns any bad mesh edges. Used by the editor script for debugging.
 

Static Public Member Functions

static SlicePlaneSerializable CreateSlicePlane (Plane worldPlane, Transform targetGameObject)
 This will create a valid slice plane for slicing a mesh.
 

Public Attributes

Material InsideMaterial
 The material assigned to the “inside” triangles of the fracture pieces. These are the triangles that DinoFracture creates. The surface triangles of the original mesh retain their materials.
 
bool OptimizeMaterialUsage = true
 If true, newly generated triangles using the "InsideMaterial" will attempt to be part of the same existing material in th mesh.
 
GameObject FractureTemplate
 This game object will be cloned for each facture piece. It is required to have a MeshFilter component. If a MeshCollider component is added, it will be assigned the fracture mesh.
 
Transform PiecesParent
 The parent of the generated pieces. Each fracture produces a root object with fracture pieces (clones of FractureTemplate) as children. The root object is parented to PiecesParent.
 
FractureType FractureType = FractureType.Shatter
 The type of fracture to produce when Fracture() is called.
 
SlicePlaneSerializable[] SlicePlanes
 The planes to use when slicing the mesh. Not used when fracturing into pieces.
 
int NumFracturePieces = 5
 The number of fracture pieces generated per iteration. Fault lines are spread evenly around the fracture point. The number of total pieces generated is NumFracturePieces ^ NumIterations.
 
int NumIterations = 2
 The number of passes of fracturing. Using lower piece count with a higher iteration count is computationally faster than a higher piece count with a lower iteration count. Ex: 5 pieces with 2 iterations is faster than 25 pieces and 1 iteration. The downside to using more iterations is fractures can become less uniform. In general, keep this number below 4. The number of total pieces generated is NumFracturePieces ^ NumIterations.

 
bool EvenlySizedPieces = true
 If true, the engine will attempt to make all the randomly generated pieces roughly the same size. This adds a little processing time to the fracture.
 
int NumGenerations = 1
 To allow for fracture pieces to be further fractured, the FractureTemplate should have a FractureGeometry component. NumGenerations dictates how many times the geometry can be re-fractured. The count is decremented and passed on to the component in each generated piece. Ex: A value of 2 means this piece can be fractured and each generated piece can be fractured. The second generation of fractures cannot be fractured further.

 
float FractureRadius
 A value between 0 and 1 that indicates how clustered the fracture lines are. A value of 0 or 1 means fractures are evenly distributed across the mesh. A value between means they are clustered within a percentage of the mesh bounds. Ex: a value of 0.3 means fractures are clustered around the fracture point in a volume 30% the size of the mesh. Pre-fracture geometry typically has this value set to 0 or 1 because there isn’t always a pre-determined point of fracture.
 
SizeSerializable FractureSize
 The approximate size of fractures to create during shatter. When combined with a position through a call to Fracture(), the shatter planes will be clustered within this bounds.
 
FractureUVScale UVScale = FractureUVScale.Piece
 If set to EntireMesh, the UV map for each inside triangle will be mapped to a box the size of the original mesh. If set to piece, inside triangles will be mapped to a box the size of the individual fracture piece.
 
UVBoundsSerializable UVBounds = new UVBoundsSerializable(Vector2.zero, Vector2.one)
 Final 'inside' triangles will be remapped to be within this range. This does not affect the UVs on the incoming mesh and works with any value set for the UVScale.
 
bool DistributeMass = true
 If true and both this game object and the FractureTemplate have a RigidBody component, each fracture piece will have a mass set to a value proportional to its volume. That is, the density of the fracture piece will equal the density of the original mesh. If false, the mass property goes untouched.
 
bool SeparateDisjointPieces = false
 If true, a final pass will be done to separate out meshes that are not physically connected. This can only happen when the mesh has concave parts.
 
VertexMergingPolicy VertexMergingPolicy = VertexMergingPolicy.Default
 Defines how aggressively to merge the vertices of this fracture. More aggressive merging will result in meshes that have a reduced number of vertices and triangles at the cost of more computation time during fracture.
 
int RandomSeed = 0
 The random seed to use when initiating the fracture. If set to zero, then the system clock will be used to create a random seed.
 
OnFractureEvent OnFractureCompleted
 Unity event that fires whenever a fracture on this object completes.
 
bool SkipMeshCleaning = false
 Not recommended to be set. But if set to true, no mesh cleaning will occur during the fracture process. This has no effect if the mesh is already clean.
 

Properties

MeshValidity MeshValidity [get]
 Used to determine if the mesh is of known good quality to fracture.
 
bool IsProcessingFracture [get]
 Are we in the middle of computing a fracture for this object?
 

Detailed Description

This is the base class for the PreFractureGeometry and RuntimeFractureGeometry components. As such, it is not intended to be directly added to any game object even though fracture initiator components rely on it.

Member Function Documentation

◆ CreateSlicePlane()

static SlicePlaneSerializable DinoFracture.FractureGeometry.CreateSlicePlane ( Plane worldPlane,
Transform targetGameObject )
inlinestatic

This will create a valid slice plane for slicing a mesh.

While valid, it is not intended to be displayed in the editor and is meant for runtime use.

◆ ForceValidGeometry()

void DinoFracture.FractureGeometry.ForceValidGeometry ( )
inline

This will force the geometry to pass all validity checks.

This method can be useful to call in very custom scenarios of fracturing through script when you know the mesh you are passing in is valid.

◆ Fracture() [1/2]

AsyncFractureResult DinoFracture.FractureGeometry.Fracture ( )
inline

Initiate a fracture at the origin.

Returns

◆ Fracture() [2/2]

AsyncFractureResult DinoFracture.FractureGeometry.Fracture ( Vector3 localPos)
inline

Initiate a fracture at the specified position relative to this object.

Parameters
localPos
Returns

◆ FractureAndForget() [1/2]

void DinoFracture.FractureGeometry.FractureAndForget ( )
inline

Initiate a fracture at the origin and does not return a handle to the async operation.

The OnFracture() callback will still fire. This method is compatible with Unity events.

◆ FractureAndForget() [2/2]

void DinoFracture.FractureGeometry.FractureAndForget ( Vector3 localPos)
inline

Initiate a fracture at the specified position relative to this object and does not return a handle to the async operation.

The OnFracture() callback will still fire. This method is compatible with Unity events.

Member Data Documentation

◆ EvenlySizedPieces

bool DinoFracture.FractureGeometry.EvenlySizedPieces = true

If true, the engine will attempt to make all the randomly generated pieces roughly the same size. This adds a little processing time to the fracture.

Do not set this to true if FractureRadius > 0.

◆ NumGenerations

int DinoFracture.FractureGeometry.NumGenerations = 1

To allow for fracture pieces to be further fractured, the FractureTemplate should have a FractureGeometry component. NumGenerations dictates how many times the geometry can be re-fractured. The count is decremented and passed on to the component in each generated piece. Ex: A value of 2 means this piece can be fractured and each generated piece can be fractured. The second generation of fractures cannot be fractured further.

Specify a negative value on the main piece to allow for infinite repeated fractures

◆ NumIterations

int DinoFracture.FractureGeometry.NumIterations = 2

The number of passes of fracturing. Using lower piece count with a higher iteration count is computationally faster than a higher piece count with a lower iteration count. Ex: 5 pieces with 2 iterations is faster than 25 pieces and 1 iteration. The downside to using more iterations is fractures can become less uniform. In general, keep this number below 4. The number of total pieces generated is NumFracturePieces ^ NumIterations.

It is recommended you use an iteration count of 1 when 0 < FractureRadius < 1.

◆ OptimizeMaterialUsage

bool DinoFracture.FractureGeometry.OptimizeMaterialUsage = true

If true, newly generated triangles using the "InsideMaterial" will attempt to be part of the same existing material in th mesh.

If false, newly generated triangles will always be put in a new material placed after all used existing materials. Additionally, new materials will continue to be appended upon further fractures.

◆ SeparateDisjointPieces

bool DinoFracture.FractureGeometry.SeparateDisjointPieces = false

If true, a final pass will be done to separate out meshes that are not physically connected. This can only happen when the mesh has concave parts.

This process can be slow. It is recommended to be off for runtime fractures unless there is a good chance of disjoint pieces.

◆ SlicePlanes

SlicePlaneSerializable [] DinoFracture.FractureGeometry.SlicePlanes

The planes to use when slicing the mesh. Not used when fracturing into pieces.

Each slice plane must be in local space. Use FractureGeometry.CreateSlicePlane() to create a compatible local space plane from a Unity world space plane.

◆ UVBounds

UVBoundsSerializable DinoFracture.FractureGeometry.UVBounds = new UVBoundsSerializable(Vector2.zero, Vector2.one)

Final 'inside' triangles will be remapped to be within this range. This does not affect the UVs on the incoming mesh and works with any value set for the UVScale.

This can be used with an atlas texture to constrain the generated triangles to use only a specific portion of the texture map.

◆ VertexMergingPolicy

VertexMergingPolicy DinoFracture.FractureGeometry.VertexMergingPolicy = VertexMergingPolicy.Default

Defines how aggressively to merge the vertices of this fracture. More aggressive merging will result in meshes that have a reduced number of vertices and triangles at the cost of more computation time during fracture.

Vertex merging only applies to vertices on the ring of a slice. The original hull of the mesh will never have vertices merged.