What caused the “changed” status of a chunk to be reset?

…and can they be reset manually?

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).

Thank you for any help!

It’s not a bool. It is much more clever than that. Version Numbers | Package Manager UI website

Related to this can you explain to me why DynamicBuffer tileBuffer = TileBuffer[e]; trigger a change when it read only ?

        [BurstCompile]
        struct GetMeshTrianglePositions : IJobForEach_BC<TriangleBufferComponent, TileBufferReferneceComponent>
        {

            [WriteOnly] public NativeArray<Vector3> MeshTrianglePositions;
            [ReadOnly] public BufferFromEntity<TilesBufferComponent> TileBuffer;


            public void Execute([ReadOnly] DynamicBuffer<TriangleBufferComponent> t, [ReadOnly] ref TileBufferReferneceComponent c)
            {
                DebugInfo();
                Entity e = c.TileBufferEntity;
                DynamicBuffer<TilesBufferComponent> tileBuffer = TileBuffer[e];  //// THIS CAUSES A CHANGE BUT WHY
                 .....
            }

            [BurstDiscard]
            private void DebugInfo()
            {
                Debug.Log("<b> <size=13> <color=#EA70A3>Info: PlanetCreateMeshSystem : GetMeshTrianglePositions.</color> </size> </b>");
            }
        }
            var meshTrianglePositions = new NativeArray<Vector3>(triangleCount[0]*3, Allocator.TempJob);

            inputDeps = new GetMeshTrianglePositions()
            {
                MeshTrianglePositions = meshTrianglePositions,
                TileBuffer = GetBufferFromEntity<TilesBufferComponent>(true)


            }.ScheduleSingle(qTrianglesBuffer, inputDeps);
[code]

Are you sure it’s this system triggering it?

What other jobs/system are you accessing TilesBufferComponent

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>");
            }
        }
..
            inputDeps = new SetTiles()
            {
                ecb = ecbs.CreateCommandBuffer().ToConcurrent(),
                eTiles = qTiles.ToEntityArray(Allocator.TempJob)

            }.ScheduleSingle( qTileBuffer, inputDeps);
..
..
qTileBuffer.SetFilterChanged(typeof(TilesBufferComponent));
..

Here is what i seen when I comment it out


Vs not

both the last two systems implement IJobForEach_B. DynamicBuffer tileBuffer = TileBuffer[e]; is in PlanetCreateMeshSystem : GetMeshTrianglePositions[/QUOTE]

How is your EntityQuery (qTileBuffer??!!??) looks like?
It should declare TilesBufferComponent as readonly too.

Its read only but setfilter is just typeof, i dont have Unity in front of me atm but should SetFilter be read only ?

 qTileBuffer = GetEntityQuery(ComponentType.ReadOnly < TilesBufferComponent>());

// but ..
qTileBuffer.SetFilterChanged(typeof(TilesBufferComponent));

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.

OK thanks for digging into this …

Are there any obvious drawbacks if I just deleted the entity with the buffers. The mesh build system is not intended to updated per frame