fixes in pybullet.loadTexture, changeVisualShape replacing texture.

(also works for OpenGL3 renderer now)
This commit is contained in:
Erwin Coumans
2017-06-30 13:35:07 -07:00
parent dcaaed9238
commit dd3d55610b
14 changed files with 275 additions and 76 deletions

View File

@@ -1070,12 +1070,15 @@ void TinyRendererVisualShapeConverter::resetAll()
void TinyRendererVisualShapeConverter::activateShapeTexture(int shapeUniqueId, int textureUniqueId)
{
btAssert(textureUniqueId < m_data->m_textures.size());
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances.getAtIndex(shapeUniqueId);
if (ptrptr && *ptrptr)
{
TinyRendererObjectArray* ptr = *ptrptr;
ptr->m_renderObjects[0]->m_model->setDiffuseTextureFromData(m_data->m_textures[textureUniqueId].textureData,m_data->m_textures[textureUniqueId].m_width,m_data->m_textures[textureUniqueId].m_height);
}
if (textureUniqueId>=0 && textureUniqueId<m_data->m_textures.size())
{
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances.getAtIndex(shapeUniqueId);
if (ptrptr && *ptrptr)
{
TinyRendererObjectArray* ptr = *ptrptr;
ptr->m_renderObjects[0]->m_model->setDiffuseTextureFromData(m_data->m_textures[textureUniqueId].textureData,m_data->m_textures[textureUniqueId].m_width,m_data->m_textures[textureUniqueId].m_height);
}
}
}
void TinyRendererVisualShapeConverter::activateShapeTexture(int objectUniqueId, int jointIndex, int shapeIndex, int textureUniqueId)
@@ -1085,18 +1088,26 @@ void TinyRendererVisualShapeConverter::activateShapeTexture(int objectUniqueId,
{
if (m_data->m_visualShapes[i].m_objectUniqueId == objectUniqueId && m_data->m_visualShapes[i].m_linkIndex == jointIndex)
{
start = i;
break;
}
}
if (start >= 0)
{
if (start + shapeIndex < m_data->m_visualShapes.size())
{
activateShapeTexture(start + shapeIndex, textureUniqueId);
if (shapeIndex<0)
{
activateShapeTexture(i, textureUniqueId);
} else
{
start = i;
break;
}
}
}
if (shapeIndex>=0)
{
if (start >= 0)
{
if (start + shapeIndex < m_data->m_visualShapes.size())
{
activateShapeTexture(start + shapeIndex, textureUniqueId);
}
}
}
}
int TinyRendererVisualShapeConverter::registerTexture(unsigned char* texels, int width, int height)