///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {

            mesh = entryA as StaticMesh;
            convex = entryB as ConvexCollidable;

            if (mesh == null || convex == null)
            {
                mesh = entryB as StaticMesh;
                convex = entryA as ConvexCollidable;

                if (mesh == null || convex == null)
                    throw new Exception("Inappropriate types used to initialize pair.");
            }

            //Contact normal goes from A to B.
            broadPhaseOverlap.entryA = convex;
            broadPhaseOverlap.entryB = mesh;

            UpdateMaterialProperties(convex.entity != null ? convex.entity.material : null, mesh.material);

            base.Initialize(entryA, entryB);




        }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {


            box = entryA as ConvexCollidable<BoxShape>;
            sphere = entryB as ConvexCollidable<SphereShape>;

            if (box == null || sphere == null)
            {
                box = entryB as ConvexCollidable<BoxShape>;
                sphere = entryA as ConvexCollidable<SphereShape>;
                if (box == null || sphere == null)
                {
                    throw new Exception("Inappropriate types used to initialize pair.");
                }
            }

            //Reorder the entries so that the guarantee that the normal points from A to B is satisfied.
            broadPhaseOverlap.entryA = box;
            broadPhaseOverlap.entryB = sphere;
            
            base.Initialize(entryA, entryB);


        }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {

            mobileMesh = entryA as MobileMeshCollidable;
            convex = entryB as ConvexCollidable;

            if (mobileMesh == null || convex == null)
            {
                mobileMesh = entryB as MobileMeshCollidable;
                convex = entryA as ConvexCollidable;

                if (mobileMesh == null || convex == null)
                    throw new Exception("Inappropriate types used to initialize pair.");
            }


            //Contact normal goes from A to B.
            broadPhaseOverlap.entryA = convex;
            broadPhaseOverlap.entryB = mobileMesh;

            //It's possible that the convex does not have an entity if it is a proxy for a non-entity collidable.
            //Similarly, the mesh could be a query object.
            UpdateMaterialProperties(convex.entity != null ? convex.entity.material : null, mobileMesh.entity != null ? mobileMesh.entity.material : null);


            base.Initialize(entryA, entryB);

        }
Ejemplo n.º 4
0
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {

            //Child initialization is responsible for setting up the entries.
            //Child initialization is responsible for setting up the manifold, if any.
            manifoldConstraintGroup.Initialize(EntityA, EntityB);

            base.Initialize(entryA, entryB);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds a broad phase overlap if the collision rules permit it.
 /// </summary>
 /// <param name="entryA">First entry of the overlap.</param>
 /// <param name="entryB">Second entry of the overlap.</param>
 protected internal void TryToAddOverlap(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
 {
     CollisionRule rule;
     if ((rule = GetCollisionRule(entryA, entryB)) < CollisionRule.NoBroadPhase)
     {
         overlapAddLock.Enter();
         overlaps.Add(new BroadPhaseOverlap(entryA, entryB, rule));
         overlapAddLock.Exit();
     }
 }
Ejemplo n.º 6
0
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            compoundInfoB = entryB as CompoundCollidable;
            if (compoundInfoB == null)
            {
                throw new Exception("Inappropriate types used to initialize pair.");
            }

            base.Initialize(entryA, entryB);
        }
Ejemplo n.º 7
0
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            //Child initialization is responsible for setting up the entries.

            ContactManifold.Initialize(CollidableA, CollidableB);
            ContactConstraint.Initialize(EntityA, EntityB, this);

            base.Initialize(entryA, entryB);



        }
Ejemplo n.º 8
0
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            boxA = entryA as ConvexCollidable<BoxShape>;
            boxB = entryB as ConvexCollidable<BoxShape>;

            if (boxA == null || boxB == null)
            {
                throw new Exception("Inappropriate types used to initialize pair.");
            }

            base.Initialize(entryA, entryB);

        }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            mesh = entryA as InstancedMesh;
            if (mesh == null)
            {
                mesh = entryB as InstancedMesh;
                if (mesh == null)
                {
                    throw new Exception("Inappropriate types used to initialize pair.");
                }
            }

            base.Initialize(entryA, entryB);
        }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            //Other member of the pair is initialized by the child.
            mobileMesh = entryA as MobileMeshCollidable;
            if (mobileMesh == null)
            {
                mobileMesh = entryB as MobileMeshCollidable;
                if (mobileMesh == null)
                {
                    throw new Exception("Inappropriate types used to initialize pair.");
                }
            }

            base.Initialize(entryA, entryB);
        }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            terrain = entryA as Terrain;
            if (terrain == null)
            {

                terrain = entryB as Terrain;
                if (terrain == null)
                {
                    throw new Exception("Inappropriate types used to initialize pair.");
                }
            }

            base.Initialize(entryA, entryB);
        }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            //Other member of the pair is initialized by the child.
            compoundInfo = entryA as CompoundCollidable;
            if (compoundInfo == null)
            {
                compoundInfo = entryB as CompoundCollidable;
                if (compoundInfo == null)
                {
                    throw new Exception("Inappropriate types used to initialize pair.");
                }
            }

            base.Initialize(entryA, entryB);
        }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {

            triangle = entryA as ConvexCollidable<TriangleShape>;
            convex = entryB as ConvexCollidable;

            if (triangle == null || convex == null)
            {
                triangle = entryB as ConvexCollidable<TriangleShape>;
                convex = entryA as ConvexCollidable;

                if (triangle == null || convex == null)
                    throw new Exception("Inappropriate types used to initialize pair.");
            }

            //Contact normal goes from A to B.
            broadPhaseOverlap.entryA = convex;
            broadPhaseOverlap.entryB = triangle;

            base.Initialize(entryA, entryB);

        }
