Specifically, I’m referring to the ‘changed’ values for each component type which would cause a chunk to show up in a EntityQuery with a change filter.
Are these values only reset once, at the end of the ESC loop?
Can they be reset manually, by us?
As a use case, imagine you wanted to capture all chunks which had been changed at an early point in your loop. Then later in your loop, you wanted to capture all chunks which had been changed since the first time you checked.
(This is not a real example, and there may be better ways to accomplish this specific case with different logic. But I’m wondering if a manual reset is possible).
I have other Jobs assessing the buffer but those system only run again for the second time if I use DynamicBuffer tileBuffer = TileBuffer[e]; . If I comment it out the system only runs once.
Here is the job
struct SetTiles : IJobForEach_B<TilesBufferComponent>
{
public EntityCommandBuffer.Concurrent ecb;
[DeallocateOnJobCompletion]
public NativeArray<Entity> eTiles;
public void Execute([ReadOnly] DynamicBuffer<TilesBufferComponent> b)
{
DebugInfo();
for (int i = 0; i < b.Length; i++)
{
Entity e = eTiles[i];
ecb.SetComponent<TilePositionComponents>(i, e, new TilePositionComponents
{
Position = new float3(b[i].PositionX,
b[i].PositionY,
b[i].PositionZ)
});
}
}
[BurstDiscard]
private void DebugInfo()
{
Debug.Log("<b> <size=13> <color=#A2E721>Info : PlanetSetTileDataSystem : SetTiles 1.</color> </size> </b>");
}
}
both the last two systems implement IJobForEach_B. DynamicBuffer tileBuffer = TileBuffer[e]; is in PlanetCreateMeshSystem : GetMeshTrianglePositions[/QUOTE]
SetFilterChanged doesn’t care about read/write permissions as far as i know.
Anyway after looking at your code it work as expected.
Where are you invoking qTileBuffer.SetFilterChanged(typeof(TilesBufferComponent)); ? It should be on the system update method before everything.
Ok. Now i see what you mean and it seems that when you access a BufferFromEntity it will always be accessed as RW no matter what. Hence your data will be marked as changed just from accessing it this way.
If you look at BufferFromEntity source code you can see a remark about it:
public DynamicBuffer<T> this[Entity entity]
{
get
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
// Note that this check is only for the lookup table into the entity manager
// The native array performs the actual read only / write only checks
AtomicSafetyHandle.CheckReadAndThrow(m_Safety0);
m_EntityComponentStore->AssertEntityHasComponent(entity, m_TypeIndex);
#endif
// TODO(dep): We don't really have a way to mark the native array as read only.
BufferHeader* header = (BufferHeader*) m_EntityComponentStore->GetComponentDataWithTypeRW(entity, m_TypeIndex, m_GlobalSystemVersion, ref m_TypeLookupCache);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
return new DynamicBuffer<T>(header, m_Safety0, m_ArrayInvalidationSafety, m_IsReadOnly, m_InternalCapacity);
#else
return new DynamicBuffer<T>(header, m_InternalCapacity);
#endif
}
}
I would suggest you to rethink the way your access that data.