| 47 | //------------------------------------------------------------------------------------- |
| 48 | |
| 49 | bool TSShapeInstance::buildPolyList(AbstractPolyList * polyList, S32 dl) |
| 50 | { |
| 51 | // if dl==-1, nothing to do |
| 52 | if (dl==-1) |
| 53 | return false; |
| 54 | |
| 55 | AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildPolyList"); |
| 56 | |
| 57 | // get subshape and object detail |
| 58 | const TSDetail * detail = &mShape->details[dl]; |
| 59 | S32 ss = detail->subShapeNum; |
| 60 | S32 od = detail->objectDetailNum; |
| 61 | |
| 62 | // This detail does not have any geometry. |
| 63 | if ( ss < 0 ) |
| 64 | return false; |
| 65 | |
| 66 | // nothing emitted yet... |
| 67 | bool emitted = false; |
| 68 | U32 surfaceKey = 0; |
| 69 | |
| 70 | S32 start = mShape->subShapeFirstObject[ss]; |
| 71 | S32 end = mShape->subShapeNumObjects[ss] + start; |
| 72 | if (start<end) |
| 73 | { |
| 74 | MatrixF initialMat; |
| 75 | Point3F initialScale; |
| 76 | polyList->getTransform(&initialMat,&initialScale); |
| 77 | |
| 78 | // set up for first object's node |
| 79 | MatrixF mat; |
| 80 | MatrixF scaleMat(true); |
| 81 | F32* p = scaleMat; |
| 82 | p[0] = initialScale.x; |
| 83 | p[5] = initialScale.y; |
| 84 | p[10] = initialScale.z; |
| 85 | const MatrixF *previousMat = &mMeshObjects[start].getTransform(); |
| 86 | mat.mul(initialMat,scaleMat); |
| 87 | mat.mul(*previousMat); |
| 88 | polyList->setTransform(&mat,Point3F(1, 1, 1)); |
| 89 | |
| 90 | // run through objects and collide |
| 91 | for (S32 i=start; i<end; i++) |
| 92 | { |
| 93 | MeshObjectInstance * mesh = &mMeshObjects[i]; |
| 94 | |
| 95 | if (od >= mesh->object->numMeshes) |
| 96 | continue; |
| 97 | |
| 98 | if (&mesh->getTransform() != previousMat) |
| 99 | { |
| 100 | // different node from before, set up for this node |
| 101 | previousMat = &mesh->getTransform(); |
| 102 | |
| 103 | if (previousMat != NULL) |
| 104 | { |
| 105 | mat.mul(initialMat,scaleMat); |
| 106 | mat.mul(*previousMat); |
no test coverage detected