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

DinoFracture.PreFracturedGeometry Class Reference

Apply this component to any game object you wish to pre-fracture. Pre-fracturing is a way of baking fracture pieces into the scene. Each time the object is fractured, the same set of pieces will activate. This is very useful when creating a large number of pieces or high poly meshes, which would be too slow to create at runtime. The pieces will be in the scene as a disabled root object with piece children. When the object is fractured, those pieces will activate. More...

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

Public Member Functions

void Prime ()
 Primes the pre-fractured pieces when the game starts by activating them and then deactivating them. This avoids a large delay on fracture if there are a lot of rigid bodies.
 
- Public Member Functions inherited from DinoFracture.FractureGeometry
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.
 

Public Attributes

GameObject GeneratedPieces
 A reference to the root of the pre-fractured pieces. This is not normally set manually. Instead, you press the “Create Fractures” button in the inspector window to generate the fracture immediately.

 
Bounds EntireMeshBounds
 The encapsulating bounds of the entire set of pieces. In local space.
 
- Public Attributes inherited from DinoFracture.FractureGeometry
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.
 

Protected Member Functions

bool PopulatePreFractureFields (OnFractureEventArgs args)
 Populates the pre-fracture generated pieces and bounds fields.
 

Additional Inherited Members

- Static Public Member Functions inherited from DinoFracture.FractureGeometry
static SlicePlaneSerializable CreateSlicePlane (Plane worldPlane, Transform targetGameObject)
 This will create a valid slice plane for slicing a mesh.
 
- Properties inherited from DinoFracture.FractureGeometry
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

Apply this component to any game object you wish to pre-fracture. Pre-fracturing is a way of baking fracture pieces into the scene. Each time the object is fractured, the same set of pieces will activate. This is very useful when creating a large number of pieces or high poly meshes, which would be too slow to create at runtime. The pieces will be in the scene as a disabled root object with piece children. When the object is fractured, those pieces will activate.

Member Function Documentation

◆ PopulatePreFractureFields()

bool DinoFracture.PreFracturedGeometry.PopulatePreFractureFields ( OnFractureEventArgs args)
inlineprotected

Populates the pre-fracture generated pieces and bounds fields.

Internal fields will be unchanged if the incoming data is invalid.

Returns
True if the incoming data is valid, false if it is not.

Member Data Documentation

◆ GeneratedPieces

GameObject DinoFracture.PreFracturedGeometry.GeneratedPieces

A reference to the root of the pre-fractured pieces. This is not normally set manually. Instead, you press the “Create Fractures” button in the inspector window to generate the fracture immediately.

The “Create Fractures” button is only intended to be used in edit mode; not game mode.