| 837 | } |
| 838 | |
| 839 | void 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); |
nothing calls this directly
no test coverage detected