void btContinuousDynamicsWorld::internalSingleStepSimulation( btScalar timeStep) { startProfiling(timeStep); if(0 != m_internalPreTickCallback) { (*m_internalPreTickCallback)(this, timeStep); } ///update aabbs information updateAabbs(); //static int frame=0; // printf("frame %d\n",frame++); ///apply gravity, predict motion predictUnconstraintMotion(timeStep); btDispatcherInfo& dispatchInfo = getDispatchInfo(); dispatchInfo.m_timeStep = timeStep; dispatchInfo.m_stepCount = 0; dispatchInfo.m_debugDraw = getDebugDrawer(); ///perform collision detection performDiscreteCollisionDetection(); calculateSimulationIslands(); getSolverInfo().m_timeStep = timeStep; ///solve contact and other joint constraints solveConstraints(getSolverInfo()); ///CallbackTriggers(); calculateTimeOfImpacts(timeStep); btScalar toi = dispatchInfo.m_timeOfImpact; // if (toi < 1.f) // printf("toi = %f\n",toi); if (toi < 0.f) kdPrintf("toi = %f\n",toi); ///integrate transforms integrateTransforms(timeStep * toi); ///update vehicle simulation updateActions(timeStep); updateActivationState( timeStep ); if(0 != m_internalTickCallback) { (*m_internalTickCallback)(this, timeStep); } }
void btDiscreteDynamicsWorld::internalSingleStepSimulation(btScalar timeStep) { BT_PROFILE("internalSingleStepSimulation"); if(0 != m_internalPreTickCallback) { (*m_internalPreTickCallback)(this, timeStep); } ///apply gravity, predict motion predictUnconstraintMotion(timeStep); btDispatcherInfo& dispatchInfo = getDispatchInfo(); dispatchInfo.m_timeStep = timeStep; dispatchInfo.m_stepCount = 0; dispatchInfo.m_debugDraw = getDebugDrawer(); ///perform collision detection performDiscreteCollisionDetection(); if (getDispatchInfo().m_useContinuous) addSpeculativeContacts(timeStep); calculateSimulationIslands(); getSolverInfo().m_timeStep = timeStep; ///solve contact and other joint constraints solveConstraints(getSolverInfo()); ///CallbackTriggers(); ///integrate transforms integrateTransforms(timeStep); ///update vehicle simulation updateActions(timeStep); updateActivationState( timeStep ); if(0 != m_internalTickCallback) { (*m_internalTickCallback)(this, timeStep); } }
// Public functions void Physics::stepSimulation(const float& elapsedTime, SceneManager* s) { proximityList.clear(); collisionList.clear(); collidingPairs.clear(); //std::cout << "moving object count : " << movingEntity.size() << std::endl; predictTransform(elapsedTime); computeBoundingShapes(elapsedTime); detectPairs(elapsedTime); computeContacts(elapsedTime); solveConstraints(elapsedTime); integratePositions(elapsedTime); //std::cout << std::endl; }
ExprType *typeRule( RuleDesc *rule, Env *funcDesc, Hashtable *varTypes, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r ) { /* printf("%s\n", node->subtrees[0]->text); */ addRErrorMsg( errmsg, -1, ERR_MSG_SEP ); char buf[ERR_MSG_LEN]; Node *node = rule->node; int dynamictyping = rule->dynamictyping; ExprType *resType = typeExpression3( node->subtrees[1], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r ); /*printf("Type %d\n",resType->t); */ RE_ERROR( getNodeType( resType ) == T_ERROR ); if ( getNodeType( resType ) != T_BOOL && getNodeType( resType ) != T_VAR && getNodeType( resType ) != T_DYNAMIC ) { char buf2[1024], buf3[ERR_MSG_LEN]; typeToString( resType, varTypes, buf2, 1024 ); snprintf( buf3, ERR_MSG_LEN, "error: the type %s of the rule condition is not supported", buf2 ); generateErrMsg( buf3, NODE_EXPR_POS( node->subtrees[1] ), node->subtrees[1]->base, buf ); addRErrorMsg( errmsg, RE_TYPE_ERROR, buf ); RE_ERROR( 1 ); } resType = typeExpression3( node->subtrees[2], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r ); RE_ERROR( getNodeType( resType ) == T_ERROR ); resType = typeExpression3( node->subtrees[3], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r ); RE_ERROR( getNodeType( resType ) == T_ERROR ); /* printVarTypeEnvToStdOut(varTypes); */ RE_ERROR( solveConstraints( typingConstraints, varTypes, errmsg, errnode, r ) == ABSURDITY ); int i; for ( i = 1; i <= 3; i++ ) { // 1 = cond, 2 = actions, 3 = recovery postProcessCoercion( node->subtrees[i], varTypes, errmsg, errnode, r ); postProcessActions( node->subtrees[i], funcDesc, errmsg, errnode, r ); } /*printTree(node, 0); */ return newSimpType( T_INT, r ); error: snprintf( buf, ERR_MSG_LEN, "type error: in rule %s", node->subtrees[0]->text ); addRErrorMsg( errmsg, RE_TYPE_ERROR, buf ); return resType; }
void FlowNode::solve(const glm::vec3& constrainPoint, float maxDistance, const FlowCollisionResult& collision) { solveConstraints(constrainPoint, maxDistance); solveCollisions(collision); };