Continue working on RHI

This commit is contained in:
2025-09-12 21:44:32 +09:00
parent 1b0ef03728
commit 1dfed83e38
49 changed files with 1780 additions and 2195 deletions

View File

@@ -39,7 +39,7 @@ internal interface IComponentPool<T> : IComponentPool
internal class ComponentPool<T> : IComponentPool<T>
where T : unmanaged, IComponentData
{
private struct ComponentData
private struct ComponentMetadata
{
public T data;
public Entity owner;
@@ -48,7 +48,7 @@ internal class ComponentPool<T> : IComponentPool<T>
private EntityID _nextId;
private EntityID _capacity;
private ComponentData[] _components;
private ComponentMetadata[] _components;
private EntityID[] _lookup;
public EntityID Count => _nextId;
@@ -58,7 +58,7 @@ internal class ComponentPool<T> : IComponentPool<T>
_nextId = 0;
_capacity = initialSize;
_components = new ComponentData[initialSize];
_components = new ComponentMetadata[initialSize];
_lookup = new EntityID[initialSize];
_lookup.AsSpan().Fill(Entity.INVALID_ID);
@@ -124,7 +124,7 @@ internal class ComponentPool<T> : IComponentPool<T>
}
_lookup[lookupIndex] = _nextId;
_components[_nextId] = new ComponentData
_components[_nextId] = new ComponentMetadata
{
data = component,
owner = entity
@@ -205,7 +205,7 @@ internal class ComponentPool<T> : IComponentPool<T>
public void Dispose()
{
_components = Array.Empty<ComponentData>();
_components = Array.Empty<ComponentMetadata>();
_lookup = Array.Empty<EntityID>();
_nextId = 0;
_capacity = 0;

View File

@@ -47,7 +47,7 @@ public struct Entity : IEquatable<Entity>, IComparable<Entity>
public readonly bool Equals(Entity other)
{
return _id == other._id;
return _id == other._id && _generation == other._generation;
}
public readonly int CompareTo(Entity other)