Пример #1
0
 /// <summary>
 /// Don't call this, while the key is used in the arbitermap.
 /// It changes the hashcode of this object.
 /// </summary>
 /// <param name="body1">The first body.</param>
 /// <param name="body2">The second body.</param>
 internal void SetBodies(RigidBody body1, RigidBody body2)
 {
     this.body1 = body1;
     this.body2 = body2;
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the ArbiterKey class.
 /// </summary>
 /// <param name="body1"></param>
 /// <param name="body2"></param>
 public ArbiterKey(RigidBody body1, RigidBody body2)
 {
     this.body1 = body1;
     this.body2 = body2;
 }
Пример #3
0
        /// <summary>
        /// Sends a ray (definied by start and direction) through the scene (all bodies added).
        /// NOTE: For performance reasons terrain and trianglemeshshape aren't checked
        /// against rays (rays are of infinite length). They are checked against segments
        /// which start at rayOrigin and end in rayOrigin + rayDirection.
        /// </summary>
        #region public override bool Raycast(JVector rayOrigin, JVector rayDirection, out JVector normal,out FP fraction)
        public override bool Raycast(TSVector rayOrigin, TSVector rayDirection, RaycastCallback raycast, out RigidBody body, out TSVector normal, out FP fraction)
        {
            body = null; normal = TSVector.zero; fraction = FP.MaxValue;

            TSVector tempNormal; FP tempFraction;
            bool     result = false;

            // TODO: This can be done better in CollisionSystemPersistenSAP
            foreach (IBroadphaseEntity e in bodyList)
            {
                if (e is SoftBody)
                {
                    SoftBody softBody = e as SoftBody;
                    foreach (RigidBody b in softBody.VertexBodies)
                    {
                        if (this.Raycast(b, rayOrigin, rayDirection, out tempNormal, out tempFraction))
                        {
                            if (tempFraction < fraction && (raycast == null || raycast(b, tempNormal, tempFraction)))
                            {
                                body     = b;
                                normal   = tempNormal;
                                fraction = tempFraction;
                                result   = true;
                            }
                        }
                    }
                }
                else
                {
                    RigidBody b = e as RigidBody;

                    if (this.Raycast(b, rayOrigin, rayDirection, out tempNormal, out tempFraction))
                    {
                        if (tempFraction < fraction && (raycast == null || raycast(b, tempNormal, tempFraction)))
                        {
                            body     = b;
                            normal   = tempNormal;
                            fraction = tempFraction;
                            result   = true;
                        }
                    }
                }
            }

            return(result);
        }
Пример #4
0
 /// <summary>
 /// Checks if an arbiter is within the arbiter map.
 /// </summary>
 /// <param name="body1">The first body.</param>
 /// <param name="body2">The second body.</param>
 /// <returns>Returns true if the arbiter could be found, otherwise false.</returns>
 public bool ContainsArbiter(RigidBody body1, RigidBody body2)
 {
     lookUpKey.SetBodies(body1, body2);
     return(dictionaryKeys.ContainsKey(lookUpKey));
 }
Пример #5
0
 /// <summary>
 /// </summary>
 /// <param name="body1"></param>
 /// <param name="body2"></param>
 public Arbiter(RigidBody body1, RigidBody body2)
 {
     this.contactList = new ContactList();
     this.body1       = body1;
     this.body2       = body2;
 }