コード例 #1
0
            public void Execute(int index)
            {
                var chunk = Chunks[index];

                var instanceBounds = chunk.GetNativeArray(WorldRenderBoundsType);

                if (instanceBounds.Length == 0)
                {
                    return;
                }

                // TODO: Improve this approach
                // See: https://www.inf.ethz.ch/personal/emo/DoctThesisFiles/fischer05.pdf

                var chunkBounds = (Bounds)instanceBounds[0].Value;

                for (int j = 1; j < instanceBounds.Length; j++)
                {
                    chunkBounds.Encapsulate(instanceBounds[j].Value);
                }

                ChunkBounds[index] = new WorldRenderBounds {
                    Value = chunkBounds
                };
            }
コード例 #2
0
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                var        worldBounds  = chunk.GetNativeArray(WorldRenderBounds);
                var        localBounds  = chunk.GetNativeArray(RendererBounds);
                var        localToWorld = chunk.GetNativeArray(LocalToWorld);
                MinMaxAABB combined     = MinMaxAABB.Empty;

                for (int i = 0; i != localBounds.Length; i++)
                {
                    var transformed = AABB.Transform(localToWorld[i].Value, localBounds[i].Value);

                    worldBounds[i] = new WorldRenderBounds {
                        Value = transformed
                    };
                    combined.Encapsulate(transformed);
                }

                chunk.SetChunkComponentData(ChunkWorldRenderBounds, new ChunkWorldRenderBounds {
                    Value = combined
                });
            }