Ejemplo n.º 14
0
 protected internal CollisionRule GetCollisionRule(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
 {
     if (entryA.IsActive || entryB.IsActive)
         return CollisionRules.collisionRuleCalculator(entryA.collisionRules, entryB.collisionRules);
     return CollisionRule.NoBroadPhase;
 }
Ejemplo n.º 15
0
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            UpdateMaterialProperties();

            base.Initialize(entryA, entryB);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Removes an entry from the broad phase.
 /// </summary>
 /// <param name="entry">Entry to remove.</param>
 public abstract void Remove(BroadPhaseEntry entry);
Ejemplo n.º 17
0
 ///<summary>
 /// Gets a narrow phase pair for a given pair of entries.
 ///</summary>
 ///<param name="entryA">First entry in the pair.</param>
 /// <param name="entryB">Second entry in the pair.</param>
 /// <param name="rule">Collision rule governing the pair.</param>
 ///<returns>A INarrowPhasePair for the overlap.</returns>
 public static NarrowPhasePair GetPair(BroadPhaseEntry entryA, BroadPhaseEntry entryB, CollisionRule rule)
 {
     BroadPhaseOverlap overlap = new BroadPhaseOverlap(entryA, entryB, rule);
     return GetPair(ref overlap);
 }
Ejemplo n.º 18
0
 ///<summary>
 /// Gets a narrow phase pair for a given pair of entries.
 ///</summary>
 ///<param name="entryA">First entry in the pair.</param>
 /// <param name="entryB">Second entry in the pair.</param>
 ///<returns>A INarrowPhasePair for the overlap.</returns>
 public static NarrowPhasePair GetPair(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
 {
     BroadPhaseOverlap overlap = new BroadPhaseOverlap(entryA, entryB);
     return GetPair(ref overlap);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Adds an entry to the broad phase.
 /// </summary>
 /// <param name="entry">Entry to add.</param>
 public abstract void Add(BroadPhaseEntry entry);
Ejemplo n.º 20
0
 internal EventStoragePairRemoved(BroadPhaseEntry other)
 {
     this.other = other;
 }
 void RemoveFriction(EntityCollidable sender, BroadPhaseEntry other, NarrowPhasePair pair)
 {
     var collidablePair = pair as CollidablePairHandler;
     if (collidablePair != null)
     {
         //The default values for InteractionProperties is all zeroes- zero friction, zero bounciness.
         //That's exactly how we want the character to behave when hitting objects.
         collidablePair.UpdateMaterialProperties(new InteractionProperties());
     }
 }
 /// <summary>
 /// Recovers iobject from broad phase entry.
 /// </summary>
 /// <param name="entry">The entry.</param>
 /// <returns></returns>
 public static IObject RecoverObjectFromBroadPhase(BroadPhaseEntry entry)
 {
     IPhysicObject phyObj = null;
     if (entry is Collidable)
     {
         Collidable collidable = (entry as Collidable);
         phyObj = collidable.Tag as IPhysicObject;
         return phyObj.ObjectOwner;
     }
     else
     {
         return null;
     }
     
 }
 /// <summary>
 /// Recovers physicobject from broad phase entry.
 /// </summary>
 /// <param name="entry">The entry.</param>
 /// <returns></returns>
 public static IPhysicObject RecoverIPhysicObjectFromBroadPhase(BroadPhaseEntry entry)
 {
     IPhysicObject phyObj = null;
     if (entry is Collidable)
     {
         Collidable collidable = (entry as Collidable);
         phyObj = collidable.Tag as IPhysicObject;
     }
     return phyObj;
 }      
Ejemplo n.º 24
0
 ///<summary>
 /// Initializes the pair.
 ///</summary>
 ///<param name="entryA">First entry in the pair.</param>
 ///<param name="entryB">Second entry in the pair.</param>
 public abstract void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB);
Ejemplo n.º 25
0
 public override void Remove(BroadPhaseEntry entry)
 {
     entries.Remove(entry);
 }
Ejemplo n.º 26
0
 internal EventStoragePairUpdated(BroadPhaseEntry other, NarrowPhasePair pair)
 {
     this.other = other;
     this.pair = pair;
 }
Ejemplo n.º 27
0
 ///<summary>
 /// Constructs a new ray cast result.
 ///</summary>
 ///<param name="hitData">Ray cast hit data.</param>
 ///<param name="hitObject">Object hit by the ray.</param>
 public RayCastResult(RayHit hitData, BroadPhaseEntry hitObject)
 {
     HitData = hitData;
     HitObject = hitObject;
 }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            mesh = (MobileMeshCollidable)entryB;

            base.Initialize(entryA, entryB);
        }
Ejemplo n.º 29
0
 bool SupportRayFilterFunction(BroadPhaseEntry entry)
 {
     //Only permit an object to be used as a support if it fully collides with the character.
     return CollisionRules.CollisionRuleCalculator(entry.CollisionRules, character.Body.CollisionInformation.CollisionRules) == CollisionRule.Normal;
 }
        ///<summary>
        /// Initializes the pair handler.
        ///</summary>
        ///<param name="entryA">First entry in the pair.</param>
        ///<param name="entryB">Second entry in the pair.</param>
        public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            //Child initialization is responsible for setting up the entries.
            //Child initialization is responsible for setting up the material.
            //Child initialization is responsible for setting up the manifold.
            //Child initialization is responsible for setting up the constraint.

            if (!suppressEvents)
            {
                CollidableA.EventTriggerer.OnPairCreated(CollidableB, this);
                CollidableB.EventTriggerer.OnPairCreated(CollidableA, this);
            }
        }