コード例 #1
0
        protected override void OnCreateManager( )
        {
            base.OnCreateManager( );


            // Test bounds
            // Many bounds, to many octrees
            // Where each bounds has one entity target.
            // Results return, weather collision with an instance occured.


            // Toggle manually only one example systems at the time
            if (!(ExampleSelector.selector == Selector.IsBoundsCollidingSystem_Bounds2Octree))
            {
                return;                                                                                     // Early exit
            }
            Debug.Log("Start Test Is Bounds Colliding Octree System");


            // ***** Initialize Octree ***** //

            // Create new octree
            // See arguments details (names) of _CreateNewOctree and coresponding octree readme file.
            EntityCommandBuffer ecb = barrier.CreateCommandBuffer();
            Entity newOctreeEntity  = EntityManager.CreateEntity( );

            AddNewOctreeSystem._CreateNewOctree(ecb, newOctreeEntity, 8, float3.zero, 1, 1, 1);

            EntityManager.AddComponent(newOctreeEntity, typeof(IsBoundsCollidingTag));



            // Assign target bounds entity, to octree entity
            Entity octreeEntity = newOctreeEntity;



            // ***** Example Components To Add / Remove Instance ***** //

            // Example of adding and removing some instanceses, hence entity blocks.


            // Add

            int i_instances2AddCount = ExampleSelector.i_generateInstanceInOctreeCount;  // Example of x octrees instances. // 100
            NativeArray <Entity> a_instanceEntities = Common._CreateInstencesArray(EntityManager, i_instances2AddCount);

            // Request to add n instances.
            // User is responsible to ensure, that instances IDs are unique in the octrtree.
            EntityManager.AddBuffer <AddInstanceBufferElement> (octreeEntity);    // Once system executed and instances were added, buffer will be deleted.
            BufferFromEntity <AddInstanceBufferElement> addInstanceBufferElement = GetBufferFromEntity <AddInstanceBufferElement> ();

            Common._RequesAddInstances(ecb, octreeEntity, addInstanceBufferElement, ref a_instanceEntities, i_instances2AddCount);



            // Remove

            EntityManager.AddBuffer <RemoveInstanceBufferElement> (octreeEntity);    // Once system executed and instances were removed, component will be deleted.
            BufferFromEntity <RemoveInstanceBufferElement> removeInstanceBufferElement = GetBufferFromEntity <RemoveInstanceBufferElement> ();

            // Request to remove some instances
            // Se inside method, for details
            int i_instances2RemoveCount = ExampleSelector.i_deleteInstanceInOctreeCount = 53;  // Example of x octrees instances / entities to delete. // 53

            Common._RequestRemoveInstances(ecb, octreeEntity, removeInstanceBufferElement, ref a_instanceEntities, i_instances2RemoveCount);


            // Ensure example array is disposed.
            a_instanceEntities.Dispose();



            // ***** Example Bounds Components For Collision Checks ***** //

            Debug.Log("Octree: create dummy boundary box, to test for collision.");
            float3 f3_blockCenter = new float3(10, 2, 10);

            // Only test
            Blocks.PublicMethods._AddBlockRequestViaCustomBufferWithEntity(ecb, EntityManager.CreateEntity(), f3_blockCenter, new float3(1, 1, 1) * 5);

            // Create test bounds
            // Many bounds, to many octrees
            // Where each bounds has one octree entity target.
            for (int i = 0; i < 10; i++)
            {
                ecb.CreateEntity( );   // Check bounds collision with octree and return colliding instances.
                ecb.AddComponent(new IsActiveTag());
                ecb.AddComponent(new IsBoundsCollidingTag());
                // This may be overritten by, other system. Check corresponding collision check system.
                ecb.AddComponent(new BoundsData()
                {
                    bounds = new Bounds()
                    {
                        center = float3.zero, size = new float3(5, 5, 5)
                    }
                });
                // Check bounds collision with octree and return colliding instances.
                ecb.AddComponent(new OctreeEntityPair4CollisionData()
                {
                    octree2CheckEntity = newOctreeEntity
                });
                ecb.AddComponent(new IsCollidingData());      // Check bounds collision with octree and return colliding instances.
                // ecb.AddBuffer <CollisionInstancesBufferElement> () ; // Not required in this system
            } // for
        }
        protected override void OnCreateManager( )
        {
            base.OnCreateManager( );


            // Test octrees
            // Many octrees, to ray pair
            // Where each octree has one ray entity target.
            // Results return, weather collision with an instance occured.

            // Toggle manually only one example systems at the time
            if (!(ExampleSelector.selector == Selector.IsRayCollidingSystem_Octrees2Ray))
            {
                return;                                                                                // Early exit
            }
            Debug.Log("Start Test Is Ray Colliding Octree System");


            // Create new octree
            // See arguments details (names) of _CreateNewOctree and coresponding octree readme file.
            EntityCommandBuffer ecb = barrier.CreateCommandBuffer();



            // Many octrees, to single, or many rays
            // Where each octree has one ray entity target.

            // ***** Example Ray Components For Collision Checks ***** //

            // Test ray entity
            // for each octree
            Entity rayEntity = EntityManager.CreateEntity();

            EntityManager.AddComponentData(rayEntity, new IsActiveTag());
            EntityManager.AddComponentData(rayEntity, new RayData());
            EntityManager.AddComponentData(rayEntity, new RayMaxDistanceData()
            {
                f = 100f
            });


            // ***** Initialize Octree ***** //

            int i_octreesCount = ExampleSelector.i_generateInstanceInOctreeCount;  // Example of x octrees instances. // 1000

            for (int i_octreeEntityIndex = 0; i_octreeEntityIndex < i_octreesCount; i_octreeEntityIndex++)
            {
                ecb = barrier.CreateCommandBuffer();
                Entity newOctreeEntity = EntityManager.CreateEntity( );

                AddNewOctreeSystem._CreateNewOctree(ecb, newOctreeEntity, 8, float3.zero - new float3(1, 1, 1) * 0.5f, 1, 1.01f, 1);

                EntityManager.AddComponent(newOctreeEntity, typeof(IsRayCollidingTag));

                EntityManager.AddComponentData(newOctreeEntity, new IsCollidingData());      // Check bounds collision with octree and return colliding instances.
                EntityManager.AddBuffer <CollisionInstancesBufferElement> (newOctreeEntity);


                // Assign target ray entity, to octree entity
                Entity octreeEntity = newOctreeEntity;

                // Check bounds collision with octree and return colliding instances.
                EntityManager.AddComponentData(octreeEntity, new RayEntityPair4CollisionData()
                {
                    ray2CheckEntity = rayEntity
                });



                // ***** Example Components To Add / Remove Instance ***** //

                // Example of adding and removing some instanceses, hence entity blocks.


                // Add

                int i_instances2AddCount = 100;
                NativeArray <Entity> a_instanceEntities = Common._CreateInstencesArray(EntityManager, i_instances2AddCount);

                // Request to add n instances.
                // User is responsible to ensure, that instances IDs are unique in the octrtree.
                EntityManager.AddBuffer <AddInstanceBufferElement> (octreeEntity);    // Once system executed and instances were added, buffer will be deleted.
                BufferFromEntity <AddInstanceBufferElement> addInstanceBufferElement = GetBufferFromEntity <AddInstanceBufferElement> ();

                Common._RequesAddInstances(ecb, octreeEntity, addInstanceBufferElement, ref a_instanceEntities, i_instances2AddCount);



                // Remove

                EntityManager.AddBuffer <RemoveInstanceBufferElement> (octreeEntity);    // Once system executed and instances were removed, component will be deleted.
                BufferFromEntity <RemoveInstanceBufferElement> removeInstanceBufferElement = GetBufferFromEntity <RemoveInstanceBufferElement> ();

                // Request to remove some instances
                // Se inside method, for details
                int i_instances2RemoveCount = ExampleSelector.i_deleteInstanceInOctreeCount;  // Example of x octrees instances / entities to delete. // 53
                Common._RequestRemoveInstances(ecb, octreeEntity, removeInstanceBufferElement, ref a_instanceEntities, i_instances2RemoveCount);


                // Ensure example array is disposed.
                a_instanceEntities.Dispose();
            } // for
        }
