|
106 | 106 | public abstract class AbstractSceneFileEditor<M extends Spatial, MA extends AbstractSceneEditor3DPart, ES extends BaseEditorSceneEditorState> extends |
107 | 107 | Advanced3DFileEditorWithSplitRightTool<MA, ES> implements ModelChangeConsumer, ModelEditingProvider { |
108 | 108 |
|
109 | | - private static final int OBJECTS_TOOL = 0; |
110 | | - private static final int PAINTING_TOOL = 1; |
| 109 | + protected static final int OBJECTS_TOOL = 0; |
| 110 | + protected static final int PAINTING_TOOL = 1; |
| 111 | + protected static final int SCRIPTING_TOOL = 2; |
111 | 112 |
|
112 | 113 | @NotNull |
113 | 114 | private static final Array<String> ACCEPTED_FILES = ArrayFactory.asArray( |
@@ -727,13 +728,31 @@ public void notifySelected(@Nullable Object object) { |
727 | 728 |
|
728 | 729 | setIgnoreCameraMove(true); |
729 | 730 | try { |
| 731 | + |
730 | 732 | final ModelNodeTree modelNodeTree = getModelNodeTree(); |
731 | 733 | modelNodeTree.selectSingle(object); |
| 734 | + |
| 735 | + final SingleSelectionModel<Tab> selectionModel = getEditorToolComponent().getSelectionModel(); |
| 736 | + if (isNeedToOpenObjectsTool(selectionModel.getSelectedIndex())) { |
| 737 | + selectionModel.select(OBJECTS_TOOL); |
| 738 | + } |
| 739 | + |
732 | 740 | } finally { |
733 | 741 | setIgnoreCameraMove(false); |
734 | 742 | } |
735 | 743 | } |
736 | 744 |
|
| 745 | + /** |
| 746 | + * Return true if need to open objects tool. |
| 747 | + * |
| 748 | + * @param current the current opened tool. |
| 749 | + * @return true if need to open objects tool. |
| 750 | + */ |
| 751 | + @FxThread |
| 752 | + protected boolean isNeedToOpenObjectsTool(final int current) { |
| 753 | + return !(current == OBJECTS_TOOL || current == SCRIPTING_TOOL); |
| 754 | + } |
| 755 | + |
737 | 756 | /** |
738 | 757 | * Return true of the spatial can be selected. |
739 | 758 | * |
@@ -880,14 +899,12 @@ protected void singleSelectNodesFromTree(@NotNull final Array<?> objects, @NotNu |
880 | 899 | spatial = null; |
881 | 900 | } |
882 | 901 |
|
883 | | - if (spatial != null) { |
| 902 | + if (spatial != null && canSelect(spatial)) { |
884 | 903 |
|
885 | | - if (canSelect(spatial)) { |
886 | | - editor3DPart.select(spatial); |
887 | | - } |
| 904 | + editor3DPart.select(spatial); |
888 | 905 |
|
889 | 906 | if (!isIgnoreCameraMove() && !isVisibleOnEditor(spatial)) { |
890 | | - editor3DPart.cameraLookAt(spatial.getWorldTranslation()); |
| 907 | + editor3DPart.cameraLookAt(spatial); |
891 | 908 | } |
892 | 909 | } |
893 | 910 |
|
@@ -1322,7 +1339,7 @@ private void addNewModel(@NotNull final DragEvent dragEvent, @NotNull final Path |
1322 | 1339 | camera.getHeight() - (float) areaPoint.getY()); |
1323 | 1340 | final Vector3f result = local.nextVector(scenePoint) |
1324 | 1341 | .subtractLocal(parent.getWorldTranslation()); |
1325 | | - |
| 1342 | + |
1326 | 1343 | final boolean isPhysics = NodeUtils.children(loadedModel) |
1327 | 1344 | .flatMap(ControlUtils::controls) |
1328 | 1345 | .anyMatch(PhysicsControl.class::isInstance); |
|
0 commit comments