MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / loadChunk

Method loadChunk

deps/physx/physx/samples/samplelargeworld/ChunkLoader.cpp:902–965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

900}
901
902PxCollection* BackgroundLoader::loadChunk(ChunkID id)
903{
904 {
905 shdfnd::Mutex::ScopedLock al(mCollectionLock);
906 if( mCollectionIdMap.find(id) != mCollectionIdMap.end() )
907 return NULL;
908 }
909
910 const char* theBinPath = getPathname( id );
911
912 PxCollection* theCollection = NULL;
913 void *theMemory = NULL;
914
915 Ps::Time localTimer;
916
917 SampleFramework::File* fp = NULL;
918 PxToolkit::fopen_s(&fp, theBinPath, "rb");
919 //If cannot find/deserilize the chunk file, create one collection
920 if( !fp )
921 {
922 theCollection = PxCreateCollection();
923 mSampleLargeWorld->createChunk( id.coord.x, id.coord.y, *theCollection );
924 }
925 else
926 {
927 localTimer.getElapsedSeconds();
928 PxU32 fileSize = getFileSize(theBinPath);
929 theMemory = malloc(fileSize + PX_SERIAL_FILE_ALIGN);
930
931 void* theMemoryA = (void*)((size_t(theMemory) + PX_SERIAL_FILE_ALIGN)&~(PX_SERIAL_FILE_ALIGN-1));
932 size_t numRead = fread(theMemoryA, 1, fileSize, fp);
933 fclose(fp);
934
935 mDiskIOTimeCounter += localTimer.getElapsedSeconds();
936 if(numRead != fileSize)
937 {
938 free(theMemory);
939 theMemory = NULL;
940 return NULL;
941 }
942
943 PxCollection* theExtRef = PxCreateCollection();
944 theExtRef->add(mMaterial, MATERIAL_ID);
945
946 theCollection = PxSerialization::createCollectionFromBinary(theMemoryA, *mSr, theExtRef);
947
948 theExtRef->release();
949
950 mPhyXStreamTimeCounter += localTimer.getElapsedSeconds();
951
952 }
953
954 CollectionMemory temp;
955 temp.collection = theCollection;
956 temp.memory = theMemory;
957 temp.addToScene = false;
958
959 {

Callers

nothing calls this directly

Calls 9

PxCreateCollectionFunction · 0.85
getFileSizeFunction · 0.85
createChunkMethod · 0.80
fopen_sFunction · 0.50
findMethod · 0.45
endMethod · 0.45
getElapsedSecondsMethod · 0.45
addMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected