Skip to content

Commit

Permalink
Merge pull request #3832 from erwincoumans/master
Browse files Browse the repository at this point in the history
expose roll angle, fix python 2.x compatibility
  • Loading branch information
erwincoumans authored May 7, 2021
2 parents 00cd39d + adcf785 commit 39d981b
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 60 deletions.
2 changes: 2 additions & 0 deletions examples/CommonInterfaces/CommonGUIHelperInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct GUIHelperInterface
virtual int getShapeIndexFromInstance(int instanceUid) { return -1; }
virtual void replaceTexture(int shapeIndex, int textureUid) {}
virtual void removeTexture(int textureUid) {}
virtual void setBackgroundColor(const double rgbBackground[3]) {}


virtual Common2dCanvasInterface* get2dCanvasInterface() = 0;

Expand Down
2 changes: 2 additions & 0 deletions examples/CommonInterfaces/CommonRenderInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct CommonRenderInterface

virtual void setLightPosition(const float lightPos[3]) = 0;
virtual void setLightPosition(const double lightPos[3]) = 0;
virtual void setBackgroundColor(const double rgbBackground[3]) = 0;

virtual void setShadowMapResolution(int shadowMapResolution) = 0;
virtual void setShadowMapIntensity(double shadowMapIntensity) = 0;

Expand Down
8 changes: 7 additions & 1 deletion examples/ExampleBrowser/OpenGLGuiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,19 @@ OpenGLGuiHelper::OpenGLGuiHelper(CommonGraphicsApp* glApp, bool useOpenGL2)
m_data->m_debugDraw = 0;
}

OpenGLGuiHelper::~OpenGLGuiHelper()

OpenGLGuiHelper::~OpenGLGuiHelper()
{
delete m_data->m_debugDraw;

delete m_data;
}

void OpenGLGuiHelper::setBackgroundColor(const double rgbBackground[3])
{
this->getRenderInterface()->setBackgroundColor(rgbBackground);
}

struct CommonRenderInterface* OpenGLGuiHelper::getRenderInterface()
{
return m_data->m_glApp->m_renderer;
Expand Down
2 changes: 1 addition & 1 deletion examples/ExampleBrowser/OpenGLGuiHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct OpenGLGuiHelper : public GUIHelperInterface
virtual int getShapeIndexFromInstance(int instanceUid);
virtual void replaceTexture(int shapeIndex, int textureUid);
virtual void updateShape(int shapeIndex, float* vertices, int numVertices);

virtual void setBackgroundColor(const double rgbBackground[3]);
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape);

virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld);
Expand Down
5 changes: 5 additions & 0 deletions examples/OpenGLWindow/GLInstancingRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,11 @@ void GLInstancingRenderer::setLightPosition(const double lightPos[3])
m_data->m_lightPos[2] = lightPos[2];
}

void GLInstancingRenderer::setBackgroundColor(const double rgbBackground[3])
{
glClearColor(rgbBackground[0], rgbBackground[1], rgbBackground[2], 1.f);
}

void GLInstancingRenderer::setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])
{
for (int i = 0; i < 16; i++)
Expand Down
2 changes: 1 addition & 1 deletion examples/OpenGLWindow/GLInstancingRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class GLInstancingRenderer : public CommonRenderInterface
void setLightSpecularIntensity(const float lightSpecularIntensity[3]);
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]);
virtual void setProjectiveTexture(bool useProjectiveTexture);

