PyBullet change API (since it was broken): pybullet_changeVisualShape with textureUniqueId ==-1 will clear the texture

b3InitUpdateVisualShape doesn't take textureUniqueId by default. new API b3UpdateVisualShapeTexture to change texture (-1 will clear texture)
PyBullet/BulletRobotics: allow to reset the textureUniqueId to -1, to clear a texture
PyBullet/BulletRobotics: save all texture handles
This commit is contained in:
erwincoumans
2018-10-20 15:56:56 -07:00
parent 9a9386b6a7
commit ed49edc1af
8 changed files with 90 additions and 42 deletions

View File

@@ -1159,7 +1159,7 @@ void TinyRendererVisualShapeConverter::resetAll()
void TinyRendererVisualShapeConverter::changeShapeTexture(int objectUniqueId, int jointIndex, int shapeIndex, int textureUniqueId)
{
btAssert(textureUniqueId < m_data->m_textures.size());
if (textureUniqueId >= 0 && textureUniqueId < m_data->m_textures.size())
if (textureUniqueId >= -1 && textureUniqueId < m_data->m_textures.size())
{
for (int n = 0; n < m_data->m_swRenderInstances.size(); n++)
{
@@ -1176,7 +1176,13 @@ void TinyRendererVisualShapeConverter::changeShapeTexture(int objectUniqueId, in
if ((shapeIndex < 0) || (shapeIndex == v))
{
renderObj->m_model->setDiffuseTextureFromData(m_data->m_textures[textureUniqueId].textureData1, m_data->m_textures[textureUniqueId].m_width, m_data->m_textures[textureUniqueId].m_height);
if (textureUniqueId>=0)
{
renderObj->m_model->setDiffuseTextureFromData(m_data->m_textures[textureUniqueId].textureData1, m_data->m_textures[textureUniqueId].m_width, m_data->m_textures[textureUniqueId].m_height);
} else
{
renderObj->m_model->setDiffuseTextureFromData(0,0,0);
}
}
}
}