| 4679 | //---------------------------------------------------------------------------- |
| 4680 | |
| 4681 | bool Player::step(Point3F *pos,F32 *maxStep,F32 time) |
| 4682 | { |
| 4683 | const Point3F& scale = getScale(); |
| 4684 | Box3F box; |
| 4685 | VectorF offset = mVelocity * time; |
| 4686 | box.minExtents = mObjBox.minExtents + offset + *pos; |
| 4687 | box.maxExtents = mObjBox.maxExtents + offset + *pos; |
| 4688 | box.maxExtents.z += mDataBlock->maxStepHeight * scale.z + sMinFaceDistance; |
| 4689 | |
| 4690 | SphereF sphere; |
| 4691 | sphere.center = (box.minExtents + box.maxExtents) * 0.5f; |
| 4692 | VectorF bv = box.maxExtents - sphere.center; |
| 4693 | sphere.radius = bv.len(); |
| 4694 | |
| 4695 | ClippedPolyList polyList; |
| 4696 | polyList.mPlaneList.clear(); |
| 4697 | polyList.mNormal.set(0.0f, 0.0f, 0.0f); |
| 4698 | polyList.mPlaneList.setSize(6); |
| 4699 | polyList.mPlaneList[0].set(box.minExtents,VectorF(-1.0f, 0.0f, 0.0f)); |
| 4700 | polyList.mPlaneList[1].set(box.maxExtents,VectorF(0.0f, 1.0f, 0.0f)); |
| 4701 | polyList.mPlaneList[2].set(box.maxExtents,VectorF(1.0f, 0.0f, 0.0f)); |
| 4702 | polyList.mPlaneList[3].set(box.minExtents,VectorF(0.0f, -1.0f, 0.0f)); |
| 4703 | polyList.mPlaneList[4].set(box.minExtents,VectorF(0.0f, 0.0f, -1.0f)); |
| 4704 | polyList.mPlaneList[5].set(box.maxExtents,VectorF(0.0f, 0.0f, 1.0f)); |
| 4705 | |
| 4706 | CollisionWorkingList& rList = mConvex.getWorkingList(); |
| 4707 | CollisionWorkingList* pList = rList.wLink.mNext; |
| 4708 | while (pList != &rList) { |
| 4709 | Convex* pConvex = pList->mConvex; |
| 4710 | |
| 4711 | // Alright, here's the deal... a polysoup mesh really needs to be |
| 4712 | // designed with stepping in mind. If there are too many smallish polygons |
| 4713 | // the stepping system here gets confused and allows you to run up walls |
| 4714 | // or on the edges/seams of meshes. |
| 4715 | |
| 4716 | TSStatic *st = dynamic_cast<TSStatic *> (pConvex->getObject()); |
| 4717 | bool skip = false; |
| 4718 | if (st && !st->allowPlayerStep()) |
| 4719 | skip = true; |
| 4720 | |
| 4721 | if ((pConvex->getObject()->getTypeMask() & StaticObjectType) != 0 && !skip) |
| 4722 | { |
| 4723 | Box3F convexBox = pConvex->getBoundingBox(); |
| 4724 | if (box.isOverlapped(convexBox)) |
| 4725 | pConvex->getPolyList(&polyList); |
| 4726 | } |
| 4727 | pList = pList->wLink.mNext; |
| 4728 | } |
| 4729 | |
| 4730 | // Find max step height |
| 4731 | F32 stepHeight = pos->z - sMinFaceDistance; |
| 4732 | U32* vp = polyList.mIndexList.begin(); |
| 4733 | U32* ep = polyList.mIndexList.end(); |
| 4734 | for (; vp != ep; vp++) { |
| 4735 | F32 h = polyList.mVertexList[*vp].point.z + sMinFaceDistance; |
| 4736 | if (h > stepHeight) |
| 4737 | stepHeight = h; |
| 4738 | } |
nothing calls this directly
no test coverage detected