]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d/src/org/simantics/proconf/g3d/tools/ScenegraphLockTraverser.java
Naming fixes.
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / proconf / g3d / tools / ScenegraphLockTraverser.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.tools;\r
12 \r
13 import java.util.ArrayList;\r
14 \r
15 import com.jme.scene.Node;\r
16 import com.jme.scene.Spatial;\r
17 \r
18 public class ScenegraphLockTraverser {\r
19         Node root;\r
20         boolean lock;\r
21         public ScenegraphLockTraverser(Node root, boolean lock) {\r
22                 this.root = root;\r
23                 this.lock = lock;\r
24                 lock(root);\r
25         }\r
26         \r
27         private void lock(Spatial spatial) {\r
28                 if (lock)\r
29                         spatial.lock();\r
30                 else\r
31                         spatial.unlock();\r
32                 if (spatial instanceof Node) {\r
33                         Node node = (Node)spatial;\r
34                         ArrayList<Spatial> children = node.getChildren();\r
35                 for (Spatial s : children) {\r
36                         s.lock();\r
37                         lock(s);\r
38                 }\r
39                 }\r
40                 \r
41         }\r
42 }\r