mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-12 21:00:11 +00:00
wait until a frame is rendered, when using the COV_ENABLE_SINGLE_STEP_RENDERING command (Windows and Linux only)
This commit is contained in:
parent
81f6a63490
commit
0b08881ab8
@ -393,7 +393,15 @@ void OpenGLExampleBrowserVisualizerFlagCallback(int flag, bool enable)
|
||||
|
||||
if (flag == COV_ENABLE_SINGLE_STEP_RENDERING)
|
||||
{
|
||||
singleStepSimulation = true;
|
||||
if (enable)
|
||||
{
|
||||
gEnableRenderLoop = false;
|
||||
singleStepSimulation = true;
|
||||
} else
|
||||
{
|
||||
gEnableRenderLoop = true;
|
||||
singleStepSimulation = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1235,7 +1243,7 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
||||
{
|
||||
b3ChromeUtilsEnableProfiling();
|
||||
|
||||
if (!gEnableRenderLoop)
|
||||
if (!gEnableRenderLoop && !singleStepSimulation)
|
||||
{
|
||||
sCurrentDemo->updateGraphics();
|
||||
return;
|
||||
|
@ -137,6 +137,7 @@ enum MultiThreadedGUIHelperCommunicationEnums
|
||||
eGUIHelperGetShapeIndexFromInstance,
|
||||
eGUIHelperChangeTexture,
|
||||
eGUIHelperRemoveTexture,
|
||||
eGUIHelperSetVisualizerFlagCheckRenderedFrame,
|
||||
};
|
||||
|
||||
|
||||
@ -940,7 +941,9 @@ public:
|
||||
|
||||
int m_visualizerFlag;
|
||||
int m_visualizerEnable;
|
||||
void setVisualizerFlag(int flag, int enable)
|
||||
int m_renderedFrames;
|
||||
|
||||
void setVisualizerFlag(int flag, int enable)
|
||||
{
|
||||
m_visualizerFlag = flag;
|
||||
m_visualizerEnable = enable;
|
||||
@ -1358,6 +1361,7 @@ class PhysicsServerExample : public SharedMemoryCommon
|
||||
int m_canvasRGBIndex;
|
||||
int m_canvasDepthIndex;
|
||||
int m_canvasSegMaskIndex;
|
||||
|
||||
|
||||
// int m_options;
|
||||
|
||||
@ -1365,6 +1369,8 @@ class PhysicsServerExample : public SharedMemoryCommon
|
||||
TinyVRGui* m_tinyVrGui;
|
||||
#endif
|
||||
|
||||
int m_renderedFrames;
|
||||
|
||||
public:
|
||||
|
||||
PhysicsServerExample(MultiThreadedOpenGLGuiHelper* helper, CommandProcessorCreationInterface* commandProcessorCreator, SharedMemoryInterface* sharedMem=0, int options=0);
|
||||
@ -1723,6 +1729,7 @@ m_canvasSegMaskIndex(-1)
|
||||
#ifdef BT_ENABLE_VR
|
||||
,m_tinyVrGui(0)
|
||||
#endif
|
||||
,m_renderedFrames(0)
|
||||
{
|
||||
|
||||
m_multiThreadedHelper = helper;
|
||||
@ -2066,11 +2073,29 @@ void PhysicsServerExample::updateGraphics()
|
||||
gEnableDefaultMousePicking = (enable!=0);
|
||||
}
|
||||
|
||||
m_multiThreadedHelper->m_renderedFrames = m_renderedFrames;
|
||||
|
||||
m_multiThreadedHelper->m_childGuiHelper->setVisualizerFlag(m_multiThreadedHelper->m_visualizerFlag,m_multiThreadedHelper->m_visualizerEnable);
|
||||
m_multiThreadedHelper->mainThreadRelease();
|
||||
|
||||
//postpone the release until an actual frame is rendered
|
||||
if (flag == COV_ENABLE_SINGLE_STEP_RENDERING)
|
||||
{
|
||||
m_multiThreadedHelper->getCriticalSection()->setSharedParam(1,eGUIHelperSetVisualizerFlagCheckRenderedFrame);
|
||||
} else
|
||||
{
|
||||
m_multiThreadedHelper->mainThreadRelease();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case eGUIHelperSetVisualizerFlagCheckRenderedFrame:
|
||||
{
|
||||
if (m_renderedFrames!=m_multiThreadedHelper->m_renderedFrames)
|
||||
{
|
||||
m_multiThreadedHelper->mainThreadRelease();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case eGUIHelperRegisterGraphicsInstance:
|
||||
{
|
||||
@ -2732,6 +2757,8 @@ void PhysicsServerExample::drawUserDebugLines()
|
||||
|
||||
void PhysicsServerExample::renderScene()
|
||||
{
|
||||
m_renderedFrames++;
|
||||
|
||||
btTransform vrTrans;
|
||||
|
||||
|
||||
@ -2893,12 +2920,14 @@ void PhysicsServerExample::renderScene()
|
||||
|
||||
drawUserDebugLines();
|
||||
|
||||
|
||||
|
||||
//m_args[0].m_cs->unlock();
|
||||
}
|
||||
|
||||
void PhysicsServerExample::physicsDebugDraw(int debugDrawFlags)
|
||||
{
|
||||
m_renderedFrames++;
|
||||
|
||||
if (gEnableSyncPhysicsRendering)
|
||||
{
|
||||
m_physicsServer.syncPhysicsToGraphics();
|
||||
|
Loading…
Reference in New Issue
Block a user