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

Method onTick

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

Source from the content-addressed store, hash-verified

552}
553
554void BackgroundLoader::onTick()
555{
556 //Use local queue here to minimize the lock time, prevent blocking loader thread.
557 std::vector<ChunkCommand> theCmdQueue;
558 std::vector<DeferredLoadedRenderData> theLoadedRenderDataQueue;
559
560 mQueueLock.lock();
561 theCmdQueue = mChunkCmds;
562 theLoadedRenderDataQueue = mLoadedRenderDataQueue;
563 mLoadedRenderDataQueue.clear();
564 mChunkCmds.clear();
565 mQueueLock.unlock();
566
567 size_t cmdQueueSize = theCmdQueue.size();
568 if(cmdQueueSize == 0)
569 return;
570
571 //filter the same chunk with different commands
572 for(PxU32 i = 0; i < cmdQueueSize; ++i)
573 {
574 ChunkCommand cmdQueue = theCmdQueue[i];
575
576 bool isOutdatedCommand = false;
577 for(PxU32 j = i + 1; j < cmdQueueSize && !isOutdatedCommand; ++j)
578 {
579 isOutdatedCommand = (cmdQueue.id == theCmdQueue[j].id);
580 }
581
582 if(isOutdatedCommand)
583 continue;
584
585 ChunkCommandType::Enum type = cmdQueue.type;
586 if(type == ChunkCommandType::eAdd)
587 {
588 addReadyChunkToScene(cmdQueue.id);
589 }
590 else if(type == ChunkCommandType::eRemove)
591 {
592 destroyChunk(cmdQueue.id);
593 }
594 }
595
596 Ps::Time localTimer;
597 for(PxU32 i = 0; i < theLoadedRenderDataQueue.size(); i++)
598 {
599 DeferredLoadedRenderData& cq = theLoadedRenderDataQueue[i];
600 RenderBaseActor* renderMesh = mSampleLargeWorld->createRenderMeshFromRawMesh( cq);
601
602 //Link physic actor to render actor
603 cq.shape->userData = renderMesh;
604
605 {
606 PxSceneReadLock scopedLock(mSampleLargeWorld->getActiveScene());
607 renderMesh->setPhysicsShape(cq.shape, cq.shape->getActor());
608 renderMesh->setEnableCameraCull(true);
609
610 PxTriangleMeshGeometry geometry;
611 cq.shape->getTriangleMeshGeometry(geometry);

Callers 1

onTickPreRenderMethod · 0.80

Calls 14

setPhysicsShapeMethod · 0.80
setEnableCameraCullMethod · 0.80
setMeshScaleMethod · 0.80
lockMethod · 0.45
clearMethod · 0.45
unlockMethod · 0.45
sizeMethod · 0.45
getActorMethod · 0.45
getElapsedSecondsMethod · 0.45
lockWriterMethod · 0.45

Tested by

no test coverage detected