Merge pull request #3996 from wkentaro/addUserDebugPoints

Add pybullet.addUserDebugPoints
This commit is contained in:
erwincoumans
2022-03-06 20:54:09 -08:00
committed by GitHub
17 changed files with 365 additions and 50 deletions

View File

@@ -4192,6 +4192,44 @@ B3_SHARED_API b3SharedMemoryCommandHandle b3InitUserDebugDrawAddLine3D(b3Physics
return (b3SharedMemoryCommandHandle)command;
}
B3_SHARED_API b3SharedMemoryCommandHandle b3InitUserDebugDrawAddPoints3D(b3PhysicsClientHandle physClient, const double positionsXYZ[/*3n*/], const double colorsRGB[/*3n*/], const double pointSize, const double lifeTime, const int pointNum)
{
PhysicsClient* cl = (PhysicsClient*)physClient;
b3Assert(cl);
b3Assert(cl->canSubmitCommand());
struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand();
b3Assert(command);
command->m_type = CMD_USER_DEBUG_DRAW;
command->m_updateFlags = USER_DEBUG_HAS_POINTS;
command->m_userDebugDrawArgs.m_debugPointNum = pointNum;
command->m_userDebugDrawArgs.m_pointSize = pointSize;
command->m_userDebugDrawArgs.m_lifeTime = lifeTime;
command->m_userDebugDrawArgs.m_parentObjectUniqueId = -1;
command->m_userDebugDrawArgs.m_parentLinkIndex = -1;
command->m_userDebugDrawArgs.m_optionFlags = 0;
int totalUploadSizeInBytes = pointNum * sizeof(double) * 3 * 2;
char* data = new char[totalUploadSizeInBytes];
double* pointPositionsUpload = (double*) data;
double* pointColorsUpload = (double*)(data + pointNum * sizeof(double) * 3);
for (int i = 0; i < pointNum; i++)
{
pointPositionsUpload[i * 3 + 0] = positionsXYZ[i * 3 + 0];
pointPositionsUpload[i * 3 + 1] = positionsXYZ[i * 3 + 1];
pointPositionsUpload[i * 3 + 2] = positionsXYZ[i * 3 + 2];
}
for (int i = 0; i < pointNum; i++)
{
pointColorsUpload[i * 3 + 0] = colorsRGB[i * 3 + 0];
pointColorsUpload[i * 3 + 1] = colorsRGB[i * 3 + 1];
pointColorsUpload[i * 3 + 2] = colorsRGB[i * 3 + 2];
}
cl->uploadBulletFileToSharedMemory(data, totalUploadSizeInBytes);
delete[] data;
return (b3SharedMemoryCommandHandle)command;
}
B3_SHARED_API b3SharedMemoryCommandHandle b3InitUserDebugDrawAddText3D(b3PhysicsClientHandle physClient, const char* txt, const double positionXYZ[3], const double colorRGB[3], double textSize, double lifeTime)
{