aboutsummaryrefslogtreecommitdiff
path: root/engine/src/core/com/jme3/scene/SimpleBatchNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/core/com/jme3/scene/SimpleBatchNode.java')
-rw-r--r--engine/src/core/com/jme3/scene/SimpleBatchNode.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/engine/src/core/com/jme3/scene/SimpleBatchNode.java b/engine/src/core/com/jme3/scene/SimpleBatchNode.java
new file mode 100644
index 0000000..0f1ed29
--- /dev/null
+++ b/engine/src/core/com/jme3/scene/SimpleBatchNode.java
@@ -0,0 +1,56 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.jme3.scene;
+
+import com.jme3.math.Transform;
+
+/**
+ *
+ * SimpleBatchNode comes with some restrictions, but can yield better performances.
+ * Geometries to be batched has to be attached directly to the BatchNode
+ * You can't attach a Node to a SimpleBatchNode
+ * SimpleBatchNode is recommended when you have a large number of geometries using the same material that does not require a complex scene graph structure.
+ * @see BatchNode
+ * @author Nehon
+ */
+public class SimpleBatchNode extends BatchNode {
+
+ public SimpleBatchNode() {
+ super();
+ }
+
+ public SimpleBatchNode(String name) {
+ super(name);
+ }
+
+ @Override
+ public int attachChild(Spatial child) {
+
+ if (!(child instanceof Geometry)) {
+ throw new UnsupportedOperationException("BatchNode is BatchMode.Simple only support child of type Geometry, use BatchMode.Complex to use a complex structure");
+ }
+
+ return super.attachChild(child);
+ }
+
+ @Override
+ protected void setTransformRefresh() {
+
+ refreshFlags |= RF_TRANSFORM;
+ setBoundRefresh();
+ for (Batch batch : batches.values()) {
+ batch.geometry.setTransformRefresh();
+ }
+ }
+
+ protected Transform getTransforms(Geometry geom){
+ return geom.getLocalTransform();
+ }
+
+ @Override
+ public void batch() {
+ doBatch();
+ }
+}