aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2004-10-06 01:52:48 +0000
committerKevin Rushforth <[email protected]>2004-10-06 01:52:48 +0000
commit713f2d069ca4e891c251989deff8e0edd33a0814 (patch)
tree60c0f53e6c9b24fc87d4db52849182ef3afad035 /src
parentfe828671ea6e137c4caf9d119e601c6fb80543f0 (diff)
Issue number: 23
Obtained from: nvaidya Submitted by: kcr Reviewed by: kcr, jada Fixed Issue 23 : Enhancement to Reduce MemoryBloat in IndexedGeometryArray git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@53 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r--src/classes/share/javax/media/j3d/ExceptionStrings.properties3
-rw-r--r--src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java145
-rw-r--r--src/classes/share/javax/media/j3d/MorphRetained.java26
3 files changed, 133 insertions, 41 deletions
diff --git a/src/classes/share/javax/media/j3d/ExceptionStrings.properties b/src/classes/share/javax/media/j3d/ExceptionStrings.properties
index 9e8b25b..c3e8674 100644
--- a/src/classes/share/javax/media/j3d/ExceptionStrings.properties
+++ b/src/classes/share/javax/media/j3d/ExceptionStrings.properties
@@ -384,6 +384,9 @@ IndexedGeometryArray27=IndexedGeometryArray: index value less than zero
IndexedLineArray0=IndexedLineArray: illegal vertexCount
IndexedLineArray1=IndexedLineArray: illegal indexCount
IndexedGeometryArrayRetained0=execute() called on indexed geometry
+IndexedGeometryArrayRetained1=WARNING: Memory redundantly allocated for Color Indices array since the USE_COORD_INDEX_ONLY flag has been specified. This will throw a NPE in a subsequent version
+IndexedGeometryArrayRetained2=WARNING: Memory redundantly allocated for Normal Indices array since the USE_COORD_INDEX_ONLY flag has been specified. This will throw a NPE in a subsequent version
+IndexedGeometryArrayRetained3=WARNING: Memory redundantly allocated for TextureCoordinate Indices array since the USE_COORD_INDEX_ONLY flag has been specified. This will throw a NPE in a subsequent version
IndexedGeometryStripArray0=IndexedGeometryStripArray: no capability to get number of strips
IndexedGeometryStripArray1=IndexedGeometryStripArray: no capability to get strip index counts
IndexedGeometryStripArray2=IndexedGeometryStripArray: no capability to set strip index counts
diff --git a/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java
index 632e4ec..b36d9f1 100644
--- a/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java
+++ b/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java
@@ -51,21 +51,26 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
void createIndexedGeometryArrayData(int indexCount) {
this.indexCount = indexCount;
this.validIndexCount = indexCount;
+
+
+ boolean notUCIO = (this.vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0;
if((this.vertexFormat & GeometryArray.COORDINATES) != 0)
this.indexCoord = new int[indexCount];
- if((this.vertexFormat & GeometryArray.NORMALS) != 0)
+ if(((this.vertexFormat & GeometryArray.NORMALS) != 0) && notUCIO)
this.indexNormal = new int[indexCount];
- if((this.vertexFormat & GeometryArray.COLOR) != 0)
+ if(((this.vertexFormat & GeometryArray.COLOR) != 0) && notUCIO)
this.indexColor = new int[indexCount];
if((this.vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {
this.indexTexCoord = new Object[this.texCoordSetCount];
- for (int i = 0; i < this.texCoordSetCount; i++) {
- this.indexTexCoord[i] = new int[indexCount];
- }
+ if(notUCIO) {
+ for (int i = 0; i < this.texCoordSetCount; i++) {
+ this.indexTexCoord[i] = new int[indexCount];
+ }
+ }
maxTexCoordIndices = new int[texCoordSetCount];
}
}
@@ -581,8 +586,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
}
}
else {
- maxColorIndex = maxCoordIndex;
- this.indexColor[index] = colorIndex;
+ if ((vertexFormat & GeometryArray.COLOR) != 0) {
+ if (this.indexColor == null) {
+ this.indexColor = new int[indexCount];
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained1"));
+ }
+ }
+ this.indexColor[index] = colorIndex;
}
}
@@ -613,7 +623,12 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
}
}
else {
- maxColorIndex = maxCoordIndex;
+ if ((vertexFormat & GeometryArray.COLOR) != 0) {
+ if (this.indexColor == null) {
+ this.indexColor = new int[indexCount];
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained1"));
+ }
+ }
for (i=0, j = index; i < num;i++, j++) {
this.indexColor[j] = colorIndices[i];
}
@@ -644,7 +659,12 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
}
}
else {
- maxNormalIndex = maxCoordIndex;
+ if ((vertexFormat & GeometryArray.NORMALS) != 0) {
+ if (this.indexNormal == null) {
+ this.indexNormal = new int[indexCount];
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained2"));
+ }
+ }
this.indexNormal[index] = normalIndex;
}
@@ -676,7 +696,12 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
}
}
else {
- maxNormalIndex = maxCoordIndex;
+ if ((vertexFormat & GeometryArray.NORMALS) != 0) {
+ if (this.indexNormal == null) {
+ this.indexNormal = new int[indexCount];
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained2"));
+ }
+ }
for (i=0, j = index; i < num;i++, j++) {
this.indexNormal[j] = normalIndices[i];
}
@@ -709,7 +734,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
}
}
else {
- maxTexCoordIndices[texCoordSet] = maxCoordIndex;
+ if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {
+ if (indices == null) {
+ indices = new int[indexCount];
+ this.indexTexCoord[texCoordSet] = indices;
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained3"));
+ }
+ }
indices[index] = texCoordIndex;
}
@@ -746,7 +777,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
}
else {
- maxTexCoordIndices[texCoordSet] = maxCoordIndex;
+ if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {
+ if (indices == null) {
+ indices = new int[indexCount];
+ this.indexTexCoord[texCoordSet] = indices;
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained3"));
+ }
+ }
for (i=0, j = index; i < num;i++, j++) {
indices[j] = texCoordIndices[i];
}
@@ -786,6 +823,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
* @return the color index
*/
final int getColorIndex(int index) {
+ if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) &&
+ ((vertexFormat & GeometryArray.COLOR) != 0)) {
+ if (this.indexColor == null) {
+ this.indexColor = new int[indexCount];
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained1"));
+ }
+ }
return this.indexColor[index];
}
@@ -797,6 +841,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
*/
final void getColorIndices(int index, int colorIndices[]) {
int i, j, num = colorIndices.length;
+ if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) &&
+ ((vertexFormat & GeometryArray.COLOR) != 0)) {
+ if (this.indexColor == null) {
+ this.indexColor = new int[indexCount];
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained1"));
+ }
+ }
for (i=0, j = index;i < num;i++, j++)
{
@@ -811,6 +862,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
* @return the normal index
*/
final int getNormalIndex(int index) {
+ if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) &&
+ ((vertexFormat & GeometryArray.NORMALS) != 0)) {
+ if (this.indexNormal == null) {
+ this.indexNormal = new int[indexCount];
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained2"));
+ }
+ }
return this.indexNormal[index];
}
@@ -822,6 +880,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
*/
final void getNormalIndices(int index, int normalIndices[]) {
int i, j, num = normalIndices.length;
+ if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) &&
+ ((vertexFormat & GeometryArray.NORMALS) != 0)) {
+ if (this.indexNormal == null) {
+ this.indexNormal = new int[indexCount];
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained2"));
+ }
+ }
for (i=0, j = index;i < num;i++, j++)
{
@@ -837,7 +902,16 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
* @return the texture coordinate index
*/
final int getTextureCoordinateIndex(int texCoordSet, int index) {
- return ((int[])this.indexTexCoord[texCoordSet])[index];
+ int [] indices = (int[])this.indexTexCoord[texCoordSet];
+ if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) &&
+ ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0)) {
+ if (indices == null) {
+ indices = new int[indexCount];
+ this.indexTexCoord[texCoordSet] = indices;
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained3"));
+ }
+ }
+ return indices[index];
}
/**
@@ -850,6 +924,14 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
final void getTextureCoordinateIndices(int texCoordSet, int index, int texCoordIndices[]) {
int i, j, num = texCoordIndices.length;
int [] indices = (int[])this.indexTexCoord[texCoordSet];
+ if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) &&
+ ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0)) {
+ if (indices == null) {
+ indices = new int[indexCount];
+ this.indexTexCoord[texCoordSet] = indices;
+ System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained3"));
+ }
+ }
for (i=0, j = index;i < num;i++, j++)
{
@@ -1390,16 +1472,19 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
compileIndexCount = new int[numMerge];
compileIndexOffset = new int[numMerge];
indexCoord = new int[indexCount];
- if ((vertexFormat & GeometryArray.COLOR) != 0)
- indexColor = new int[indexCount];
- if ((vertexFormat & GeometryArray.NORMALS) != 0)
- indexNormal = new int[indexCount];
- // We only merge if texCoordSetCount = 1
- if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {
- indexTexCoord = new Object[1];
- indexTexCoord[0] = new int[indexCount];
- texCoord = (int[])indexTexCoord[0];
- }
+ boolean notUCIO = (vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0;
+ if (notUCIO) {
+ if ((vertexFormat & GeometryArray.COLOR) != 0)
+ indexColor = new int[indexCount];
+ if ((vertexFormat & GeometryArray.NORMALS) != 0)
+ indexNormal = new int[indexCount];
+ // We only merge if texCoordSetCount = 1
+ if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {
+ indexTexCoord = new Object[1];
+ indexTexCoord[0] = new int[indexCount];
+ texCoord = (int[])indexTexCoord[0];
+ }
+ }
int curDataOffset = 0;
int curIndexOffset = 0;
for (int i = 0; i < numMerge; i++) {
@@ -1409,12 +1494,14 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained {
// Copy all the indices
for (int j = 0; j < curIndexCount; j++) {
indexCoord[j+curIndexOffset] = geo.indexCoord[j+geo.initialIndexIndex]+curDataOffset;
- if ((vertexFormat & GeometryArray.COLOR) != 0)
- indexColor[j+curIndexOffset] = geo.indexColor[j+geo.initialIndexIndex]+curDataOffset;
- if ((vertexFormat & GeometryArray.NORMALS) != 0)
- indexNormal[j+curIndexOffset] = geo.indexNormal[j+geo.initialIndexIndex]+curDataOffset;
- if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0)
- texCoord[j+curIndexOffset] = ((int[])geo.indexTexCoord[0])[j+geo.initialIndexIndex]+curDataOffset;
+ if (notUCIO) {
+ if ((vertexFormat & GeometryArray.COLOR) != 0)
+ indexColor[j+curIndexOffset] = geo.indexColor[j+geo.initialIndexIndex]+curDataOffset;
+ if ((vertexFormat & GeometryArray.NORMALS) != 0)
+ indexNormal[j+curIndexOffset] = geo.indexNormal[j+geo.initialIndexIndex]+curDataOffset;
+ if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0)
+ texCoord[j+curIndexOffset] = ((int[])geo.indexTexCoord[0])[j+geo.initialIndexIndex]+curDataOffset;
+ }
}
maxCoordIndex = geo.maxCoordIndex +curDataOffset;
compileIndexOffset[i] = curIndexOffset;
diff --git a/src/classes/share/javax/media/j3d/MorphRetained.java b/src/classes/share/javax/media/j3d/MorphRetained.java
index ac3c0df..5a37fd8 100644
--- a/src/classes/share/javax/media/j3d/MorphRetained.java
+++ b/src/classes/share/javax/media/j3d/MorphRetained.java
@@ -1758,18 +1758,20 @@ class MorphRetained extends LeafRetained implements GeometryUpdater {
if ((vFormat & GeometryArray.COORDINATES) != 0) {
morphedGeo.setCoordinateIndices(0, igeo.indexCoord);
}
- if ((vFormat & GeometryArray.NORMALS) != 0) {
- morphedGeo.setNormalIndices(0, igeo.indexNormal);
- }
- if ((vFormat & GeometryArray.COLOR) != 0) {
- morphedGeo.setColorIndices(0, igeo.indexColor);
- }
- if ((vFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {
- for (k = 0; k < texCoordSetCount; k++) {
- morphedGeo.setTextureCoordinateIndices(k, 0,
- (int[]) igeo.indexTexCoord[k]);
- }
- }
+ if ((vFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) {
+ if ((vFormat & GeometryArray.NORMALS) != 0) {
+ morphedGeo.setNormalIndices(0, igeo.indexNormal);
+ }
+ if ((vFormat & GeometryArray.COLOR) != 0) {
+ morphedGeo.setColorIndices(0, igeo.indexColor);
+ }
+ if ((vFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {
+ for (k = 0; k < texCoordSetCount; k++) {
+ morphedGeo.setTextureCoordinateIndices(k, 0,
+ (int[]) igeo.indexTexCoord[k]);
+ }
+ }
+ }
}
this.morphedGeometryArray.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);