- simplify GeometryBatchFactory.optimize() by expecting a Node as parameter

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7214 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent 0dacbb77e1
commit dd749a699b
  1. 24
      engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java

@ -24,6 +24,7 @@ import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -254,30 +255,27 @@ public class GeometryBatchFactory {
}
/**
* Optimizes a scene by combining Geometry with the same material. If the
* given spatial has a parent it is removed from the parent and the newly
* generated scene is attached instead.
* Optimizes a scene by combining Geometry with the same material.
* All Geometries found in the scene are detached from their parent and
* a new Node containing the optimized Geometries is attached.
* @param scene The scene to optimize
* @return The newly created optimized scene
* @return The newly created optimized geometries attached to a node
*/
public static Spatial optimize(Spatial scene){
public static Node optimize(Node scene){
ArrayList<Geometry> geoms = new ArrayList<Geometry>();
gatherGeoms(scene, geoms);
List<Geometry> batchedGeoms = makeBatches(geoms);
Node node = new Node(scene.getName());
for (Geometry geom : batchedGeoms){
node.attachChild(geom);
scene.attachChild(geom);
}
Node parent = scene.getParent();
if(parent != null){
scene.removeFromParent();
parent.attachChild(node);
for (Iterator<Geometry> it = geoms.iterator(); it.hasNext();) {
Geometry geometry = it.next();
geometry.removeFromParent();
}
return node;
return scene;
}
public static void printMesh(Mesh mesh){

Loading…
Cancel
Save