File tree Expand file tree Collapse file tree 4 files changed +40
-14
lines changed
src/main/java/com/ss/editor
tree/action/impl/control/physics Expand file tree Collapse file tree 4 files changed +40
-14
lines changed Original file line number Diff line number Diff line change 4343import com .ss .editor .model .undo .editor .ChangeConsumer ;
4444import com .ss .editor .model .undo .editor .ModelChangeConsumer ;
4545import com .ss .editor .part3d .editor .impl .scene .handler .DisableControlsTransformationHandler ;
46+ import com .ss .editor .part3d .editor .impl .scene .handler .ReactivatePhysicsControlsTransformationHandler ;
4647import com .ss .editor .plugin .api .editor .part3d .Advanced3DEditorPart ;
4748import com .ss .editor .ui .component .editor .impl .scene .AbstractSceneFileEditor ;
4849import com .ss .editor .ui .control .property .operation .PropertyOperation ;
@@ -159,6 +160,7 @@ public static void registerPostTransformHandler(@NotNull final Consumer<Spatial>
159160
160161 registerPreTransformHandler (transformationHandler ::onPreTransform );
161162 registerPostTransformHandler (transformationHandler ::onPostTransform );
163+ registerPostTransformHandler (new ReactivatePhysicsControlsTransformationHandler ());
162164 }
163165
164166 /**
Original file line number Diff line number Diff line change 1+ package com .ss .editor .part3d .editor .impl .scene .handler ;
2+
3+ import com .jme3 .bullet .control .RigidBodyControl ;
4+ import com .jme3 .bullet .objects .PhysicsRigidBody ;
5+ import com .jme3 .scene .Spatial ;
6+ import com .ss .editor .util .ControlUtils ;
7+ import com .ss .editor .util .NodeUtils ;
8+ import org .jetbrains .annotations .NotNull ;
9+
10+ import java .util .function .Consumer ;
11+
12+ /**
13+ * The handler to reactivate enabled physics controls during transforming spatial.
14+ *
15+ * @author JavaSaBr
16+ */
17+ public class ReactivatePhysicsControlsTransformationHandler implements Consumer <Spatial > {
18+
19+ @ Override
20+ public void accept (@ NotNull final Spatial spatial ) {
21+ NodeUtils .children (spatial )
22+ .flatMap (ControlUtils ::controls )
23+ .filter (RigidBodyControl .class ::isInstance )
24+ .map (RigidBodyControl .class ::cast )
25+ .filter (RigidBodyControl ::isEnabled )
26+ .filter (control -> !control .isActive ())
27+ .forEach (PhysicsRigidBody ::activate );
28+ }
29+ }
Original file line number Diff line number Diff line change 44import com .jme3 .material .Material ;
55import com .jme3 .scene .AssetLinkNode ;
66import com .jme3 .scene .Spatial ;
7+ import com .jme3 .scene .control .Control ;
78import com .ss .editor .annotation .FxThread ;
89import com .ss .editor .model .undo .editor .ModelChangeConsumer ;
910import com .ss .editor .ui .control .property .PropertyEditor ;
@@ -70,7 +71,9 @@ protected boolean isNeedUpdate(@Nullable final Object object) {
7071 @ FxThread
7172 protected boolean canEdit (@ NotNull final Object object , @ Nullable final Object parent ) {
7273
73- if (object instanceof Material ) {
74+ if (object instanceof Control ) {
75+ return true ;
76+ } else if (object instanceof Material ) {
7477 final Material material = (Material ) object ;
7578 if (material .getKey () != null ) return false ;
7679 } else if (object instanceof Spatial ) {
Original file line number Diff line number Diff line change 1919 */
2020public class ReactivatePhysicsControl extends AbstractNodeAction <ModelChangeConsumer > {
2121
22- /**
23- * Instantiates a new Reactivate physics control.
24- *
25- * @param nodeTree the node tree
26- * @param node the node
27- */
2822 public ReactivatePhysicsControl (@ NotNull final NodeTree <?> nodeTree , @ NotNull final TreeNode <?> node ) {
2923 super (nodeTree , node );
3024 }
3125
32- @ FxThread
33- @ Nullable
3426 @ Override
35- protected Image getIcon () {
27+ @ FxThread
28+ protected @ Nullable Image getIcon () {
3629 return Icons .REPLAY_16 ;
3730 }
3831
39- @ FxThread
40- @ NotNull
4132 @ Override
42- protected String getName () {
33+ @ FxThread
34+ protected @ NotNull String getName () {
4335 return Messages .MODEL_NODE_TREE_ACTION_REACTIVATE ;
4436 }
4537
46- @ FxThread
4738 @ Override
39+ @ FxThread
4840 protected void process () {
4941
5042 final Object element = getNode ().getElement ();
You can’t perform that action at this time.
0 commit comments