virtual void setBackgroundColor(const double rgbBackground[3]);
virtual void resize(int width, int height);
virtual int getScreenWidth()
{
Expand Down
1 change: 1 addition & 0 deletions examples/OpenGLWindow/SimpleOpenGL2Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SimpleOpenGL2Renderer : public CommonRenderInterface
virtual void setShadowMapIntensity(double shadowMapIntensity) {}
virtual void setShadowMapWorldSize(float worldSize) {}
virtual void resize(int width, int height);
virtual void setBackgroundColor(const double rgbBackground[3]) {}

virtual void removeAllInstances();
virtual void removeGraphicsInstance(int instanceUid);
Expand Down
17 changes: 16 additions & 1 deletion examples/SharedMemory/PhysicsClientC_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4572,7 +4572,7 @@ B3_SHARED_API void b3ComputeViewMatrixFromYawPitchRoll(const float cameraTargetP

b3Scalar yawRad = yaw * b3Scalar(0.01745329251994329547); // rads per deg
b3Scalar pitchRad = pitch * b3Scalar(0.01745329251994329547); // rads per deg
b3Scalar rollRad = 0.0;
b3Scalar rollRad = roll * b3Scalar(0.01745329251994329547); // rads per deg
b3Quaternion eyeRot;

int forwardAxis(-1);
Expand Down Expand Up @@ -6064,6 +6064,21 @@ B3_SHARED_API void b3ConfigureOpenGLVisualizerSetLightPosition(b3SharedMemoryCom
}
}

B3_SHARED_API void b3ConfigureOpenGLVisualizerSetLightRgbBackground(b3SharedMemoryCommandHandle commandHandle, const float rgbBackground[3])
{
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
b3Assert(command);
b3Assert(command->m_type == CMD_CONFIGURE_OPENGL_VISUALIZER);
if (command->m_type == CMD_CONFIGURE_OPENGL_VISUALIZER)
{
command->m_updateFlags |= COV_SET_RGB_BACKGROUND;
command->m_configureOpenGLVisualizerArguments.m_rgbBackground[0] = rgbBackground[0];
command->m_configureOpenGLVisualizerArguments.m_rgbBackground[1] = rgbBackground[1];
command->m_configureOpenGLVisualizerArguments.m_rgbBackground[2] = rgbBackground[2];
}
}


B3_SHARED_API void b3ConfigureOpenGLVisualizerSetShadowMapResolution(b3SharedMemoryCommandHandle commandHandle, int shadowMapResolution)
{
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
Expand Down
2 changes: 2 additions & 0 deletions examples/SharedMemory/PhysicsClientC_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ extern "C"
B3_SHARED_API void b3ConfigureOpenGLVisualizerSetLightPosition(b3SharedMemoryCommandHandle commandHandle, const float lightPosition[3]);
B3_SHARED_API void b3ConfigureOpenGLVisualizerSetShadowMapResolution(b3SharedMemoryCommandHandle commandHandle, int shadowMapResolution);
B3_SHARED_API void b3ConfigureOpenGLVisualizerSetShadowMapIntensity(b3SharedMemoryCommandHandle commandHandle, double shadowMapIntensity);
B3_SHARED_API void b3ConfigureOpenGLVisualizerSetLightRgbBackground(b3SharedMemoryCommandHandle commandHandle, const float rgbBackground[3]);


B3_SHARED_API void b3ConfigureOpenGLVisualizerSetShadowMapWorldSize(b3SharedMemoryCommandHandle commandHandle, int shadowMapWorldSize);
B3_SHARED_API void b3ConfigureOpenGLVisualizerSetRemoteSyncTransformInterval(b3SharedMemoryCommandHandle commandHandle, double remoteSyncTransformInterval);

Expand Down
4 changes: 4 additions & 0 deletions examples/SharedMemory/PhysicsServerCommandProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11305,6 +11305,10 @@ bool PhysicsServerCommandProcessor::processConfigureOpenGLVisualizerCommand(cons
{
m_data->m_guiHelper->getRenderInterface()->setLightPosition(clientCmd.m_configureOpenGLVisualizerArguments.m_lightPosition);
}
if (clientCmd.m_updateFlags & COV_SET_RGB_BACKGROUND)
{
m_data->m_guiHelper->setBackgroundColor(clientCmd.m_configureOpenGLVisualizerArguments.m_rgbBackground);
}
if (clientCmd.m_updateFlags & COV_SET_SHADOWMAP_RESOLUTION)
{
m_data->m_guiHelper->getRenderInterface()->setShadowMapResolution(clientCmd.m_configureOpenGLVisualizerArguments.m_shadowMapResolution);
Expand Down
Loading

0 comments on commit 39d981b

Please sign in to comment.