@@ -129,6 +129,7 @@ public enum Mode {
129129 * for each patch (default is 3 for triangle tessellation)
130130 */
131131 Patch (true );
132+
132133 private boolean listMode = false ;
133134
134135 private Mode (boolean listMode ) {
@@ -148,28 +149,44 @@ public boolean isListMode() {
148149 return listMode ;
149150 }
150151 }
152+
153+ /**
154+ * Default Variables
155+ */
156+ private static final int DEFAULT_VERTEX_ARRAY_ID = -1 ;
157+ private static final CollisionData DEFAULT_COLLISION_TREE = null ;
158+
159+ private static final float DEFAULT_POINT_SIZE = 1.0f ;
160+ private static final float DEFAULT_LINE_WIDTH = 1.0f ;
151161
162+ private static final int DEFAULT_VERT_COUNT = -1 ;
163+ private static final int DEFAULT_ELEMENT_COUNT = -1 ;
164+ private static final int DEFAULT_INSTANCE_COUNT = -1 ;
165+ private static final int DEFAULT_PATCH_VERTEX_COUNT = 3 ;
166+ private static final int DEFAULT_MAX_NUM_WEIGHTS = -1 ;
167+
152168 /**
153169 * The bounding volume that contains the mesh entirely.
154170 * By default a BoundingBox (AABB).
155171 */
156172 private BoundingVolume meshBound = new BoundingBox ();
157173
158- private CollisionData collisionTree = null ;
174+ private CollisionData collisionTree = DEFAULT_COLLISION_TREE ;
159175
160176 private SafeArrayList <VertexBuffer > buffersList = new SafeArrayList <>(VertexBuffer .class );
161177 private IntMap <VertexBuffer > buffers = new IntMap <>();
162178 private VertexBuffer [] lodLevels ;
163- private float pointSize = 1 ;
164- private float lineWidth = 1 ;
179+
180+ private float pointSize = DEFAULT_POINT_SIZE ;
181+ private float lineWidth = DEFAULT_LINE_WIDTH ;
165182
166- private transient int vertexArrayID = - 1 ;
183+ private transient int vertexArrayID = DEFAULT_VERTEX_ARRAY_ID ;
167184
168- private int vertCount = - 1 ;
169- private int elementCount = - 1 ;
170- private int instanceCount = - 1 ;
171- private int patchVertexCount = 3 ; //only used for tessellation
172- private int maxNumWeights = - 1 ; // only if using skeletal animation
185+ private int vertCount = DEFAULT_VERT_COUNT ;
186+ private int elementCount = DEFAULT_ELEMENT_COUNT ;
187+ private int instanceCount = DEFAULT_INSTANCE_COUNT ;
188+ private int patchVertexCount = DEFAULT_PATCH_VERTEX_COUNT ; //only used for tessellation
189+ private int maxNumWeights = DEFAULT_MAX_NUM_WEIGHTS ; // only if using skeletal animation
173190
174191 private int [] elementLengths ;
175192 private int [] modeStart ;
@@ -199,7 +216,7 @@ public Mesh clone() {
199216 clone .collisionTree = collisionTree != null ? collisionTree : null ;
200217 clone .buffers = buffers .clone ();
201218 clone .buffersList = new SafeArrayList <>(VertexBuffer .class , buffersList );
202- clone .vertexArrayID = - 1 ;
219+ clone .vertexArrayID = DEFAULT_VERTEX_ARRAY_ID ;
203220 if (elementLengths != null ) {
204221 clone .elementLengths = elementLengths .clone ();
205222 }
@@ -226,7 +243,7 @@ public Mesh deepClone() {
226243
227244 // TODO: Collision tree cloning
228245 //clone.collisionTree = collisionTree != null ? collisionTree : null;
229- clone .collisionTree = null ; // it will get re-generated in any case
246+ clone .collisionTree = DEFAULT_COLLISION_TREE ; // it will get re-generated in any case
230247
231248 clone .buffers = new IntMap <>();
232249 clone .buffersList = new SafeArrayList <>(VertexBuffer .class );
@@ -236,7 +253,7 @@ public Mesh deepClone() {
236253 clone .buffersList .add (bufClone );
237254 }
238255
239- clone .vertexArrayID = - 1 ;
256+ clone .vertexArrayID = DEFAULT_VERTEX_ARRAY_ID ;
240257 clone .vertCount = vertCount ;
241258 clone .elementCount = elementCount ;
242259 clone .instanceCount = instanceCount ;
@@ -296,7 +313,7 @@ public Mesh cloneForAnim() {
296313 public Mesh jmeClone () {
297314 try {
298315 Mesh clone = (Mesh ) super .clone ();
299- clone .vertexArrayID = - 1 ;
316+ clone .vertexArrayID = DEFAULT_VERTEX_ARRAY_ID ;
300317 return clone ;
301318 } catch (CloneNotSupportedException ex ) {
302319 throw new AssertionError ();
@@ -309,7 +326,7 @@ public Mesh jmeClone() {
309326 @ Override
310327 public void cloneFields (Cloner cloner , Object original ) {
311328 // Probably could clone this now but it will get regenerated anyway.
312- this .collisionTree = null ;
329+ this .collisionTree = DEFAULT_COLLISION_TREE ;
313330
314331 this .meshBound = cloner .clone (meshBound );
315332 this .buffersList = cloner .clone (buffersList );
@@ -616,7 +633,7 @@ public void setMaxNumWeights(int maxNumWeights) {
616633 */
617634 @ Deprecated
618635 public float getPointSize () {
619- return 1.0f ;
636+ return DEFAULT_POINT_SIZE ;
620637 }
621638
622639 /**
@@ -969,7 +986,7 @@ public int getId() {
969986 * @param id the array ID
970987 */
971988 public void setId (int id ) {
972- if (vertexArrayID != - 1 ) {
989+ if (vertexArrayID != DEFAULT_VERTEX_ARRAY_ID ) {
973990 throw new IllegalStateException ("ID has already been set." );
974991 }
975992
@@ -995,7 +1012,7 @@ public void createCollisionData() {
9951012 * generated BIHTree.
9961013 */
9971014 public void clearCollisionData () {
998- collisionTree = null ;
1015+ collisionTree = DEFAULT_COLLISION_TREE ;
9991016 }
10001017
10011018 /**
@@ -1620,15 +1637,15 @@ public void write(JmeExporter ex) throws IOException {
16201637 OutputCapsule out = ex .getCapsule (this );
16211638
16221639 out .write (meshBound , "modelBound" , null );
1623- out .write (vertCount , "vertCount" , - 1 );
1624- out .write (elementCount , "elementCount" , - 1 );
1625- out .write (instanceCount , "instanceCount" , - 1 );
1626- out .write (maxNumWeights , "max_num_weights" , - 1 );
1640+ out .write (vertCount , "vertCount" , DEFAULT_VERT_COUNT );
1641+ out .write (elementCount , "elementCount" , DEFAULT_ELEMENT_COUNT );
1642+ out .write (instanceCount , "instanceCount" , DEFAULT_INSTANCE_COUNT );
1643+ out .write (maxNumWeights , "max_num_weights" , DEFAULT_MAX_NUM_WEIGHTS );
16271644 out .write (mode , "mode" , Mode .Triangles );
1628- out .write (collisionTree , "collisionTree" , null );
1645+ out .write (collisionTree , "collisionTree" , DEFAULT_COLLISION_TREE );
16291646 out .write (elementLengths , "elementLengths" , null );
16301647 out .write (modeStart , "modeStart" , null );
1631- out .write (pointSize , "pointSize" , 1f );
1648+ out .write (pointSize , "pointSize" , DEFAULT_POINT_SIZE );
16321649
16331650 //Removing HW skinning buffers to not save them
16341651 VertexBuffer hwBoneIndex = null ;
@@ -1663,17 +1680,17 @@ public void write(JmeExporter ex) throws IOException {
16631680 public void read (JmeImporter im ) throws IOException {
16641681 InputCapsule in = im .getCapsule (this );
16651682 meshBound = (BoundingVolume ) in .readSavable ("modelBound" , null );
1666- vertCount = in .readInt ("vertCount" , - 1 );
1667- elementCount = in .readInt ("elementCount" , - 1 );
1668- instanceCount = in .readInt ("instanceCount" , - 1 );
1669- maxNumWeights = in .readInt ("max_num_weights" , - 1 );
1683+ vertCount = in .readInt ("vertCount" , DEFAULT_VERT_COUNT );
1684+ elementCount = in .readInt ("elementCount" , DEFAULT_ELEMENT_COUNT );
1685+ instanceCount = in .readInt ("instanceCount" , DEFAULT_INSTANCE_COUNT );
1686+ maxNumWeights = in .readInt ("max_num_weights" , DEFAULT_MAX_NUM_WEIGHTS );
16701687 mode = in .readEnum ("mode" , Mode .class , Mode .Triangles );
16711688 elementLengths = in .readIntArray ("elementLengths" , null );
16721689 modeStart = in .readIntArray ("modeStart" , null );
1673- collisionTree = (BIHTree ) in .readSavable ("collisionTree" , null );
1690+ collisionTree = (BIHTree ) in .readSavable ("collisionTree" , DEFAULT_COLLISION_TREE );
16741691 elementLengths = in .readIntArray ("elementLengths" , null );
16751692 modeStart = in .readIntArray ("modeStart" , null );
1676- pointSize = in .readFloat ("pointSize" , 1f );
1693+ pointSize = in .readFloat ("pointSize" , DEFAULT_POINT_SIZE );
16771694
16781695// in.readStringSavableMap("buffers", null);
16791696 buffers = (IntMap <VertexBuffer >) in .readIntSavableMap ("buffers" , null );
0 commit comments