--------------------------- Best-fit oriented bounding box
| 399 | //--------------------------- |
| 400 | // Best-fit oriented bounding box |
| 401 | void MeshFit::addBox( const Point3F& sides, const MatrixF& mat ) |
| 402 | { |
| 403 | TSMesh* mesh = initMeshFromFile( TSShapeConstructor::getCubeShapePath() ); |
| 404 | if ( !mesh ) |
| 405 | return; |
| 406 | |
| 407 | if (mesh->mVerts.size() > 0) |
| 408 | { |
| 409 | for (S32 i = 0; i < mesh->mVerts.size(); i++) |
| 410 | { |
| 411 | Point3F v = mesh->mVerts[i]; |
| 412 | v.convolve(sides); |
| 413 | mesh->mVerts[i] = v; |
| 414 | } |
| 415 | |
| 416 | mesh->mVertexData.setReady(false); |
| 417 | } |
| 418 | else |
| 419 | { |
| 420 | for (S32 i = 0; i < mesh->mVertexData.size(); i++) |
| 421 | { |
| 422 | TSMesh::__TSMeshVertexBase &vdata = mesh->mVertexData.getBase(i); |
| 423 | Point3F v = vdata.vert(); |
| 424 | v.convolve(sides); |
| 425 | vdata.vert(v); |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | mesh->computeBounds(); |
| 430 | |
| 431 | mMeshes.increment(); |
| 432 | mMeshes.last().type = MeshFit::Box; |
| 433 | mMeshes.last().transform = mat; |
| 434 | mMeshes.last().tsmesh = mesh; |
| 435 | } |
| 436 | |
| 437 | void MeshFit::fitOBB() |
| 438 | { |
no test coverage detected