Initialize the contact constraints
| 64 | |
| 65 | // Initialize the contact constraints |
| 66 | void ContactSolverSystem::init(Array<ContactManifold>* contactManifolds, Array<ContactPoint>* contactPoints, decimal timeStep) { |
| 67 | |
| 68 | mAllContactManifolds = contactManifolds; |
| 69 | mAllContactPoints = contactPoints; |
| 70 | |
| 71 | RP3D_PROFILE("ContactSolver::init()", mProfiler); |
| 72 | |
| 73 | mTimeStep = timeStep; |
| 74 | |
| 75 | const uint32 nbContactManifolds = static_cast<uint32>(mAllContactManifolds->size()); |
| 76 | const uint32 nbContactPoints = static_cast<uint32>(mAllContactPoints->size()); |
| 77 | |
| 78 | mNbContactManifolds = 0; |
| 79 | mNbContactPoints = 0; |
| 80 | |
| 81 | mContactConstraints = nullptr; |
| 82 | mContactPoints = nullptr; |
| 83 | |
| 84 | if (nbContactManifolds == 0 || nbContactPoints == 0) return; |
| 85 | |
| 86 | mContactPoints = static_cast<ContactPointSolver*>(mMemoryManager.allocate(MemoryManager::AllocationType::Frame, |
| 87 | sizeof(ContactPointSolver) * nbContactPoints)); |
| 88 | assert(mContactPoints != nullptr); |
| 89 | |
| 90 | mContactConstraints = static_cast<ContactManifoldSolver*>(mMemoryManager.allocate(MemoryManager::AllocationType::Frame, |
| 91 | sizeof(ContactManifoldSolver) * nbContactManifolds)); |
| 92 | assert(mContactConstraints != nullptr); |
| 93 | |
| 94 | // For each island of the world |
| 95 | const uint32 nbIslands = mIslands.getNbIslands(); |
| 96 | for (uint32 i = 0; i < nbIslands; i++) { |
| 97 | |
| 98 | if (mIslands.nbContactManifolds[i] > 0) { |
| 99 | initializeForIsland(i); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // Warmstarting |
| 104 | warmStart(); |
| 105 | } |
| 106 | |
| 107 | // Release allocated memory |
| 108 | void ContactSolverSystem::reset() { |
nothing calls this directly
no test coverage detected