| 874 | } |
| 875 | |
| 876 | void 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); |
nothing calls this directly
no test coverage detected