2015-11-23 04:50:32 +00:00
|
|
|
#include "PhysicsDirect.h"
|
|
|
|
|
|
|
|
#include "PhysicsClientSharedMemory.h"
|
|
|
|
#include "../CommonInterfaces/CommonGUIHelperInterface.h"
|
|
|
|
#include "SharedMemoryCommands.h"
|
2016-11-04 20:15:10 +00:00
|
|
|
#include "PhysicsCommandProcessorInterface.h"
|
|
|
|
|
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
#include "LinearMath/btHashMap.h"
|
|
|
|
#include "LinearMath/btAlignedObjectArray.h"
|
|
|
|
#include "../../Extras/Serialize/BulletFileLoader/btBulletFile.h"
|
|
|
|
#include "../../Extras/Serialize/BulletFileLoader/autogenerated/bullet.h"
|
|
|
|
#include "BodyJointInfoUtility.h"
|
2016-09-27 19:13:45 +00:00
|
|
|
#include <string>
|
2015-11-23 04:50:32 +00:00
|
|
|
|
|
|
|
struct BodyJointInfoCache2
|
|
|
|
{
|
2016-09-27 19:13:45 +00:00
|
|
|
std::string m_baseName;
|
2015-11-23 04:50:32 +00:00
|
|
|
btAlignedObjectArray<b3JointInfo> m_jointInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PhysicsDirectInternalData
|
|
|
|
{
|
|
|
|
DummyGUIHelper m_noGfx;
|
|
|
|
|
2016-11-05 00:06:55 +00:00
|
|
|
btAlignedObjectArray<char> m_serverDNA;
|
2015-11-23 04:50:32 +00:00
|
|
|
SharedMemoryCommand m_command;
|
|
|
|
SharedMemoryStatus m_serverStatus;
|
|
|
|
bool m_hasStatus;
|
|
|
|
bool m_verboseOutput;
|
|
|
|
|
|
|
|
btAlignedObjectArray<TmpFloat3> m_debugLinesFrom;
|
|
|
|
btAlignedObjectArray<TmpFloat3> m_debugLinesTo;
|
|
|
|
btAlignedObjectArray<TmpFloat3> m_debugLinesColor;
|
|
|
|
|
|
|
|
btHashMap<btHashInt,BodyJointInfoCache2*> m_bodyJointMap;
|
|
|
|
|
|
|
|
char m_bulletStreamDataServerToClient[SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE];
|
|
|
|
|
2016-06-04 02:03:56 +00:00
|
|
|
int m_cachedCameraPixelsWidth;
|
|
|
|
int m_cachedCameraPixelsHeight;
|
|
|
|
btAlignedObjectArray<unsigned char> m_cachedCameraPixelsRGBA;
|
|
|
|
btAlignedObjectArray<float> m_cachedCameraDepthBuffer;
|
2016-08-11 21:55:30 +00:00
|
|
|
btAlignedObjectArray<int> m_cachedSegmentationMask;
|
|
|
|
|
2016-09-02 01:28:39 +00:00
|
|
|
btAlignedObjectArray<b3ContactPointData> m_cachedContactPoints;
|
2016-11-10 19:22:22 +00:00
|
|
|
btAlignedObjectArray<b3OverlappingObject> m_cachedOverlappingObjects;
|
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
btAlignedObjectArray<b3VisualShapeData> m_cachedVisualShapes;
|
2016-12-27 03:40:09 +00:00
|
|
|
btAlignedObjectArray<b3VRControllerEvent> m_cachedVREvents;
|
|
|
|
|
|
|
|
btAlignedObjectArray<b3RayHitInfo> m_raycastHits;
|
|
|
|
|
2016-11-04 20:15:10 +00:00
|
|
|
PhysicsCommandProcessorInterface* m_commandProcessor;
|
|
|
|
bool m_ownsCommandProcessor;
|
2015-11-23 04:50:32 +00:00
|
|
|
|
|
|
|
PhysicsDirectInternalData()
|
|
|
|
:m_hasStatus(false),
|
2016-11-04 20:15:10 +00:00
|
|
|
m_verboseOutput(false),
|
|
|
|
m_ownsCommandProcessor(false)
|
2015-11-23 04:50:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-04 20:15:10 +00:00
|
|
|
PhysicsDirect::PhysicsDirect(PhysicsCommandProcessorInterface* physSdk)
|
2015-11-23 04:50:32 +00:00
|
|
|
{
|
|
|
|
m_data = new PhysicsDirectInternalData;
|
2016-11-04 20:15:10 +00:00
|
|
|
m_data->m_commandProcessor = physSdk;
|
|
|
|
m_data->m_ownsCommandProcessor = false;
|
2015-11-23 04:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PhysicsDirect::~PhysicsDirect()
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
if (m_data->m_commandProcessor->isConnected())
|
|
|
|
{
|
|
|
|
m_data->m_commandProcessor->disconnect();
|
|
|
|
}
|
|
|
|
if (m_data->m_ownsCommandProcessor)
|
|
|
|
{
|
|
|
|
delete m_data->m_commandProcessor;
|
|
|
|
}
|
2015-11-23 04:50:32 +00:00
|
|
|
delete m_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// return true if connection succesfull, can also check 'isConnected'
|
|
|
|
bool PhysicsDirect::connect()
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
bool connected = m_data->m_commandProcessor->connect();
|
2015-11-23 04:50:32 +00:00
|
|
|
m_data->m_commandProcessor->setGuiHelper(&m_data->m_noGfx);
|
2016-11-05 00:06:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
//also request serialization data
|
|
|
|
{
|
|
|
|
SharedMemoryCommand command;
|
|
|
|
command.m_type = CMD_REQUEST_INTERNAL_DATA;
|
|
|
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command, m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
|
|
|
if (hasStatus)
|
|
|
|
{
|
|
|
|
postProcessStatus(m_data->m_serverStatus);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int timeout = 1024 * 1024 * 1024;
|
|
|
|
while ((!hasStatus) && (timeout-- > 0))
|
|
|
|
{
|
|
|
|
const SharedMemoryStatus* stat = processServerStatus();
|
|
|
|
if (stat)
|
|
|
|
{
|
|
|
|
hasStatus = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-04 20:15:10 +00:00
|
|
|
return connected;
|
2016-08-19 17:30:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// return true if connection succesfull, can also check 'isConnected'
|
|
|
|
bool PhysicsDirect::connect(struct GUIHelperInterface* guiHelper)
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
bool connected = m_data->m_commandProcessor->connect();
|
|
|
|
|
2016-08-19 17:30:02 +00:00
|
|
|
m_data->m_commandProcessor->setGuiHelper(guiHelper);
|
|
|
|
|
2016-11-04 20:15:10 +00:00
|
|
|
return connected;
|
2015-11-23 04:50:32 +00:00
|
|
|
}
|
|
|
|
|
2016-08-19 17:30:02 +00:00
|
|
|
void PhysicsDirect::renderScene()
|
|
|
|
{
|
|
|
|
m_data->m_commandProcessor->renderScene();
|
|
|
|
}
|
2016-11-04 20:15:10 +00:00
|
|
|
|
2016-08-19 17:30:02 +00:00
|
|
|
void PhysicsDirect::debugDraw(int debugDrawMode)
|
|
|
|
{
|
|
|
|
m_data->m_commandProcessor->physicsDebugDraw(debugDrawMode);
|
|
|
|
}
|
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
////todo: rename to 'disconnect'
|
|
|
|
void PhysicsDirect::disconnectSharedMemory()
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
m_data->m_commandProcessor->disconnect();
|
2015-11-23 04:50:32 +00:00
|
|
|
m_data->m_commandProcessor->setGuiHelper(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PhysicsDirect::isConnected() const
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
return m_data->m_commandProcessor->isConnected();
|
2015-11-23 04:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// return non-null if there is a status, nullptr otherwise
|
|
|
|
const SharedMemoryStatus* PhysicsDirect::processServerStatus()
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
|
|
|
|
if (!m_data->m_hasStatus)
|
|
|
|
{
|
|
|
|
m_data->m_hasStatus = m_data->m_commandProcessor->receiveStatus(m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
|
|
|
}
|
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
SharedMemoryStatus* stat = 0;
|
|
|
|
if (m_data->m_hasStatus)
|
|
|
|
{
|
|
|
|
stat = &m_data->m_serverStatus;
|
2016-11-04 20:15:10 +00:00
|
|
|
|
|
|
|
postProcessStatus(m_data->m_serverStatus);
|
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
m_data->m_hasStatus = false;
|
|
|
|
}
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedMemoryCommand* PhysicsDirect::getAvailableSharedMemoryCommand()
|
|
|
|
{
|
|
|
|
return &m_data->m_command;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PhysicsDirect::canSubmitCommand() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PhysicsDirect::processDebugLines(const struct SharedMemoryCommand& orgCommand)
|
|
|
|
{
|
|
|
|
SharedMemoryCommand command = orgCommand;
|
|
|
|
|
|
|
|
const SharedMemoryStatus& serverCmd = m_data->m_serverStatus;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
|
|
|
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
2016-11-04 20:15:10 +00:00
|
|
|
|
|
|
|
int timeout = 1024 * 1024 * 1024;
|
|
|
|
while ((!hasStatus) && (timeout-- > 0))
|
|
|
|
{
|
|
|
|
const SharedMemoryStatus* stat = processServerStatus();
|
|
|
|
if (stat)
|
|
|
|
{
|
|
|
|
hasStatus = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
m_data->m_hasStatus = hasStatus;
|
2016-11-04 20:15:10 +00:00
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
if (hasStatus)
|
|
|
|
{
|
|
|
|
btAssert(m_data->m_serverStatus.m_type == CMD_DEBUG_LINES_COMPLETED);
|
|
|
|
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Success receiving %d debug lines",
|
|
|
|
serverCmd.m_sendDebugLinesArgs.m_numDebugLines);
|
|
|
|
}
|
|
|
|
|
|
|
|
int numLines = serverCmd.m_sendDebugLinesArgs.m_numDebugLines;
|
|
|
|
float* linesFrom =
|
|
|
|
(float*)&m_data->m_bulletStreamDataServerToClient[0];
|
|
|
|
float* linesTo =
|
|
|
|
(float*)(&m_data->m_bulletStreamDataServerToClient[0] +
|
|
|
|
numLines * 3 * sizeof(float));
|
|
|
|
float* linesColor =
|
|
|
|
(float*)(&m_data->m_bulletStreamDataServerToClient[0] +
|
|
|
|
2 * numLines * 3 * sizeof(float));
|
|
|
|
|
|
|
|
m_data->m_debugLinesFrom.resize(serverCmd.m_sendDebugLinesArgs.m_startingLineIndex +
|
|
|
|
numLines);
|
|
|
|
m_data->m_debugLinesTo.resize(serverCmd.m_sendDebugLinesArgs.m_startingLineIndex +
|
|
|
|
numLines);
|
|
|
|
m_data->m_debugLinesColor.resize(
|
|
|
|
serverCmd.m_sendDebugLinesArgs.m_startingLineIndex + numLines);
|
|
|
|
|
|
|
|
for (int i = 0; i < numLines; i++)
|
|
|
|
{
|
|
|
|
TmpFloat3 from = CreateTmpFloat3(linesFrom[i * 3], linesFrom[i * 3 + 1],
|
|
|
|
linesFrom[i * 3 + 2]);
|
|
|
|
TmpFloat3 to =
|
|
|
|
CreateTmpFloat3(linesTo[i * 3], linesTo[i * 3 + 1], linesTo[i * 3 + 2]);
|
|
|
|
TmpFloat3 color = CreateTmpFloat3(linesColor[i * 3], linesColor[i * 3 + 1],
|
|
|
|
linesColor[i * 3 + 2]);
|
|
|
|
|
|
|
|
m_data
|
|
|
|
->m_debugLinesFrom[serverCmd.m_sendDebugLinesArgs.m_startingLineIndex + i] =
|
|
|
|
from;
|
|
|
|
m_data->m_debugLinesTo[serverCmd.m_sendDebugLinesArgs.m_startingLineIndex + i] =
|
|
|
|
to;
|
|
|
|
m_data->m_debugLinesColor[serverCmd.m_sendDebugLinesArgs.m_startingLineIndex +
|
|
|
|
i] = color;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serverCmd.m_sendDebugLinesArgs.m_numRemainingDebugLines > 0)
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
m_data->m_hasStatus = false;
|
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
command.m_type = CMD_REQUEST_DEBUG_LINES;
|
|
|
|
command.m_requestDebugLinesArguments.m_startingLineIndex =
|
|
|
|
serverCmd.m_sendDebugLinesArgs.m_numDebugLines +
|
|
|
|
serverCmd.m_sendDebugLinesArgs.m_startingLineIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (serverCmd.m_sendDebugLinesArgs.m_numRemainingDebugLines > 0);
|
|
|
|
|
|
|
|
return m_data->m_hasStatus;
|
|
|
|
}
|
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
bool PhysicsDirect::processVisualShapeData(const struct SharedMemoryCommand& orgCommand)
|
|
|
|
{
|
|
|
|
SharedMemoryCommand command = orgCommand;
|
|
|
|
const SharedMemoryStatus& serverCmd = m_data->m_serverStatus;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command, m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
2016-11-04 20:15:10 +00:00
|
|
|
|
|
|
|
int timeout = 1024 * 1024 * 1024;
|
|
|
|
while ((!hasStatus) && (timeout-- > 0))
|
|
|
|
{
|
|
|
|
const SharedMemoryStatus* stat = processServerStatus();
|
|
|
|
if (stat)
|
|
|
|
{
|
|
|
|
hasStatus = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
m_data->m_hasStatus = hasStatus;
|
|
|
|
if (hasStatus)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Visual Shape Information Request OK\n");
|
|
|
|
}
|
|
|
|
int startVisualShapeIndex = serverCmd.m_sendVisualShapeArgs.m_startingVisualShapeIndex;
|
|
|
|
int numVisualShapesCopied = serverCmd.m_sendVisualShapeArgs.m_numVisualShapesCopied;
|
|
|
|
m_data->m_cachedVisualShapes.resize(startVisualShapeIndex + numVisualShapesCopied);
|
|
|
|
b3VisualShapeData* shapeData = (b3VisualShapeData*)&m_data->m_bulletStreamDataServerToClient[0];
|
|
|
|
for (int i = 0; i < numVisualShapesCopied; i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedVisualShapes[startVisualShapeIndex + i] = shapeData[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serverCmd.m_sendVisualShapeArgs.m_numRemainingVisualShapes >0 && serverCmd.m_sendVisualShapeArgs.m_numVisualShapesCopied)
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
m_data->m_hasStatus = false;
|
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
command.m_type = CMD_REQUEST_VISUAL_SHAPE_INFO;
|
|
|
|
command.m_requestVisualShapeDataArguments.m_startingVisualShapeIndex = serverCmd.m_sendVisualShapeArgs.m_startingVisualShapeIndex + serverCmd.m_sendVisualShapeArgs.m_numVisualShapesCopied;
|
|
|
|
command.m_requestVisualShapeDataArguments.m_bodyUniqueId = serverCmd.m_sendVisualShapeArgs.m_bodyUniqueId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (serverCmd.m_sendVisualShapeArgs.m_numRemainingVisualShapes > 0 && serverCmd.m_sendVisualShapeArgs.m_numVisualShapesCopied);
|
|
|
|
|
|
|
|
return m_data->m_hasStatus;
|
|
|
|
}
|
|
|
|
|
2016-11-10 19:22:22 +00:00
|
|
|
bool PhysicsDirect::processOverlappingObjects(const struct SharedMemoryCommand& orgCommand)
|
|
|
|
{
|
|
|
|
SharedMemoryCommand command = orgCommand;
|
|
|
|
|
|
|
|
const SharedMemoryStatus& serverCmd = m_data->m_serverStatus;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command, m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
|
|
|
|
|
|
|
int timeout = 1024 * 1024 * 1024;
|
|
|
|
while ((!hasStatus) && (timeout-- > 0))
|
|
|
|
{
|
|
|
|
const SharedMemoryStatus* stat = processServerStatus();
|
|
|
|
if (stat)
|
|
|
|
{
|
|
|
|
hasStatus = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_data->m_hasStatus = hasStatus;
|
|
|
|
if (hasStatus)
|
|
|
|
{
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Overlapping Objects Request OK\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int startOverlapIndex = serverCmd.m_sendOverlappingObjectsArgs.m_startingOverlappingObjectIndex;
|
|
|
|
int numOverlapCopied = serverCmd.m_sendOverlappingObjectsArgs.m_numOverlappingObjectsCopied;
|
|
|
|
m_data->m_cachedOverlappingObjects.resize(startOverlapIndex + numOverlapCopied);
|
|
|
|
b3OverlappingObject* objects = (b3OverlappingObject*)&m_data->m_bulletStreamDataServerToClient[0];
|
|
|
|
|
|
|
|
for (int i = 0; i < numOverlapCopied; i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedOverlappingObjects[startOverlapIndex + i] = objects[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serverCmd.m_sendOverlappingObjectsArgs.m_numRemainingOverlappingObjects > 0 && serverCmd.m_sendOverlappingObjectsArgs.m_numOverlappingObjectsCopied)
|
|
|
|
{
|
|
|
|
m_data->m_hasStatus = false;
|
|
|
|
command.m_type = CMD_REQUEST_AABB_OVERLAP;
|
|
|
|
command.m_requestOverlappingObjectsArgs.m_startingOverlappingObjectIndex = serverCmd.m_sendOverlappingObjectsArgs.m_startingOverlappingObjectIndex + serverCmd.m_sendOverlappingObjectsArgs.m_numOverlappingObjectsCopied;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} while (serverCmd.m_sendOverlappingObjectsArgs.m_numRemainingOverlappingObjects > 0 && serverCmd.m_sendOverlappingObjectsArgs.m_numOverlappingObjectsCopied);
|
|
|
|
|
|
|
|
return m_data->m_hasStatus;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
|
2016-09-02 01:28:39 +00:00
|
|
|
bool PhysicsDirect::processContactPointData(const struct SharedMemoryCommand& orgCommand)
|
|
|
|
{
|
|
|
|
SharedMemoryCommand command = orgCommand;
|
|
|
|
|
|
|
|
const SharedMemoryStatus& serverCmd = m_data->m_serverStatus;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
2016-11-04 20:15:10 +00:00
|
|
|
|
|
|
|
int timeout = 1024 * 1024 * 1024;
|
|
|
|
while ((!hasStatus) && (timeout-- > 0))
|
|
|
|
{
|
|
|
|
const SharedMemoryStatus* stat = processServerStatus();
|
|
|
|
if (stat)
|
|
|
|
{
|
|
|
|
hasStatus = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_data->m_hasStatus = hasStatus;
|
2016-09-02 01:28:39 +00:00
|
|
|
if (hasStatus)
|
|
|
|
{
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Contact Point Information Request OK\n");
|
|
|
|
}
|
|
|
|
int startContactIndex = serverCmd.m_sendContactPointArgs.m_startingContactPointIndex;
|
|
|
|
int numContactsCopied = serverCmd.m_sendContactPointArgs.m_numContactPointsCopied;
|
|
|
|
|
|
|
|
m_data->m_cachedContactPoints.resize(startContactIndex+numContactsCopied);
|
|
|
|
|
|
|
|
b3ContactPointData* contactData = (b3ContactPointData*)&m_data->m_bulletStreamDataServerToClient[0];
|
|
|
|
|
|
|
|
for (int i=0;i<numContactsCopied;i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedContactPoints[startContactIndex+i] = contactData[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serverCmd.m_sendContactPointArgs.m_numRemainingContactPoints>0 && serverCmd.m_sendContactPointArgs.m_numContactPointsCopied)
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
|
|
|
|
m_data->m_hasStatus = false;
|
|
|
|
|
|
|
|
command.m_type = CMD_REQUEST_CONTACT_POINT_INFORMATION;
|
2016-09-02 01:28:39 +00:00
|
|
|
command.m_requestContactPointArguments.m_startingContactPointIndex = serverCmd.m_sendContactPointArgs.m_startingContactPointIndex+serverCmd.m_sendContactPointArgs.m_numContactPointsCopied;
|
|
|
|
command.m_requestContactPointArguments.m_objectAIndexFilter = -1;
|
|
|
|
command.m_requestContactPointArguments.m_objectBIndexFilter = -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} while (serverCmd.m_sendContactPointArgs.m_numRemainingContactPoints > 0 && serverCmd.m_sendContactPointArgs.m_numContactPointsCopied);
|
|
|
|
|
|
|
|
return m_data->m_hasStatus;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-04 02:03:56 +00:00
|
|
|
bool PhysicsDirect::processCamera(const struct SharedMemoryCommand& orgCommand)
|
|
|
|
{
|
|
|
|
SharedMemoryCommand command = orgCommand;
|
|
|
|
|
|
|
|
const SharedMemoryStatus& serverCmd = m_data->m_serverStatus;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
|
|
|
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
2016-11-04 20:15:10 +00:00
|
|
|
|
|
|
|
int timeout = 1024 * 1024 * 1024;
|
|
|
|
while ((!hasStatus) && (timeout-- > 0))
|
|
|
|
{
|
|
|
|
const SharedMemoryStatus* stat = processServerStatus();
|
|
|
|
if (stat)
|
|
|
|
{
|
|
|
|
hasStatus = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-04 02:03:56 +00:00
|
|
|
m_data->m_hasStatus = hasStatus;
|
|
|
|
if (hasStatus)
|
|
|
|
{
|
|
|
|
btAssert(m_data->m_serverStatus.m_type == CMD_CAMERA_IMAGE_COMPLETED);
|
|
|
|
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Camera image OK\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int numBytesPerPixel = 4;//RGBA
|
|
|
|
int numTotalPixels = serverCmd.m_sendPixelDataArguments.m_startingPixelIndex+
|
|
|
|
serverCmd.m_sendPixelDataArguments.m_numPixelsCopied+
|
|
|
|
serverCmd.m_sendPixelDataArguments.m_numRemainingPixels;
|
|
|
|
|
|
|
|
m_data->m_cachedCameraPixelsWidth = 0;
|
|
|
|
m_data->m_cachedCameraPixelsHeight = 0;
|
|
|
|
|
|
|
|
int numPixels = serverCmd.m_sendPixelDataArguments.m_imageWidth*serverCmd.m_sendPixelDataArguments.m_imageHeight;
|
|
|
|
|
|
|
|
m_data->m_cachedCameraPixelsRGBA.reserve(numPixels*numBytesPerPixel);
|
|
|
|
m_data->m_cachedCameraDepthBuffer.resize(numTotalPixels);
|
2016-08-11 21:55:30 +00:00
|
|
|
m_data->m_cachedSegmentationMask.resize(numTotalPixels);
|
2016-06-04 02:03:56 +00:00
|
|
|
m_data->m_cachedCameraPixelsRGBA.resize(numTotalPixels*numBytesPerPixel);
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char* rgbaPixelsReceived =
|
|
|
|
(unsigned char*)&m_data->m_bulletStreamDataServerToClient[0];
|
2016-06-07 23:11:58 +00:00
|
|
|
|
|
|
|
float* depthBuffer = (float*)&(m_data->m_bulletStreamDataServerToClient[serverCmd.m_sendPixelDataArguments.m_numPixelsCopied*4]);
|
2016-08-11 21:55:30 +00:00
|
|
|
int* segmentationMaskBuffer = (int*)&(m_data->m_bulletStreamDataServerToClient[serverCmd.m_sendPixelDataArguments.m_numPixelsCopied*8]);
|
2016-06-07 23:11:58 +00:00
|
|
|
|
|
|
|
// printf("pixel = %d\n", rgbaPixelsReceived[0]);
|
2016-06-04 02:03:56 +00:00
|
|
|
|
2016-06-07 23:11:58 +00:00
|
|
|
for (int i=0;i<serverCmd.m_sendPixelDataArguments.m_numPixelsCopied;i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedCameraDepthBuffer[i + serverCmd.m_sendPixelDataArguments.m_startingPixelIndex] = depthBuffer[i];
|
|
|
|
}
|
2016-08-11 21:55:30 +00:00
|
|
|
for (int i=0;i<serverCmd.m_sendPixelDataArguments.m_numPixelsCopied;i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedSegmentationMask[i + serverCmd.m_sendPixelDataArguments.m_startingPixelIndex] = segmentationMaskBuffer[i];
|
|
|
|
}
|
2016-06-04 02:03:56 +00:00
|
|
|
for (int i=0;i<serverCmd.m_sendPixelDataArguments.m_numPixelsCopied*numBytesPerPixel;i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedCameraPixelsRGBA[i + serverCmd.m_sendPixelDataArguments.m_startingPixelIndex*numBytesPerPixel]
|
|
|
|
= rgbaPixelsReceived[i];
|
|
|
|
}
|
|
|
|
|
2016-08-08 21:23:44 +00:00
|
|
|
if (serverCmd.m_sendPixelDataArguments.m_numRemainingPixels > 0 && serverCmd.m_sendPixelDataArguments.m_numPixelsCopied)
|
2016-06-04 02:03:56 +00:00
|
|
|
{
|
|
|
|
|
2016-11-04 20:15:10 +00:00
|
|
|
m_data->m_hasStatus = false;
|
2016-06-04 02:03:56 +00:00
|
|
|
|
|
|
|
// continue requesting remaining pixels
|
|
|
|
command.m_type = CMD_REQUEST_CAMERA_IMAGE_DATA;
|
|
|
|
command.m_requestPixelDataArguments.m_startPixelIndex =
|
|
|
|
serverCmd.m_sendPixelDataArguments.m_startingPixelIndex +
|
|
|
|
serverCmd.m_sendPixelDataArguments.m_numPixelsCopied;
|
2016-06-07 23:11:58 +00:00
|
|
|
|
2016-06-04 02:03:56 +00:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
m_data->m_cachedCameraPixelsWidth = serverCmd.m_sendPixelDataArguments.m_imageWidth;
|
|
|
|
m_data->m_cachedCameraPixelsHeight = serverCmd.m_sendPixelDataArguments.m_imageHeight;
|
|
|
|
}
|
|
|
|
}
|
2016-08-08 21:23:44 +00:00
|
|
|
} while (serverCmd.m_sendPixelDataArguments.m_numRemainingPixels > 0 && serverCmd.m_sendPixelDataArguments.m_numPixelsCopied);
|
2016-06-04 02:03:56 +00:00
|
|
|
|
|
|
|
return m_data->m_hasStatus;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-15 01:41:19 +00:00
|
|
|
|
|
|
|
void PhysicsDirect::processBodyJointInfo(int bodyUniqueId, const SharedMemoryStatus& serverCmd)
|
|
|
|
{
|
|
|
|
bParse::btBulletFile bf(
|
|
|
|
&m_data->m_bulletStreamDataServerToClient[0],
|
2016-11-04 20:15:10 +00:00
|
|
|
serverCmd.m_numDataStreamBytes);
|
2016-11-05 00:06:55 +00:00
|
|
|
if (m_data->m_serverDNA.size())
|
|
|
|
{
|
|
|
|
bf.setFileDNA(false, &m_data->m_serverDNA[0], m_data->m_serverDNA.size());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bf.setFileDNAisMemoryDNA();
|
|
|
|
}
|
2016-06-15 01:41:19 +00:00
|
|
|
bf.parse(false);
|
2016-09-27 19:13:45 +00:00
|
|
|
|
2016-06-15 01:41:19 +00:00
|
|
|
BodyJointInfoCache2* bodyJoints = new BodyJointInfoCache2;
|
|
|
|
m_data->m_bodyJointMap.insert(bodyUniqueId,bodyJoints);
|
|
|
|
|
|
|
|
for (int i = 0; i < bf.m_multiBodies.size(); i++)
|
|
|
|
{
|
|
|
|
int flag = bf.getFlags();
|
|
|
|
if ((flag & bParse::FD_DOUBLE_PRECISION) != 0)
|
|
|
|
{
|
|
|
|
Bullet::btMultiBodyDoubleData* mb =
|
|
|
|
(Bullet::btMultiBodyDoubleData*)bf.m_multiBodies[i];
|
2016-11-05 05:30:41 +00:00
|
|
|
|
|
|
|
if (mb->m_baseName)
|
|
|
|
{
|
|
|
|
bodyJoints->m_baseName = mb->m_baseName;
|
|
|
|
}
|
2016-06-15 01:41:19 +00:00
|
|
|
addJointInfoFromMultiBodyData(mb,bodyJoints, m_data->m_verboseOutput);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
Bullet::btMultiBodyFloatData* mb =
|
|
|
|
(Bullet::btMultiBodyFloatData*)bf.m_multiBodies[i];
|
2016-09-27 19:13:45 +00:00
|
|
|
|
2016-11-05 05:30:41 +00:00
|
|
|
|
|
|
|
if (mb->m_baseName)
|
|
|
|
{
|
|
|
|
bodyJoints->m_baseName = mb->m_baseName;
|
|
|
|
}
|
2016-06-15 01:41:19 +00:00
|
|
|
addJointInfoFromMultiBodyData(mb,bodyJoints, m_data->m_verboseOutput);
|
|
|
|
}
|
|
|
|
}
|
2016-11-05 00:06:55 +00:00
|
|
|
if (bf.ok())
|
|
|
|
{
|
2016-06-15 01:41:19 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Received robot description ok!\n");
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
b3Warning("Robot description not received");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-04 20:15:10 +00:00
|
|
|
void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd)
|
|
|
|
{
|
|
|
|
switch (serverCmd.m_type)
|
|
|
|
{
|
2016-11-10 19:22:22 +00:00
|
|
|
|
2016-12-27 03:40:09 +00:00
|
|
|
case CMD_REQUEST_RAY_CAST_INTERSECTIONS_COMPLETED:
|
|
|
|
{
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Raycast completed");
|
|
|
|
}
|
|
|
|
m_data->m_raycastHits.clear();
|
|
|
|
for (int i=0;i<serverCmd.m_raycastHits.m_numRaycastHits;i++)
|
|
|
|
{
|
|
|
|
m_data->m_raycastHits.push_back(serverCmd.m_raycastHits.m_rayHits[i]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REQUEST_VR_EVENTS_DATA_COMPLETED:
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Request VR Events completed");
|
|
|
|
}
|
|
|
|
m_data->m_cachedVREvents.clear();
|
|
|
|
for (int i=0;i< serverCmd.m_sendVREvents.m_numVRControllerEvents;i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedVREvents.push_back(serverCmd.m_sendVREvents.m_controllerEvents[i]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-11-05 00:06:55 +00:00
|
|
|
case CMD_REQUEST_INTERNAL_DATA_COMPLETED:
|
|
|
|
{
|
|
|
|
if (serverCmd.m_numDataStreamBytes)
|
|
|
|
{
|
|
|
|
int numStreamBytes = serverCmd.m_numDataStreamBytes;
|
|
|
|
m_data->m_serverDNA.resize(numStreamBytes);
|
|
|
|
for (int i = 0; i < numStreamBytes; i++)
|
|
|
|
{
|
|
|
|
m_data->m_serverDNA[i] = m_data->m_bulletStreamDataServerToClient[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-11-04 20:15:10 +00:00
|
|
|
case CMD_RESET_SIMULATION_COMPLETED:
|
|
|
|
{
|
|
|
|
m_data->m_debugLinesFrom.clear();
|
|
|
|
m_data->m_debugLinesTo.clear();
|
|
|
|
m_data->m_debugLinesColor.clear();
|
|
|
|
for (int i = 0; i<m_data->m_bodyJointMap.size(); i++)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache2** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i);
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache2* bodyJoints = *bodyJointsPtr;
|
|
|
|
for (int j = 0; j<bodyJoints->m_jointInfo.size(); j++) {
|
|
|
|
if (bodyJoints->m_jointInfo[j].m_jointName)
|
|
|
|
{
|
|
|
|
free(bodyJoints->m_jointInfo[j].m_jointName);
|
|
|
|
}
|
|
|
|
if (bodyJoints->m_jointInfo[j].m_linkName)
|
|
|
|
{
|
|
|
|
free(bodyJoints->m_jointInfo[j].m_linkName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete (*bodyJointsPtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_data->m_bodyJointMap.clear();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_SDF_LOADING_COMPLETED:
|
|
|
|
{
|
|
|
|
//we'll stream further info from the physics server
|
|
|
|
//so serverCmd will be invalid, make a copy
|
|
|
|
|
|
|
|
|
|
|
|
int numBodies = serverCmd.m_sdfLoadedArgs.m_numBodies;
|
|
|
|
for (int i = 0; i<numBodies; i++)
|
|
|
|
{
|
|
|
|
int bodyUniqueId = serverCmd.m_sdfLoadedArgs.m_bodyUniqueIds[i];
|
|
|
|
SharedMemoryCommand infoRequestCommand;
|
|
|
|
infoRequestCommand.m_type = CMD_REQUEST_BODY_INFO;
|
|
|
|
infoRequestCommand.m_sdfRequestInfoArgs.m_bodyUniqueId = bodyUniqueId;
|
|
|
|
SharedMemoryStatus infoStatus;
|
|
|
|
bool hasStatus = m_data->m_commandProcessor->processCommand(infoRequestCommand, infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
int timeout = 1024 * 1024 * 1024;
|
|
|
|
while ((!hasStatus) && (timeout-- > 0))
|
|
|
|
{
|
|
|
|
hasStatus = m_data->m_commandProcessor->receiveStatus(infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasStatus)
|
|
|
|
{
|
|
|
|
processBodyJointInfo(bodyUniqueId, infoStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_URDF_LOADING_COMPLETED:
|
|
|
|
{
|
|
|
|
|
|
|
|
if (serverCmd.m_numDataStreamBytes > 0)
|
|
|
|
{
|
|
|
|
int bodyIndex = serverCmd.m_dataStreamArguments.m_bodyUniqueId;
|
|
|
|
processBodyJointInfo(bodyIndex, serverCmd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-11-12 02:07:42 +00:00
|
|
|
case CMD_BULLET_LOADING_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Couldn't load .bullet file");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_BULLET_LOADING_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2016-11-14 22:08:05 +00:00
|
|
|
case CMD_USER_CONSTRAINT_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_USER_CONSTRAINT_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("createConstraint failed");
|
|
|
|
break;
|
|
|
|
}
|
2016-11-04 20:15:10 +00:00
|
|
|
default:
|
|
|
|
{
|
2016-11-14 22:08:05 +00:00
|
|
|
//b3Warning("Unknown server status type");
|
2016-11-04 20:15:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2015-11-23 04:50:32 +00:00
|
|
|
bool PhysicsDirect::submitClientCommand(const struct SharedMemoryCommand& command)
|
|
|
|
{
|
|
|
|
if (command.m_type==CMD_REQUEST_DEBUG_LINES)
|
|
|
|
{
|
|
|
|
return processDebugLines(command);
|
|
|
|
}
|
|
|
|
|
2016-06-04 02:03:56 +00:00
|
|
|
if (command.m_type==CMD_REQUEST_CAMERA_IMAGE_DATA)
|
|
|
|
{
|
|
|
|
return processCamera(command);
|
|
|
|
}
|
2016-09-02 01:28:39 +00:00
|
|
|
if (command.m_type == CMD_REQUEST_CONTACT_POINT_INFORMATION)
|
|
|
|
{
|
|
|
|
return processContactPointData(command);
|
|
|
|
}
|
2016-06-04 02:03:56 +00:00
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
if (command.m_type == CMD_REQUEST_VISUAL_SHAPE_INFO)
|
|
|
|
{
|
|
|
|
return processVisualShapeData(command);
|
|
|
|
}
|
2016-11-10 19:22:22 +00:00
|
|
|
if (command.m_type == CMD_REQUEST_AABB_OVERLAP)
|
|
|
|
{
|
|
|
|
return processOverlappingObjects(command);
|
|
|
|
}
|
2016-10-19 05:05:28 +00:00
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
|
|
|
m_data->m_hasStatus = hasStatus;
|
|
|
|
if (hasStatus)
|
|
|
|
{
|
2016-11-04 20:15:10 +00:00
|
|
|
postProcessStatus(m_data->m_serverStatus);
|
2015-11-23 04:50:32 +00:00
|
|
|
}
|
|
|
|
return hasStatus;
|
|
|
|
}
|
|
|
|
|
2016-09-27 19:13:45 +00:00
|
|
|
int PhysicsDirect::getNumBodies() const
|
|
|
|
{
|
|
|
|
return m_data->m_bodyJointMap.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PhysicsDirect::getBodyUniqueId(int serialIndex) const
|
|
|
|
{
|
|
|
|
if ((serialIndex >= 0) && (serialIndex < getNumBodies()))
|
|
|
|
{
|
|
|
|
return m_data->m_bodyJointMap.getKeyAtIndex(serialIndex).getUid1();
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PhysicsDirect::getBodyInfo(int bodyUniqueId, struct b3BodyInfo& info) const
|
|
|
|
{
|
|
|
|
BodyJointInfoCache2** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache2* bodyJoints = *bodyJointsPtr;
|
|
|
|
info.m_baseName = bodyJoints->m_baseName.c_str();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-23 04:50:32 +00:00
|
|
|
int PhysicsDirect::getNumJoints(int bodyIndex) const
|
|
|
|
{
|
|
|
|
BodyJointInfoCache2** bodyJointsPtr = m_data->m_bodyJointMap[bodyIndex];
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache2* bodyJoints = *bodyJointsPtr;
|
|
|
|
return bodyJoints->m_jointInfo.size();
|
|
|
|
}
|
|
|
|
btAssert(0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-16 01:01:41 +00:00
|
|
|
bool PhysicsDirect::getJointInfo(int bodyIndex, int jointIndex, struct b3JointInfo& info) const
|
2015-11-23 04:50:32 +00:00
|
|
|
{
|
|
|
|
BodyJointInfoCache2** bodyJointsPtr = m_data->m_bodyJointMap[bodyIndex];
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache2* bodyJoints = *bodyJointsPtr;
|
2016-11-04 20:15:10 +00:00
|
|
|
if ((jointIndex >=0) && (jointIndex < bodyJoints->m_jointInfo.size()))
|
2016-06-16 01:01:41 +00:00
|
|
|
{
|
|
|
|
info = bodyJoints->m_jointInfo[jointIndex];
|
|
|
|
return true;
|
|
|
|
}
|
2015-11-23 04:50:32 +00:00
|
|
|
}
|
2016-06-16 01:01:41 +00:00
|
|
|
return false;
|
2015-11-23 04:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///todo: move this out of the
|
|
|
|
void PhysicsDirect::setSharedMemoryKey(int key)
|
|
|
|
{
|
|
|
|
//m_data->m_physicsServer->setSharedMemoryKey(key);
|
|
|
|
//m_data->m_physicsClient->setSharedMemoryKey(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PhysicsDirect::uploadBulletFileToSharedMemory(const char* data, int len)
|
|
|
|
{
|
|
|
|
//m_data->m_physicsClient->uploadBulletFileToSharedMemory(data,len);
|
|
|
|
}
|
|
|
|
|
|
|
|
int PhysicsDirect::getNumDebugLines() const
|
|
|
|
{
|
|
|
|
return m_data->m_debugLinesFrom.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
const float* PhysicsDirect::getDebugLinesFrom() const
|
|
|
|
{
|
|
|
|
if (getNumDebugLines())
|
|
|
|
{
|
|
|
|
return &m_data->m_debugLinesFrom[0].m_x;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
const float* PhysicsDirect::getDebugLinesTo() const
|
|
|
|
{
|
|
|
|
if (getNumDebugLines())
|
|
|
|
{
|
|
|
|
return &m_data->m_debugLinesTo[0].m_x;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
const float* PhysicsDirect::getDebugLinesColor() const
|
|
|
|
{
|
|
|
|
if (getNumDebugLines())
|
|
|
|
{
|
|
|
|
return &m_data->m_debugLinesColor[0].m_x;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-05-31 17:23:04 +00:00
|
|
|
|
|
|
|
void PhysicsDirect::getCachedCameraImage(b3CameraImageData* cameraData)
|
|
|
|
{
|
|
|
|
if (cameraData)
|
|
|
|
{
|
2016-06-04 02:03:56 +00:00
|
|
|
cameraData->m_pixelWidth = m_data->m_cachedCameraPixelsWidth;
|
|
|
|
cameraData->m_pixelHeight = m_data->m_cachedCameraPixelsHeight;
|
2016-08-12 20:55:37 +00:00
|
|
|
cameraData->m_depthValues = m_data->m_cachedCameraDepthBuffer.size() ? &m_data->m_cachedCameraDepthBuffer[0] : 0;
|
2016-06-04 02:03:56 +00:00
|
|
|
cameraData->m_rgbColorData = m_data->m_cachedCameraPixelsRGBA.size() ? &m_data->m_cachedCameraPixelsRGBA[0] : 0;
|
2016-08-11 21:55:30 +00:00
|
|
|
cameraData->m_segmentationMaskValues = m_data->m_cachedSegmentationMask.size()? &m_data->m_cachedSegmentationMask[0] : 0;
|
2016-05-31 17:23:04 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-01 20:30:07 +00:00
|
|
|
|
|
|
|
void PhysicsDirect::getCachedContactPointInformation(struct b3ContactInformation* contactPointData)
|
|
|
|
{
|
2016-09-02 01:28:39 +00:00
|
|
|
contactPointData->m_numContactPoints = m_data->m_cachedContactPoints.size();
|
|
|
|
contactPointData->m_contactPointData = contactPointData->m_numContactPoints? &m_data->m_cachedContactPoints[0] : 0;
|
|
|
|
|
2016-09-01 20:30:07 +00:00
|
|
|
}
|
|
|
|
|
2016-11-10 19:22:22 +00:00
|
|
|
void PhysicsDirect::getCachedOverlappingObjects(struct b3AABBOverlapData* overlappingObjects)
|
|
|
|
{
|
|
|
|
overlappingObjects->m_numOverlappingObjects = m_data->m_cachedOverlappingObjects.size();
|
|
|
|
overlappingObjects->m_overlappingObjects = m_data->m_cachedOverlappingObjects.size() ?
|
|
|
|
&m_data->m_cachedOverlappingObjects[0] : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
void PhysicsDirect::getCachedVisualShapeInformation(struct b3VisualShapeInformation* visualShapesInfo)
|
|
|
|
{
|
|
|
|
visualShapesInfo->m_numVisualShapes = m_data->m_cachedVisualShapes.size();
|
|
|
|
visualShapesInfo->m_visualShapeData = visualShapesInfo->m_numVisualShapes ? &m_data->m_cachedVisualShapes[0] : 0;
|
|
|
|
}
|
2016-12-27 03:40:09 +00:00
|
|
|
|
|
|
|
void PhysicsDirect::getCachedVREvents(struct b3VREventsData* vrEventsData)
|
|
|
|
{
|
|
|
|
vrEventsData->m_numControllerEvents = m_data->m_cachedVREvents.size();
|
|
|
|
vrEventsData->m_controllerEvents = vrEventsData->m_numControllerEvents?
|
|
|
|
&m_data->m_cachedVREvents[0] : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PhysicsDirect::getCachedRaycastHits(struct b3RaycastInformation* raycastHits)
|
|
|
|
{
|
|
|
|
raycastHits->m_numRayHits = m_data->m_raycastHits.size();
|
|
|
|
raycastHits->m_rayHits = raycastHits->m_numRayHits? &m_data->m_raycastHits[0] : 0;
|
|
|
|
}
|