コード例 #3
0
        protected override void OnCreate( )
        {
            // Test octrees
            // Many octrees, to bounds pair
            // Where each octree has one bounds entity target.
            // Results return, weather collision with an instance occured.

            // Toggle manually only one example systems at the time
            // if ( !( OctreeExample_Selector.selector == Selector.IsBoundsCollidingSystem_Octrees2Bounds ) ) return ; // Early exit


            Debug.Log("Start Test Is Bounds Colliding Octree System");


            // Create new octree
            // See arguments details (names) of _CreateNewOctree and coresponding octree readme file.

            eiecb = World.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem> ();
            EntityCommandBuffer ecb = eiecb.CreateCommandBuffer();



            // Many octrees, to single, or many rays
            // Where each octree has one ray entity target.

            // ***** Example Ray Components For Collision Checks ***** //

            // RenderMeshTypesData renderMeshTypes = EntityManager.GetComponentData <RenderMeshTypesData> ( Bootstrap.renderMeshTypesEntity ) ;

            // Test bounds entity
            // for each octree
            Entity boundsEntity = EntityManager.Instantiate(PrefabsSpawner_FromEntity.spawnerEntitiesPrefabs.boundingBoxEntity);

            EntityManager.AddComponent <IsActiveTag> (boundsEntity);
            // EntityManager.AddComponent <MeshTypeData> ( boundsEntity ) ;

            // This may be overritten, by other system. Check corresponding "collision check system".
            EntityManager.AddComponentData(boundsEntity, new BoundsData()
            {
                bounds = new Bounds()
                {
                    center = float3.zero, size = new float3(1, 1, 1) * 5
                }
            });


            Debug.Log("Octree: create dummy (for visualization only) boundary box, to test for collision.");
            float3 f3_blockCenter = new float3(10, 2, 3);

            // Only test
            Blocks.PublicMethods._AddBlockRequestViaCustomBufferWithEntity(ref ecb, boundsEntity, f3_blockCenter, new float3(1, 1, 1) * 5, MeshType.BoundingBox);
            //Blocks.PublicMethods._AddBlockRequestViaCustomBufferWithEntity ( ref ecb, boundsEntity, f3_blockCenter, new float3 ( 1, 1, 1 ) * 5 ) ;


            // ***** Initialize Octree ***** //

            int i_octreesCount = OctreeExample_Selector.i_octreesCount;  // Example of x octrees.

            // int i_octreesCount = 100 ; // Example of x octrees.

            for (int i_octreeEntityIndex = 0; i_octreeEntityIndex < i_octreesCount; i_octreeEntityIndex++)
            {
                // ecb = eiecb.CreateCommandBuffer () ;
                Entity newOctreeEntity = EntityManager.CreateEntity(AddNewOctreeSystem.octreeArchetype);
                AddNewOctreeSystem._CreateNewOctree(ref ecb, newOctreeEntity, 4, float3.zero - new float3(1, 1, 1) * 2, 2, 1);        // ok // Minimum node size of 2 -> up to 8 instances per node.

                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 1, float3.zero - new float3 ( 1, 1, 1 ) * 0.5f, 1, 1 ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 2, float3.zero - new float3 ( 1, 1, 1 ), 1, 1 ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 4, float3.zero - new float3 ( 1, 1, 1 ) * 2, 1, 1 ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 8, float3.zero - new float3 ( 1, 1, 1 ) * 4, 1, 1 ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 16, float3.zero - new float3 ( 1, 1, 1 ) * 8, 1, 1 ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 8, float3.zero - new float3 ( 1, 1, 1 ) * 0.5f, 1, 1 ) ; // Faulty
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 8, float3.zero, 1, 1 ) ; // Faulty

                EntityManager.AddComponent(newOctreeEntity, typeof(IsBoundsCollidingTag));

                EntityManager.AddComponentData(newOctreeEntity, new IsCollidingData());      // Check bounds collision with octree and return colliding instances.


                // Assign target bounds entity, to octree entity
                Entity octreeEntity = newOctreeEntity;

                // Check bounds collision with octree and return colliding instances.
                EntityManager.AddComponentData(octreeEntity, new BoundsEntityPair4CollisionData()
                {
                    bounds2CheckEntity = boundsEntity
                });



                // ***** Example Components To Add / Remove Instance ***** //

                // Example of adding and removing some instanceses, hence entity blocks.


                // Add

                // Bootstrap.EntitiesPrefabsData entitiesPrefabs = EntityManager.GetComponentData <Bootstrap.EntitiesPrefabsData> ( Bootstrap.entitiesPrefabsEntity ) ;

                int i_instances2AddCount = OctreeExample_Selector.i_generateInstanceInOctreeCount;                       // Example of x octrees instances. // 1000
                NativeArray <Entity> na_instanceEntities = Common._CreateInstencesArray(EntityManager, i_instances2AddCount);

                // Request to add n instances.
                // User is responsible to ensure, that instances IDs are unique in the octrtree.
                ecb.AddComponent <AddInstanceTag> (octreeEntity);    // Once system executed and instances were added, tag component will be deleted.
                // EntityManager.AddBuffer <AddInstanceBufferElement> ( octreeEntity ) ; // Once system executed and instances were added, buffer will be deleted.
                BufferFromEntity <AddInstanceBufferElement> addInstanceBufferElement = GetBufferFromEntity <AddInstanceBufferElement> ();

                Common._RequesAddInstances(ref ecb, octreeEntity, addInstanceBufferElement, ref na_instanceEntities, i_instances2AddCount);



                // Remove

                ecb.AddComponent <RemoveInstanceTag> (octreeEntity);    // Once system executed and instances were removed, tag component will be deleted.
                // EntityManager.AddBuffer <RemoveInstanceBufferElement> ( octreeEntity ) ; // Once system executed and instances were removed, component will be deleted.
                BufferFromEntity <RemoveInstanceBufferElement> removeInstanceBufferElement = GetBufferFromEntity <RemoveInstanceBufferElement> ();

                // Request to remove some instances
                // Se inside method, for details
                int i_instances2RemoveCount = OctreeExample_Selector.i_deleteInstanceInOctreeCount;  // Example of x octrees instances / entities to delete. // 53
                Common._RequestRemoveInstances(ref ecb, octreeEntity, removeInstanceBufferElement, ref na_instanceEntities, i_instances2RemoveCount);


                // Ensure example array is disposed.
                na_instanceEntities.Dispose();
            } // for
        }
        protected override void OnCreate( )
        {
            // Test rays
            // Many rays, to many octrees
            // Where each ray has one entity target.
            // Results return, weather collision with an instance occured.


            // Toggle manually only one example systems at the time
            // if ( !( OctreeExample_Selector.selector == Selector.IsRayCollidingSystem_Rays2Octree ) ) return ; // Early exit

            Debug.Log("Start Test Is Ray Colliding Octree System");


            // ***** Initialize Octree ***** //

            // Create new octree
            // See arguments details (names) of _CreateNewOctree and coresponding octree readme file.

            Entity newOctreeEntity = EntityManager.CreateEntity(AddNewOctreeSystem.octreeArchetype);

            eiecb = World.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem> ();
            EntityCommandBuffer ecb = eiecb.CreateCommandBuffer();

            AddNewOctreeSystem._CreateNewOctree(ref ecb, newOctreeEntity, 4, float3.zero - new float3(1, 1, 1) * 2, 2, 1.01f);        // ok // Minimum node size of 2 -> up to 8 instances per node.

            // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 1, float3.zero - new float3 ( 1, 1, 1 ) * 0.5f, 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
            // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 2, float3.zero - new float3 ( 1, 1, 1 ), 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
            // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 4, float3.zero - new float3 ( 1, 1, 1 ) * 2, 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
            // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 8, float3.zero - new float3 ( 1, 1, 1 ) * 4, 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
            // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 16, float3.zero - new float3 ( 1, 1, 1 ) * 8, 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
            // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 8, float3.zero - new float3 ( 1, 1, 1 ) * 0.5f, 1, 1.01f ) ; // Faulty

            // EntityManager.AddComponent ( newOctreeEntity, typeof ( IsRayCollidingTag ) ) ;



            // Assign target ray entity, to octree entity
            Entity octreeEntity = newOctreeEntity;


            // ***** Example Components To Add / Remove Instance ***** //

            // Example of adding and removing some instanceses, hence entity blocks.


            // Add

            // RenderMeshTypesData renderMeshTypes = EntityManager.GetComponentData <RenderMeshTypesData> ( Bootstrap.renderMeshTypesEntity ) ;
            // Bootstrap.EntitiesPrefabsData entitiesPrefabs = EntityManager.GetComponentData <Bootstrap.EntitiesPrefabsData> ( Bootstrap.entitiesPrefabsEntity ) ;

            int i_instances2AddCount = OctreeExample_Selector.i_generateInstanceInOctreeCount;                       // Example of x octrees instances. // 100
            NativeArray <Entity> na_instanceEntities = Common._CreateInstencesArray(EntityManager, i_instances2AddCount);

            // Request to add n instances.
            // User is responsible to ensure, that instances IDs are unique in the octrtree.
            ecb.AddComponent <AddInstanceTag> (octreeEntity);    // Once system executed and instances were added, tag component will be deleted.
            // EntityManager.AddBuffer <AddInstanceBufferElement> ( octreeEntity ) ; // Once system executed and instances were added, buffer will be deleted.
            BufferFromEntity <AddInstanceBufferElement> addInstanceBufferElement = GetBufferFromEntity <AddInstanceBufferElement> ();

            Common._RequesAddInstances(ref ecb, octreeEntity, addInstanceBufferElement, ref na_instanceEntities, i_instances2AddCount);



            // Remove

            ecb.AddComponent <RemoveInstanceTag> (octreeEntity);    // Once system executed and instances were removed, tag component will be deleted.
            // EntityManager.AddBuffer <RemoveInstanceBufferElement> ( octreeEntity ) ; // Once system executed and instances were removed, component will be deleted.
            BufferFromEntity <RemoveInstanceBufferElement> removeInstanceBufferElement = GetBufferFromEntity <RemoveInstanceBufferElement> ();

            // Request to remove some instances
            // Se inside method, for details
            int i_instances2RemoveCount = OctreeExample_Selector.i_deleteInstanceInOctreeCount;  // Example of x octrees instances / entities to delete. // 53

            Common._RequestRemoveInstances(ref ecb, octreeEntity, removeInstanceBufferElement, ref na_instanceEntities, i_instances2RemoveCount);


            // Ensure example array is disposed.
            na_instanceEntities.Dispose();



            // ***** Example Ray Components For Collision Checks ***** //

            int i_raysCount = OctreeExample_Selector.i_raysCount;  // Example of x rays.

            // Create test rays
            // Many rays, to many octrees
            // Where each ray has one octree entity target.
            for (int i = 0; i < i_raysCount; i++)
            {
                Entity testEntity = ecb.CreateEntity( );   // Check bounds collision with octree and return colliding instances.

                ecb.AddComponent(testEntity, new IsActiveTag());
                ecb.AddComponent(testEntity, new IsRayCollidingTag());
                ecb.AddComponent(testEntity, new RayData());
                ecb.AddComponent(testEntity, new RayMaxDistanceData()
                {
                    f = 100f
                });
                // Check bounds collision with octree and return colliding instances.
                ecb.AddComponent(testEntity, new OctreeEntityPair4CollisionData()
                {
                    octree2CheckEntity = newOctreeEntity
                });
                ecb.AddComponent(testEntity, new IsCollidingData());      // Check bounds collision with octree and return colliding instances.
                // ecb.AddBuffer <CollisionInstancesBufferElement> () ; // Not required in this system
            } // for
        }
