Exemplo n.º 1
0
        static void applyForceToLinearAndAngularVelocity(PhysicsComponent physicsComponent, SpatialVectorDouble localForce, SpatialVectorDouble objectLocalPositionOfForce)
        {
            { // linear part
              // to calculate the linear component we use the dot product
                double scaleOfLinearForce = 0.0;
                if (localForce.length > double.Epsilon)
                {
                    double dotOfForceAndLocalPosition = SpatialVectorDouble.dot(localForce.normalized(), objectLocalPositionOfForce.normalized());
                    scaleOfLinearForce = System.Math.Abs(dotOfForceAndLocalPosition);
                }

                // the linear force (and resulting acceleration) is the force scaled by the dot product

                Matrix rotationMatrix           = physicsComponent.calcLocalToGlobalRotationMatrix();
                Matrix globalForceAsMatrix      = rotationMatrix * SpatialVectorUtilities.toVector4(localForce).asMatrix;
                SpatialVectorDouble globalForce = SpatialVectorUtilities.toVector3(new SpatialVectorDouble(globalForceAsMatrix));

                physicsComponent.linearAcceleration += globalForce.scale(scaleOfLinearForce * physicsComponent.invMass);
            }

            { // angular part
                physicsComponent.eulerAngularAcceleration += physicsComponent.calcAngularAccelerationOfRigidBodyForAppliedForce(objectLocalPositionOfForce, localForce);
            }
        }
Exemplo n.º 2
0
 static bool checkParticleOverlap(ProximityDetector detector, PhysicsComponent particle)
 {
     return(detector.cachedKDop.checkIntersectPosition(particle.position));
 }
Exemplo n.º 3
0
 static bool checkObjectOverlap(ProximityDetector detector, PhysicsComponent object_)
 {
     return(!KDop.checkIntersectAabb(object_.boundingVolume.kdop, detector.cachedKDop));
 }
Exemplo n.º 4
0
 static bool checkParticleExitingExitOfObject(ProximityDetector detector, PhysicsComponent particle)
 {
     return(!detector.cachedKDop.checkIntersectPosition(particle.position));
 }
Exemplo n.º 5
0
        public void removeParticle(PhysicsComponent particle)
        {
            // TODO< inform proximity detectors that particle was removed >

            particles.Remove(particle);
        }
Exemplo n.º 6
0
 public void addParticle(PhysicsComponent particle)
 {
     particles.Add(particle);
 }
Exemplo n.º 7
0
 public PhysicsComponentAndCollidersPair(PhysicsComponent physicsComponent)
 {
     this.physicsComponent = physicsComponent;
 }
Exemplo n.º 8
0
 public PhysicsComponentAndCollidersPair(PhysicsComponent physicsComponent, IList <ColliderComponent> colliders)
 {
     this.physicsComponent = physicsComponent;
     this.colliders        = colliders;
 }