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

@@ -392,6 +392,15 @@ GLInstancingRenderer::~GLInstancingRenderer()
int GLInstancingRenderer::getShapeIndexFromInstance(int srcIndex)
{
b3PublicGraphicsInstance* pg = m_data->m_publicGraphicsInstances.getHandle(srcIndex);
if (pg)
{
return pg->m_shapeIndex;
}
return -1;
}
@@ -955,6 +964,17 @@ int GLInstancingRenderer::registerTexture(const unsigned char* texels, int width
}
void GLInstancingRenderer::replaceTexture(int shapeIndex, int textureId)
{
if (shapeIndex >=0 && shapeIndex < m_data->m_textureHandles.size())
{
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
if (textureId>=0)
{
gfxObj->m_texturehandle = m_data->m_textureHandles[textureId].m_glTexture;
}
}
}
void GLInstancingRenderer::updateTexture(int textureIndex, const unsigned char* texels, bool flipPixelsY)
{

View File

@@ -67,7 +67,8 @@ public:
virtual int registerTexture(const unsigned char* texels, int width, int height, bool flipPixelsY=true);
virtual void updateTexture(int textureIndex, const unsigned char* texels, bool flipPixelsY=true);
virtual void activateTexture(int textureIndex);
virtual void replaceTexture(int shapeIndex, int textureId);
virtual int getShapeIndexFromInstance(int srcIndex);
///position x,y,z, quaternion x,y,z,w, color r,g,b,a, scaling x,y,z
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);