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

Method softSnapSelection

Engine/source/gui/worldEditor/worldEditor.cpp:839–1033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839void WorldEditor::softSnapSelection(Selection* sel, U8 modifier, Point3F gizmoPos)
840{
841 mSoftSnapIsStuck = false;
842 mSoftSnapActivated = false;
843
844 // If soft snap is activated, holding CTRL will temporarily deactivate it.
845 // Conversely, if soft snapping is deactivated, holding CTRL will activate it.
846 if( (mSoftSnap && (modifier & SI_PRIMARY_CTRL)) || (!mSoftSnap && !(modifier & SI_PRIMARY_CTRL)) )
847 return;
848
849 if(!sel->size())
850 return;
851
852 if(sel->containsGlobalBounds())
853 return;
854
855 mSoftSnapActivated = true;
856
857 Point3F centroid = mObjectsUseBoxCenter ? sel->getBoxCentroid() : sel->getCentroid();
858
859 // Find objects we may stick against
860 Vector<SceneObject*> foundobjs;
861
862 SceneObject *controlObj = getControlObject();
863 if ( controlObj )
864 controlObj->disableCollision();
865
866 sel->disableCollision();
867
868 if(mSoftSnapSizeByBounds)
869 {
870 mSoftSnapBounds = sel->getBoxBounds();
871 mSoftSnapBounds.setCenter(centroid);
872 }
873 else
874 {
875 mSoftSnapBounds.set(Point3F(mSoftSnapSize, mSoftSnapSize, mSoftSnapSize));
876 mSoftSnapBounds.setCenter(centroid);
877 }
878
879 mSoftSnapPreBounds = mSoftSnapBounds;
880 mSoftSnapPreBounds.setCenter(gizmoPos);
881
882 SphereF sphere(gizmoPos, mSoftSnapPreBounds.len()*0.5f);
883
884 gServerContainer.findObjectList(mSoftSnapPreBounds, 0xFFFFFFFF, &foundobjs);
885
886 sel->enableCollision();
887
888 if ( controlObj )
889 controlObj->enableCollision();
890
891 ConcretePolyList polys;
892 for(S32 i=0; i<foundobjs.size(); ++i)
893 {
894 SceneObject* so = foundobjs[i];
895 polys.setTransform(&(so->getTransform()), so->getScale());
896 polys.setObject(so);

Callers

nothing calls this directly

Calls 15

mTriangleDistanceFunction · 0.85
mDegToRadFunction · 0.85
createOrientFromDirFunction · 0.85
containsGlobalBoundsMethod · 0.80
setCenterMethod · 0.80
findObjectListMethod · 0.80
orientMethod · 0.80
mulPMethod · 0.80
Point3FClass · 0.50
sizeMethod · 0.45
disableCollisionMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected