fixes for RemoteGUIHelper
This commit is contained in:
@@ -7717,7 +7717,7 @@ bool PhysicsServerCommandProcessor::processForwardDynamicsCommand(const struct S
|
||||
}
|
||||
serverCmd.m_type = CMD_STEP_FORWARD_SIMULATION_COMPLETED;
|
||||
|
||||
syncPhysicsToGraphics();
|
||||
syncPhysicsToGraphics2();
|
||||
return hasStatus;
|
||||
}
|
||||
|
||||
@@ -11569,6 +11569,13 @@ void PhysicsServerCommandProcessor::syncPhysicsToGraphics()
|
||||
m_data->m_guiHelper->syncPhysicsToGraphics(m_data->m_dynamicsWorld);
|
||||
}
|
||||
|
||||
|
||||
void PhysicsServerCommandProcessor::syncPhysicsToGraphics2()
|
||||
{
|
||||
m_data->m_guiHelper->syncPhysicsToGraphics2(m_data->m_dynamicsWorld);
|
||||
}
|
||||
|
||||
|
||||
void PhysicsServerCommandProcessor::renderScene(int renderFlags)
|
||||
{
|
||||
if (m_data->m_guiHelper)
|
||||
|
||||
@@ -138,6 +138,7 @@ public:
|
||||
virtual void physicsDebugDraw(int debugDrawFlags);
|
||||
virtual void setGuiHelper(struct GUIHelperInterface* guiHelper);
|
||||
virtual void syncPhysicsToGraphics();
|
||||
virtual void syncPhysicsToGraphics2();
|
||||
|
||||
//@todo(erwincoumans) Should we have shared memory commands for picking objects?
|
||||
///The pickBody method will try to pick the first body along a ray, return true if succeeds, false otherwise
|
||||
|
||||
@@ -821,41 +821,11 @@ public:
|
||||
{
|
||||
m_childGuiHelper->syncPhysicsToGraphics(rbWorld);
|
||||
}
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<GUISyncPosition> updatedPositions;
|
||||
|
||||
int numCollisionObjects = rbWorld->getNumCollisionObjects();
|
||||
{
|
||||
B3_PROFILE("write all InstanceTransformToCPU2");
|
||||
for (int i = 0; i < numCollisionObjects; i++)
|
||||
{
|
||||
//B3_PROFILE("writeSingleInstanceTransformToCPU");
|
||||
btCollisionObject* colObj = rbWorld->getCollisionObjectArray()[i];
|
||||
btCollisionShape* collisionShape = colObj->getCollisionShape();
|
||||
|
||||
btVector3 pos = colObj->getWorldTransform().getOrigin();
|
||||
btQuaternion orn = colObj->getWorldTransform().getRotation();
|
||||
int index = colObj->getUserIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
GUISyncPosition p;
|
||||
p.m_graphicsInstanceId = index;
|
||||
for (int q = 0; q < 4; q++)
|
||||
{
|
||||
p.m_pos[q] = pos[q];
|
||||
p.m_orn[q] = orn[q];
|
||||
}
|
||||
updatedPositions.push_back(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedPositions.size())
|
||||
{
|
||||
syncPhysicsToGraphics2(&updatedPositions[0], updatedPositions.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void syncPhysicsToGraphics2(const btDiscreteDynamicsWorld* rbWorld)
|
||||
{
|
||||
m_childGuiHelper->syncPhysicsToGraphics2(rbWorld);
|
||||
}
|
||||
|
||||
virtual void syncPhysicsToGraphics2(const GUISyncPosition* positions, int numPositions)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
||||
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||
|
||||
struct RemoteGUIHelperInternalData
|
||||
{
|
||||
@@ -282,6 +283,44 @@ void RemoteGUIHelper::syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWor
|
||||
{
|
||||
}
|
||||
|
||||
void RemoteGUIHelper::syncPhysicsToGraphics2(const btDiscreteDynamicsWorld* rbWorld)
|
||||
{
|
||||
b3AlignedObjectArray<GUISyncPosition> updatedPositions;
|
||||
|
||||
int numCollisionObjects = rbWorld->getNumCollisionObjects();
|
||||
{
|
||||
B3_PROFILE("write all InstanceTransformToCPU2");
|
||||
for (int i = 0; i < numCollisionObjects; i++)
|
||||
{
|
||||
//B3_PROFILE("writeSingleInstanceTransformToCPU");
|
||||
btCollisionObject* colObj = rbWorld->getCollisionObjectArray()[i];
|
||||
btCollisionShape* collisionShape = colObj->getCollisionShape();
|
||||
|
||||
btVector3 pos = colObj->getWorldTransform().getOrigin();
|
||||
btQuaternion orn = colObj->getWorldTransform().getRotation();
|
||||
int index = colObj->getUserIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
GUISyncPosition p;
|
||||
p.m_graphicsInstanceId = index;
|
||||
for (int q = 0; q < 4; q++)
|
||||
{
|
||||
p.m_pos[q] = pos[q];
|
||||
p.m_orn[q] = orn[q];
|
||||
}
|
||||
updatedPositions.push_back(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedPositions.size())
|
||||
{
|
||||
syncPhysicsToGraphics2(&updatedPositions[0], updatedPositions.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RemoteGUIHelper::syncPhysicsToGraphics2(const GUISyncPosition* positions, int numPositions)
|
||||
{
|
||||
uploadData((unsigned char*) positions, numPositions * sizeof(GUISyncPosition), 0);
|
||||
|
||||
@@ -21,6 +21,7 @@ struct RemoteGUIHelper : public GUIHelperInterface
|
||||
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape);
|
||||
|
||||
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld);
|
||||
virtual void syncPhysicsToGraphics2(const class btDiscreteDynamicsWorld* rbWorld);
|
||||
virtual void syncPhysicsToGraphics2(const GUISyncPosition* positions, int numPositions);
|
||||
|
||||
virtual void render(const btDiscreteDynamicsWorld* rbWorld);
|
||||
|
||||
@@ -41,6 +41,8 @@ myfiles =
|
||||
"GraphicsSharedMemoryBlock.h",
|
||||
"GraphicsSharedMemoryCommands.h",
|
||||
"GraphicsSharedMemoryPublic.h",
|
||||
"RemoteGUIHelper.cpp",
|
||||
"RemoteGUIHelper.h",
|
||||
"SharedMemoryCommands.h",
|
||||
"SharedMemoryPublic.h",
|
||||
"PhysicsServer.cpp",
|
||||
|
||||
Reference in New Issue
Block a user