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

Method step

Engine/source/T3D/player.cpp:4681–4749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4679//----------------------------------------------------------------------------
4680
4681bool 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 }

Callers

nothing calls this directly

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