示例#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);
            }
        }
示例#2
0
 static bool checkParticleOverlap(ProximityDetector detector, PhysicsComponent particle)
 {
     return(detector.cachedKDop.checkIntersectPosition(particle.position));
 }
示例#3
0
 static bool checkObjectOverlap(ProximityDetector detector, PhysicsComponent object_)
 {
     return(!KDop.checkIntersectAabb(object_.boundingVolume.kdop, detector.cachedKDop));
 }
示例#4
0
 static bool checkParticleExitingExitOfObject(ProximityDetector detector, PhysicsComponent particle)
 {
     return(!detector.cachedKDop.checkIntersectPosition(particle.position));
 }
示例#5
0
        public void removeParticle(PhysicsComponent particle)
        {
            // TODO< inform proximity detectors that particle was removed >

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