Photon Quantum 3.0.0

Public Member Functions | Properties | List of all members
Quantum.EditMeshScope Struct Reference

Scope for editing triangles of a mesh collider. More...

Inherits IDisposable.

Public Member Functions

 EditMeshScope (FrameBase frame, DynamicMap map, int colliderIndex)
 Creates a new scope for editing the triangles of a mesh collider. More...
 
void AddTriangle (ref TriangleCCW tri)
 Adds a triangle to the mesh collider. More...
 
void Dispose ()
 Releases the resources used by the EditTrianglesScope. More...
 
TriangleCCW GetTriangle (int index)
 Gets the triangle at the specified index from the edit data in the EditTrianglesScope. More...
 
Int32 ReserveTriangleCapacity (FrameBase f, int capacity)
 Ensures that the mesh capacity is at least the specified capacity value. More...
 
void SetTriangle (int index, ref TriangleCCW tri)
 Sets a triangle within the used range of a mesh collider. More...
 
void SetTriangleUnchecked (int index, ref TriangleCCW tri)
 Setting a triangle of a mesh collider without checking the validity of the index . More...
 
bool TryAddTriangle (ref TriangleCCW tri)
 Tries to add a triangle to the mesh collider. More...
 
bool TrySetTriangle (int index, ref TriangleCCW tri)
 Try setting a triangle within the used range of a mesh collider. More...
 

Properties

MeshUnmanagedTrianglesRef EditData [get]
 The mesh collider being edited. More...
 

Detailed Description

Scope for editing triangles of a mesh collider.

Constructor & Destructor Documentation

◆ EditMeshScope()

Quantum.EditMeshScope.EditMeshScope ( FrameBase  frame,
DynamicMap  map,
int  colliderIndex 
)
inline

Creates a new scope for editing the triangles of a mesh collider.

Parameters
frameCurrent Frame instance. Must be a Verified Frame.
mapDynamic map currently loaded by the physics engine.
colliderIndexIndex of the mesh collider in the map .
Exceptions
InvalidOperationExceptionIf the frame is Predicted.
InvalidOperationExceptionIf the map is not the same map currently loaded by the Physics Engine.

Member Function Documentation

◆ ReserveTriangleCapacity()

Int32 Quantum.EditMeshScope.ReserveTriangleCapacity ( FrameBase  f,
int  capacity 
)
inline

Ensures that the mesh capacity is at least the specified capacity value.

Parameters
fCurrent Frame instance.
capacityThe requested capacity to be reserved. If smaller than the current capacity, nothing happens.
Returns
The new triangle capacity of the mesh. If the requested capacity is smaller than or equal the current capacity, it returns the current capacity

◆ SetTriangle()

void Quantum.EditMeshScope.SetTriangle ( int  index,
ref TriangleCCW  tri 
)
inline

Sets a triangle within the used range of a mesh collider.

Parameters
indexThe index of the triangle.
triThe triangle to set.
Exceptions
IndexOutOfRangeExceptionIf index is out bounds, considering the capacity of this mesh.
InvalidOperationExceptionIf index is out of the range of USED triangles.

How to set a triangle of a mesh collider:

using (var scope = dynamicMap.EditMeshTriangles(frame, colliderIndex)) {
TriangleCCW triangle = new TriangleCCW { A = v0, B = v1, C = v2 };
scope.SetTriangle(0, ref triangle);
}

◆ TrySetTriangle()

bool Quantum.EditMeshScope.TrySetTriangle ( int  index,
ref TriangleCCW  tri 
)
inline

Try setting a triangle within the used range of a mesh collider.

Parameters
indexThe index of the triangle.
triThe triangle to set.
Returns
false if the index is out of the range of USED triangles. true otherwise.

How to try setting a triangle of a mesh collider:

using (var scope = dynamicMap.EditMeshTriangles(frame, colliderIndex)) {
TriangleCCW triangle = new TriangleCCW { A = v0, B = v1, C = v2 };
if(scope.TrySetTriangle(0, ref triangle)) {
Log.Info("Triangle set successfully.");
}
else {
LogError?.Log("Failed to set triangle.");
}
}

◆ SetTriangleUnchecked()

void Quantum.EditMeshScope.SetTriangleUnchecked ( int  index,
ref TriangleCCW  tri 
)
inline

Setting a triangle of a mesh collider without checking the validity of the index .

Parameters
indexThe index of the triangle.
triThe triangle to set.

How to set a triangle of a mesh collider without checking the index:

using (var scope = dynamicMap.EditMeshTriangles(frame, colliderIndex)) {
TriangleCCW triangle = new TriangleCCW { A = v0, B = v1, C = v2 };
scope.SetTriangleUnchecked(0, ref triangle);
}

◆ AddTriangle()

void Quantum.EditMeshScope.AddTriangle ( ref TriangleCCW  tri)
inline

Adds a triangle to the mesh collider.

Parameters
triThe triangle to be added.
Exceptions
InvalidOperationExceptionIf all triangles within the mesh capacity are already being used.

How to add a triangle to a mesh collider:

using (var scope = dynamicMap.EditMeshTriangles(frame, colliderIndex)) {
TriangleCCW triangle = new TriangleCCW { A = v0, B = v1, C = v2 };
scope.AddTriangle(ref triangle);
}

If the mesh collider is at capacity, an InvalidOperationException is thrown.

See also
TryAddTriangle

◆ TryAddTriangle()

bool Quantum.EditMeshScope.TryAddTriangle ( ref TriangleCCW  tri)
inline

Tries to add a triangle to the mesh collider.

Parameters
triThe triangle to be added.
Returns
false if all triangles within the mesh capacity are already being used. true otherwise.

How to try adding a triangle to a mesh collider:

using (var scope = dynamicMap.EditMeshTriangles(frame, colliderIndex)) {
TriangleCCW triangle = new TriangleCCW { A = v0, B = v1, C = v2 };
if(scope.TryAddTriangle(ref triangle)) {
Log.Info("Triangle added successfully.");
}
else {
LogError?.Log("Failed to add triangle.");
}
}
See also
AddTriangle

◆ GetTriangle()

TriangleCCW Quantum.EditMeshScope.GetTriangle ( int  index)
inline

Gets the triangle at the specified index from the edit data in the EditTrianglesScope.

Parameters
indexThe index of the triangle to get.
Returns
The TriangleCCW object at the specified index.
Exceptions
IndexOutOfRangeExceptionIf the index is out of bounds for the collider, considering its capacity.

How to get a triangle from a mesh collider:

using (var scope = dynamicMap.EditMeshTriangles(frame, colliderIndex)) {
TriangleCCW triangle = scope.GetTriangle(0);
}

◆ Dispose()

void Quantum.EditMeshScope.Dispose ( )
inline

Releases the resources used by the EditTrianglesScope.

If the current frame is predicted, the method does nothing. Otherwise, it assigns the EditData to the collider at the specified index in the CollidersRuntimeTriangles dictionary and inserts the mesh collider into the physics engine scene using the TriangleReference obtained from Physics3D.SceneMesh.

Property Documentation

◆ EditData

MeshUnmanagedTrianglesRef Quantum.EditMeshScope.EditData
get

The mesh collider being edited.