Game.Areas.Triangle
Assembly:
Assembly-CSharp
Namespace: Game.Areas
Type:
struct (value type) — IBufferElementData
Base:
Implements Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.IEmptySerializable
Summary:
Triangle is a small, plain-data buffer element used by the game's ECS to represent a triangle by its three vertex indices, a 1D bounds/height range, and a minimum level-of-detail (LOD) value. It is tagged with [InternalBufferCapacity(2)] which sets a small inline capacity for the DynamicBuffer storage so typical buffers can avoid heap allocations for very small lists. This struct is designed to be lightweight and serializable for use in Entities/DynamicBuffer workflows.
Fields
-
public int3 m_Indices
Stores the three vertex indices that form the triangle. The type int3 (from Unity.Mathematics / Colossal.Mathematics) packs three integers as a single value for compactness and SIMD friendliness. Each component corresponds to one corner of the triangle (order matters according to the calling code / mesh winding). -
public Bounds1 m_HeightRange
A 1-dimensional bounds structure (from Colossal.Mathematics) that holds the min/max or center/extent information for the triangle's height range. Used for quick tests against height/LOD systems or for culling/visibility checks that only need a vertical interval. -
public int m_MinLod
Integer storing the minimum LOD at which this triangle should be considered or rendered. A value of 0 is used by the constructor by default.
Properties
- (none)
This struct exposes only public fields; there are no C# properties.
Constructors
public Triangle(int a, int b, int c)
Initializes a Triangle by setting m_Indices to int3(a, b, c), m_HeightRange to default(Bounds1) and m_MinLod to 0. Use this constructor to quickly create a triangle element with given vertex indices.
Methods
- (none)
Triangle contains no instance methods. It's a plain data container (POD) intended for storage in a DynamicBufferon an Entity. It implements IEmptySerializable to participate in the game's custom serialization pipeline.
Usage Example
// Example: creating and using a DynamicBuffer<Triangle> in a System or MonoBehaviour that has access to an EntityManager / Entity
using Unity.Entities;
using Unity.Mathematics;
using Game.Areas;
// Assume entity has a DynamicBuffer<Triangle> (or we add it here)
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = em.CreateEntity();
em.AddBuffer<Triangle>(e);
// Fill buffer with triangles
DynamicBuffer<Triangle> tris = em.GetBuffer<Triangle>(e);
tris.Add(new Triangle(0, 1, 2));
tris.Add(new Triangle(2, 3, 0));
// Reading values
for (int i = 0; i < tris.Length; i++)
{
Triangle t = tris[i];
int a = t.m_Indices.x;
int b = t.m_Indices.y;
int c = t.m_Indices.z;
Bounds1 heightRange = t.m_HeightRange;
int minLod = t.m_MinLod;
// Use the indices and other data for mesh building / culling / LOD decisions...
}
Additional notes: - The [InternalBufferCapacity(2)] attribute hints the ECS to reserve space for up to 2 elements inline on the chunk to reduce allocations for small numbers of triangles. - int3 and Bounds1 come from the Colossal/Unity mathematics libraries used by the game; treat them as lightweight math/geometry types optimized for performance and serialization. - Because Triangle implements IEmptySerializable, it can be serialized by the game's custom serializer; default values (Bounds1 default and m_MinLod = 0) are set in the constructor.