Beispiel #1
0
 public TFCollision(TFCollider collider)
 {
     this.collider = collider;
     gameObject    = collider.gameObject;
     rigidbody     = collider.body;
     transform     = collider.tdTransform;
 }
 public void TFOnTriggerExit(TFCollider col)
 {
     if (onTriggerExitEvent != null)
     {
         onTriggerExitEvent(col);
     }
 }
 public void TFOnTriggerStay(TFCollider col)
 {
     if (onTriggerStayEvent != null)
     {
         onTriggerStayEvent(col);
     }
 }
Beispiel #4
0
        public static bool AABBvsAABB(TFCollider aCol, TFCollider bCol)
        {
            // Exit with no intersection if found separated along an axis
            if (aCol.boundingBox.max.x < bCol.boundingBox.min.x || aCol.boundingBox.min.x > bCol.boundingBox.max.x)
            {
                return(false);
            }

            if (aCol.boundingBox.max.y < bCol.boundingBox.min.y || aCol.boundingBox.min.y > bCol.boundingBox.max.y)
            {
                return(false);
            }

            // No separating axis found, therefor there is at least one overlapping axis
            return(true);
        }
Beispiel #5
0
        private void Start()
        {
            fpTransform = GetComponent <TFTransform>();
            coll        = GetComponent <TFCollider>();
            if (!Application.isPlaying)
            {
                //In edit mode, return out.
                return;
            }
            coll.body            = this;
            info.position        = (FixVec2)fpTransform.Position;
            info.velocity        = FixVec2.zero;
            info.angularVelocity = Fix.zero;
            info.torque          = Fix.zero;
            info.force           = FixVec2.zero;

            invMass    = mass != Fix.zero ? Fix.one / mass : Fix.zero;
            invInertia = inertia != Fix.zero ? Fix.one / inertia : Fix.zero;
            RecalcAABB();
            TFPhysics.AddBody(this);
        }
Beispiel #6
0
 private void Awake()
 {
     fpTransform = GetComponent <TFTransform>();
     coll        = GetComponent <TFCollider>();
 }
 private void contactSetup(TFCollider collider, TFContact contact)
 {
     contact.contactInfo.fdir1 = collider.transform.up;
 }
Beispiel #8
0
 private void contactSetup(TFCollider collider, TFContact contact)
 {
     contact.contactInfo.fdir1 = Vector3.Cross(contact.contactGeom.normal, collider.transform.up).normalized;
 }