| 3548 | |
| 3549 | |
| 3550 | void ShapeBaseConvex::getFeatures(const MatrixF& mat, const VectorF& n, ConvexFeature* cf) |
| 3551 | { |
| 3552 | cf->material = 0; |
| 3553 | cf->mObject = mObject; |
| 3554 | |
| 3555 | TSShape::ConvexHullAccelerator* pAccel = |
| 3556 | pShapeBase->mShapeInstance->getShape()->getAccelerator(pShapeBase->mDataBlock->collisionDetails[hullId]); |
| 3557 | AssertFatal(pAccel != NULL, "Error, no accel!"); |
| 3558 | |
| 3559 | F32 currMaxDP = mDot(pAccel->vertexList[0], n); |
| 3560 | U32 index = 0; |
| 3561 | U32 i; |
| 3562 | for (i = 1; i < pAccel->numVerts; i++) { |
| 3563 | F32 dp = mDot(pAccel->vertexList[i], n); |
| 3564 | if (dp > currMaxDP) { |
| 3565 | currMaxDP = dp; |
| 3566 | index = i; |
| 3567 | } |
| 3568 | } |
| 3569 | |
| 3570 | const U8* emitString = pAccel->emitStrings[index]; |
| 3571 | U32 currPos = 0; |
| 3572 | U32 numVerts = emitString[currPos++]; |
| 3573 | for (i = 0; i < numVerts; i++) { |
| 3574 | cf->mVertexList.increment(); |
| 3575 | U32 vListIDx = emitString[currPos++]; |
| 3576 | mat.mulP(pAccel->vertexList[vListIDx], &cf->mVertexList.last()); |
| 3577 | } |
| 3578 | |
| 3579 | U32 numEdges = emitString[currPos++]; |
| 3580 | for (i = 0; i < numEdges; i++) { |
| 3581 | U32 ev0 = emitString[currPos++]; |
| 3582 | U32 ev1 = emitString[currPos++]; |
| 3583 | cf->mEdgeList.increment(); |
| 3584 | cf->mEdgeList.last().vertex[0] = ev0; |
| 3585 | cf->mEdgeList.last().vertex[1] = ev1; |
| 3586 | } |
| 3587 | |
| 3588 | U32 numFaces = emitString[currPos++]; |
| 3589 | for (i = 0; i < numFaces; i++) { |
| 3590 | cf->mFaceList.increment(); |
| 3591 | U32 plane = emitString[currPos++]; |
| 3592 | mat.mulV(pAccel->normalList[plane], &cf->mFaceList.last().normal); |
| 3593 | for (U32 j = 0; j < 3; j++) |
| 3594 | cf->mFaceList.last().vertex[j] = emitString[currPos++]; |
| 3595 | } |
| 3596 | } |
| 3597 | |
| 3598 | |
| 3599 | void ShapeBaseConvex::getPolyList(AbstractPolyList* list) |