| 918 | } |
| 919 | |
| 920 | void Scb::Scene::syncEntireScene() |
| 921 | { |
| 922 | PX_PROFILE_ZONE("Sim.syncState", getContextId()); |
| 923 | |
| 924 | setPhysicsBuffering(false); // Clear the buffering flag to allow buffered writes to execute immediately. Once collision detection is running, buffering is automatically forced on |
| 925 | |
| 926 | mStream.lock(); |
| 927 | syncState(); |
| 928 | // |
| 929 | // Process aggregates (needs to be done before adding actors because the actor's aggregateID needs to get set) |
| 930 | // |
| 931 | |
| 932 | for(PxU32 i=0; i < mAggregateManager.getBufferedCount(); i++) |
| 933 | { |
| 934 | Aggregate* a = static_cast<Aggregate*>(mAggregateManager.getBuffered()[i]); |
| 935 | if (a->getControlState() == ControlState::eINSERT_PENDING) |
| 936 | { |
| 937 | PxU32 aggregateID = mScene.createAggregate(a->mPxAggregate, a->getSelfCollide()); |
| 938 | a->setAggregateID(aggregateID); |
| 939 | #if PX_SUPPORT_PVD |
| 940 | mScenePvdClient.createPvdInstance(a); |
| 941 | #endif |
| 942 | a->syncState(*this); // Necessary to set the aggregate ID for all actors of the aggregate |
| 943 | } |
| 944 | else if(a->getControlFlags() & ControlFlag::eIS_UPDATED) |
| 945 | { |
| 946 | a->syncState(*this); |
| 947 | } |
| 948 | } |
| 949 | mAggregateManager.clear(); |
| 950 | mActorPtrBuffer.clear(); |
| 951 | |
| 952 | |
| 953 | // rigid statics |
| 954 | processUserUpdates<Scb::RigidStatic>(mRigidStaticManager); |
| 955 | mRigidStaticManager.clear(); |
| 956 | |
| 957 | |
| 958 | // rigid dynamics and articulation links |
| 959 | // |
| 960 | // 1) Sync simulation changed data |
| 961 | { |
| 962 | PX_PROFILE_ZONE("SyncActiveBodies", getContextId()); |
| 963 | Sc::BodyCore*const* activeBodies = mScene.getActiveBodiesArray(); |
| 964 | PxU32 nbActiveBodies = mScene.getNumActiveBodies(); |
| 965 | while(nbActiveBodies--) |
| 966 | { |
| 967 | Sc::BodyCore* bodyCore = *activeBodies++; |
| 968 | Scb::Body& bufferedBody = Scb::Body::fromSc(*bodyCore); |
| 969 | if (!(bufferedBody.getControlFlags() & ControlFlag::eIS_UPDATED)) // Else the data will be synced further below |
| 970 | bufferedBody.syncState(); |
| 971 | } |
| 972 | } |
| 973 | |
| 974 | // 2) Sync data of rigid dynamics which were put to sleep by the simulation |
| 975 | |
| 976 | PxU32 nbSleepingBodies; |
| 977 | Sc::BodyCore* const* sleepingBodies = mScene.getSleepBodiesArray(nbSleepingBodies); |
no test coverage detected