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

Method updatePos

Engine/source/T3D/item.cpp:732–1024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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