Quellcode durchsuchen

Fixed error in SceneGraphVisitor code example where spatial was not used for method parameter.

mitm vor 6 Jahren
Ursprung
Commit
2d59f409aa
1 geänderte Dateien mit 9 neuen und 9 gelöschten Zeilen
  1. 9 9
      src/docs/asciidoc/jme3/advanced/traverse_scenegraph.adoc

+ 9 - 9
src/docs/asciidoc/jme3/advanced/traverse_scenegraph.adoc

@@ -1,6 +1,6 @@
 = Traverse the SceneGraph
-:author: 
-:revnumber: 
+:author:
+:revnumber:
 :revdate: 2016/03/17 20:48
 :keywords: spatial, node, mesh, geometry, scenegraph
 :relfileprefix: ../../
@@ -16,13 +16,13 @@ You can run a search across the whole scene graph and search for individual Spat
 *Example 1:*
 
 .  You have created a procedural scene with lots of dynamically generated elements.
-.  You want to find individual Spatials under ever-changing conditions and modify their state. 
+.  You want to find individual Spatials under ever-changing conditions and modify their state.
 
 *Example 2:*
 
 .  You created a mostly static scene in the jMonkeyEngine SDK and exported it as .j3o file. +
-The scene also contains interactive objects, for example a particle emitter, spatials with user data, or spatials with custom controls. 
-.  You load the .j3o scene using the assetManager. 
+The scene also contains interactive objects, for example a particle emitter, spatials with user data, or spatials with custom controls.
+.  You load the .j3o scene using the assetManager.
 .  You want to interact with one of the loaded interactive scene elements in your Java code. +
 For example, you want to call `emitAllParticles()` on the particle emitter. Or you want to find all NPC's Geometries with a custom CivilianControl, and call the CivilianControl method that makes them start acting their role.
 
@@ -39,18 +39,18 @@ For each search, you create a `com.jme3.scene.SceneGraphVisitorAdapter` that def
 SceneGraphVisitor visitor = new SceneGraphVisitor() {
 
   @Override
-  public void visit(Spatial spat) {
+  public void visit(Spatial spatial) {
     // search criterion can be control class:
     MyControl control = spatial.getControl(MyControl.class);
     if (control != null) {
       // you have access to any method, e.g. name.
-      System.out.println("Instance of " + control.getClass().getName() 
+      System.out.println("Instance of " + control.getClass().getName()
                        + " found for " + spatial.getName());
     }
   }
 
 };
-  
+
 // Now scan the tree either depth first...
 rootNode.depthFirstTraversal(visitor);
 // ... or scan it breadth first.
@@ -58,7 +58,7 @@ rootNode.breadthFirstTraversal(visitor);
 
 ----
 
-Which of the two methods is faster depends on how you designed the scengraph, and what tree element you are looking for. If you are searching for one single Geometry that is a “leaf of the tree, and then stop searching, depth-first may be faster. If you search for a high-level grouping Node, breadth-first may be faster. 
+Which of the two methods is faster depends on how you designed the scengraph, and what tree element you are looking for. If you are searching for one single Geometry that is a “leaf of the tree, and then stop searching, depth-first may be faster. If you search for a high-level grouping Node, breadth-first may be faster.
 
 The choice of depth- vs breadth-first also influences the order in which found elements are returned (children first or parents first). If you want to modify user data that is inherited from the parent node (e.g. transformations), the order of application is important, because the side-effects add up.