| 243 | } |
| 244 | |
| 245 | void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh ) |
| 246 | { |
| 247 | // Add indices |
| 248 | S32 indicesBase = mIndices.size(); |
| 249 | for ( S32 i = 0; i < mesh->mPrimitives.size(); i++ ) |
| 250 | { |
| 251 | const TSDrawPrimitive& draw = mesh->mPrimitives[i]; |
| 252 | if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles ) |
| 253 | { |
| 254 | mIndices.merge( &mesh->mIndices[draw.start], draw.numElements ); |
| 255 | } |
| 256 | else |
| 257 | { |
| 258 | U32 idx0 = mesh->mIndices[draw.start + 0]; |
| 259 | U32 idx1; |
| 260 | U32 idx2 = mesh->mIndices[draw.start + 1]; |
| 261 | U32 *nextIdx = &idx1; |
| 262 | for ( S32 j = 2; j < draw.numElements; j++ ) |
| 263 | { |
| 264 | *nextIdx = idx2; |
| 265 | nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1); |
| 266 | idx2 = mesh->mIndices[draw.start + j]; |
| 267 | if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 ) |
| 268 | continue; |
| 269 | |
| 270 | mIndices.push_back( idx0 ); |
| 271 | mIndices.push_back( idx1 ); |
| 272 | mIndices.push_back( idx2 ); |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | // Offset indices for already added verts |
| 278 | for ( S32 j = indicesBase; j < mIndices.size(); j++ ) |
| 279 | mIndices[j] += mVerts.size(); |
| 280 | |
| 281 | // Add verts |
| 282 | S32 count, stride; |
| 283 | U8* pVert; |
| 284 | |
| 285 | if ( mesh->mVertexData.isReady() && mesh->mVerts.size() == 0 ) |
| 286 | { |
| 287 | count = mesh->mVertexData.size(); |
| 288 | stride = mesh->mVertexData.vertSize(); |
| 289 | pVert = (U8*)mesh->mVertexData.address(); |
| 290 | } |
| 291 | else |
| 292 | { |
| 293 | count = mesh->mVerts.size(); |
| 294 | stride = sizeof(Point3F); |
| 295 | pVert = (U8*)mesh->mVerts.address(); |
| 296 | } |
| 297 | |
| 298 | MatrixF objMat; |
| 299 | mShape->getNodeWorldTransform( obj.nodeIndex, &objMat ); |
| 300 | |
| 301 | mVerts.reserve( mVerts.size() + count ); |
| 302 | for ( S32 j = 0; j < count; j++, pVert += stride ) |
nothing calls this directly
no test coverage detected