Photon Quantum 3.0.0

Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
Quantum.Shape2D.CompoundShape2D Struct Reference

A 2D shape type that can reference a group of other 2D shapes (including other compounds). Compound shape overlaps and physics colliders with compound shapes are supported. More...

Public Member Functions

void AddShape (FrameBase f, ref Shape2D shape, bool updateCompoundMeta=true)
 Adds the shape to the compound buffer. More...
 
void CopyFrom (FrameBase f, ref Shape2D shape)
 Creates a copy of another compound shape 's and any nested compound's buffers. The resultant shapes will not share data. More...
 
void FreePersistent (FrameBase f, Boolean freeNestedPersistent=true)
 Dispose any persistently allocated memory for this compound shape. More...
 
override int GetHashCode ()
 Overrides the hash code generation of this type. More...
 
bool GetShapes (FrameBase f, out Shape2D *shapesBuffer, out Int32 count)
 Gets a pointer to the buffer of shapes added to this compound. More...
 
bool RemoveShapes (FrameBase f, Int32? userTag=null, Boolean resetCompoundMeta=true, Boolean removeFromNested=true)
 Removes all shapes in a compound that have a Shape2D.UserTag field matching the specified userTag . More...
 
void ReserveCapacity (FrameBase f, Int32 capacity)
 Ensures that this compound shape capacity can hold at least capacity shapes. More...
 
void ResetCompoundMeta (FrameBase f)
 Recomputes the compound shape broad radius, centroid and area sum (the later is used internally). More...
 

Static Public Member Functions

static void Serialize (void *ptr, FrameSerializer serializer)
 Serializes a CompoundShape2D into a FrameSerializer. More...
 

Static Public Attributes

const int SIZE = Transform2D.SIZE + 2 * FP.SIZE + Ptr.SIZE + 2 * sizeof(UInt16) + 2 * sizeof(int)
 The size of the struct in bytes. More...
 

Properties

Int32 Count [get]
 The number of shapes in the compound buffer. More...
 
Boolean IsPersistent [get]
 If the buffer of shapes is persistently allocated. More...
 

Detailed Description

A 2D shape type that can reference a group of other 2D shapes (including other compounds). Compound shape overlaps and physics colliders with compound shapes are supported.

Member Function Documentation

◆ CopyFrom()

void Quantum.Shape2D.CompoundShape2D.CopyFrom ( FrameBase  f,
ref Shape2D  shape 
)
inline

Creates a copy of another compound shape 's and any nested compound's buffers. The resultant shapes will not share data.

Any existing persistent compounds in this shape's hierarchy are disposed before copying.

Parameters
fThe current frame being simulated.
shapeThe compound shape that will be copied from.

◆ AddShape()

void Quantum.Shape2D.CompoundShape2D.AddShape ( FrameBase  f,
ref Shape2D  shape,
bool  updateCompoundMeta = true 
)
inline

Adds the shape to the compound buffer.

Trying to add a compound shape that holds a buffer already reference in this shape's hierarchy will throw an error in debug mode.

Parameters
fThe frame currently being simulated.
shapeThe shape being added to the compound.
updateCompoundMetaIf the compound meta data (e.g. broad radius and centroid) should be automatically updated.

◆ RemoveShapes()

bool Quantum.Shape2D.CompoundShape2D.RemoveShapes ( FrameBase  f,
Int32?  userTag = null,
Boolean  resetCompoundMeta = true,
Boolean  removeFromNested = true 
)
inline

Removes all shapes in a compound that have a Shape2D.UserTag field matching the specified userTag .

Parameters
fThe frame currently being simulated.
userTagA tag that specifies a shape or group of shapes. Any shape in a compound that has a matching Shape2D.UserTag field will be removed. If none is specified, all shapes are removed.
resetCompoundMetaIf the compound meta data (e.g. broad radius, centroid) should be automatically reset if any shapes are removed.
removeFromNestedIf shapes should also be removed from any compound shape nested inside this.
Returns
true if at least one shape has been removed by this method.

◆ GetShapes()

bool Quantum.Shape2D.CompoundShape2D.GetShapes ( FrameBase  f,
out Shape2D shapesBuffer,
out Int32  count 
)
inline

Gets a pointer to the buffer of shapes added to this compound.

Parameters
fThe frame currently being simulated.
shapesBufferA pointer to the buffer of shapes added to this compound. null if the compound doesn't have shapes.
countThe number of shapes in the shapesBuffer .
Returns
true if the buffer has at least one shape

◆ ResetCompoundMeta()

void Quantum.Shape2D.CompoundShape2D.ResetCompoundMeta ( FrameBase  f)
inline

Recomputes the compound shape broad radius, centroid and area sum (the later is used internally).

Parameters
fThe frame currently being simulated.

◆ FreePersistent()

void Quantum.Shape2D.CompoundShape2D.FreePersistent ( FrameBase  f,
Boolean  freeNestedPersistent = true 
)
inline

Dispose any persistently allocated memory for this compound shape.

Parameters
fThe frame currently being simulated.
freeNestedPersistentIf nested compound shapes should also have persistent buffers disposed.

◆ ReserveCapacity()

void Quantum.Shape2D.CompoundShape2D.ReserveCapacity ( FrameBase  f,
Int32  capacity 
)
inline

Ensures that this compound shape capacity can hold at least capacity shapes.

Parameters
fThe current Frame instance
capacityThe desired capacity. The resultant capacity can be greater than or equal this value.

◆ Serialize()

static void Quantum.Shape2D.CompoundShape2D.Serialize ( void *  ptr,
FrameSerializer  serializer 
)
inlinestatic

Serializes a CompoundShape2D into a FrameSerializer.

Parameters
ptrThe pointer to the CompoundShape2D.
serializerThe FrameSerializer instance into which the struct will be serialized.

◆ GetHashCode()

override int Quantum.Shape2D.CompoundShape2D.GetHashCode ( )
inline

Overrides the hash code generation of this type.

Returns
A hash code of the current state of this instance.

Member Data Documentation

◆ SIZE

const int Quantum.Shape2D.CompoundShape2D.SIZE = Transform2D.SIZE + 2 * FP.SIZE + Ptr.SIZE + 2 * sizeof(UInt16) + 2 * sizeof(int)
static

The size of the struct in bytes.

Property Documentation

◆ IsPersistent

Boolean Quantum.Shape2D.CompoundShape2D.IsPersistent
get

If the buffer of shapes is persistently allocated.

Persistently allocated memory is not disposed automatically. Call FreePersistent when done using a persistent compound.

◆ Count

Int32 Quantum.Shape2D.CompoundShape2D.Count
get

The number of shapes in the compound buffer.