Merge remote-tracking branch 'upstream/master'

This commit is contained in:
yunfeibai
2018-02-15 14:31:34 -08:00
parent cf4a0a3503
commit 36dcabbaf5
50 changed files with 332 additions and 138 deletions

View File

@@ -1992,15 +1992,15 @@ void GLInstancingRenderer::drawLine(const float from[4], const float to[4], cons
B3_ATTRIBUTE_ALIGNED16(struct) SortableTransparentInstance
{
b3Scalar m_projection;
int m_shapeIndex;
int m_instanceId;
};
B3_ATTRIBUTE_ALIGNED16(struct) TransparentDistanceSortPredicate
{
inline bool operator() (const SortableTransparentInstance& a, const SortableTransparentInstance& b) const
inline bool operator() (const SortableTransparentInstance& a, const SortableTransparentInstance& b) const
{
return (a.m_projection > b.m_projection);
@@ -2218,7 +2218,6 @@ b3Assert(glGetError() ==GL_NO_ERROR);
}
b3AlignedObjectArray<SortableTransparentInstance> transparentInstances;
{
int curOffset = 0;
//GLuint lastBindTexture = 0;
@@ -2229,7 +2228,8 @@ b3Assert(glGetError() ==GL_NO_ERROR);
m_data->m_activeCamera->getCameraForwardVector(fwd);
b3Vector3 camForwardVec;
camForwardVec.setValue(fwd[0],fwd[1],fwd[2]);
for (int obj=0;obj<m_graphicsInstances.size();obj++)
{
b3GraphicsInstance* gfxObj = m_graphicsInstances[obj];
@@ -2245,8 +2245,8 @@ b3Assert(glGetError() ==GL_NO_ERROR);
inst.m_instanceId = curOffset;
b3Vector3 centerPosition;
centerPosition.setValue(m_data->m_instance_positions_ptr[inst.m_instanceId*4+0],
m_data->m_instance_positions_ptr[inst.m_instanceId*4+1],
m_data->m_instance_positions_ptr[inst.m_instanceId*4+2]);
m_data->m_instance_positions_ptr[inst.m_instanceId*4+1],
m_data->m_instance_positions_ptr[inst.m_instanceId*4+2]);
centerPosition *= -1;//reverse sort opaque instances
inst.m_projection = centerPosition.dot(camForwardVec);
transparentInstances.push_back(inst);
@@ -2256,10 +2256,10 @@ b3Assert(glGetError() ==GL_NO_ERROR);
{
inst.m_instanceId = curOffset+i;
b3Vector3 centerPosition;
centerPosition.setValue(m_data->m_instance_positions_ptr[inst.m_instanceId*4+0],
m_data->m_instance_positions_ptr[inst.m_instanceId*4+1],
m_data->m_instance_positions_ptr[inst.m_instanceId*4+2]);
m_data->m_instance_positions_ptr[inst.m_instanceId*4+1],
m_data->m_instance_positions_ptr[inst.m_instanceId*4+2]);
inst.m_projection = centerPosition.dot(camForwardVec);
transparentInstances.push_back(inst);
}
@@ -2270,6 +2270,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
TransparentDistanceSortPredicate sorter;
transparentInstances.quickSort(sorter);
}