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

Method updatePos

Engine/source/T3D/item.cpp:731–1023  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729
730
731void Item::updatePos(const U32 /*mask*/, const F32 dt)
732{
733 // Try and move
734 Point3F pos;
735 mObjToWorld.getColumn(3,&pos);
736 delta.posVec = pos;
737
738 bool contact = false;
739 bool nonStatic = false;
740 bool stickyNotify = false;
741 CollisionList collisionList;
742 F32 time = dt;
743
744 static Polyhedron sBoxPolyhedron;
745 static ExtrudedPolyList sExtrudedPolyList;
746 static EarlyOutPolyList sEarlyOutPolyList;
747 MatrixF collisionMatrix(true);
748 Point3F end = pos + mVelocity * time;
749 U32 mask = isServerObject() ? sServerCollisionMask : sClientCollisionMask;
750
751 // Part of our speed problem here is that we don't track contact surfaces, like we do
752 // with the player. In order to handle the most common and performance impacting
753 // instance of this problem, we'll use a ray cast to detect any contact surfaces below
754 // us. This won't be perfect, but it only needs to catch a few of these to make a
755 // big difference. We'll cast from the top center of the bounding box at the tick's
756 // beginning to the bottom center of the box at the end.
757 Point3F startCast((mObjBox.minExtents.x + mObjBox.maxExtents.x) * 0.5,
758 (mObjBox.minExtents.y + mObjBox.maxExtents.y) * 0.5,
759 mObjBox.maxExtents.z);
760 Point3F endCast((mObjBox.minExtents.x + mObjBox.maxExtents.x) * 0.5,
761 (mObjBox.minExtents.y + mObjBox.maxExtents.y) * 0.5,
762 mObjBox.minExtents.z);
763 collisionMatrix.setColumn(3, pos);
764 collisionMatrix.mulP(startCast);
765 collisionMatrix.setColumn(3, end);
766 collisionMatrix.mulP(endCast);
767 RayInfo rinfo;
768 bool doToughCollision = true;
769 disableCollision();
770 if (mCollisionObject)
771 mCollisionObject->disableCollision();
772 if (getContainer()->castRay(startCast, endCast, mask, &rinfo))
773 {
774 F32 bd = -mDot(mVelocity, rinfo.normal);
775
776 if (bd >= 0.0)
777 {
778 // Contact!
779 if (mDataBlock->sticky && rinfo.object->getTypeMask() & (STATIC_COLLISION_TYPEMASK)) {
780 mVelocity.set(0, 0, 0);
781 mAtRest = true;
782 mAtRestCounter = 0;
783 stickyNotify = true;
784 mStickyCollisionPos = rinfo.point;
785 mStickyCollisionNormal = rinfo.normal;
786 doToughCollision = false;;
787 } else {
788 // Subtract out velocity into surface and friction

Callers

nothing calls this directly

Calls 15

getColumnMethod · 0.80
setColumnMethod · 0.80
mulPMethod · 0.80
getTypeMaskMethod · 0.80
setCollisionListMethod · 0.80
isOverlappedMethod · 0.60
getContainerFunction · 0.50
mDotFunction · 0.50
disableCollisionMethod · 0.45
castRayMethod · 0.45
setMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected