Class DestructionResource

A resource containing pre-computed fracture data for a mesh.

DestructionResource is a saveable asset that stores the results of mesh fracturing. It can be assigned to a CDestructable component to provide instant access to fracture pieces without runtime computation.

Workflow: 1. Assign a source mesh 2. Configure fracture settings 3. Call Generate() to compute fractures 4. Save the resource 5. Assign to CDestructable components

Hierarchy (view full)

Constructors

Accessors

  • get interiorMaterial(): Material
  • Sets the material used for interior (cut) faces.

    Returns Material

  • set interiorMaterial(value): void
  • Sets the material used for interior (cut) faces.

    Parameters

    Returns void

  • get isDestroyed(): boolean
  • Determines if the resource is destroyed.

    Returns boolean

    This can happen when the Resource was forcefully unloaded or reverted. For this reason, it is safer to hold on to a instead of directly referencing a resource pointer, as the current Resource can always be retrieved via .value.

  • get isGenerated(): boolean
  • Determines if fracture data has been generated.

    Returns boolean

  • get isValid(): boolean
  • Determines if the resource is valid and ready for use.

    Returns boolean

    True if the resource has a source mesh and generated data.

  • get name(): string
  • Name of the resource. Use primarily for easier identification and not important to the engine itself.

    Returns string

  • get pieceCount(): number
  • Gets the number of pieces in the generated data.

    Returns number

  • get sourceMesh(): Mesh
  • Sets the source mesh to fracture.

    Returns Mesh

  • set sourceMesh(value): void
  • Sets the source mesh to fracture.

    Parameters

    Returns void

  • get uuid(): UUID
  • Returns a universally unique identifier of this resource.

    Returns UUID

Methods

  • Clears the generated fracture data.

    Returns void

  • Duplicates the resource and creates a unique UUID for the duplicated resource.

    Returns Resource

    The duplicated resource or null, if the duplication failed.

  • Generates fracture data from the source mesh using the current settings.

    This operation runs asynchronously as it may need to perform a GPU readback if the mesh has no cached CPU data.

    Returns UncertainAsyncOp<boolean, string>

    Async operation that completes with true if generation succeeded, or fails with an error message.

  • Virtual

    Method called by RSX to perform actions required after the creation of the resource.

    Returns void

  • Virtual

    Method called by RSX to perform any operations needed after deserialization.

    Returns void

    Use this API to restore your serializable data into live objects.

  • Virtual

    Method called by RSX to disable the resource.

    Returns void

    Use this API to deactivate the resource before it is serialized.

  • Virtual

    Method called by RSX to enable the resource.

    Returns void

    Use this API to activate the resource after it has been disabled by serialization.

  • Virtual

    Method called by RSX to perform initialization of the resource.

    Returns void

    Use this API to initialize data and default construct all fields.

  • Virtual

    Method called by RSX to perform any operations before serialization.

    Returns void

    Use this API to bake your live data into serializable data.

  • Reverts the resource to the on-disk representation.

    Returns boolean

    This is a potentially expensive call, as it needs to deserialize and replace all existing in-memory resource handles.