Triangle clone fix

A small fix for the triangle class to avoid this error when cloning:


java.lang.AssertionError
   at com.jme.math.Triangle.clone(Triangle.java:232)



 ### Eclipse Workspace Patch 1.0
#P jME2
Index: src/com/jme/math/Triangle.java
===================================================================
--- src/com/jme/math/Triangle.java   (revision 4337)
+++ src/com/jme/math/Triangle.java   (working copy)
@@ -222,14 +222,12 @@
 
     @Override
     public Triangle clone() {
-        try {
-            Triangle t = (Triangle) super.clone();
-            t.pointa = pointa.clone();
-            t.pointb = pointb.clone();
-            t.pointc = pointc.clone();
-            return t;
-        } catch (CloneNotSupportedException e) {
-            throw new AssertionError();
-        }
+        Triangle t = new Triangle();
+        t.pointa = pointa.clone();
+        t.pointb = pointb.clone();
+        t.pointc = pointc.clone();
+        t.index = index;
+        t.projection = projection;
+        return t;
     }
 }
 

Hi!



Which class was throwing a CloneNotSupportedException? Your fix worries me a bit.

The Object class which the triangle class extends from (automatically).

Haladria said:

The Object class which the triangle class extends from (automatically).

Ok. Sorry. Your fix is fine.