001: /*
002: * $RCSfile: CachedTargets.java,v $
003: *
004: * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.6 $
028: * $Date: 2008/02/28 20:17:20 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: class CachedTargets {
035: // cached targets, used by J3d threads
036:
037: // 0 - Data type is GeometryAtom.
038: // 1 - Data type is Light, Fog, Background, ModelClip, AlternateAppearance,
039: // Clip
040: // 2 - Data type is BehaviorRetained.
041: // 3 - Data type is Sound or Soundscape
042: // 4 - Data type is ViewPlatformRetained.
043: // 5 - Data type is BoundingLeafRetained.
044: // 6 - Data type is GroupRetained.
045:
046: // Order of index is as above.
047: // The handling of BoundingLeaf isn't optimize. Target threads should be
048: // more specific.
049:
050: static String typeString[] = { "GEO_TARGETS", "ENV_TARGETS",
051: "BEH_TARGETS", "SND_TARGETS", "VPF_TARGETS", "BLN_TARGETS",
052: "GRP_TARGETS", };
053:
054: static int updateTargetThreads[] = {
055: // GEO
056: J3dThread.UPDATE_TRANSFORM | J3dThread.UPDATE_RENDER
057: | J3dThread.UPDATE_GEOMETRY,
058:
059: // ENV
060: J3dThread.UPDATE_RENDER
061: | J3dThread.UPDATE_RENDERING_ENVIRONMENT,
062:
063: // BEH
064: J3dThread.UPDATE_BEHAVIOR,
065:
066: // SND
067: J3dThread.UPDATE_SOUND | J3dThread.SOUND_SCHEDULER,
068:
069: // VPF
070: J3dThread.UPDATE_RENDER | J3dThread.UPDATE_BEHAVIOR
071: | J3dThread.UPDATE_SOUND
072: | J3dThread.SOUND_SCHEDULER,
073:
074: // BLN
075: J3dThread.UPDATE_RENDER
076: | J3dThread.UPDATE_RENDERING_ENVIRONMENT
077: | J3dThread.UPDATE_BEHAVIOR
078: | J3dThread.UPDATE_SOUND,
079:
080: // GRP
081: J3dThread.UPDATE_TRANSFORM | J3dThread.UPDATE_GEOMETRY };
082:
083: NnuId targetArr[][] = new NnuId[Targets.MAX_NODELIST][];
084:
085: int computeTargetThreads() {
086: int targetThreads = 0;
087:
088: for (int i = 0; i < Targets.MAX_NODELIST; i++) {
089: if (targetArr[i] != null) {
090: targetThreads |= updateTargetThreads[i];
091: }
092: }
093: return targetThreads;
094: }
095:
096: void copy(CachedTargets ct) {
097:
098: for (int i = 0; i < Targets.MAX_NODELIST; i++) {
099: targetArr[i] = ct.targetArr[i];
100: }
101: }
102:
103: void replace(NnuId oldObj, NnuId newObj, int type) {
104:
105: NnuId[] newArr = new NnuId[targetArr[type].length];
106: System.arraycopy(targetArr[type], 0, newArr, 0,
107: targetArr[type].length);
108: targetArr[type] = newArr;
109: NnuIdManager.replace((NnuId) oldObj, (NnuId) newObj,
110: (NnuId[]) targetArr[type]);
111: }
112:
113: void dump() {
114: for (int i = 0; i < Targets.MAX_NODELIST; i++) {
115: if (targetArr[i] != null) {
116: System.err.println(" " + typeString[i]);
117: for (int j = 0; j < targetArr[i].length; j++) {
118: System.err.println(" " + targetArr[i][j]);
119: }
120: }
121: }
122: }
123:
124: }
|