MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / step

Method step

Engine/source/T3D/player.cpp:4601–4669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4599//----------------------------------------------------------------------------
4600
4601bool Player::step(Point3F *pos,F32 *maxStep,F32 time)
4602{
4603 const Point3F& scale = getScale();
4604 Box3F box;
4605 VectorF offset = mVelocity * time;
4606 box.minExtents = mObjBox.minExtents + offset + *pos;
4607 box.maxExtents = mObjBox.maxExtents + offset + *pos;
4608 box.maxExtents.z += mDataBlock->maxStepHeight * scale.z + sMinFaceDistance;
4609
4610 SphereF sphere;
4611 sphere.center = (box.minExtents + box.maxExtents) * 0.5f;
4612 VectorF bv = box.maxExtents - sphere.center;
4613 sphere.radius = bv.len();
4614
4615 ClippedPolyList polyList;
4616 polyList.mPlaneList.clear();
4617 polyList.mNormal.set(0.0f, 0.0f, 0.0f);
4618 polyList.mPlaneList.setSize(6);
4619 polyList.mPlaneList[0].set(box.minExtents,VectorF(-1.0f, 0.0f, 0.0f));
4620 polyList.mPlaneList[1].set(box.maxExtents,VectorF(0.0f, 1.0f, 0.0f));
4621 polyList.mPlaneList[2].set(box.maxExtents,VectorF(1.0f, 0.0f, 0.0f));
4622 polyList.mPlaneList[3].set(box.minExtents,VectorF(0.0f, -1.0f, 0.0f));
4623 polyList.mPlaneList[4].set(box.minExtents,VectorF(0.0f, 0.0f, -1.0f));
4624 polyList.mPlaneList[5].set(box.maxExtents,VectorF(0.0f, 0.0f, 1.0f));
4625
4626 CollisionWorkingList& rList = mConvex.getWorkingList();
4627 CollisionWorkingList* pList = rList.wLink.mNext;
4628 while (pList != &rList) {
4629 Convex* pConvex = pList->mConvex;
4630
4631 // Alright, here's the deal... a polysoup mesh really needs to be
4632 // designed with stepping in mind. If there are too many smallish polygons
4633 // the stepping system here gets confused and allows you to run up walls
4634 // or on the edges/seams of meshes.
4635
4636 TSStatic *st = dynamic_cast<TSStatic *> (pConvex->getObject());
4637 bool skip = false;
4638 if (st && !st->allowPlayerStep())
4639 skip = true;
4640
4641 if ((pConvex->getObject()->getTypeMask() & StaticObjectType) != 0 && !skip)
4642 {
4643 Box3F convexBox = pConvex->getBoundingBox();
4644 if (box.isOverlapped(convexBox))
4645 pConvex->getPolyList(&polyList);
4646 }
4647 pList = pList->wLink.mNext;
4648 }
4649
4650 // Find max step height
4651 F32 stepHeight = pos->z - sMinFaceDistance;
4652 U32* vp = polyList.mIndexList.begin();
4653 U32* ep = polyList.mIndexList.end();
4654 for (; vp != ep; vp++) {
4655 F32 h = polyList.mVertexList[*vp].point.z + sMinFaceDistance;
4656 if (h > stepHeight)
4657 stepHeight = h;
4658 }

Callers 2

FFunction · 0.45
FFunction · 0.45

Calls 12

allowPlayerStepMethod · 0.80
getTypeMaskMethod · 0.80
isOverlappedMethod · 0.60
lenMethod · 0.45
clearMethod · 0.45
setMethod · 0.45
setSizeMethod · 0.45
getObjectMethod · 0.45
getBoundingBoxMethod · 0.45
getPolyListMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected