[committed] Support manual handling of TrailMesh data

  1. To avoid mesh update when there is no change, invalid variable is introduced.
  2. To handle trail manually, getTrailData() method is introduced.



    Even when TrailMesh data is not changed, mesh data is updated every frame.

    Only when facing mode is Billboard or new TrailFront is added, it will be updated automatically.



    And because there is a requirement to change width without modifying locations,

    getTrailData() and invalidate() method is added.



Index: src/com/jmex/effects/TrailMesh.java
===================================================================
--- src/com/jmex/effects/TrailMesh.java   (revision 4386)
+++ src/com/jmex/effects/TrailMesh.java   (working copy)
@@ -83,7 +83,7 @@
     /**
      * Storage for each section in the trailmesh.
      */
-    private class TrailData {
+    public class TrailData {
         public Vector3f position = new Vector3f();
         public Vector3f tangent;
         public float width;
@@ -101,6 +101,8 @@
     private final Vector3f trailCamVec = new Vector3f();
     private final Vector3f trailDirection = new Vector3f();
 
+    private boolean invalid;
+
     /**
      * Creates a new TrailMesh.
      *
@@ -179,6 +181,7 @@
             trail.tangent.set(tangent.x, tangent.y, tangent.z);
         }
         trail.width = width;
+        invalid = true;
     }
 
     /**
@@ -192,12 +195,19 @@
             return;
         }
 
-        if (updateMode == UpdateMode.Step) {
-            updateStep(camPos);
-        } else {
-            updateInterpolate(camPos);
+        if (invalid || facingMode == FacingMode.Billboard) {
+            if (updateMode == UpdateMode.Step) {
+                updateStep(camPos);
+            } else {
+                updateInterpolate(camPos);
+            }
+            invalid = false;
         }
     }
+   
+    public void invalidate() {
+        invalid = true;
+    }
 
     private void updateStep(Vector3f camPos) {
         FloatBuffer vertBuf = getVertexBuffer();
@@ -239,7 +249,8 @@
             vertBuf.put(trailVector.z + trailDirection.z);
         }
     }
-
+   
+   
     private void updateInterpolate(Vector3f camPos) {
         for (int i = 0; i < nrTrailSections; i++) {
             TrailData trailData = trailVectors.get(i);
@@ -365,6 +376,10 @@
     public UpdateMode getUpdateMode() {
         return updateMode;
     }
+   
+    public LinkedList<TrailData> getTrailData() {
+        return trailVectors;
+    }
 
     public void setFacingMode(FacingMode facingMode) {
         this.facingMode = facingMode;