Duality.Components.Physics.RigidBody.ICmpUpdatable C# (CSharp) Method

ICmpUpdatable() private method

private ICmpUpdatable ( ) : void
return void
        void ICmpUpdatable.OnUpdate()
        {
            this.CheckValidTransform();

            // Synchronize physical body / perform shape updates, etc.
            this.RemoveDisposedJoints();
            this.SynchronizeBodyShape();

            // Update velocity and transform values
            if (this.body != null)
            {
                this.linearVel = PhysicsConvert.ToDualityUnit(this.body.LinearVelocity) * Time.SPFMult;
                this.angularVel = this.body.AngularVelocity * Time.SPFMult;
                this.revolutions = this.body.Revolutions;
                Transform t = this.gameobj.Transform;
                if (this.bodyType == BodyType.Dynamic || this.bodyType == BodyType.Kinematic)
                {
                    // Make sure we're not overwriting any previously occuring changes
                    t.CommitChanges();

                    // The current PhysicsAlpha interpolation probably isn't the best one. Maybe replace later.
                    Vector2 bodyVel = this.body.LinearVelocity;
                    Vector2 bodyPos = this.body.Position - bodyVel * (1.0f - Scene.PhysicsAlpha) * Time.SPFMult;
                    float bodyAngleVel = this.body.AngularVelocity;
                    float bodyAngle = this.body.Rotation - bodyAngleVel * (1.0f - Scene.PhysicsAlpha) * Time.SPFMult;
                    t.IgnoreParent = true; // Force ignore parent!
                    t.MoveToAbs(new Vector3(
                        PhysicsConvert.ToDualityUnit(bodyPos.X),
                        PhysicsConvert.ToDualityUnit(bodyPos.Y),
                        t.Pos.Z));
                    t.TurnToAbs(bodyAngle);
                    t.CommitChanges(this);
                }
            }

            // Process events
            this.ProcessCollisionEvents();

            this.CheckValidTransform();
        }