コード例 #1
0
 public ConvexCompoundLeafProcessor(CompoundCollider *compoundCollider)
 {
     m_CompoundCollider = compoundCollider;
 }
コード例 #2
0
 public CompoundLeafProcessor(CompoundCollider *compound)
 {
     m_CompoundCollider   = compound;
     m_NumColliderKeyBits = compound->NumColliderKeyBits;
     m_NumKeys            = 0;
 }
コード例 #3
0
 /// <summary>
 /// Remaps the Entity references baked into a CompoundCollider from one hierarchy to a new one, via the LinkedEntityGroup arrays.
 /// </summary>
 /// <param name="compoundColliderPtr">A <see cref="CompoundCollider"/> with old Entity references, e.g. a new instance.</param>
 /// <param name="oldLinkedEntityGroup">An array of <see cref="LinkedEntityGroup"/> from an original hierarchy e.g. a prefab.</param>
 /// <param name="newLinkedEntityGroup">An array of <see cref="LinkedEntityGroup"/> from a new hierarchy e.g. an instance.</param>
 public static unsafe void RemapCompoundColliderEntityReferences(
     CompoundCollider *compoundColliderPtr,
     in NativeArray <LinkedEntityGroup> oldLinkedEntityGroup,
コード例 #4
0
        protected override void OnUpdate()
        {
            m_Counter++;
            if (m_Counter == 10)
            {
                m_ExportPhysicsWorld.GetOutputDependency().Complete();

                var staticEntities = m_BuildPhysicsWorld.StaticEntityGroup.ToEntityArray(Allocator.TempJob);

                // Change filter of child 0 in compound
                unsafe
                {
                    var colliderComponent = EntityManager.GetComponentData <PhysicsCollider>(staticEntities[0]);

                    ColliderKey colliderKey0 = ColliderKey.Empty;
                    colliderKey0.PushSubKey(colliderComponent.Value.Value.NumColliderKeyBits, 0);

                    CompoundCollider *compoundCollider = (CompoundCollider *)colliderComponent.ColliderPtr;
                    compoundCollider->GetChild(ref colliderKey0, out ChildCollider child0);
                    child0.Collider->Filter = CollisionFilter.Zero;
                    compoundCollider->RefreshCollisionFilter();

                    EntityManager.SetComponentData(staticEntities[0], colliderComponent);
                }

                // Change filter of child 1 in compound
                unsafe
                {
                    var colliderComponent = EntityManager.GetComponentData <PhysicsCollider>(staticEntities[1]);

                    ColliderKey colliderKey1 = ColliderKey.Empty;
                    colliderKey1.PushSubKey(colliderComponent.Value.Value.NumColliderKeyBits, 1);

                    CompoundCollider *compoundCollider = (CompoundCollider *)colliderComponent.ColliderPtr;
                    compoundCollider->GetChild(ref colliderKey1, out ChildCollider child1);
                    child1.Collider->Filter = CollisionFilter.Zero;
                    compoundCollider->RefreshCollisionFilter();

                    EntityManager.SetComponentData(staticEntities[1], colliderComponent);
                }

                // Change filter of both children in compound
                unsafe
                {
                    var colliderComponent = EntityManager.GetComponentData <PhysicsCollider>(staticEntities[2]);

                    ColliderKey colliderKey0 = ColliderKey.Empty;
                    colliderKey0.PushSubKey(colliderComponent.Value.Value.NumColliderKeyBits, 0);
                    ColliderKey colliderKey1 = ColliderKey.Empty;
                    colliderKey1.PushSubKey(colliderComponent.Value.Value.NumColliderKeyBits, 1);

                    CompoundCollider *compoundCollider = (CompoundCollider *)colliderComponent.ColliderPtr;
                    compoundCollider->GetChild(ref colliderKey0, out ChildCollider child0);
                    compoundCollider->GetChild(ref colliderKey1, out ChildCollider child1);
                    child0.Collider->Filter = CollisionFilter.Zero;
                    child1.Collider->Filter = CollisionFilter.Zero;
                    compoundCollider->RefreshCollisionFilter();

                    EntityManager.SetComponentData(staticEntities[2], colliderComponent);
                }

                // Change filter of the compound itself
                {
                    var colliderComponent = EntityManager.GetComponentData <PhysicsCollider>(staticEntities[3]);
                    colliderComponent.Value.Value.Filter = CollisionFilter.Zero;
                    EntityManager.SetComponentData(staticEntities[3], colliderComponent);
                }

                staticEntities.Dispose();
            }
            else if (m_Counter == 50)
            {
                var dynamicEntities = m_BuildPhysicsWorld.DynamicEntityGroup.ToEntityArray(Allocator.TempJob);

                // First 2 boxes should stay still, while other 2 should fall through
                {
                    var translation1 = EntityManager.GetComponentData <Translation>(dynamicEntities[0]);
                    Assert.IsTrue(translation1.Value.y > 0.99f, "Box started falling!");
                    var translation2 = EntityManager.GetComponentData <Translation>(dynamicEntities[1]);
                    Assert.IsTrue(translation2.Value.y > 0.99f, "Box started falling!");
                    var translation3 = EntityManager.GetComponentData <Translation>(dynamicEntities[2]);
                    Assert.IsTrue(translation3.Value.y < 0.9f, "Box didn't start falling!");
                    var translation4 = EntityManager.GetComponentData <Translation>(dynamicEntities[3]);
                    Assert.IsTrue(translation4.Value.y < 0.9f, "Box didn't start falling!");
                }

                dynamicEntities.Dispose();
            }
        }
コード例 #5
0
 /// <summary>
 /// Remaps the Entity references baked into a CompoundCollider from one hierarchy to a new one.
 /// </summary>
 /// <param name="compoundColliderPtr">A <see cref="CompoundCollider"/> with old Entity references, e.g. a new instance.</param>
 /// <param name="keyEntityPairs">An array of <see cref="ColliderKey"/> and <see cref="Entity"/> pairs.</param>
 public static unsafe void RemapColliderEntityReferences(
     CompoundCollider *compoundColliderPtr, in NativeArray <PhysicsColliderKeyEntityPair> keyEntityPairs) =>