| 399 | } |
| 400 | |
| 401 | void TSShapeInstance::computeBounds(S32 dl, Box3F & bounds) |
| 402 | { |
| 403 | // if dl==-1, nothing to do |
| 404 | if (dl==-1) |
| 405 | return; |
| 406 | |
| 407 | AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::computeBounds"); |
| 408 | |
| 409 | // get subshape and object detail |
| 410 | const TSDetail * detail = &mShape->details[dl]; |
| 411 | S32 ss = detail->subShapeNum; |
| 412 | S32 od = detail->objectDetailNum; |
| 413 | |
| 414 | // use shape bounds for imposter details |
| 415 | if (ss < 0) |
| 416 | { |
| 417 | bounds = mShape->mBounds; |
| 418 | return; |
| 419 | } |
| 420 | |
| 421 | S32 start = mShape->subShapeFirstObject[ss]; |
| 422 | S32 end = mShape->subShapeNumObjects[ss] + start; |
| 423 | |
| 424 | // run through objects and updating bounds as we go |
| 425 | bounds.minExtents.set( 10E30f, 10E30f, 10E30f); |
| 426 | bounds.maxExtents.set(-10E30f,-10E30f,-10E30f); |
| 427 | Box3F box; |
| 428 | for (S32 i=start; i<end; i++) |
| 429 | { |
| 430 | MeshObjectInstance * mesh = &mMeshObjects[i]; |
| 431 | |
| 432 | if (od >= mesh->object->numMeshes) |
| 433 | continue; |
| 434 | |
| 435 | if (mesh->getMesh(od)) |
| 436 | { |
| 437 | mesh->getMesh(od)->computeBounds(mesh->getTransform(),box, 0); // use frame 0 so TSSkinMesh uses skinned verts to compute bounds |
| 438 | bounds.minExtents.setMin(box.minExtents); |
| 439 | bounds.maxExtents.setMax(box.maxExtents); |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | //------------------------------------------------------------------------------------- |
| 445 | // Object (MeshObjectInstance & PluginObjectInstance) collision methods |