Skip to content

Game.GroupData

Assembly: Assembly-CSharp
Namespace: Game.Rendering

Type: struct

Base: System.ValueType

Summary:
Represents per-mesh-group rendering data used by the rendering system. Holds a reference to the mesh entity, bounding/secondary bounds, mesh layer/type, partitioning, render flags, LOD count, and a small fixed-size property-index table for up to 16 properties. The struct uses an unsafe fixed buffer to store property indices and therefore requires the project to be compiled with unsafe code enabled.


Fields

  • public Entity m_Mesh
    Reference to the Entity that owns or represents the mesh for this group.

  • public float3 m_SecondaryCenter
    Secondary bounding center (float3). Typically used for secondary bounds or offset used by the renderer.

  • public float3 m_SecondarySize
    Secondary bounding size (float3). Typically used for secondary bounds used by culling/rendering decisions.

  • public MeshLayer m_Layer
    Mesh layer (from Game.Prefabs.MeshLayer) indicating which rendering layer this group belongs to.

  • public MeshType m_MeshType
    Mesh type (from Game.Prefabs.MeshType) describing the category/type of mesh.

  • public ushort m_Partition
    Partition index (unsigned short) used to split render groups across partitions/buckets.

  • public BatchRenderFlags m_RenderFlags
    Flags controlling batch/render behavior for this group.

  • public byte m_LodCount
    Number of LODs available for this mesh group (0..255, but practically small).

  • private const int MAX_PROPERTY_COUNT1 = 15
    Internal legacy/auxiliary constant. Not used directly by external code.

  • private const int MAX_PROPERTY_COUNT2 = 16
    Internal legacy/auxiliary constant. Matches MAX_PROPERTY_COUNT.

  • public const int MAX_PROPERTY_COUNT = 16
    Maximum number of property slots available in the fixed property table.

  • private unsafe fixed sbyte m_Properties[16]
    Unsafe fixed-size buffer storing up to 16 signed-byte property indices. Each slot contains a signed index; negative values indicate "not present".

Properties

  • (none)

Constructors

  • public GroupData()
    Structs in C# have an implicit parameterless constructor that zero-initializes all fields. That means m_Mesh will be Entity.Null (or default), numeric fields zero, and all entries in m_Properties will be 0. Note: if 0 is a valid property index you should explicitly initialize m_Properties slots to -1 to mark them as empty.

Methods

  • public unsafe bool GetPropertyIndex(int property, out int index)
    Retrieves the stored property index for the given property slot (0..15). Implementation reads the sbyte value stored in m_Properties[property], assigns it to the out parameter, and returns true when the stored index is >= 0 (meaning present). Caller responsibilities and notes:
  • The method is unsafe because it indexes a fixed buffer.
  • The caller must ensure property is within range [0, MAX_PROPERTY_COUNT-1] (0..15); there is no bounds checking in the method.
  • The returned index value can be negative to indicate absence (method returns false when negative).
  • Because values are stored as sbyte, valid index range is -128..127. Ensure indices you write fit in that range.

  • public unsafe void SetPropertyIndex(int property, int index)
    Sets the property index for the given property slot by casting the provided int to sbyte and storing it into m_Properties[property]. Notes:

  • The method is unsafe because it writes into a fixed buffer.
  • The caller must ensure property is within range [0, MAX_PROPERTY_COUNT-1].
  • The index is cast to sbyte; if the int is outside sbyte range (-128..127) it will overflow/truncate. Use -1 to mark "not present".

Usage Example

// Example usage of GroupData to set and get property indices.
// Requires project to be compiled with /unsafe because GroupData uses an unsafe fixed buffer.

var group = new Game.Rendering.GroupData();

// Mark all property slots as empty if needed (recommended to use -1 as "not present")
for (int i = 0; i < Game.Rendering.GroupData.MAX_PROPERTY_COUNT; i++)
{
    group.SetPropertyIndex(i, -1);
}

// Assign a property index (e.g., set property slot 3 to index 5)
group.SetPropertyIndex(3, 5);

// Read it back
if (group.GetPropertyIndex(3, out int idx) && idx >= 0)
{
    // idx == 5
    UnityEngine.Debug.Log($"Property 3 index = {idx}");
}
else
{
    UnityEngine.Debug.Log("Property 3 not present");
}

Additional notes: - Because the struct uses a fixed sbyte buffer, any direct manipulation or compilation must allow unsafe code (enable /unsafe in project settings). - The fixed buffer reduces allocations and keeps the struct compact for use in performance-sensitive contexts (e.g., rendering/batching systems).