mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-10-06 00:45:28 +00:00
Merge pull request #3056 from erwincoumans/master
re-enable pybullet.getVisualShapeData for deformables
This commit is contained in:
@@ -18,7 +18,7 @@ struct UrdfRenderingInterface
|
||||
///use the visualShapeUniqueId as a unique identifier to synchronize the world transform and to remove the visual shape.
|
||||
virtual int convertVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, const UrdfLink* linkPtr, const UrdfModel* model, int visualShapeUniqueId, int bodyUniqueId, struct CommonFileIOInterface* fileIO) = 0;
|
||||
|
||||
virtual int registerShapeAndInstance(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId, int orgGraphicsUniqueId, int bodyUniqueId, int linkIndex)=0;
|
||||
virtual int registerShapeAndInstance(const struct b3VisualShapeData& visualShape, const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId, int orgGraphicsUniqueId, int bodyUniqueId, int linkIndex)=0;
|
||||
|
||||
virtual void updateShape(int shapeUniqueId, const btVector3* vertices, int numVertices) = 0;
|
||||
|
||||
|
||||
@@ -8839,9 +8839,39 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo
|
||||
bodyHandle->m_softBody = psb;
|
||||
psb->setUserIndex2(*bodyUniqueId);
|
||||
|
||||
b3VisualShapeData visualShape;
|
||||
|
||||
visualShape.m_objectUniqueId = *bodyUniqueId;
|
||||
visualShape.m_linkIndex = -1;
|
||||
visualShape.m_visualGeometryType = URDF_GEOM_MESH;
|
||||
//dimensions just contains the scale
|
||||
visualShape.m_dimensions[0] = scale;
|
||||
visualShape.m_dimensions[1] = scale;
|
||||
visualShape.m_dimensions[2] = scale;
|
||||
//filename
|
||||
strncpy(visualShape.m_meshAssetFileName, relativeFileName, VISUAL_SHAPE_MAX_PATH_LEN);
|
||||
visualShape.m_meshAssetFileName[VISUAL_SHAPE_MAX_PATH_LEN - 1] = 0;
|
||||
//position and orientation
|
||||
visualShape.m_localVisualFrame[0] = pos[0];
|
||||
visualShape.m_localVisualFrame[1] = pos[1];
|
||||
visualShape.m_localVisualFrame[2] = pos[2];
|
||||
visualShape.m_localVisualFrame[3] = orn[0];
|
||||
visualShape.m_localVisualFrame[4] = orn[1];
|
||||
visualShape.m_localVisualFrame[5] = orn[2];
|
||||
visualShape.m_localVisualFrame[6] = orn[3];
|
||||
//color and ids to be set by the renderer
|
||||
visualShape.m_rgbaColor[0] = 0;
|
||||
visualShape.m_rgbaColor[1] = 0;
|
||||
visualShape.m_rgbaColor[2] = 0;
|
||||
visualShape.m_rgbaColor[3] = 1;
|
||||
visualShape.m_tinyRendererTextureId = -1;
|
||||
visualShape.m_textureUniqueId = -1;
|
||||
visualShape.m_openglTextureId = -1;
|
||||
|
||||
if (meshData.m_gfxShape)
|
||||
{
|
||||
int texUid1 = m_data->m_guiHelper->registerTexture(meshData.m_textureImage1, meshData.m_textureWidth, meshData.m_textureHeight);
|
||||
visualShape.m_openglTextureId = texUid1;
|
||||
int shapeUid1 = m_data->m_guiHelper->registerGraphicsShape(&meshData.m_gfxShape->m_vertices->at(0).xyzw[0], meshData.m_gfxShape->m_numvertices, &meshData.m_gfxShape->m_indices->at(0), meshData.m_gfxShape->m_numIndices, B3_GL_TRIANGLES, texUid1);
|
||||
psb->getCollisionShape()->setUserIndex(shapeUid1);
|
||||
float position[4] = { 0,0,0,0 };
|
||||
@@ -8854,8 +8884,10 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo
|
||||
if (m_data->m_enableTinyRenderer)
|
||||
{
|
||||
int texUid2 = m_data->m_pluginManager.getRenderInterface()->registerTexture(meshData.m_textureImage1, meshData.m_textureWidth, meshData.m_textureHeight);
|
||||
visualShape.m_tinyRendererTextureId = texUid2;
|
||||
int linkIndex = -1;
|
||||
int softBodyGraphicsShapeUid = m_data->m_pluginManager.getRenderInterface()->registerShapeAndInstance(
|
||||
visualShape,
|
||||
&meshData.m_gfxShape->m_vertices->at(0).xyzw[0],
|
||||
meshData.m_gfxShape->m_numvertices,
|
||||
&meshData.m_gfxShape->m_indices->at(0),
|
||||
@@ -8928,6 +8960,7 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo
|
||||
}
|
||||
|
||||
int texId = m_data->m_guiHelper->registerTexture(&texels[0], texWidth, texHeight);
|
||||
visualShape.m_openglTextureId = texId;
|
||||
int shapeId = m_data->m_guiHelper->registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, texId);
|
||||
b3Assert(shapeId >= 0);
|
||||
psb->getCollisionShape()->setUserIndex(shapeId);
|
||||
@@ -8935,8 +8968,10 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo
|
||||
{
|
||||
|
||||
int texUid2 = m_data->m_pluginManager.getRenderInterface()->registerTexture(&texels[0], texWidth, texHeight);
|
||||
visualShape.m_tinyRendererTextureId = texUid2;
|
||||
int linkIndex = -1;
|
||||
int softBodyGraphicsShapeUid = m_data->m_pluginManager.getRenderInterface()->registerShapeAndInstance(
|
||||
visualShape,
|
||||
&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, texUid2,
|
||||
psb->getBroadphaseHandle()->getUid(),
|
||||
*bodyUniqueId,
|
||||
|
||||
@@ -915,10 +915,10 @@ static btVector4 sColors[4] =
|
||||
btVector4(72. / 256., 133. / 256., 237. / 256., 1),
|
||||
};
|
||||
|
||||
int EGLRendererVisualShapeConverter::registerShapeAndInstance(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId, int orgGraphicsUniqueId, int bodyUniqueId, int linkIndex)
|
||||
int EGLRendererVisualShapeConverter::registerShapeAndInstance(const b3VisualShapeData& visualShape, const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId, int orgGraphicsUniqueId, int bodyUniqueId, int linkIndex)
|
||||
{
|
||||
int uniqueId = orgGraphicsUniqueId;
|
||||
float rgbaColor[4] = { 1,1,1,1 };
|
||||
float rgbaColor[4] = { visualShape.m_rgbaColor[0],visualShape.m_rgbaColor[1],visualShape.m_rgbaColor[2],visualShape.m_rgbaColor[3] };
|
||||
|
||||
EGLRendererObjectArray** visualsPtr = m_data->m_swRenderInstances[uniqueId];
|
||||
if (visualsPtr == 0)
|
||||
@@ -945,16 +945,15 @@ int EGLRendererVisualShapeConverter::registerShapeAndInstance(const float* verti
|
||||
int shapeIndex = m_data->m_instancingRenderer->registerShape(&vertices[0],
|
||||
numvertices, &indices[0], numIndices, B3_GL_TRIANGLES, innerTexId);
|
||||
|
||||
double scaling[3] = { 1, 1, 1 };
|
||||
double color[4] = { 1,1,1,1 };
|
||||
double position[4] = { 0,0,0,1 };
|
||||
double orn[4] = { 0,0,0,1 };
|
||||
double scaling[3] = { visualShape.m_dimensions[0], visualShape.m_dimensions[1],visualShape.m_dimensions[2] };
|
||||
double position[4] = { visualShape.m_localVisualFrame[0],visualShape.m_localVisualFrame[1],visualShape.m_localVisualFrame[2],1 };
|
||||
double orn[4] = { visualShape.m_localVisualFrame[3],visualShape.m_localVisualFrame[4],visualShape.m_localVisualFrame[5],visualShape.m_localVisualFrame[6]};
|
||||
|
||||
int graphicsIndex = m_data->m_instancingRenderer->registerGraphicsInstance(
|
||||
shapeIndex,
|
||||
position,
|
||||
orn,
|
||||
color,
|
||||
visualShape.m_rgbaColor,
|
||||
scaling);
|
||||
|
||||
int segmentationMask = bodyUniqueId + ((linkIndex + 1) << 24);
|
||||
@@ -980,6 +979,8 @@ int EGLRendererVisualShapeConverter::registerShapeAndInstance(const float* verti
|
||||
visuals->m_vertices[v] = orgVertices[v];
|
||||
}
|
||||
}
|
||||
|
||||
m_data->m_visualShapes.push_back(visualShape);
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ struct EGLRendererVisualShapeConverter : public UrdfRenderingInterface
|
||||
|
||||
virtual int getVisualShapesData(int bodyUniqueId, int shapeIndex, struct b3VisualShapeData* shapeData);
|
||||
|
||||
virtual int registerShapeAndInstance(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId, int orgGraphicsUniqueId, int bodyUniqueId, int linkIndex);
|
||||
virtual int registerShapeAndInstance(const b3VisualShapeData& visualShape, const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId, int orgGraphicsUniqueId, int bodyUniqueId, int linkIndex);
|
||||
|
||||
virtual void updateShape(int shapeUniqueId, const btVector3* vertices, int numVertices);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ struct TinyRendererVisualShapeConverter : public UrdfRenderingInterface
|
||||
virtual int convertVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, const UrdfLink* linkPtr, const UrdfModel* model, int orgGraphicsUniqueId, int bodyUniqueId, struct CommonFileIOInterface* fileIO);
|
||||
|
||||
//returns a shapeUniqueId
|
||||
virtual int registerShapeAndInstance(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId, int orgGraphicsUniqueId, int bodyUniqueId, int linkIndex);
|
||||
virtual int registerShapeAndInstance(const b3VisualShapeData& visualShape, const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId, int orgGraphicsUniqueId, int bodyUniqueId, int linkIndex);
|
||||
|
||||
virtual void updateShape(int shapeUniqueId, const btVector3* vertices, int numVertices);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user