Cache PxRenderBuffer

This commit is contained in:
rextimmy 2017-01-04 01:47:43 +10:00
parent b23b8d118e
commit e896ce0e4e
2 changed files with 14 additions and 14 deletions

View file

@ -63,7 +63,8 @@ Px3World::Px3World(): mScene( NULL ),
mEditorTimeScale( 1.0f ), mEditorTimeScale( 1.0f ),
mAccumulator( 0 ), mAccumulator( 0 ),
mControllerManager(NULL), mControllerManager(NULL),
mIsSceneLocked(false) mIsSceneLocked(false),
mRenderBuffer(NULL)
{ {
} }
@ -177,6 +178,8 @@ void Px3World::destroyWorld()
{ {
getPhysicsResults(); getPhysicsResults();
mRenderBuffer = NULL;
// Release the tick processing signals. // Release the tick processing signals.
if ( mProcessList ) if ( mProcessList )
{ {
@ -223,13 +226,14 @@ bool Px3World::initWorld( bool isServer, ProcessList *processList )
sceneDesc.cpuDispatcher = smCpuDispatcher; sceneDesc.cpuDispatcher = smCpuDispatcher;
Con::printf("PhysX3 using Cpu: %d workers", smCpuDispatcher->getWorkerCount()); Con::printf("PhysX3 using Cpu: %d workers", smCpuDispatcher->getWorkerCount());
} }
sceneDesc.flags |= physx::PxSceneFlag::eENABLE_CCD; sceneDesc.flags |= physx::PxSceneFlag::eENABLE_CCD;
sceneDesc.flags |= physx::PxSceneFlag::eENABLE_ACTIVETRANSFORMS; sceneDesc.flags |= physx::PxSceneFlag::eENABLE_ACTIVETRANSFORMS;
sceneDesc.filterShader = physx::PxDefaultSimulationFilterShader; sceneDesc.filterShader = physx::PxDefaultSimulationFilterShader;
mScene = gPhysics3SDK->createScene(sceneDesc); mScene = gPhysics3SDK->createScene(sceneDesc);
//cache renderbuffer for use with debug drawing
mRenderBuffer = const_cast<physx::PxRenderBuffer*>(&mScene->getRenderBuffer());
physx::PxDominanceGroupPair debrisDominance( 0.0f, 1.0f ); physx::PxDominanceGroupPair debrisDominance( 0.0f, 1.0f );
mScene->setDominanceGroupPair(0,31,debrisDominance); mScene->setDominanceGroupPair(0,31,debrisDominance);
@ -548,22 +552,17 @@ static ColorI getDebugColor( physx::PxU32 packed )
void Px3World::onDebugDraw( const SceneRenderState *state ) void Px3World::onDebugDraw( const SceneRenderState *state )
{ {
if ( !mScene ) if ( !mScene || !mRenderBuffer )
return; return;
mScene->setVisualizationParameter(physx::PxVisualizationParameter::eSCALE,1.0f); mScene->setVisualizationParameter(physx::PxVisualizationParameter::eSCALE,1.0f);
mScene->setVisualizationParameter(physx::PxVisualizationParameter::eBODY_AXES,1.0f); mScene->setVisualizationParameter(physx::PxVisualizationParameter::eBODY_AXES,1.0f);
mScene->setVisualizationParameter(physx::PxVisualizationParameter::eCOLLISION_SHAPES,1.0f); mScene->setVisualizationParameter(physx::PxVisualizationParameter::eCOLLISION_SHAPES,1.0f);
const physx::PxRenderBuffer *renderBuffer = &mScene->getRenderBuffer();
if(!renderBuffer)
return;
// Render points // Render points
{ {
physx::PxU32 numPoints = renderBuffer->getNbPoints(); physx::PxU32 numPoints = mRenderBuffer->getNbPoints();
const physx::PxDebugPoint *points = renderBuffer->getPoints(); const physx::PxDebugPoint *points = mRenderBuffer->getPoints();
PrimBuild::begin( GFXPointList, numPoints ); PrimBuild::begin( GFXPointList, numPoints );
@ -579,8 +578,8 @@ void Px3World::onDebugDraw( const SceneRenderState *state )
// Render lines // Render lines
{ {
physx::PxU32 numLines = renderBuffer->getNbLines(); physx::PxU32 numLines = mRenderBuffer->getNbLines();
const physx::PxDebugLine *lines = renderBuffer->getLines(); const physx::PxDebugLine *lines = mRenderBuffer->getLines();
PrimBuild::begin( GFXLineList, numLines * 2 ); PrimBuild::begin( GFXLineList, numLines * 2 );
@ -598,8 +597,8 @@ void Px3World::onDebugDraw( const SceneRenderState *state )
// Render triangles // Render triangles
{ {
physx::PxU32 numTris = renderBuffer->getNbTriangles(); physx::PxU32 numTris = mRenderBuffer->getNbTriangles();
const physx::PxDebugTriangle *triangles = renderBuffer->getTriangles(); const physx::PxDebugTriangle *triangles = mRenderBuffer->getTriangles();
PrimBuild::begin( GFXTriangleList, numTris * 3 ); PrimBuild::begin( GFXTriangleList, numTris * 3 );

View file

@ -61,6 +61,7 @@ protected:
ProcessList *mProcessList; ProcessList *mProcessList;
F32 mEditorTimeScale; F32 mEditorTimeScale;
bool mErrorReport; bool mErrorReport;
physx::PxRenderBuffer *mRenderBuffer;
physx::PxControllerManager* mControllerManager; physx::PxControllerManager* mControllerManager;
static Px3ConsoleStream *smErrorCallback; static Px3ConsoleStream *smErrorCallback;
static physx::PxDefaultAllocator smMemoryAlloc; static physx::PxDefaultAllocator smMemoryAlloc;