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

Method softSnapSelection

Engine/source/gui/worldEditor/worldEditor.cpp:876–1070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874}
875
876void WorldEditor::softSnapSelection(Selection* sel, U8 modifier, Point3F gizmoPos)
877{
878 mSoftSnapIsStuck = false;
879 mSoftSnapActivated = false;
880
881 // If soft snap is activated, holding CTRL will temporarily deactivate it.
882 // Conversely, if soft snapping is deactivated, holding CTRL will activate it.
883 if( (mSoftSnap && (modifier & SI_PRIMARY_CTRL)) || (!mSoftSnap && !(modifier & SI_PRIMARY_CTRL)) )
884 return;
885
886 if(!sel->size())
887 return;
888
889 if(sel->containsGlobalBounds())
890 return;
891
892 mSoftSnapActivated = true;
893
894 Point3F centroid = mObjectsUseBoxCenter ? sel->getBoxCentroid() : sel->getCentroid();
895
896 // Find objects we may stick against
897 Vector<SceneObject*> foundobjs;
898
899 SceneObject *controlObj = getControlObject();
900 if ( controlObj )
901 controlObj->disableCollision();
902
903 sel->disableCollision();
904
905 if(mSoftSnapSizeByBounds)
906 {
907 mSoftSnapBounds = sel->getBoxBounds();
908 mSoftSnapBounds.setCenter(centroid);
909 }
910 else
911 {
912 mSoftSnapBounds.set(Point3F(mSoftSnapSize, mSoftSnapSize, mSoftSnapSize));
913 mSoftSnapBounds.setCenter(centroid);
914 }
915
916 mSoftSnapPreBounds = mSoftSnapBounds;
917 mSoftSnapPreBounds.setCenter(gizmoPos);
918
919 SphereF sphere(gizmoPos, mSoftSnapPreBounds.len()*0.5f);
920
921 gServerContainer.findObjectList(mSoftSnapPreBounds, 0xFFFFFFFF, &foundobjs);
922
923 sel->enableCollision();
924
925 if ( controlObj )
926 controlObj->enableCollision();
927
928 ConcretePolyList polys;
929 for(S32 i=0; i<foundobjs.size(); ++i)
930 {
931 SceneObject* so = foundobjs[i];
932 polys.setTransform(&(so->getTransform()), so->getScale());
933 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