mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-07-06 22:23:30 +00:00
Add pybullet.addUserDebugPoints
This commit is contained in:
@@ -4163,6 +4163,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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user