Get RAPTOR

RaptorHotspotLocks

Block hotspot locks (Hotspot v2) for code that builds a derived copy of a Block's mesh.

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, since 0.1.0

Use these members when code such as a modifier that cuts, rounds or re-tessellates a Block's mesh needs the copy to keep the Block's hotspot mapping. Locks are stored per mesh instance and keyed by that mesh's face indices. None of these members change how a lock is fitted.

The usual sequence for a derived copy:

  1. Call CopyThrough (or Load).
  2. Make the cut.
  3. Call Drop on the faces the cut rebuilt.
  4. Call Set to restore a face's earlier state.
  5. Call MarkAllFitted.
  6. Call Inherit or Release on the new faces.
  7. Call Refit.
public static class RaptorHotspotLocks

Methods

Any

public static bool Any(PolygonMesh mesh)

Whether mesh has a lock table with at least one entry. Does not create a table.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.

Returns: True when it has one.

CopyThrough

public static void CopyThrough(PolygonMesh from, PolygonMesh to, Dictionary<FaceHandle, FaceHandle> faceMap)

Copies from's locks to a renumbered copy through its face map. Each lock, its island label and its fitted signature move with their face. Does nothing when from has no lock table.

ParameterTypeDescription
fromPolygonMeshThe source.
toPolygonMeshThe copy.
faceMapDictionary<FaceHandle, FaceHandle>Old face to new face.

Drop

public static void Drop(PolygonMesh mesh, int face)

Removes the lock, fitted signature and origin stored for face face. Use it when an operation reuses a face slot for a different face. Does not create a table.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.
faceintA face index of the mesh.

Inherit

public static bool Inherit(PolygonMesh mesh, int face, int from)

Gives face face the lock settings of face from as a separate island, with the same lock word, a new island label and an automatic pick. This is Hotspot v2's rule for a face grown from a locked neighbour.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.
faceintA face index of the mesh.
fromintThe face to copy the lock from.

Returns: False, with nothing changed, when face from has no entry.

IsLocked

public static bool IsLocked(PolygonMesh mesh, int face)

Whether face face of mesh is locked, meaning it has an entry with a nonzero mode.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.
faceintA face index of the mesh.

Returns: True when locked.

Load

public static void Load(PolygonMesh mesh, int[] stored)

Replaces mesh's locks with a stored table, in the quadruple format RaptorMesh.HotspotLocks uses and indexed by mesh's faces. Every locked face is recorded as fitted.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.
storedint[]The stored table.

MarkAllFitted

public static void MarkAllFitted(PolygonMesh mesh)

Records every locked face of mesh as fitted in its current state, so the next Refit skips it.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.

Refit

public static int Refit(PolygonMesh mesh, bool all = false)

Refits the locked islands of mesh that changed since they were fitted, or every island when all is true. Call it after new faces inherit. An island that fails to fit does not throw.

ParameterTypeDefaultDescription
meshPolygonMeshThe Block's editable mesh.
allboolfalseTrue refits every island.

Returns: The number of faces written.

Release

public static void Release(PolygonMesh mesh, int face)

Releases face face by setting its lock word to 0, so it does not inherit a lock later. Its fitted signature and origin are kept.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.
faceintA face index of the mesh.

Set

public static void Set(PolygonMesh mesh, int face, RaptorHotspotLockState state)

Sets the lock of face face to state. Its fitted signature and origin are unchanged.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.
faceintA face index of the mesh.
stateRaptorHotspotLockStateThe lock.

SheetKey

public static object SheetKey(UnityEngine.Material material)

Gets an identity object for the hotspot sheet that material belongs to, or null when it is not a sheet material. Materials of the same sheet return the same object. Compare keys with object.ReferenceEquals.

ParameterTypeDescription
materialUnityEngine.MaterialThe material.

Returns: The key, or null.

TableFaces

public static List<int> TableFaces(PolygonMesh mesh)

Gets every face index with an entry in mesh's lock table, including released faces, in table order. The list is empty when the mesh has no lock table.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.

Returns: A new list.

TryGet

public static bool TryGet(PolygonMesh mesh, int face, out RaptorHotspotLockState state)

Gets the lock of face face when it is locked. Returns false and sets state to default for a released face, a face with no entry, or a mesh with no lock table. Does not create a table.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.
faceintA face index of the mesh.
stateout RaptorHotspotLockStateThe lock.

Returns: False when not locked.

Unfit

public static void Unfit(PolygonMesh mesh, int face)

Releases face face by setting its lock word to 0, so it does not inherit a lock later, and clears its fitted signature. Its origin is kept.

ParameterTypeDescription
meshPolygonMeshThe Block's editable mesh.
faceintA face index of the mesh.
  • RaptorHotspotLockState: A face's hotspot lock as a value that can be copied to another face, read with RaptorHotspotLocks.TryGet and written with RaptorHotspotLocks.Set.
  • RaptorMesh: A RAPTOR Mesh Block.