Skip to content

Game.LocalNodeCache

Assembly:
Assembly-CSharp (typical for game/mod code)

Namespace:
Game.Tools

Type:
struct

Base:
Unity.Entities.IBufferElementData

Summary:
LocalNodeCache is a lightweight buffer element used to store per-node data for local mesh/node caching. It contains a position (float3) and an integer index referring to a parent mesh. The struct is marked with [InternalBufferCapacity(0)], which forces the buffer to have no inline capacity (elements are stored out-of-line), making it suitable for variable-size collections attached to entities.


Fields

  • public float3 m_Position
    Stores the node's position in local space (Unity.Mathematics.float3). Typically used for spatial lookups, transformations, or reconstruction of cached node geometry.

  • public int m_ParentMesh
    Index or identifier of the parent mesh associated with this node. The meaning of the index depends on the caller's conventions (for example: index into a mesh table, or -1 if no parent). Used to associate cached nodes back to their source mesh.

Properties

  • None (this is a plain data buffer element; fields are accessed directly)

Constructors

  • public LocalNodeCache()
    Implicit default constructor provided by the runtime. Create and initialize instances via object initializer syntax:
new LocalNodeCache { m_Position = new float3(0f, 0f, 0f), m_ParentMesh = -1 };

Methods

  • None (no methods defined on this struct)

Usage Example

Common usage is to attach a DynamicBuffer to an Entity and read/write entries from a SystemBase or other ECS code:

// Add a buffer to an entity (EntityManager or in a system)
EntityManager.AddBuffer<LocalNodeCache>(entity);

// Fill the buffer
var buffer = EntityManager.GetBuffer<LocalNodeCache>(entity);
buffer.Add(new LocalNodeCache { m_Position = new float3(1f, 2f, 3f), m_ParentMesh = parentMeshIndex });

// In a SystemBase job/for-each
Entities
    .WithName("ProcessLocalNodeCache")
    .ForEach((ref DynamicBuffer<LocalNodeCache> cache) =>
    {
        for (int i = 0; i < cache.Length; i++)
        {
            var entry = cache[i];
            // process entry.m_Position and entry.m_ParentMesh
        }
    }).Schedule();

Notes and recommendations: - Because the struct implements IBufferElementData, it must remain blittable (current fields are blittable). - The [InternalBufferCapacity(0)] attribute means the buffer stores no inline elements on the entity; use this when buffer sizes vary or may grow large to avoid entity memory bloat. - Define and follow a consistent convention for what m_ParentMesh contains (index base, sentinel values such as -1).