Optimize draw3DBox generic case
This commit is contained in:
parent
80a289986c
commit
9bf90368b8
@ -619,20 +619,17 @@ void CNullDriver::draw3DBox(const core::aabbox3d<f32> &box, SColor color)
|
|||||||
core::vector3df edges[8];
|
core::vector3df edges[8];
|
||||||
box.getEdges(edges);
|
box.getEdges(edges);
|
||||||
|
|
||||||
// TODO: optimize into one big drawIndexPrimitive call.
|
video::S3DVertex v[8];
|
||||||
|
for (u32 i = 0; i < 8; i++) {
|
||||||
|
v[i].Pos = edges[i];
|
||||||
|
v[i].Color = color;
|
||||||
|
}
|
||||||
|
|
||||||
draw3DLine(edges[5], edges[1], color);
|
const static u16 box_indices[24] = {
|
||||||
draw3DLine(edges[1], edges[3], color);
|
5, 1, 1, 3, 3, 7, 7, 5, 0, 2, 2, 6, 6, 4, 4, 0, 1, 0, 3, 2, 7, 6, 5, 4
|
||||||
draw3DLine(edges[3], edges[7], color);
|
};
|
||||||
draw3DLine(edges[7], edges[5], color);
|
|
||||||
draw3DLine(edges[0], edges[2], color);
|
drawVertexPrimitiveList(v, 8, box_indices, 12, EVT_STANDARD, scene::EPT_LINES);
|
||||||
draw3DLine(edges[2], edges[6], color);
|
|
||||||
draw3DLine(edges[6], edges[4], color);
|
|
||||||
draw3DLine(edges[4], edges[0], color);
|
|
||||||
draw3DLine(edges[1], edges[0], color);
|
|
||||||
draw3DLine(edges[3], edges[2], color);
|
|
||||||
draw3DLine(edges[7], edges[6], color);
|
|
||||||
draw3DLine(edges[5], edges[4], color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! draws an 2d image
|
//! draws an 2d image
|
||||||
|
@ -2462,66 +2462,6 @@ void COpenGLDriver::setFog(SColor c, E_FOG_TYPE fogType, f32 start,
|
|||||||
glFogfv(GL_FOG_COLOR, data);
|
glFogfv(GL_FOG_COLOR, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Draws a 3d box.
|
|
||||||
void COpenGLDriver::draw3DBox(const core::aabbox3d<f32> &box, SColor color)
|
|
||||||
{
|
|
||||||
core::vector3df edges[8];
|
|
||||||
box.getEdges(edges);
|
|
||||||
|
|
||||||
setRenderStates3DMode();
|
|
||||||
|
|
||||||
video::S3DVertex v[24];
|
|
||||||
|
|
||||||
for (u32 i = 0; i < 24; i++)
|
|
||||||
v[i].Color = color;
|
|
||||||
|
|
||||||
v[0].Pos = edges[5];
|
|
||||||
v[1].Pos = edges[1];
|
|
||||||
v[2].Pos = edges[1];
|
|
||||||
v[3].Pos = edges[3];
|
|
||||||
v[4].Pos = edges[3];
|
|
||||||
v[5].Pos = edges[7];
|
|
||||||
v[6].Pos = edges[7];
|
|
||||||
v[7].Pos = edges[5];
|
|
||||||
v[8].Pos = edges[0];
|
|
||||||
v[9].Pos = edges[2];
|
|
||||||
v[10].Pos = edges[2];
|
|
||||||
v[11].Pos = edges[6];
|
|
||||||
v[12].Pos = edges[6];
|
|
||||||
v[13].Pos = edges[4];
|
|
||||||
v[14].Pos = edges[4];
|
|
||||||
v[15].Pos = edges[0];
|
|
||||||
v[16].Pos = edges[1];
|
|
||||||
v[17].Pos = edges[0];
|
|
||||||
v[18].Pos = edges[3];
|
|
||||||
v[19].Pos = edges[2];
|
|
||||||
v[20].Pos = edges[7];
|
|
||||||
v[21].Pos = edges[6];
|
|
||||||
v[22].Pos = edges[5];
|
|
||||||
v[23].Pos = edges[4];
|
|
||||||
|
|
||||||
if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra])
|
|
||||||
getColorBuffer(v, 24, EVT_STANDARD);
|
|
||||||
|
|
||||||
CacheHandler->setClientState(true, false, true, false);
|
|
||||||
|
|
||||||
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(v))[0].Pos);
|
|
||||||
|
|
||||||
#ifdef GL_BGRA
|
|
||||||
const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4;
|
|
||||||
#else
|
|
||||||
const GLint colorSize = 4;
|
|
||||||
#endif
|
|
||||||
if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
|
|
||||||
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(v))[0].Color);
|
|
||||||
else {
|
|
||||||
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0);
|
|
||||||
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
glDrawArrays(GL_LINES, 0, 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Draws a 3d line.
|
//! Draws a 3d line.
|
||||||
void COpenGLDriver::draw3DLine(const core::vector3df &start,
|
void COpenGLDriver::draw3DLine(const core::vector3df &start,
|
||||||
const core::vector3df &end, SColor color)
|
const core::vector3df &end, SColor color)
|
||||||
|
@ -170,9 +170,6 @@ public:
|
|||||||
const core::position2d<s32> &end,
|
const core::position2d<s32> &end,
|
||||||
SColor color = SColor(255, 255, 255, 255)) override;
|
SColor color = SColor(255, 255, 255, 255)) override;
|
||||||
|
|
||||||
//! Draws a 3d box
|
|
||||||
void draw3DBox(const core::aabbox3d<f32> &box, SColor color = SColor(255, 255, 255, 255)) override;
|
|
||||||
|
|
||||||
//! Draws a 3d line.
|
//! Draws a 3d line.
|
||||||
virtual void draw3DLine(const core::vector3df &start,
|
virtual void draw3DLine(const core::vector3df &start,
|
||||||
const core::vector3df &end,
|
const core::vector3df &end,
|
||||||
|
Loading…
Reference in New Issue
Block a user