diff --git a/Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/LCPConstraintSolver.cpp b/Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/LCPConstraintSolver.cpp index 22f7f043714..f2317f710a7 100644 --- a/Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/LCPConstraintSolver.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/LCPConstraintSolver.cpp @@ -99,6 +99,7 @@ bool LCPConstraintSolver::prepareStates(const core::ConstraintParams * /*cParams msg_info() <<" propagate DXn performed - collision called" ; SCOPED_TIMER("resetContactForce"); + for (const auto& cc : l_constraintCorrections) { cc->resetContactForce(); @@ -1026,7 +1027,7 @@ int LCPConstraintSolver::lcp_gaussseidel_unbuilt(SReal *dfree, SReal *f, std::ve { bool elem1 = false; bool elem2 = false; - for (const auto cc : l_constraintCorrections) + for (const auto& cc : l_constraintCorrections) { if(cc->hasConstraintNumber(c1)) { diff --git a/Sofa/Component/LinearSystem/src/sofa/component/linearsystem/ConstantSparsityPatternSystem.inl b/Sofa/Component/LinearSystem/src/sofa/component/linearsystem/ConstantSparsityPatternSystem.inl index 565e95689b8..7409254c279 100644 --- a/Sofa/Component/LinearSystem/src/sofa/component/linearsystem/ConstantSparsityPatternSystem.inl +++ b/Sofa/Component/LinearSystem/src/sofa/component/linearsystem/ConstantSparsityPatternSystem.inl @@ -263,7 +263,8 @@ void ConstantSparsityPatternSystem::resizeSystem(sofa::Size n) if (this->getSystemMatrix()) { - if (n != this->getSystemMatrix()->rowSize() || n != this->getSystemMatrix()->colSize()) + Index nIndex = sofa::helper::narrow_cast(n); + if (nIndex != this->getSystemMatrix()->rowSize() || nIndex != this->getSystemMatrix()->colSize()) { this->getSystemMatrix()->resize(n, n); } @@ -336,12 +337,6 @@ void ConstantSparsityPatternSystem::preAssembleSystem(const co if (isConstantSparsityPatternUsedYet()) { - // this->getSystemMatrix()->compressed = true; - for (const auto& mat : this->m_localMappedMatrices) - { - // mat.second->compressed = true; - } - reinitLocalMatrices(this->template getLocalMatrixMap()); reinitLocalMatrices(this->template getLocalMatrixMap()); reinitLocalMatrices(this->template getLocalMatrixMap()); diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.inl index c93af64a589..4459517d8eb 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.inl @@ -104,11 +104,14 @@ void EllipsoidForceField::addForce(const sofa::core::MechanicalParams const Real stiffabs = helper::rabs(stiffness); //const Real s2 = (stiff < 0 ? - stiff*stiff : stiff*stiff ); Coord inv_r2; - for (int j=0; j* contacts = this->d_contacts.beginEdit(); contacts->clear(); f1.resize(p1.size()); - for (unsigned int i=0; i::addForce(const sofa::core::MechanicalParams Real norm = helper::rsqrt(norm2); Real v = norm-1; Coord grad; - for (int j=0; j::addForce(const sofa::core::MechanicalParams Real fact1 = -stiffabs / (norm * gnorm); Real fact2 = -stiffabs*v / gnorm; Real fact3 = -stiffabs*v / gnorm2; - for (int ci = 0; ci < N; ++ci) + for (unsigned int ci = 0; ci < N; ++ci) { - for (int cj = 0; cj < N; ++cj) + for (unsigned int cj = 0; cj < N; ++cj) c.m[ci][cj] = grad[ci]*grad[cj] * (fact1 + fact3*inv_r2[cj]); c.m[ci][ci] += fact2*inv_r2[ci]; } diff --git a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixConstraintEigenUtils.h b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixConstraintEigenUtils.h index 8627f175666..dfdb2afd0c8 100644 --- a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixConstraintEigenUtils.h +++ b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/CompressedRowSparseMatrixConstraintEigenUtils.h @@ -203,7 +203,7 @@ void addMultTransposeEigen(LhsMatrixDeriv& lhs, const Eigen::SparseMatrixload(filename.c_str()); + m_RootNode = sofa::simulation::node::load(filename.c_str()); int result = API_SUCCESS; if (m_RootNode.get()) { sceneFileName = filename; - m_Simulation->init(m_RootNode.get()); + sofa::simulation::node::initRoot(m_RootNode.get()); result = updateOutputMeshes(); if ( useGUI ) { @@ -410,7 +409,7 @@ int SofaPhysicsSimulation::load(const char* cfilename) } else { - m_RootNode = m_Simulation->createNewGraph(""); + m_RootNode = sofa::simulation::getSimulation()->createNewGraph(""); return API_SCENE_FAILED; } initTexturesDone = false; @@ -425,7 +424,7 @@ int SofaPhysicsSimulation::unload() { if (m_RootNode.get()) { - m_Simulation->unload(m_RootNode); + sofa::simulation::node::unload(m_RootNode); } else { @@ -471,7 +470,7 @@ void SofaPhysicsSimulation::createScene() m_RootNode->setGravity({ 0,-9.8,0 }); this->createScene_impl(); - m_Simulation->init(m_RootNode.get()); + sofa::simulation::node::initRoot(m_RootNode.get()); updateOutputMeshes(); } @@ -604,7 +603,7 @@ void SofaPhysicsSimulation::reset() { if (getScene()) { - getSimulation()->reset(getScene()); + sofa::simulation::node::reset(getScene()); this->update(); } } @@ -632,8 +631,8 @@ void SofaPhysicsSimulation::step() sofa::simulation::Node* groot = getScene(); if (!groot) return; beginStep(); - getSimulation()->animate(groot); - getSimulation()->updateVisual(groot); + sofa::simulation::node::animate(groot); + sofa::simulation::node::updateVisual(groot); if ( useGUI ) { sofa::gui::common::BaseGUI* gui = sofa::gui::common::GUIManager::getGUI(); gui->stepMainLoop(); @@ -779,7 +778,7 @@ std::string SofaPhysicsSimulation::getMessage(int messageId, int& msgType) { const std::vector& msgs = m_msgHandler->getMessages(); - if (messageId >= msgs.size()) { + if (messageId >= (int)msgs.size()) { msgType = -1; return "Error messageId out of bounds"; } @@ -958,7 +957,7 @@ void SofaPhysicsSimulation::drawGL() if (!initTexturesDone) { std::cout << "INIT VISUAL" << std::endl; - getSimulation()->initTextures(groot); + sofa::simulation::node::initTextures(groot); bool setView = false; groot->get(currentCamera); if (!currentCamera) @@ -1049,7 +1048,7 @@ void SofaPhysicsSimulation::drawGL() glMatrixMode(GL_MODELVIEW); glLoadMatrixd(lastModelviewMatrix); - getSimulation()->draw(vparams,groot); + sofa::simulation::node::draw(vparams,groot); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); diff --git a/applications/projects/SofaPhysicsAPI/src/SofaPhysicsAPI/SofaPhysicsSimulation.h b/applications/projects/SofaPhysicsAPI/src/SofaPhysicsAPI/SofaPhysicsSimulation.h index 05446f685bc..2f1418c702c 100644 --- a/applications/projects/SofaPhysicsAPI/src/SofaPhysicsAPI/SofaPhysicsSimulation.h +++ b/applications/projects/SofaPhysicsAPI/src/SofaPhysicsAPI/SofaPhysicsSimulation.h @@ -115,7 +115,6 @@ class SOFA_SOFAPHYSICSAPI_API SofaPhysicsSimulation #endif protected: - sofa::simulation::Simulation* m_Simulation; sofa::simulation::Node::SPtr m_RootNode; std::string sceneFileName; /// Pointer to the LoggingMessageHandler @@ -174,7 +173,7 @@ class SOFA_SOFAPHYSICSAPI_API SofaPhysicsSimulation } sofa::simulation::Simulation* getSimulation() const { - return m_Simulation; + return sofa::simulation::getSimulation(); } sofa::simulation::Node* getScene() const { diff --git a/examples/Demos/caduceus.scn b/examples/Demos/caduceus.scn index 81eb50261f5..9843110f503 100644 --- a/examples/Demos/caduceus.scn +++ b/examples/Demos/caduceus.scn @@ -21,6 +21,7 @@ +