MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / destroyChunk

Method destroyChunk

physx/samples/samplelargeworld/ChunkLoader.cpp:788–866  ·  view source on GitHub ↗

just removed the actors from scene, do not release them

Source from the content-addressed store, hash-verified

786
787//just removed the actors from scene, do not release them
788void BackgroundLoader::destroyChunk(ChunkID id)
789{
790 PxCollection *theCollection = NULL;
791 bool inScene = false;
792 void* memory = NULL;
793 {
794 shdfnd::Mutex::ScopedLock al(mCollectionLock);
795
796 CollectionIdMap::iterator it = mCollectionIdMap.find(id);
797 if( it == mCollectionIdMap.end() )
798 return;
799
800 inScene = it->second.addToScene;
801 theCollection = it->second.collection;
802 memory = it->second.memory;
803 mCollectionIdMap.erase(it);
804 }
805
806
807 if(inScene)
808 {
809 //remove objects from scene first
810 PxU32 count = theCollection->getNbObjects();
811 {
812 PxSceneWriteLock scopedLock(mSampleLargeWorld->getActiveScene());
813 for(PxU32 i = 0; i < count; i++)
814 {
815 PxBase *object = &theCollection->getObject(i);
816 PX_ASSERT(object);
817 PxType type = object->getConcreteType();
818 if( type == PxConcreteType::eRIGID_STATIC || type == PxConcreteType::eRIGID_DYNAMIC )
819 {
820 mScene.removeActor( *static_cast<PxActor*>(object) );
821 }
822 }
823 }
824 }
825
826 //serialize the objects when they are not used
827 serialize(theCollection, id);
828 PxCollectionExt::releaseObjects(*theCollection);
829 theCollection->release();
830
831 if(memory)
832 {
833 free(memory);
834 memory = NULL;
835 }
836
837 //Remove the un-important actors on this chunk, freeze the important actors
838 std::vector<DynamicObjects*>::iterator it = mDyncActors.begin();
839 while(it != mDyncActors.end())
840 {
841 PxRigidDynamic* actor = (*it)->actor;
842 PxVec3 actorPos;
843 {
844 PxSceneReadLock scopedLock(mSampleLargeWorld->getActiveScene());
845 actorPos = actor->getGlobalPose().p;

Callers

nothing calls this directly

Calls 13

releaseObjectsFunction · 0.85
getChunkIdFromPositionFunction · 0.85
setRigidBodyFlagMethod · 0.80
freeFunction · 0.50
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
getNbObjectsMethod · 0.45
getConcreteTypeMethod · 0.45
removeActorMethod · 0.45
releaseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected