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

Method updateWorkingCollisionSet

Engine/source/T3D/item.cpp:655–712  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

653
654//----------------------------------------------------------------------------
655void Item::updateWorkingCollisionSet(const U32 mask, const F32 dt)
656{
657 // It is assumed that we will never accelerate more than 10 m/s for gravity...
658 //
659 Point3F scaledVelocity = mVelocity * dt;
660 F32 len = scaledVelocity.len();
661 F32 newLen = len + (10 * dt);
662
663 // Check to see if it is actually necessary to construct the new working list,
664 // or if we can use the cached version from the last query. We use the x
665 // component of the min member of the mWorkingQueryBox, which is lame, but
666 // it works ok.
667 bool updateSet = false;
668
669 Box3F convexBox = mConvex.getBoundingBox(getTransform(), getScale());
670 F32 l = (newLen * 1.1) + 0.1; // from Convex::updateWorkingList
671 convexBox.minExtents -= Point3F(l, l, l);
672 convexBox.maxExtents += Point3F(l, l, l);
673
674 // Check containment
675 {
676 if (mWorkingQueryBox.minExtents.x != -1e9)
677 {
678 if (mWorkingQueryBox.isContained(convexBox) == false)
679 {
680 // Needed region is outside the cached region. Update it.
681 updateSet = true;
682 }
683 else
684 {
685 // We can leave it alone, we're still inside the cached region
686 }
687 }
688 else
689 {
690 // Must update
691 updateSet = true;
692 }
693 }
694
695 // Actually perform the query, if necessary
696 if (updateSet == true)
697 {
698 mWorkingQueryBox = convexBox;
699 mWorkingQueryBox.minExtents -= Point3F(2 * l, 2 * l, 2 * l);
700 mWorkingQueryBox.maxExtents += Point3F(2 * l, 2 * l, 2 * l);
701
702 disableCollision();
703 if (mCollisionObject)
704 mCollisionObject->disableCollision();
705
706 mConvex.updateWorkingList(mWorkingQueryBox, mask);
707
708 if (mCollisionObject)
709 mCollisionObject->enableCollision();
710 enableCollision();
711 }
712}

Callers

nothing calls this directly

Calls 7

updateWorkingListMethod · 0.80
Point3FClass · 0.50
lenMethod · 0.45
getBoundingBoxMethod · 0.45
isContainedMethod · 0.45
disableCollisionMethod · 0.45
enableCollisionMethod · 0.45

Tested by

no test coverage detected