From 65cd260734a2441ca7ec63ea1c785f8babd73d01 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 9 Oct 2012 22:59:29 -0700 Subject: j3dcore: factor out very repetative block of code to a helper Signed-off-by: Harvey Harrison --- .../javax/media/j3d/Shape3DCompileRetained.java | 119 ++++----------------- 1 file changed, 21 insertions(+), 98 deletions(-) diff --git a/src/classes/share/javax/media/j3d/Shape3DCompileRetained.java b/src/classes/share/javax/media/j3d/Shape3DCompileRetained.java index 56c1fea..ab2d237 100644 --- a/src/classes/share/javax/media/j3d/Shape3DCompileRetained.java +++ b/src/classes/share/javax/media/j3d/Shape3DCompileRetained.java @@ -143,13 +143,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_TRI_SET: if (mergedList[i] != null) { @@ -159,13 +153,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_POINT_SET: if (mergedList[i] != null) { @@ -175,13 +163,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_LINE_SET: if (mergedList[i] != null) { @@ -191,13 +173,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_TRI_STRIP_SET: if (mergedList[i] != null) { @@ -207,13 +183,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_TRI_FAN_SET: if (mergedList[i] != null) { @@ -223,13 +193,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_LINE_STRIP_SET: if (mergedList[i] != null) { @@ -239,13 +203,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_INDEXED_QUAD_SET: if (mergedList[i] != null) { @@ -255,13 +213,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_INDEXED_TRI_SET: if (mergedList[i] != null) { @@ -271,13 +223,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_INDEXED_POINT_SET: if (mergedList[i] != null) { @@ -287,13 +233,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_INDEXED_LINE_SET: if (mergedList[i] != null) { @@ -303,13 +243,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET: if (mergedList[i] != null) { @@ -319,13 +253,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_INDEXED_TRI_FAN_SET: if (mergedList[i] != null) { @@ -335,13 +263,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; case GeometryArrayRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET: if (mergedList[i] != null) { @@ -351,13 +273,7 @@ ArrayList> geometryInfo = null; geometryList.add(cgeo); cgeo.setSource(((SceneGraphObjectRetained)curList.get(0)).source); } - if (separateList[i] != null) { - ArrayList glist = separateList[i]; - for (int k = 0; k < glist.size(); k++) { - geometryList.add(glist.get(k)); - } - - } + addSeparateList(separateList[i]); break; } } @@ -365,7 +281,14 @@ ArrayList> geometryInfo = null; } +private void addSeparateList(ArrayList glist) { + if (glist == null) + return; + for (int k = 0; k < glist.size(); k++) { + geometryList.add(glist.get(k)); + } +} Bounds getCollisionBounds(int childIndex) { return collisionBound; } -- cgit v1.2.3