コード例 #5
0
        protected override void OnCreate( )
        {
            // Test octrees
            // Many octrees, to ray pair
            // Where each octree has one ray entity target.
            // Results return number of colliding instance
            // index to list of the colliding instances IDs,
            // and distance to the nearest instance.

            // Toggle manually only one example systems at the time
            // if ( !( OctreeExample_Selector.selector == Selector.GetCollidingRayInstancesSystem_Octrees2Ray ) ) return ; // Early exit


            Debug.Log("Start Test Get Colliding Ray Instances System");


            // Create new octree
            // See arguments details (names) of _CreateNewOctree and coresponding octree readme file.

            eiecb = World.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem> ();
            // EntityCommandBuffer ecb = eiecb.CreateCommandBuffer () ;



            // Many octrees, to single, or many rays
            // Where each octree has one ray entity target.

            // ***** Example Ray Components For Collision Checks ***** //

            // Test ray entity
            // for each octree
            Entity rayEntity = EntityManager.CreateEntity();

            EntityManager.AddComponentData(rayEntity, new IsActiveTag());
            EntityManager.AddComponentData(rayEntity, new RayData());
            EntityManager.AddComponentData(rayEntity, new RayMaxDistanceData()
            {
                f = 1000f
            });



            // ***** Initialize Octree ***** //

            // Creates x octrees with same amount of instances.
            int i_octreesCount = OctreeExample_Selector.i_octreesCount;  // Example of x octrees.
            // int i_octreesCount = 100 ; // Example of x octrees.

            NativeArray <Entity> a_entities = new NativeArray <Entity> (i_octreesCount, Allocator.Temp);

            EntityCommandBuffer ecb = eiecb.CreateCommandBuffer();

            for (int i_octreeEntityIndex = 0; i_octreeEntityIndex < i_octreesCount; i_octreeEntityIndex++)
            {
                // ecb = barrier.CreateCommandBuffer () ;
                Entity newOctreeEntity = EntityManager.CreateEntity(AddNewOctreeSystem.octreeArchetype);
                AddNewOctreeSystem._CreateNewOctree(ref ecb, newOctreeEntity, 4, float3.zero - new float3(1, 1, 1) * 2, 2, 1.01f);        // ok // Minimum node size of 2 -> up to 8 instances per node.

                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 1, float3.zero - new float3 ( 1, 1, 1 ) * 0.5f, 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 2, float3.zero - new float3 ( 1, 1, 1 ), 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 4, float3.zero - new float3 ( 1, 1, 1 ) * 2, 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 8, float3.zero - new float3 ( 1, 1, 1 ) * 4, 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 16, float3.zero - new float3 ( 1, 1, 1 ) * 8, 1, 1.01f ) ; // ok // Minimum node size of 1 -> up to 1 instances per node.
                // AddNewOctreeSystem._CreateNewOctree ( ref ecb, newOctreeEntity, 8, float3.zero - new float3 ( 1, 1, 1 ) * 0.5f, 1, 1.01f ) ; // Faulty

                EntityManager.AddComponent(newOctreeEntity, typeof(GetCollidingRayInstancesTag));

                EntityManager.AddComponentData(newOctreeEntity, new IsCollidingData());      // Check bounds collision with octree and return colliding instances.
                EntityManager.AddBuffer <CollisionInstancesBufferElement> (newOctreeEntity);


                // Assign target ray entity, to octree entity
                Entity octreeEntity = newOctreeEntity;

                // Check bounds collision with octree and return colliding instances.
                EntityManager.AddComponentData(octreeEntity, new RayEntityPair4CollisionData()
                {
                    ray2CheckEntity = rayEntity
                });



                // ***** Example Components To Add / Remove Instance ***** //

                // Example of adding and removing some instanceses, hence entity blocks.


                // Add

                int i_instances2AddCount = OctreeExample_Selector.i_generateInstanceInOctreeCount;                  // Example of x octrees instances. // 10000
                NativeArray <Entity> na_instanceEntities = Common._CreateInstencesArray(EntityManager, i_instances2AddCount);

                // Request to add n instances.
                // User is responsible to ensure, that instances IDs are unique in the octrtree.
                ecb.AddComponent <AddInstanceTag> (octreeEntity);    // Once system executed and instances were added, tag component will be deleted.
                BufferFromEntity <AddInstanceBufferElement> addInstanceBufferElement = GetBufferFromEntity <AddInstanceBufferElement> ();

                Common._RequesAddInstances(ref ecb, octreeEntity, addInstanceBufferElement, ref na_instanceEntities, i_instances2AddCount);



                // Remove

                ecb.AddComponent <RemoveInstanceTag> (octreeEntity);    // Once system executed and instances were removed, tag component will be deleted.
                BufferFromEntity <RemoveInstanceBufferElement> removeInstanceBufferElement = GetBufferFromEntity <RemoveInstanceBufferElement> ();

                // Request to remove some instances
                // Se inside method, for details
                int i_instances2RemoveCount = OctreeExample_Selector.i_deleteInstanceInOctreeCount;  // Example of x octrees instances / entities to delete. // 53
                Common._RequestRemoveInstances(ref ecb, octreeEntity, removeInstanceBufferElement, ref na_instanceEntities, i_instances2RemoveCount);


                // Ensure example array is disposed.
                na_instanceEntities.Dispose();
            } // for
        }