static bool computeGeometryAndCollisions_proxy(const ModelHandler & model, DataHandler & data, const GeometryModelHandler & model_geom, GeometryDataHandler & data_geom, const VectorXd_fx & q, const bool stopAtFirstCollision) { return computeCollisions(*model,*data,*model_geom, *data_geom, q, stopAtFirstCollision); }
void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) { ++_frameCount; if (!_ragdoll) { return; } quint64 now = usecTimestampNow(); quint64 startTime = now; quint64 expiry = startTime + maxUsec; moveRagdolls(deltaTime); enforceContacts(); int numDolls = _otherRagdolls.size(); { PerformanceTimer perfTimer("enforce"); _ragdoll->enforceConstraints(); for (int i = 0; i < numDolls; ++i) { _otherRagdolls[i]->enforceConstraints(); } } bool collidedWithOtherRagdoll = false; int iterations = 0; float error = 0.0f; do { collidedWithOtherRagdoll = computeCollisions() || collidedWithOtherRagdoll; updateContacts(); resolveCollisions(); { // enforce constraints PerformanceTimer perfTimer("enforce"); error = _ragdoll->enforceConstraints(); for (int i = 0; i < numDolls; ++i) { error = glm::max(error, _otherRagdolls[i]->enforceConstraints()); } } applyContactFriction(); ++iterations; now = usecTimestampNow(); } while (_collisions.size() != 0 && (iterations < maxIterations) && (error > minError) && (now < expiry)); // the collisions may have moved the main ragdoll from the simulation center // so we remove this offset (potentially storing it as movement of the Ragdoll owner) _ragdoll->removeRootOffset(collidedWithOtherRagdoll); // also remove any offsets from the other ragdolls for (int i = 0; i < numDolls; ++i) { _otherRagdolls[i]->removeRootOffset(false); } pruneContacts(); }
void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) { ++_frameCount; if (!_ragdoll) { return; } quint64 now = usecTimestampNow(); quint64 startTime = now; quint64 expiry = startTime + maxUsec; moveRagdolls(deltaTime); buildContactConstraints(); int numDolls = _otherRagdolls.size(); { PerformanceTimer perfTimer("enforce"); _ragdoll->enforceRagdollConstraints(); for (int i = 0; i < numDolls; ++i) { _otherRagdolls[i]->enforceRagdollConstraints(); } } int iterations = 0; float error = 0.0f; do { computeCollisions(); updateContacts(); resolveCollisions(); { // enforce constraints PerformanceTimer perfTimer("enforce"); error = _ragdoll->enforceRagdollConstraints(); for (int i = 0; i < numDolls; ++i) { error = glm::max(error, _otherRagdolls[i]->enforceRagdollConstraints()); } } enforceContactConstraints(); ++iterations; now = usecTimestampNow(); } while (_collisions.size() != 0 && (iterations < maxIterations) && (error > minError) && (now < expiry)); pruneContacts(); }
static bool computeCollisions_proxy(GeometryDataHandler & data_geom, const bool stopAtFirstCollision) { return computeCollisions(*data_geom, stopAtFirstCollision); }