From 648c21947c6c115209e5529de6e747e474fd64e2 Mon Sep 17 00:00:00 2001 From: Kester Maddock Date: Tue, 4 May 2004 13:17:46 +0000 Subject: Use a better compare function for RAS_IPolygonMaterial Fix sharing verticies - must test pos, normal, uv & colour before sharing (not just index) --- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'source/gameengine/Rasterizer/RAS_MeshObject.cpp') diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 4f5833df50b..7ff43b53a65 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -132,14 +132,14 @@ RAS_Polygon* RAS_MeshObject::GetPolygon(int num) -set::iterator RAS_MeshObject::GetFirstMaterial() +RAS_MaterialBucket::Set::iterator RAS_MeshObject::GetFirstMaterial() { return m_materials.begin(); } -set::iterator RAS_MeshObject::GetLastMaterial() +RAS_MaterialBucket::Set::iterator RAS_MeshObject::GetLastMaterial() { return m_materials.end(); } @@ -260,36 +260,33 @@ int RAS_MeshObject::FindOrAddVertex(int vtxarray, KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray]; - + RAS_TexVert newvert(xyz,uv,rgbacolor,newnormal, 0); #define KX_FIND_SHARED_VERTICES #ifdef KX_FIND_SHARED_VERTICES - std::vector::iterator it = m_xyz_index_to_vertex_index_mapping[orgindex].begin(); - int index=-1; - while (index < 0 && !(it == m_xyz_index_to_vertex_index_mapping[orgindex].end())) + for (std::vector::iterator it = m_xyz_index_to_vertex_index_mapping[orgindex].begin(); + it != m_xyz_index_to_vertex_index_mapping[orgindex].end(); + it++) { if ((*it).m_arrayindex1 == ao->m_index1 && - ((*it).m_array == vtxarray) && - (*(RAS_IPolyMaterial*) (*it).m_matid) == *mat + (*it).m_array == vtxarray && + *(*it).m_matid == *mat && + (*ao->m_VertexArrayCache1[vtxarray])[(*it).m_index].closeTo(&newvert) ) { return (*it).m_index; } - it++; } - - if (index >= 0) - return index; #endif // KX_FIND_SHARED_VERTICES // no vertex found, add one - ao->m_VertexArrayCache1[vtxarray]->push_back(RAS_TexVert (xyz,uv,rgbacolor,newnormal, 0)); + ao->m_VertexArrayCache1[vtxarray]->push_back(newvert); // printf("(%f,%f,%f) ",xyz[0],xyz[1],xyz[2]); RAS_MatArrayIndex idx; idx.m_arrayindex1 = ao->m_index1; idx.m_array = vtxarray; idx.m_index = numverts; - idx.m_matid = (int) mat; + idx.m_matid = mat; m_xyz_index_to_vertex_index_mapping[orgindex].push_back(idx); return numverts; -- cgit v1.2.3