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

Method addReadyChunkToScene

physx/samples/samplelargeworld/ChunkLoader.cpp:727–785  ·  view source on GitHub ↗

PhysX support buffer inserting actor, so no care about whether physic is simulating here

Source from the content-addressed store, hash-verified

725
726//PhysX support buffer inserting actor, so no care about whether physic is simulating here
727void BackgroundLoader::addReadyChunkToScene(ChunkID id)
728{
729 PxCollection *theCollection = NULL;
730 {
731 shdfnd::Mutex::ScopedLock al( mCollectionLock );
732 CollectionIdMap::iterator it = mCollectionIdMap.find(id);
733 if(it == mCollectionIdMap.end() || it->second.addToScene )
734 {
735 return;
736 }
737
738 theCollection = it->second.collection;
739 if( !theCollection )
740 return;
741
742 it->second.addToScene = true;
743 }
744
745 PxU32 count = theCollection->getNbObjects();
746 for(PxU32 i = 0; i < count; i++)
747 {
748 PxBase *object = &theCollection->getObject(i);
749 PX_ASSERT(object);
750 PxType theType = object->getConcreteType();
751 if( theType == PxConcreteType::eRIGID_DYNAMIC )
752 {
753 PxRigidActor *actor = static_cast<PxRigidActor*>(object);
754 mSampleLargeWorld->createRenderObjectsFromActor(actor);
755 }
756 else if(theType == PxConcreteType::eRIGID_STATIC)
757 {
758 PxRigidStatic* actor = static_cast<PxRigidStatic*>(object);
759 PxShape* shape = getShape( *actor );
760 PxTriangleMeshGeometry geometry;
761 shape->getTriangleMeshGeometry(geometry);
762 //We create static render mesh in another loop
763 if(shape->getGeometryType() != PxGeometryType::eTRIANGLEMESH)
764 {
765 mSampleLargeWorld->createRenderObjectsFromActor(actor, NULL);
766 }
767 }
768 }
769
770 {
771 PxSceneWriteLock scopedLock(mSampleLargeWorld->getActiveScene());
772 mScene.addCollection(*theCollection);
773 }
774
775 //Melt the freezon important actors on this chunk
776 for(unsigned i = 0; i < mDyncActors.size(); ++i)
777 {
778 DynamicObjects* obj = mDyncActors[i];
779 if( obj->id.id == id.id && obj->isImportant )
780 {
781 PxSceneWriteLock scopedLock(mSampleLargeWorld->getActiveScene());
782 obj->actor->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, false);
783 }
784 }

Callers

nothing calls this directly

Calls 11

getShapeFunction · 0.85
setRigidBodyFlagMethod · 0.80
findMethod · 0.45
endMethod · 0.45
getNbObjectsMethod · 0.45
getConcreteTypeMethod · 0.45
getGeometryTypeMethod · 0.45
addCollectionMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected