Exemplo n.º 1
0
 private void OnDestroy()
 {
     if (!Application.isPlaying)
     {
         //In edit mode, return out.
         return;
     }
     TFPhysics.RemoveBody(this);
 }
Exemplo n.º 2
0
        public void PositionalCorrection()
        {
            TFPhysics settings   = TFPhysics.instance;
            FixVec2   correction = (FixMath.Max(penetration - settings.penetrationAllowance, Fix.zero)) / (A.invMass + B.invMass)
                                   * normal * settings.penetrationCorrection;

            A.Position -= correction * A.invMass;
            B.Position += correction * B.invMass;
        }
Exemplo n.º 3
0
 private void Update()
 {
     if (!Application.isPlaying)
     {
         if (instance != this)
         {
             instance = this;
         }
     }
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 private void Awake()
 {
     instance = this;
     s        = settings;
     resting  = (settings.gravity * settings.deltaTime).GetMagnitudeSquared() + Fix.Epsilon;
 }