Deformables: enable double sided rendering, reduced the number of debug lines in regular rendering.
This commit is contained in:
@@ -9,6 +9,13 @@ enum
|
|||||||
B3_GL_POINTS
|
B3_GL_POINTS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
B3_INSTANCE_TRANSPARANCY = 1,
|
||||||
|
B3_INSTANCE_TEXTURE = 2,
|
||||||
|
B3_INSTANCE_DOUBLE_SIDED = 4,
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
B3_DEFAULT_RENDERMODE = 1,
|
B3_DEFAULT_RENDERMODE = 1,
|
||||||
@@ -94,6 +101,7 @@ struct CommonRenderInterface
|
|||||||
virtual void writeSingleInstanceScaleToCPU(const double* scale, int srcIndex) = 0;
|
virtual void writeSingleInstanceScaleToCPU(const double* scale, int srcIndex) = 0;
|
||||||
virtual void writeSingleInstanceSpecularColorToCPU(const double* specular, int srcIndex) = 0;
|
virtual void writeSingleInstanceSpecularColorToCPU(const double* specular, int srcIndex) = 0;
|
||||||
virtual void writeSingleInstanceSpecularColorToCPU(const float* specular, int srcIndex) = 0;
|
virtual void writeSingleInstanceSpecularColorToCPU(const float* specular, int srcIndex) = 0;
|
||||||
|
virtual void writeSingleInstanceFlagsToCPU(int flags, int srcIndex) = 0;
|
||||||
|
|
||||||
virtual int getTotalNumInstances() const = 0;
|
virtual int getTotalNumInstances() const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -75,10 +75,11 @@ public:
|
|||||||
{
|
{
|
||||||
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
//btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// deformableWorld->getDrawFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ public:
|
|||||||
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
||||||
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
//btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// deformableWorld->getDrawFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,16 +70,19 @@ public:
|
|||||||
virtual void renderScene()
|
virtual void renderScene()
|
||||||
{
|
{
|
||||||
CommonRigidBodyBase::renderScene();
|
CommonRigidBodyBase::renderScene();
|
||||||
btDeformableMultiBodyDynamicsWorld* deformableWorld = getDeformableDynamicsWorld();
|
|
||||||
|
|
||||||
|
btDeformableMultiBodyDynamicsWorld* deformableWorld = getDeformableDynamicsWorld();
|
||||||
|
|
||||||
for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++)
|
for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++)
|
||||||
{
|
{
|
||||||
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
//btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// StddeformableWorld->getDrawFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -200,6 +203,10 @@ void DeformableContact::initPhysics()
|
|||||||
getDeformableDynamicsWorld()->setImplicit(false);
|
getDeformableDynamicsWorld()->setImplicit(false);
|
||||||
getDeformableDynamicsWorld()->setLineSearch(false);
|
getDeformableDynamicsWorld()->setLineSearch(false);
|
||||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||||
|
int numInstances = m_guiHelper->getRenderInterface()->getTotalNumInstances();
|
||||||
|
double rgbaColors[3][4] = { { 1, 0, 0, 1 } , { 0, 1, 0, 1 } ,{ 0, 0, 1, 1 } };
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeformableContact::exitPhysics()
|
void DeformableContact::exitPhysics()
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// deformableWorld->getDrawFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public:
|
|||||||
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// deformableWorld->getDrawFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// deformableWorld->getDrawFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ public:
|
|||||||
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
btSoftBody* psb = (btSoftBody*)deformableWorld->getSoftBodyArray()[i];
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// deformableWorld->getDrawFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
btSoftBodyHelpers::DrawFrame(psb, deformableWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// deformableWorld->getDrawFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1433,6 +1433,11 @@ void OpenGLGuiHelper::autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWor
|
|||||||
color.setValue(1, 1, 1, 1);
|
color.setValue(1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
createCollisionObjectGraphicsObject(colObj, color);
|
createCollisionObjectGraphicsObject(colObj, color);
|
||||||
|
if (sb)
|
||||||
|
{
|
||||||
|
int graphicsInstanceId = colObj->getUserIndex();
|
||||||
|
changeInstanceFlags(graphicsInstanceId, B3_INSTANCE_DOUBLE_SIDED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,11 +139,7 @@ static InternalDataRenderer* sData2;
|
|||||||
|
|
||||||
GLint lineWidthRange[2] = {1, 1};
|
GLint lineWidthRange[2] = {1, 1};
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
eGfxTransparency = 1,
|
|
||||||
eGfxHasTexture = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct b3GraphicsInstance
|
struct b3GraphicsInstance
|
||||||
{
|
{
|
||||||
@@ -492,6 +488,26 @@ void GLInstancingRenderer::readSingleInstanceTransformFromCPU(int srcIndex2, flo
|
|||||||
orientation[2] = m_data->m_instance_quaternion_ptr[srcIndex * 4 + 2];
|
orientation[2] = m_data->m_instance_quaternion_ptr[srcIndex * 4 + 2];
|
||||||
orientation[3] = m_data->m_instance_quaternion_ptr[srcIndex * 4 + 3];
|
orientation[3] = m_data->m_instance_quaternion_ptr[srcIndex * 4 + 3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLInstancingRenderer::writeSingleInstanceFlagsToCPU(int flags, int srcIndex2)
|
||||||
|
{
|
||||||
|
b3PublicGraphicsInstance* pg = m_data->m_publicGraphicsInstances.getHandle(srcIndex2);
|
||||||
|
b3Assert(pg);
|
||||||
|
int srcIndex = pg->m_internalInstanceIndex;
|
||||||
|
|
||||||
|
int shapeIndex = pg->m_shapeIndex;
|
||||||
|
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
||||||
|
if (flags & B3_INSTANCE_DOUBLE_SIDED)
|
||||||
|
{
|
||||||
|
gfxObj->m_flags |= B3_INSTANCE_DOUBLE_SIDED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gfxObj->m_flags &= ~B3_INSTANCE_DOUBLE_SIDED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLInstancingRenderer::writeSingleInstanceColorToCPU(const double* color, int srcIndex2)
|
void GLInstancingRenderer::writeSingleInstanceColorToCPU(const double* color, int srcIndex2)
|
||||||
{
|
{
|
||||||
b3PublicGraphicsInstance* pg = m_data->m_publicGraphicsInstances.getHandle(srcIndex2);
|
b3PublicGraphicsInstance* pg = m_data->m_publicGraphicsInstances.getHandle(srcIndex2);
|
||||||
@@ -502,11 +518,11 @@ void GLInstancingRenderer::writeSingleInstanceColorToCPU(const double* color, in
|
|||||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
||||||
if (color[3] < 1)
|
if (color[3] < 1)
|
||||||
{
|
{
|
||||||
gfxObj->m_flags |= eGfxTransparency;
|
gfxObj->m_flags |= B3_INSTANCE_TRANSPARANCY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gfxObj->m_flags &= ~eGfxTransparency;
|
gfxObj->m_flags &= ~B3_INSTANCE_TRANSPARANCY;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->m_instance_colors_ptr[srcIndex * 4 + 0] = float(color[0]);
|
m_data->m_instance_colors_ptr[srcIndex * 4 + 0] = float(color[0]);
|
||||||
@@ -525,11 +541,11 @@ void GLInstancingRenderer::writeSingleInstanceColorToCPU(const float* color, int
|
|||||||
|
|
||||||
if (color[3] < 1)
|
if (color[3] < 1)
|
||||||
{
|
{
|
||||||
gfxObj->m_flags |= eGfxTransparency;
|
gfxObj->m_flags |= B3_INSTANCE_TRANSPARANCY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gfxObj->m_flags &= ~eGfxTransparency;
|
gfxObj->m_flags &= ~B3_INSTANCE_TRANSPARANCY;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->m_instance_colors_ptr[srcIndex * 4 + 0] = color[0];
|
m_data->m_instance_colors_ptr[srcIndex * 4 + 0] = color[0];
|
||||||
@@ -916,7 +932,7 @@ int GLInstancingRenderer::registerGraphicsInstanceInternal(int newUid, const flo
|
|||||||
|
|
||||||
if (color[3] < 1 && color[3] > 0)
|
if (color[3] < 1 && color[3] > 0)
|
||||||
{
|
{
|
||||||
gfxObj->m_flags |= eGfxTransparency;
|
gfxObj->m_flags |= B3_INSTANCE_TRANSPARANCY;
|
||||||
}
|
}
|
||||||
gfxObj->m_numGraphicsInstances++;
|
gfxObj->m_numGraphicsInstances++;
|
||||||
m_data->m_totalNumInstances++;
|
m_data->m_totalNumInstances++;
|
||||||
@@ -1018,11 +1034,11 @@ void GLInstancingRenderer::replaceTexture(int shapeIndex, int textureId)
|
|||||||
if (textureId >= 0 && textureId < m_data->m_textureHandles.size())
|
if (textureId >= 0 && textureId < m_data->m_textureHandles.size())
|
||||||
{
|
{
|
||||||
gfxObj->m_textureIndex = textureId;
|
gfxObj->m_textureIndex = textureId;
|
||||||
gfxObj->m_flags |= eGfxHasTexture;
|
gfxObj->m_flags |= B3_INSTANCE_TEXTURE;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
gfxObj->m_textureIndex = -1;
|
gfxObj->m_textureIndex = -1;
|
||||||
gfxObj->m_flags &= ~eGfxHasTexture;
|
gfxObj->m_flags &= ~B3_INSTANCE_TEXTURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1110,7 +1126,7 @@ int GLInstancingRenderer::registerShape(const float* vertices, int numvertices,
|
|||||||
if (textureId >= 0)
|
if (textureId >= 0)
|
||||||
{
|
{
|
||||||
gfxObj->m_textureIndex = textureId;
|
gfxObj->m_textureIndex = textureId;
|
||||||
gfxObj->m_flags |= eGfxHasTexture;
|
gfxObj->m_flags |= B3_INSTANCE_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxObj->m_primitiveType = primitiveType;
|
gfxObj->m_primitiveType = primitiveType;
|
||||||
@@ -1754,6 +1770,7 @@ static void b3CreateLookAt(const b3Vector3& eye, const b3Vector3& center, const
|
|||||||
result[3 * 4 + 3] = 1.f;
|
result[3 * 4 + 3] = 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLInstancingRenderer::drawTexturedTriangleMesh(float worldPosition[3], float worldOrientation[4], const float* vertices, int numvertices, const unsigned int* indices, int numIndices, float colorRGBA[4], int textureIndex, int vertexLayout)
|
void GLInstancingRenderer::drawTexturedTriangleMesh(float worldPosition[3], float worldOrientation[4], const float* vertices, int numvertices, const unsigned int* indices, int numIndices, float colorRGBA[4], int textureIndex, int vertexLayout)
|
||||||
{
|
{
|
||||||
int sz = sizeof(GfxVertexFormat0);
|
int sz = sizeof(GfxVertexFormat0);
|
||||||
@@ -2263,7 +2280,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
|
|
||||||
inst.m_shapeIndex = obj;
|
inst.m_shapeIndex = obj;
|
||||||
|
|
||||||
if ((gfxObj->m_flags & eGfxTransparency) == 0)
|
if ((gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY) == 0)
|
||||||
{
|
{
|
||||||
inst.m_instanceId = curOffset;
|
inst.m_instanceId = curOffset;
|
||||||
b3Vector3 centerPosition;
|
b3Vector3 centerPosition;
|
||||||
@@ -2313,10 +2330,10 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
||||||
|
|
||||||
//only draw stuff (opaque/transparent) if it is the right pass
|
//only draw stuff (opaque/transparent) if it is the right pass
|
||||||
int drawThisPass = (pass == 0) == ((gfxObj->m_flags & eGfxTransparency) == 0);
|
int drawThisPass = (pass == 0) == ((gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY) == 0);
|
||||||
|
|
||||||
//transparent objects don't cast shadows (to simplify things)
|
//transparent objects don't cast shadows (to simplify things)
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
if (renderMode == B3_CREATE_SHADOWMAP_RENDERMODE)
|
if (renderMode == B3_CREATE_SHADOWMAP_RENDERMODE)
|
||||||
drawThisPass = 0;
|
drawThisPass = 0;
|
||||||
@@ -2326,7 +2343,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
GLuint curBindTexture = 0;
|
GLuint curBindTexture = 0;
|
||||||
if (gfxObj->m_flags & eGfxHasTexture)
|
if (gfxObj->m_flags & B3_INSTANCE_TEXTURE)
|
||||||
{
|
{
|
||||||
curBindTexture = m_data->m_textureHandles[gfxObj->m_textureIndex].m_glTexture;
|
curBindTexture = m_data->m_textureHandles[gfxObj->m_textureIndex].m_glTexture;
|
||||||
|
|
||||||
@@ -2432,6 +2449,11 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (gfxObj->m_flags & B3_INSTANCE_DOUBLE_SIDED)
|
||||||
|
{
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
}
|
||||||
|
|
||||||
switch (renderMode)
|
switch (renderMode)
|
||||||
{
|
{
|
||||||
case B3_SEGMENTATION_MASK_RENDERMODE:
|
case B3_SEGMENTATION_MASK_RENDERMODE:
|
||||||
@@ -2445,7 +2467,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
}
|
}
|
||||||
case B3_DEFAULT_RENDERMODE:
|
case B3_DEFAULT_RENDERMODE:
|
||||||
{
|
{
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
@@ -2462,7 +2484,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
|
|
||||||
glUniform1i(uniform_texture_diffuse, 0);
|
glUniform1i(uniform_texture_diffuse, 0);
|
||||||
|
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
int instanceId = transparentInstances[i].m_instanceId;
|
int instanceId = transparentInstances[i].m_instanceId;
|
||||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid*)((instanceId)*4 * sizeof(float) + m_data->m_maxShapeCapacityInBytes));
|
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid*)((instanceId)*4 * sizeof(float) + m_data->m_maxShapeCapacityInBytes));
|
||||||
@@ -2477,7 +2499,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
@@ -2495,7 +2517,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
|
|
||||||
case B3_USE_SHADOWMAP_RENDERMODE:
|
case B3_USE_SHADOWMAP_RENDERMODE:
|
||||||
{
|
{
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
@@ -2549,7 +2571,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
|
|
||||||
//gfxObj->m_instanceOffset
|
//gfxObj->m_instanceOffset
|
||||||
|
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
int instanceId = transparentInstances[i].m_instanceId;
|
int instanceId = transparentInstances[i].m_instanceId;
|
||||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid*)((instanceId)*4 * sizeof(float) + m_data->m_maxShapeCapacityInBytes));
|
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid*)((instanceId)*4 * sizeof(float) + m_data->m_maxShapeCapacityInBytes));
|
||||||
@@ -2563,7 +2585,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
@@ -2577,7 +2599,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
}
|
}
|
||||||
case B3_USE_PROJECTIVE_TEXTURE_RENDERMODE:
|
case B3_USE_PROJECTIVE_TEXTURE_RENDERMODE:
|
||||||
{
|
{
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
@@ -2617,7 +2639,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
glUniformMatrix4fv(projectiveTexture_TextureMVP, 1, false, &textureMVP[0]);
|
glUniformMatrix4fv(projectiveTexture_TextureMVP, 1, false, &textureMVP[0]);
|
||||||
|
|
||||||
//sort transparent objects
|
//sort transparent objects
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
int instanceId = transparentInstances[i].m_instanceId;
|
int instanceId = transparentInstances[i].m_instanceId;
|
||||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid*)((instanceId)*4 * sizeof(float) + m_data->m_maxShapeCapacityInBytes));
|
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid*)((instanceId)*4 * sizeof(float) + m_data->m_maxShapeCapacityInBytes));
|
||||||
@@ -2631,7 +2653,7 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indexOffset, gfxObj->m_numGraphicsInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gfxObj->m_flags & eGfxTransparency)
|
if (gfxObj->m_flags & B3_INSTANCE_TRANSPARANCY)
|
||||||
{
|
{
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
@@ -2646,6 +2668,10 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
|
|||||||
// b3Assert(0);
|
// b3Assert(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (gfxObj->m_flags & B3_INSTANCE_DOUBLE_SIDED)
|
||||||
|
{
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//glDrawElementsInstanced(GL_LINE_LOOP, indexCount, GL_UNSIGNED_INT, (void*)indexOffset, gfxObj->m_numGraphicsInstances);
|
//glDrawElementsInstanced(GL_LINE_LOOP, indexCount, GL_UNSIGNED_INT, (void*)indexOffset, gfxObj->m_numGraphicsInstances);
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ public:
|
|||||||
|
|
||||||
virtual void writeSingleInstanceColorToCPU(const float* color, int srcIndex);
|
virtual void writeSingleInstanceColorToCPU(const float* color, int srcIndex);
|
||||||
virtual void writeSingleInstanceColorToCPU(const double* color, int srcIndex);
|
virtual void writeSingleInstanceColorToCPU(const double* color, int srcIndex);
|
||||||
|
virtual void writeSingleInstanceFlagsToCPU(int flags, int srcIndex2);
|
||||||
|
|
||||||
virtual void writeSingleInstanceSpecularColorToCPU(const double* specular, int srcIndex2);
|
virtual void writeSingleInstanceSpecularColorToCPU(const double* specular, int srcIndex2);
|
||||||
virtual void writeSingleInstanceSpecularColorToCPU(const float* specular, int srcIndex2);
|
virtual void writeSingleInstanceSpecularColorToCPU(const float* specular, int srcIndex2);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
virtual void writeSingleInstanceScaleToCPU(const double* scale, int srcIndex);
|
virtual void writeSingleInstanceScaleToCPU(const double* scale, int srcIndex);
|
||||||
virtual void writeSingleInstanceSpecularColorToCPU(const double* specular, int srcIndex) {}
|
virtual void writeSingleInstanceSpecularColorToCPU(const double* specular, int srcIndex) {}
|
||||||
virtual void writeSingleInstanceSpecularColorToCPU(const float* specular, int srcIndex) {}
|
virtual void writeSingleInstanceSpecularColorToCPU(const float* specular, int srcIndex) {}
|
||||||
|
virtual void writeSingleInstanceFlagsToCPU(int flags, int srcIndex) {}
|
||||||
virtual void getCameraViewMatrix(float viewMat[16]) const;
|
virtual void getCameraViewMatrix(float viewMat[16]) const;
|
||||||
virtual void getCameraProjectionMatrix(float projMat[16]) const;
|
virtual void getCameraProjectionMatrix(float projMat[16]) const;
|
||||||
virtual void drawTexturedTriangleMesh(float worldPosition[3], float worldOrientation[4], const float* vertices, int numvertices, const unsigned int* indices, int numIndices, float color[4], int textureIndex = -1, int vertexLayout = 0)
|
virtual void drawTexturedTriangleMesh(float worldPosition[3], float worldOrientation[4], const float* vertices, int numvertices, const unsigned int* indices, int numIndices, float color[4], int textureIndex = -1, int vertexLayout = 0)
|
||||||
|
|||||||
@@ -378,6 +378,22 @@ void btDeformableMultiBodyDynamicsWorld::reinitialize(btScalar timeStep)
|
|||||||
btMultiBodyDynamicsWorld::getSolverInfo().m_timeStep = timeStep;
|
btMultiBodyDynamicsWorld::getSolverInfo().m_timeStep = timeStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void btDeformableMultiBodyDynamicsWorld::debugDrawWorld()
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int i = 0; i < getSoftBodyArray().size(); i++)
|
||||||
|
{
|
||||||
|
btSoftBody* psb = (btSoftBody*)getSoftBodyArray()[i];
|
||||||
|
{
|
||||||
|
btSoftBodyHelpers::DrawFrame(psb, getDebugDrawer());
|
||||||
|
btSoftBodyHelpers::Draw(psb, getDebugDrawer(), getDrawFlags());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
btMultiBodyDynamicsWorld::debugDrawWorld();
|
||||||
|
}
|
||||||
|
|
||||||
void btDeformableMultiBodyDynamicsWorld::applyRigidBodyGravity(btScalar timeStep)
|
void btDeformableMultiBodyDynamicsWorld::applyRigidBodyGravity(btScalar timeStep)
|
||||||
{
|
{
|
||||||
// Gravity is applied in stepSimulation and then cleared here and then applied here and then cleared here again
|
// Gravity is applied in stepSimulation and then cleared here and then applied here and then cleared here again
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ public:
|
|||||||
|
|
||||||
virtual int stepSimulation(btScalar timeStep, int maxSubSteps = 1, btScalar fixedTimeStep = btScalar(1.) / btScalar(60.));
|
virtual int stepSimulation(btScalar timeStep, int maxSubSteps = 1, btScalar fixedTimeStep = btScalar(1.) / btScalar(60.));
|
||||||
|
|
||||||
|
virtual void debugDrawWorld();
|
||||||
|
|
||||||
void setSolverCallback(btSolverCallback cb)
|
void setSolverCallback(btSolverCallback cb)
|
||||||
{
|
{
|
||||||
m_solverCallback = cb;
|
m_solverCallback = cb;
|
||||||
@@ -178,6 +180,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_lineSearch = lineSearch;
|
m_lineSearch = lineSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //BT_DEFORMABLE_MULTIBODY_DYNAMICS_WORLD_H
|
#endif //BT_DEFORMABLE_MULTIBODY_DYNAMICS_WORLD_H
|
||||||
|
|||||||
Reference in New Issue
Block a user