mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
Merge branch 'dev'
This commit is contained in:
commit
337ad33e63
@ -353,16 +353,16 @@ namespace DCFApixels.DragonECS
|
|||||||
private UnsafeArray<EcsMaskChunck> _sortIncChunckBuffer;
|
private UnsafeArray<EcsMaskChunck> _sortIncChunckBuffer;
|
||||||
private UnsafeArray<EcsMaskChunck> _sortExcChunckBuffer;
|
private UnsafeArray<EcsMaskChunck> _sortExcChunckBuffer;
|
||||||
|
|
||||||
private readonly int _entityComponentMaskLength;
|
private readonly int _entityComponentMaskBitShift;
|
||||||
|
|
||||||
public unsafe Enumerator(EcsSpan span, EcsAspect aspect)
|
public unsafe Enumerator(EcsSpan span, EcsAspect aspect)
|
||||||
{
|
{
|
||||||
_span = span.GetEnumerator();
|
|
||||||
_entityComponentMasks = aspect.World._entityComponentMasks;
|
_entityComponentMasks = aspect.World._entityComponentMasks;
|
||||||
_sortIncChunckBuffer = aspect._sortIncChunckBuffer;
|
_sortIncChunckBuffer = aspect._sortIncChunckBuffer;
|
||||||
_sortExcChunckBuffer = aspect._sortExcChunckBuffer;
|
_sortExcChunckBuffer = aspect._sortExcChunckBuffer;
|
||||||
|
|
||||||
_entityComponentMaskLength = aspect.World._entityComponentMaskLength;
|
_entityComponentMaskBitShift = aspect.World._entityComponentMaskLength;
|
||||||
|
_entityComponentMaskBitShift = BitsUtility.GetHighBitNumber(_entityComponentMaskBitShift);
|
||||||
|
|
||||||
#region Sort
|
#region Sort
|
||||||
UnsafeArray<int> _sortIncBuffer = aspect._sortIncBuffer;
|
UnsafeArray<int> _sortIncBuffer = aspect._sortIncBuffer;
|
||||||
@ -403,7 +403,11 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_sortIncChunckBuffer.Length > 0 && counts[_sortIncBuffer.ptr[0]] <= 0)
|
||||||
|
{
|
||||||
|
_span = span.Slice(0, 0).GetEnumerator();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_sortExcChunckBuffer.Length > 1)
|
if (_sortExcChunckBuffer.Length > 1)
|
||||||
{
|
{
|
||||||
ExcCountComparer excComparer = new ExcCountComparer(counts);
|
ExcCountComparer excComparer = new ExcCountComparer(counts);
|
||||||
@ -434,6 +438,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
_span = span.GetEnumerator();
|
||||||
}
|
}
|
||||||
public int Current
|
public int Current
|
||||||
{
|
{
|
||||||
@ -445,11 +450,11 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
while (_span.MoveNext())
|
while (_span.MoveNext())
|
||||||
{
|
{
|
||||||
int e = _span.Current;
|
int chunck = _span.Current << _entityComponentMaskBitShift;
|
||||||
for (int i = 0; i < _sortIncChunckBuffer.Length; i++)
|
for (int i = 0; i < _sortIncChunckBuffer.Length; i++)
|
||||||
{
|
{
|
||||||
var bit = _sortIncChunckBuffer.ptr[i];
|
var bit = _sortIncChunckBuffer.ptr[i];
|
||||||
if ((_entityComponentMasks[e * _entityComponentMaskLength + bit.chankIndex] & bit.mask) != bit.mask)
|
if ((_entityComponentMasks[chunck + bit.chankIndex] & bit.mask) != bit.mask)
|
||||||
{
|
{
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
@ -457,7 +462,7 @@ namespace DCFApixels.DragonECS
|
|||||||
for (int i = 0; i < _sortExcChunckBuffer.Length; i++)
|
for (int i = 0; i < _sortExcChunckBuffer.Length; i++)
|
||||||
{
|
{
|
||||||
var bit = _sortExcChunckBuffer.ptr[i];
|
var bit = _sortExcChunckBuffer.ptr[i];
|
||||||
if ((_entityComponentMasks[e * _entityComponentMaskLength + bit.chankIndex] & bit.mask) > 0)
|
if ((_entityComponentMasks[chunck + bit.chankIndex] & bit.mask) != 0)
|
||||||
{
|
{
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
@ -544,12 +544,17 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
_entityDispenser.Upsize(minSize);
|
_entityDispenser.Upsize(minSize);
|
||||||
}
|
}
|
||||||
|
private int CalcEntityComponentMaskLastIndex()
|
||||||
|
{
|
||||||
|
int result = _pools.Length / COMPONENT_MASK_CHUNK_SIZE;
|
||||||
|
return (result < 2 ? 2 : result);
|
||||||
|
}
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
private void OnEntityDispenserResized(int newSize)
|
private void OnEntityDispenserResized(int newSize)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _entities, newSize);
|
Array.Resize(ref _entities, newSize);
|
||||||
Array.Resize(ref _delEntBuffer, newSize);
|
Array.Resize(ref _delEntBuffer, newSize);
|
||||||
_entityComponentMaskLength = _pools.Length / COMPONENT_MASK_CHUNK_SIZE + 1;
|
_entityComponentMaskLength = CalcEntityComponentMaskLastIndex();//_pools.Length / COMPONENT_MASK_CHUNK_SIZE + 1;
|
||||||
Array.Resize(ref _entityComponentMasks, newSize * _entityComponentMaskLength);
|
Array.Resize(ref _entityComponentMasks, newSize * _entityComponentMaskLength);
|
||||||
|
|
||||||
ArrayUtility.Fill(_entities, EntitySlot.Empty, _entitiesCapacity);
|
ArrayUtility.Fill(_entities, EntitySlot.Empty, _entitiesCapacity);
|
||||||
|
@ -166,7 +166,7 @@ namespace DCFApixels.DragonECS
|
|||||||
Array.Resize(ref _poolComponentCounts, _pools.Length);
|
Array.Resize(ref _poolComponentCounts, _pools.Length);
|
||||||
ArrayUtility.Fill(_pools, _nullPool, oldCapacity, oldCapacity - _pools.Length);
|
ArrayUtility.Fill(_pools, _nullPool, oldCapacity, oldCapacity - _pools.Length);
|
||||||
|
|
||||||
int newEntityComponentMaskLength = _pools.Length / COMPONENT_MASK_CHUNK_SIZE + 1;
|
int newEntityComponentMaskLength = CalcEntityComponentMaskLastIndex(); //_pools.Length / COMPONENT_MASK_CHUNK_SIZE + 1;
|
||||||
int dif = newEntityComponentMaskLength - _entityComponentMaskLength;
|
int dif = newEntityComponentMaskLength - _entityComponentMaskLength;
|
||||||
if (dif > 0)
|
if (dif > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user