| 3755 | } |
| 3756 | |
| 3757 | class ScBeforeSolverTask : public Cm::Task |
| 3758 | { |
| 3759 | public: |
| 3760 | static const PxU32 MaxBodiesPerTask = 256; |
| 3761 | IG::NodeIndex mBodies[MaxBodiesPerTask]; |
| 3762 | PxU32 mNumBodies; |
| 3763 | const PxReal mDt; |
| 3764 | IG::SimpleIslandManager* mIslandManager; |
| 3765 | PxsSimulationController* mSimulationController; |
| 3766 | bool mSimUsesAdaptiveForce; |
| 3767 | |
| 3768 | public: |
| 3769 | |
| 3770 | ScBeforeSolverTask(PxReal dt, IG::SimpleIslandManager* islandManager, PxsSimulationController* simulationController, PxU64 contextID, bool simUsesAdaptiveForce) : |
| 3771 | Cm::Task (contextID), |
| 3772 | mDt (dt), |
| 3773 | mIslandManager (islandManager), |
| 3774 | mSimulationController (simulationController), |
| 3775 | mSimUsesAdaptiveForce (simUsesAdaptiveForce) |
| 3776 | { |
| 3777 | } |
| 3778 | |
| 3779 | virtual void runInternal() |
| 3780 | { |
| 3781 | PX_PROFILE_ZONE("Sim.ScBeforeSolverTask", mContextID); |
| 3782 | const IG::IslandSim& islandSim = mIslandManager->getAccurateIslandSim(); |
| 3783 | const PxU32 rigidBodyOffset = Sc::BodySim::getRigidBodyOffset(); |
| 3784 | |
| 3785 | PxsRigidBody* updatedBodySims[MaxBodiesPerTask]; |
| 3786 | PxU32 updatedBodyNodeIndices[MaxBodiesPerTask]; |
| 3787 | PxU32 nbUpdatedBodySims = 0; |
| 3788 | |
| 3789 | for(PxU32 i = 0; i < mNumBodies; i++) |
| 3790 | { |
| 3791 | IG::NodeIndex index = mBodies[i]; |
| 3792 | if(islandSim.getActiveNodeIndex(index) != IG_INVALID_NODE) |
| 3793 | { |
| 3794 | if (islandSim.getNode(index).mType == IG::Node::eRIGID_BODY_TYPE) |
| 3795 | { |
| 3796 | PxsRigidBody* body = islandSim.getRigidBody(index); |
| 3797 | Sc::BodySim* bodySim = reinterpret_cast<Sc::BodySim*>(reinterpret_cast<PxU8*>(body) - rigidBodyOffset); |
| 3798 | bodySim->updateForces(mDt, updatedBodySims, updatedBodyNodeIndices, nbUpdatedBodySims, NULL, false, mSimUsesAdaptiveForce); |
| 3799 | } |
| 3800 | } |
| 3801 | } |
| 3802 | |
| 3803 | if(nbUpdatedBodySims) |
| 3804 | mSimulationController->updateBodies(updatedBodySims, updatedBodyNodeIndices, nbUpdatedBodySims); |
| 3805 | } |
| 3806 | |
| 3807 | virtual const char* getName() const |
| 3808 | { |
| 3809 | return "ScScene.beforeSolver"; |
| 3810 | } |
| 3811 | |
| 3812 | private: |
| 3813 | ScBeforeSolverTask& operator = (const ScBeforeSolverTask&); |
| 3814 | }; |