store face indices per material for drawing
This commit is contained in:
parent
d13e3a60b2
commit
0bdfff50e7
7
WFObj.cc
7
WFObj.cc
@ -123,6 +123,7 @@ void WFObj::clear()
|
||||
for (int i = 0; i < sizeof(m_vertices)/sizeof(m_vertices[0]); i++)
|
||||
m_vertices[i].clear();
|
||||
m_faces.clear();
|
||||
m_face_indices.clear();
|
||||
m_materials.clear();
|
||||
m_valid = false;
|
||||
m_path = "";
|
||||
@ -451,6 +452,8 @@ bool WFObj::buildVBO()
|
||||
it != m_faces.end();
|
||||
it++)
|
||||
{
|
||||
int first = vid;
|
||||
int num = 0;
|
||||
for (vector<Face>::iterator fit = it->second.begin();
|
||||
fit != it->second.end();
|
||||
fit++)
|
||||
@ -473,9 +476,13 @@ bool WFObj::buildVBO()
|
||||
if (vf.texture != 0)
|
||||
texture_ref_count++;
|
||||
if (flat_vertices.find(vf) == flat_vertices.end())
|
||||
{
|
||||
flat_vertices[vf] = vid++;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_face_indices[it->first] = make_pair(first, num);
|
||||
}
|
||||
if (texture_ref_count == 0)
|
||||
do_textures = false;
|
||||
|
1
WFObj.h
1
WFObj.h
@ -104,6 +104,7 @@ protected:
|
||||
/* variables */
|
||||
std::vector<Vertex> m_vertices[VERTEX_TYPES];
|
||||
std::map< std::string, std::vector< Face > > m_faces;
|
||||
std::map< std::string, std::pair<int, int> > m_face_indices;
|
||||
std::map< std::string, Material > m_materials;
|
||||
float m_aabb[6];
|
||||
std::string m_path;
|
||||
|
Loading…
x
Reference in New Issue
Block a user