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); } }
static bool checkParticleOverlap(ProximityDetector detector, PhysicsComponent particle) { return(detector.cachedKDop.checkIntersectPosition(particle.position)); }
static bool checkObjectOverlap(ProximityDetector detector, PhysicsComponent object_) { return(!KDop.checkIntersectAabb(object_.boundingVolume.kdop, detector.cachedKDop)); }
static bool checkParticleExitingExitOfObject(ProximityDetector detector, PhysicsComponent particle) { return(!detector.cachedKDop.checkIntersectPosition(particle.position)); }
public void removeParticle(PhysicsComponent particle) { // TODO< inform proximity detectors that particle was removed > particles.Remove(particle); }
public void addParticle(PhysicsComponent particle) { particles.Add(particle); }
public PhysicsComponentAndCollidersPair(PhysicsComponent physicsComponent) { this.physicsComponent = physicsComponent; }
public PhysicsComponentAndCollidersPair(PhysicsComponent physicsComponent, IList <ColliderComponent> colliders) { this.physicsComponent = physicsComponent; this.colliders = colliders; }