@@ -129,6 +129,7 @@ public enum Mode {
129
129
* for each patch (default is 3 for triangle tessellation)
130
130
*/
131
131
Patch (true );
132
+
132
133
private boolean listMode = false ;
133
134
134
135
private Mode (boolean listMode ) {
@@ -148,28 +149,44 @@ public boolean isListMode() {
148
149
return listMode ;
149
150
}
150
151
}
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 ;
151
161
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
+
152
168
/**
153
169
* The bounding volume that contains the mesh entirely.
154
170
* By default a BoundingBox (AABB).
155
171
*/
156
172
private BoundingVolume meshBound = new BoundingBox ();
157
173
158
- private CollisionData collisionTree = null ;
174
+ private CollisionData collisionTree = DEFAULT_COLLISION_TREE ;
159
175
160
176
private SafeArrayList <VertexBuffer > buffersList = new SafeArrayList <>(VertexBuffer .class );
161
177
private IntMap <VertexBuffer > buffers = new IntMap <>();
162
178
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 ;
165
182
166
- private transient int vertexArrayID = - 1 ;
183
+ private transient int vertexArrayID = DEFAULT_VERTEX_ARRAY_ID ;
167
184
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
173
190
174
191
private int [] elementLengths ;
175
192
private int [] modeStart ;
@@ -199,7 +216,7 @@ public Mesh clone() {
199
216
clone .collisionTree = collisionTree != null ? collisionTree : null ;
200
217
clone .buffers = buffers .clone ();
201
218
clone .buffersList = new SafeArrayList <>(VertexBuffer .class , buffersList );
202
- clone .vertexArrayID = - 1 ;
219
+ clone .vertexArrayID = DEFAULT_VERTEX_ARRAY_ID ;
203
220
if (elementLengths != null ) {
204
221
clone .elementLengths = elementLengths .clone ();
205
222
}
@@ -226,7 +243,7 @@ public Mesh deepClone() {
226
243
227
244
// TODO: Collision tree cloning
228
245
//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
230
247
231
248
clone .buffers = new IntMap <>();
232
249
clone .buffersList = new SafeArrayList <>(VertexBuffer .class );
@@ -236,7 +253,7 @@ public Mesh deepClone() {
236
253
clone .buffersList .add (bufClone );
237
254
}
238
255
239
- clone .vertexArrayID = - 1 ;
256
+ clone .vertexArrayID = DEFAULT_VERTEX_ARRAY_ID ;
240
257
clone .vertCount = vertCount ;
241
258
clone .elementCount = elementCount ;
242
259
clone .instanceCount = instanceCount ;
@@ -296,7 +313,7 @@ public Mesh cloneForAnim() {
296
313
public Mesh jmeClone () {
297
314
try {
298
315
Mesh clone = (Mesh ) super .clone ();
299
- clone .vertexArrayID = - 1 ;
316
+ clone .vertexArrayID = DEFAULT_VERTEX_ARRAY_ID ;
300
317
return clone ;
301
318
} catch (CloneNotSupportedException ex ) {
302
319
throw new AssertionError ();
@@ -309,7 +326,7 @@ public Mesh jmeClone() {
309
326
@ Override
310
327
public void cloneFields (Cloner cloner , Object original ) {
311
328
// Probably could clone this now but it will get regenerated anyway.
312
- this .collisionTree = null ;
329
+ this .collisionTree = DEFAULT_COLLISION_TREE ;
313
330
314
331
this .meshBound = cloner .clone (meshBound );
315
332
this .buffersList = cloner .clone (buffersList );
@@ -616,7 +633,7 @@ public void setMaxNumWeights(int maxNumWeights) {
616
633
*/
617
634
@ Deprecated
618
635
public float getPointSize () {
619
- return 1.0f ;
636
+ return DEFAULT_POINT_SIZE ;
620
637
}
621
638
622
639
/**
@@ -969,7 +986,7 @@ public int getId() {
969
986
* @param id the array ID
970
987
*/
971
988
public void setId (int id ) {
972
- if (vertexArrayID != - 1 ) {
989
+ if (vertexArrayID != DEFAULT_VERTEX_ARRAY_ID ) {
973
990
throw new IllegalStateException ("ID has already been set." );
974
991
}
975
992
@@ -995,7 +1012,7 @@ public void createCollisionData() {
995
1012
* generated BIHTree.
996
1013
*/
997
1014
public void clearCollisionData () {
998
- collisionTree = null ;
1015
+ collisionTree = DEFAULT_COLLISION_TREE ;
999
1016
}
1000
1017
1001
1018
/**
@@ -1620,15 +1637,15 @@ public void write(JmeExporter ex) throws IOException {
1620
1637
OutputCapsule out = ex .getCapsule (this );
1621
1638
1622
1639
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 );
1627
1644
out .write (mode , "mode" , Mode .Triangles );
1628
- out .write (collisionTree , "collisionTree" , null );
1645
+ out .write (collisionTree , "collisionTree" , DEFAULT_COLLISION_TREE );
1629
1646
out .write (elementLengths , "elementLengths" , null );
1630
1647
out .write (modeStart , "modeStart" , null );
1631
- out .write (pointSize , "pointSize" , 1f );
1648
+ out .write (pointSize , "pointSize" , DEFAULT_POINT_SIZE );
1632
1649
1633
1650
//Removing HW skinning buffers to not save them
1634
1651
VertexBuffer hwBoneIndex = null ;
@@ -1663,17 +1680,17 @@ public void write(JmeExporter ex) throws IOException {
1663
1680
public void read (JmeImporter im ) throws IOException {
1664
1681
InputCapsule in = im .getCapsule (this );
1665
1682
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 );
1670
1687
mode = in .readEnum ("mode" , Mode .class , Mode .Triangles );
1671
1688
elementLengths = in .readIntArray ("elementLengths" , null );
1672
1689
modeStart = in .readIntArray ("modeStart" , null );
1673
- collisionTree = (BIHTree ) in .readSavable ("collisionTree" , null );
1690
+ collisionTree = (BIHTree ) in .readSavable ("collisionTree" , DEFAULT_COLLISION_TREE );
1674
1691
elementLengths = in .readIntArray ("elementLengths" , null );
1675
1692
modeStart = in .readIntArray ("modeStart" , null );
1676
- pointSize = in .readFloat ("pointSize" , 1f );
1693
+ pointSize = in .readFloat ("pointSize" , DEFAULT_POINT_SIZE );
1677
1694
1678
1695
// in.readStringSavableMap("buffers", null);
1679
1696
buffers = (IntMap <VertexBuffer >) in .readIntSavableMap ("buffers" , null );
0 commit comments