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++)
|
for (int i = 0; i < sizeof(m_vertices)/sizeof(m_vertices[0]); i++)
|
||||||
m_vertices[i].clear();
|
m_vertices[i].clear();
|
||||||
m_faces.clear();
|
m_faces.clear();
|
||||||
|
m_face_indices.clear();
|
||||||
m_materials.clear();
|
m_materials.clear();
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
m_path = "";
|
m_path = "";
|
||||||
@ -451,6 +452,8 @@ bool WFObj::buildVBO()
|
|||||||
it != m_faces.end();
|
it != m_faces.end();
|
||||||
it++)
|
it++)
|
||||||
{
|
{
|
||||||
|
int first = vid;
|
||||||
|
int num = 0;
|
||||||
for (vector<Face>::iterator fit = it->second.begin();
|
for (vector<Face>::iterator fit = it->second.begin();
|
||||||
fit != it->second.end();
|
fit != it->second.end();
|
||||||
fit++)
|
fit++)
|
||||||
@ -473,10 +476,14 @@ bool WFObj::buildVBO()
|
|||||||
if (vf.texture != 0)
|
if (vf.texture != 0)
|
||||||
texture_ref_count++;
|
texture_ref_count++;
|
||||||
if (flat_vertices.find(vf) == flat_vertices.end())
|
if (flat_vertices.find(vf) == flat_vertices.end())
|
||||||
|
{
|
||||||
flat_vertices[vf] = vid++;
|
flat_vertices[vf] = vid++;
|
||||||
|
num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_face_indices[it->first] = make_pair(first, num);
|
||||||
|
}
|
||||||
if (texture_ref_count == 0)
|
if (texture_ref_count == 0)
|
||||||
do_textures = false;
|
do_textures = false;
|
||||||
size_t n_floats_per_vref =
|
size_t n_floats_per_vref =
|
||||||
|
1
WFObj.h
1
WFObj.h
@ -104,6 +104,7 @@ protected:
|
|||||||
/* variables */
|
/* variables */
|
||||||
std::vector<Vertex> m_vertices[VERTEX_TYPES];
|
std::vector<Vertex> m_vertices[VERTEX_TYPES];
|
||||||
std::map< std::string, std::vector< Face > > m_faces;
|
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;
|
std::map< std::string, Material > m_materials;
|
||||||
float m_aabb[6];
|
float m_aabb[6];
|
||||||
std::string m_path;
|
std::string m_path;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user