Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.64 KB | None | 0 0
  1. template<typename IndexType>
  2.     void addIndexDataImpl(IndexType* iPos, const IndexType* iEnd,
  3.                                                     VertexLookupList& lookup,
  4.                                                     unsigned short submeshID)
  5.     {
  6.  
  7.         // Loop through all triangles and connect them to the vertices.
  8.         for (; iPos < iEnd; iPos += 3) {
  9.             // It should never reallocate or every pointer will be invalid.
  10.             OgreAssert(mTriangleList.capacity() > mTriangleList.size(), "");
  11.             mTriangleList.push_back(PMTriangle());
  12.             PMTriangle* tri = &mTriangleList.back();
  13.             tri->isRemoved = false;
  14.             tri->submeshID = submeshID;
  15.             for (int i = 0; i < 3; i++) {
  16.                 // Invalid index: Index is bigger then vertex buffer size.
  17.                 OgreAssert(iPos[i] < lookup.size(), "");
  18.                 tri->vertexID[i] = iPos[i];
  19.                 tri->vertex[i] = lookup[iPos[i]];
  20.             }
  21.             if (tri->isMalformed()) {
  22. #if OGRE_DEBUG_MODE
  23.                 stringstream str;
  24.                 str << "In " << mMeshName << " malformed triangle found with ID: " << getTriangleID(tri) << ". " <<
  25.                 std::endl;
  26.                 printTriangle(tri, str);
  27.                 str << "It will be excluded from LOD level calculations.";
  28.                 LogManager::getSingleton().stream() << str.str();
  29. #endif
  30.                 tri->isRemoved = true;
  31.                 mIndexBufferInfoList[tri->submeshID].indexCount -= 3;
  32.                 continue;
  33.             }
  34.             tri->computeNormal();
  35.             addTriangleToEdges(tri);
  36.         }
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement