void Flow::update(float deltaTime, AnimPoseVec& relativePoses, AnimPoseVec& absolutePoses, const std::vector<bool>& overrideFlags) { if (_initialized && _active) { uint64_t startTime = usecTimestampNow(); uint64_t updateExpiry = startTime + MAX_UPDATE_FLOW_TIME_BUDGET; if (_scale != _lastScale) { setScale(_scale); } for (size_t i = 0; i < _jointThreads.size(); i++) { size_t index = _invertThreadLoop ? _jointThreads.size() - 1 - i : i; auto &thread = _jointThreads[index]; thread.update(deltaTime); thread.solve(_collisionSystem); if (!updateRootFramePositions(absolutePoses, index)) { return; } thread.computeJointRotations(); if (usecTimestampNow() > updateExpiry) { break; qWarning(animation) << "Flow Bones ran out of time while updating threads"; } } setJoints(relativePoses, overrideFlags); updateJoints(relativePoses, absolutePoses); _invertThreadLoop = !_invertThreadLoop; } }
void PhysicsWorld::update(float delta) { if (_delayDirty) { // the updateJoints must run before the updateBodies. updateJoints(); updateBodies(); _delayDirty = !(_delayAddBodies.size() == 0 && _delayRemoveBodies.size() == 0 && _delayAddJoints.size() == 0 && _delayRemoveJoints.size() == 0); } for (auto& body : _bodies) { body->update(delta); } _updateTime += delta; if (++_updateRateCount >= _updateRate) { _info->step(_updateTime * _speed); _updateRateCount = 0; _updateTime = 0.0f; } if (_debugDrawMask != DEBUGDRAW_NONE) { debugDraw(); } }
void PhysicsWorld::update(float delta, bool userCall/* = false*/) { if (delta < FLT_EPSILON) { return; } if(_updateBodyTransform || !_delayAddBodies.empty()) { _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); updateBodies(); _updateBodyTransform = false; } else if (!_delayRemoveBodies.empty()) { updateBodies(); } if (!_delayAddJoints.empty() || !_delayRemoveJoints.empty()) { updateJoints(); } if (userCall) { cpSpaceStep(_cpSpace, delta); for (auto& body : _bodies) { body->update(delta); } } else { _updateTime += delta; if (++_updateRateCount >= _updateRate) { const float dt = _updateTime * _speed / _substeps; for (int i = 0; i < _substeps; ++i) { cpSpaceStep(_cpSpace, dt); for (auto& body : _bodies) { body->update(dt); } } _updateRateCount = 0; _updateTime = 0.0f; } } if (_debugDrawMask != DEBUGDRAW_NONE) { debugDraw(); } }
void ProjectionEditor::moveSelectedSurface(ofVec2f by) { if (surfaceManager == NULL) return; if (surfaceManager->getSelectedSurface() == NULL) return; surfaceManager->getSelectedSurface()->moveBy(by); /*vector<ofVec3f>& vertices = surfaceManager->getSelectedSurface()->getVertices(); for (int i=0; i<vertices.size(); i++) { vertices[i] += by; }*/ updateJoints(); }
void PhysicsWorld::update(float delta, bool userCall/* = false*/) { if(!_delayAddBodies.empty()) { updateBodies(); } else if (!_delayRemoveBodies.empty()) { updateBodies(); } auto sceneToWorldTransform = _scene->getNodeToParentTransform(); beforeSimulation(_scene, sceneToWorldTransform, 1.f, 1.f, 0.f); if (!_delayAddJoints.empty() || !_delayRemoveJoints.empty()) { updateJoints(); } if (delta < FLT_EPSILON) { return; } if (userCall) { cpSpaceStep(_cpSpace, delta); } else { _updateTime += delta; if (++_updateRateCount >= _updateRate) { const float dt = _updateTime * _speed / _substeps; for (int i = 0; i < _substeps; ++i) { cpSpaceStep(_cpSpace, dt); } _updateRateCount = 0; _updateTime = 0.0f; } } if (_debugDrawMask != DEBUGDRAW_NONE) { debugDraw(); } // Update physics position, should loop as the same sequence as node tree. // PhysicsWorld::afterSimulation() will depend on the sequence. afterSimulation(_scene, sceneToWorldTransform, 0.f); }
void Model::draw() { #if RENDERMODE_MOVING getPlayTime( 1, 0, m_fTotalTime , true); updateJoints(fTime); modifyVertexByJoint(); #endif GLboolean texEnabled = glIsEnabled( GL_TEXTURE_2D ); if(m_bDrawMesh) { // Draw by group for ( int i = 0; i < m_usNumMeshes; i++ ) { #if ENABLE_CROSSARRAY glInterleavedArrays(GL_T2F_N3F_V3F, 0, m_meshVertexData.m_pMesh[i].pVertexArrayDynamic); #else glVertexPointer(3, GL_FLOAT, 12, m_meshVertexData.m_pMesh[i].pVertexArrayDynamic); glEnableClientState( GL_VERTEX_ARRAY ); #endif #if RENDERMODE_POINT glDrawArrays(GL_POINTS, 0, m_pMeshes[i].m_usNumTris * 3 ); #else glDrawElements(GL_TRIANGLES, m_meshVertexData.m_pMesh[i].numOfVertex, GL_UNSIGNED_INT , m_pIndexArray); #endif #if !ENABLE_CROSSARRAY glDisableClientState( GL_VERTEX_ARRAY ); #endif } } if ( texEnabled ) glEnable( GL_TEXTURE_2D ); else glDisable( GL_TEXTURE_2D ); }
void PhysicsWorld::update(float delta) { if (_delayDirty) { // the updateJoints must run before the updateBodies. updateJoints(); updateBodies(); _delayDirty = !(_delayAddBodies->count() == 0 && _delayRemoveBodies->count() == 0 && _delayAddJoints.size() == 0 && _delayRemoveJoints.size() == 0); } for (auto body : *_bodies) { body->update(delta); } cpSpaceStep(_info->getSpace(), delta); if (_debugDrawMask != DEBUGDRAW_NONE) { debugDraw(); } }
void PhysicsWorld::update(float delta, bool userCall/* = false*/) { if(!_delayAddBodies.empty()) { updateBodies(); } else if (!_delayRemoveBodies.empty()) { updateBodies(); } auto sceneToWorldTransform = _scene->getNodeToParentTransform(); beforeSimulation(_scene, sceneToWorldTransform, 1.f, 1.f, 0.f); if (!_delayAddJoints.empty() || !_delayRemoveJoints.empty()) { updateJoints(); } if (delta < FLT_EPSILON) { return; } if (userCall) { #if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 cpSpaceStep(_cpSpace, delta); #else cpHastySpaceStep(_cpSpace, delta); #endif } else { _updateTime += delta; if(_fixedRate) { const float step = 1.0f / _fixedRate; const float dt = step * _speed; while(_updateTime>step) { _updateTime-=step; #if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 cpSpaceStep(_cpSpace, dt); #else cpHastySpaceStep(_cpSpace, dt); #endif } } else { if (++_updateRateCount >= _updateRate) { const float dt = _updateTime * _speed / _substeps; for (int i = 0; i < _substeps; ++i) { #if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 cpSpaceStep(_cpSpace, dt); #else cpHastySpaceStep(_cpSpace, dt); #endif for (auto& body : _bodies) { body->update(dt); } } _updateRateCount = 0; _updateTime = 0.0f; } } } if (_debugDrawMask != DEBUGDRAW_NONE) { debugDraw(); } // Update physics position, should loop as the same sequence as node tree. // PhysicsWorld::afterSimulation() will depend on the sequence. afterSimulation(_scene, sceneToWorldTransform, 0.f); }