Ejemplo n.º 1
0
            public void Execute(int i_arrayIndex)
            {
                Entity octreeRootNodeEntity = a_collisionChecksEntities [i_arrayIndex];


                // Its value should be 0, if no collision is detected.
                // And >= 1, if instance collision is detected, or there is more than one collision,
                // indicating number of collisions.
                IsCollidingData isCollidingData = a_isCollidingData [octreeRootNodeEntity];
                // Stores reference to detected colliding instance.
                DynamicBuffer <CollisionInstancesBufferElement> a_collisionInstancesBuffer = collisionInstancesBufferElement [octreeRootNodeEntity];


                isCollidingData.i_nearestInstanceCollisionIndex = 0;
                isCollidingData.f_nearestDistance = float.PositiveInfinity;

                isCollidingData.i_collisionsCount = 0;                // Reset colliding instances counter.


                RootNodeData octreeRootNodeData = a_octreeRootNodeData [octreeRootNodeEntity];

                DynamicBuffer <NodeBufferElement> a_nodesBuffer = nodeBufferElement [octreeRootNodeEntity];
                DynamicBuffer <NodeInstancesIndexBufferElement> a_nodeInstancesIndexBuffer = nodeInstancesIndexBufferElement [octreeRootNodeEntity];
                DynamicBuffer <NodeChildrenBufferElement>       a_nodeChildrenBuffer       = nodeChildrenBufferElement [octreeRootNodeEntity];
                DynamicBuffer <InstanceBufferElement>           a_instanceBuffer           = instanceBufferElement [octreeRootNodeEntity];


                BoundsEntityPair4CollisionData rayEntityPair4CollisionData = a_boundsEntityPair4CollisionData [octreeRootNodeEntity];

                // Ray entity pair, for collision checks

                Entity bounds2CheckEntity = rayEntityPair4CollisionData.bounds2CheckEntity;


                // Is target octree active
                if (a_isActiveTag.Exists(bounds2CheckEntity))
                {
                    BoundsData checkBounds = a_boundsData [bounds2CheckEntity];


                    // To even allow instances collision checks, octree must have at least one instance.
                    if (octreeRootNodeData.i_totalInstancesCountInTree > 0)
                    {
                        if (GetCollidingBoundsInstances_Common._GetNodeColliding(octreeRootNodeData, octreeRootNodeData.i_rootNodeIndex, checkBounds.bounds, ref a_collisionInstancesBuffer, ref isCollidingData, a_nodesBuffer, a_nodeChildrenBuffer, a_nodeInstancesIndexBuffer, a_instanceBuffer))
                        {
                            /*
                             * // Debug
                             * Debug.Log ( "Is colliding." ) ;
                             */
                        }
                    }
                }

                a_isCollidingData [octreeRootNodeEntity] = isCollidingData;  // Set back.
            }
Ejemplo n.º 2
0
            public void Execute(int i_arrayIndex)
            {
                Entity octreeEntity = a_collisionChecksEntities [i_arrayIndex];

                BoundsEntityPair4CollisionData boundsEntityPair4CollisionData = a_boundsEntityPair4CollisionData [octreeEntity];
                Entity octreeBoundsEntity = boundsEntityPair4CollisionData.bounds2CheckEntity;

                BoundsData boundsData = new BoundsData()
                {
                    bounds = checkBounds
                };

                a_boundsData [octreeBoundsEntity] = boundsData;
            }