⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indexedgeometryarrayretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	}	else {	    int multiplier = getTexStride();	    if(( vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) {		if ((vertexFormat & GeometryArray.INTERLEAVED) == 0) {		    switch ((vertexType & GeometryArrayRetained.TEXCOORD_DEFINED)) {		    case TF:			FloatBufferWrapper texBuffer;			texBuffer = (FloatBufferWrapper)(((J3DBuffer) refTexCoordsBuffer[texCoordSet]).getBufferImpl());			if(refTexCoords[texCoordSet] != null &&  multiplier * newMax >= texBuffer.limit()) {			    throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray25"));			}			break;		    }		}		else {		    if(interleavedFloatBufferImpl != null && stride * newMax >= interleavedFloatBufferImpl.limit() ) {			throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray25"));		    }		}	    } else {		if ((vertexFormat & GeometryArray.INTERLEAVED) == 0) {		    switch ((vertexType & TEXCOORD_DEFINED)) {		    case TF:			if (refTexCoords[texCoordSet] != null && (multiplier * newMax >= ((float[])refTexCoords[texCoordSet]).length)) {			    throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray25"));			}			break;		    case T2F: 			if (refTexCoords[texCoordSet] != null && (newMax >= ((TexCoord2f[])refTexCoords[texCoordSet]).length)) {			    throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray25"));			}			break;		    case T3F: 			if (refTexCoords[texCoordSet] != null && (newMax >= ((TexCoord3f[])refTexCoords[texCoordSet]).length)) {			    throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray25"));			}			break;		    default:			break;		    }		}		else {		    if (interLeavedVertexData != null && (stride * newMax >= interLeavedVertexData.length)) {			throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray25"));		    }		}	    }	}    }    void doVertexAttrCheck(int newMax, int vertexAttrNum) {        // Check to make sure that the array length defined by the user is ateast maxVertexAttrIndex long        if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) == 0) {            return;        }        // Vertex attributes must not be interleaved        assert (vertexFormat & GeometryArray.INTERLEAVED) == 0;        if ((vertexFormat & GeometryArray.BY_REFERENCE) == 0) {            if (newMax >= vertexCount) {                throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray30"));            }        } else {            int multiplier = vertexAttrSizes[vertexAttrNum];            if(( vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) {                switch (vertexType & VATTR_DEFINED) {                case AF:                    if(multiplier * newMax >= floatBufferRefVertexAttrs[vertexAttrNum].limit()) {                        throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray30"));                    }                    break;                }            } else {                switch (vertexType & VATTR_DEFINED) {                case AF:                    if (multiplier * newMax >= floatRefVertexAttrs[vertexAttrNum].length) {                        throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray30"));                    }                    break;                }            }        }    }    /**     * Sets the coordinate index associated with the vertex at     * the specified index for this object.     * @param index the vertex index     * @param coordinateIndex the new coordinate index     */    final void setCoordinateIndex(int index, int coordinateIndex) {	int newMax;	newMax = doIndexCheck(index, maxCoordIndex, indexCoord, coordinateIndex);	if (newMax > maxCoordIndex) {	    doErrorCheck(newMax);	}	if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) {	    if ((vertexFormat & GeometryArray.COLOR) != 0) {		maxColorIndex = newMax;	    }	    if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {		for (int i = 0; i < texCoordSetCount; i++) {		    maxTexCoordIndices[i] = newMax;		}	    }	    if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {		for (int i = 0; i < vertexAttrCount; i++) {		    maxVertexAttrIndices[i] = newMax;		}	    }	    if ((vertexFormat & GeometryArray.NORMALS) != 0) {		maxNormalIndex = newMax;	    }	    	}		geomLock.getLock();	dirtyFlag |= INDEX_CHANGED;	this.indexCoord[index] = coordinateIndex;	maxCoordIndex = newMax;	geomLock.unLock();	if (!inUpdater && source != null && source.isLive()) {	    sendDataChangedMessage(true);	}    }    int doIndexCheck(int index, int maxIndex, int[] indices, int dataValue) {	int newMax = maxIndex;	if (index < initialIndexIndex)	    return newMax;	if (index >= (initialIndexIndex+validIndexCount))	    return newMax;	if (dataValue < 0) {	    // Throw an exception, since index is negative	    throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray27"));	    	}		if (newMax == indices[index]) {	    if (dataValue >= newMax) {		newMax = dataValue;	    }	    // Go thru the entire list and look for the max	    else {		for (int i = 0; i < indices.length; i++) {		    if (indices[i] > newMax) {			newMax = indices[i];		    }		}	    }	}	else if (dataValue  > newMax)  {	    newMax = dataValue;	}	return newMax;    }    int doIndicesCheck(int index, int maxIndex, int[] indices, int[] newIndices) {	int newMax = maxIndex;	boolean computeNewMax = false;	int i, j, num = newIndices.length;	boolean maxReset = false;	for (j = 0; j < num; j++) {	    if ((index+j) < initialIndexIndex)		continue;	    if ((index+j) >= (initialIndexIndex+validIndexCount))		continue;	    if (newIndices[j] < 0) {		// Throw an exception, since index is negative		throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray27"));	    	    }	    if (indices[index+j] == maxIndex) {		if (newIndices[j] >= newMax) {		    newMax = newIndices[j];		    computeNewMax = false;		    maxReset = true;		}		// Go thru the entire list and look for the max		// If in the new list there is no value that is >=		// to the old maximum		else if (!maxReset){		    computeNewMax = true;		}	    }	    else if (newIndices[j]  >= newMax)  {		newMax = newIndices[j];		computeNewMax = false;		maxReset = true;	    }	}	if (computeNewMax) {	    for (i = 0; i < indices.length; i++) {		if (indices[i] > newMax) {		    newMax = indices[i];		}	    }	}	return newMax;    }    /**     * Sets the coordinate indices associated with the vertices starting at     * the specified index for this object.     * @param index the vertex index     * @param coordinateIndices an array of coordinate indices     */    final void setCoordinateIndices(int index, int coordinateIndices[]) {	int newMax;	int i, j, num = coordinateIndices.length;	newMax = doIndicesCheck(index, maxCoordIndex, indexCoord, coordinateIndices);	if (newMax > maxCoordIndex) {	    doErrorCheck(newMax);	}	if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) {	    if ((vertexFormat & GeometryArray.COLOR) != 0) {		maxColorIndex = newMax;	    }	    if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {		for (i = 0; i < texCoordSetCount; i++) {		    maxTexCoordIndices[i] = newMax;		}	    }	    if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {		for (i = 0; i < vertexAttrCount; i++) {		    maxVertexAttrIndices[i] = newMax;		}	    }	    if ((vertexFormat & GeometryArray.NORMALS) != 0) {		maxNormalIndex = newMax;	    }	    	}		geomLock.getLock();	dirtyFlag |= INDEX_CHANGED;	maxCoordIndex = newMax;	for (i=0, j = index; i < num;i++, j++) {	    this.indexCoord[j] = coordinateIndices[i];	}	geomLock.unLock();	if (!inUpdater && source != null && source.isLive()) {	    sendDataChangedMessage(true);	}    }    //NVaidya    /**     * Sets the coordinate indices by reference to the specified array     * @param coordinateIndices an array of coordinate indices     */    final void setCoordIndicesRef(int coordinateIndices[]) {        int newMax = 0;        if (coordinateIndices != null) {            if (coordinateIndices.length < initialIndexIndex + validIndexCount) {                throw new IllegalArgumentException(J3dI18N.getString("IndexedGeometryArray33"));            }            //            // option 1: could fake the args to "re-use" doIndicesCheck()            //NVaidya            // newMax = doIndicesCheck(0, maxCoordIndex, coordinateIndices, coordinateIndices);            // if (newMax > maxCoordIndex) {            //     doErrorCheck(newMax);            // }            //            // option 2: same logic as in setInitialIndexIndex: Better, I Think ?            // computeMaxIndex() doesn't check for index < 0 while doIndicesCheck() does.            // So, a new method computeMaxIndexWithCheck            //NVaidya            newMax = computeMaxIndexWithCheck(initialIndexIndex, validIndexCount, coordinateIndices);            if (newMax > maxCoordIndex) {                doErrorCheck(newMax);            }        }        if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) {            if ((vertexFormat & GeometryArray.COLOR) != 0) {                maxColorIndex = newMax;            }            if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {                for (int i = 0; i < texCoordSetCount; i++) {                    maxTexCoordIndices[i] = newMax;                }            }            if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {                for (int i = 0; i < vertexAttrCount; i++) {                    maxVertexAttrIndices[i] = newMax;                }            }            if ((vertexFormat & GeometryArray.NORMALS) != 0) {                maxNormalIndex = newMax;            }        }        geomLock.getLock();        dirtyFlag |= INDEX_CHANGED;        maxCoordIndex = newMax;        this.indexCoord = coordinateIndices;        geomLock.unLock();        if (!inUpdater && source != null && source.isLive()) {            sendDataChangedMessage(true);        }    }    //NVaidya    /**     * trigger from GeometryArrayRetained#updateData()     * to recompute maxCoordIndex and perform index integrity checks     */    final void doPostUpdaterUpdate() {        // user may have called setCoordIndicesRef and/or        // changed contents of indexCoord array. Thus, need to        // recompute maxCoordIndex unconditionally (and redundantly         // if user had only invoked setCoordIndicesRef but not also         // changed contents). geomLock is currently locked.        // Option 1:        // simply call setCoordIndicesRef(indexCoord); but this seems to cause        // deadlock or freeze - probably because the !inUpdater branch sends        // out too many sendDataChangedMessage(true) - occurs if updateData        // method is called rapidly.        // setCoordIndicesRef(indexCoord);      // Option 2:    // use only necessary code from setCoordIndicesRef    // System.err.println("IndexedGeometryArrayretained#doUpdaterUpdate");	int newMax = 0;        if (indexCoord != null) {            newMax = computeMaxIndexWithCheck(initialIndexIndex, validIndexCount, indexCoord);            if (newMax > maxCoordIndex) {                 doErrorCheck(newMax);            }        }	if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) {	    if ((vertexFormat & GeometryArray.COLOR) != 0) {		maxColorIndex = newMax;	    }	    if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {		for (int i = 0; i < texCoordSetCount; i++) {		    maxTexCoordIndices[i] = newMax;		}	    }	    if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {		for (int i = 0; i < vertexAttrCount; i++) {		    maxVertexAttrIndices[i] = newMax;		}	    }	    if ((vertexFormat & GeometryArray.NORMALS) != 0) {		maxNormalIndex = newMax;	    }	    	}		dirtyFlag |= INDEX_CHANGED;	maxCoordIndex = newMax;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -