Potential fix for Linux slow performance (usleep(0) takes a lot of time)

Remove b3RobotSimAPI, use RobotSimulator/b3RobotSimulatorClientAPI.h instead
This commit is contained in:
Erwin Coumans
2017-05-13 13:37:49 -07:00
parent 0944790577
commit ef7a7f9004
10 changed files with 204 additions and 1434 deletions

View File

@@ -60,6 +60,46 @@ void b3RobotSimulatorClientAPI::renderScene()
}
}
void b3RobotSimulatorClientAPI::debugDraw(int debugDrawMode)
{
if (!isConnected())
{
b3Warning("Not connected");
return;
}
if (m_data->m_guiHelper)
{
b3InProcessDebugDrawInternal(m_data->m_physicsClientHandle,debugDrawMode);
}
}
bool b3RobotSimulatorClientAPI::mouseMoveCallback(float x,float y)
{
if (!isConnected())
{
b3Warning("Not connected");
return false;
}
if (m_data->m_guiHelper)
{
return b3InProcessMouseMoveCallback(m_data->m_physicsClientHandle, x,y);
}
return false;
}
bool b3RobotSimulatorClientAPI::mouseButtonCallback(int button, int state, float x, float y)
{
if (!isConnected())
{
b3Warning("Not connected");
return false;
}
if (m_data->m_guiHelper)
{
return b3InProcessMouseButtonCallback(m_data->m_physicsClientHandle, button,state,x,y);
}
return false;
}
bool b3RobotSimulatorClientAPI::connect(int mode, const std::string& hostName, int portOrKey)
@@ -106,7 +146,7 @@ bool b3RobotSimulatorClientAPI::connect(int mode, const std::string& hostName, i
{
key = portOrKey;
}
sm = b3ConnectSharedMemory(key);
sm = b3ConnectSharedMemory2(key);
break;
}
case eCONNECT_UDP:
@@ -1088,4 +1128,19 @@ void b3RobotSimulatorClientAPI::submitProfileTiming(const std::string& profileN
b3SetProfileTimingDuractionInMicroSeconds(commandHandle, durationInMicroSeconds);
}
b3SubmitClientCommandAndWaitStatus(m_data->m_physicsClientHandle, commandHandle);
}
void b3RobotSimulatorClientAPI::loadBunny(double scale, double mass, double collisionMargin)
{
if (!isConnected())
{
b3Warning("Not connected");
return;
}
b3SharedMemoryCommandHandle command = b3LoadBunnyCommandInit(m_data->m_physicsClientHandle);
b3LoadBunnySetScale(command, scale);
b3LoadBunnySetMass(command, mass);
b3LoadBunnySetCollisionMargin(command, collisionMargin);
b3SubmitClientCommand(m_data->m_physicsClientHandle, command);
}

View File

@@ -148,11 +148,6 @@ public:
b3RobotSimulatorClientAPI();
virtual ~b3RobotSimulatorClientAPI();
//setGuiHelper is only used when embedded in existing example browser
void setGuiHelper(struct GUIHelperInterface* guiHelper);
//renderScene is only used when embedded in existing example browser
virtual void renderScene();
bool connect(int mode, const std::string& hostName = "localhost", int portOrKey = -1);
void disconnect();
@@ -231,6 +226,21 @@ public:
void submitProfileTiming(const std::string& profileName, int durationInMicroSeconds=1);
//////////////// INTERNAL
void loadBunny(double scale, double mass, double collisionMargin);
//setGuiHelper is only used when embedded in existing example browser
void setGuiHelper(struct GUIHelperInterface* guiHelper);
//renderScene is only used when embedded in existing example browser
virtual void renderScene();
//debugDraw is only used when embedded in existing example browser
virtual void debugDraw(int debugDrawMode);
virtual bool mouseMoveCallback(float x,float y);
virtual bool mouseButtonCallback(int button, int state, float x, float y);
////////////////INTERNAL
};
#endif //B3_ROBOT_SIMULATOR_CLIENT_API_H