void traverseSwitchChild( int child, HashKey key, int index, SwitchRetained switchRoot, boolean init, boolean swChanged, boolean switchOn, int switchLevel, ArrayList<SwitchState> updateList) { SwitchRetained sw; LinkRetained ln; Object obj; int i, j, k; ArrayList<NodeRetained> childSwitchLinks = childrenSwitchLinks.get(child); for (i = 0; i < childSwitchLinks.size(); i++) { obj = childSwitchLinks.get(i); if (obj instanceof SwitchRetained) { sw = (SwitchRetained) obj; for (j = 0; j < sw.children.size(); j++) { sw.traverseSwitchChild( j, key, index, switchRoot, init, swChanged, switchOn, switchLevel, updateList); } } else { // LinkRetained ln = (LinkRetained) obj; switchKey.set(key); switchKey.append(LinkRetained.plus).append(ln.nodeId); if (ln.sharedGroup.localToVworldKeys != null) { j = switchKey.equals( ln.sharedGroup.localToVworldKeys, 0, ln.sharedGroup.localToVworldKeys.length); if (j < 0) { System.err.println("SharedGroupRetained : Can't find hashKey"); } if (j < ln.sharedGroup.localToVworldKeys.length) { for (k = 0; k < ln.sharedGroup.children.size(); k++) { ln.sharedGroup.traverseSwitchChild( k, ln.sharedGroup.localToVworldKeys[j], j, switchRoot, init, swChanged, switchOn, switchLevel, updateList); } } } } } }
void updateChildLocalToVworld( HashKey key, int index, ArrayList<TransformGroupRetained> dirtyTransformGroups, ArrayList keySet, UpdateTargets targets, ArrayList blUsers) { LinkRetained ln; TransformGroupRetained tg; int i, j; Object obj; CachedTargets ct = j3dCTs[index]; if (ct != null) { targets.addCachedTargets(ct); if (ct.targetArr[Targets.BLN_TARGETS] != null) { gatherBlUsers(blUsers, ct.targetArr[Targets.BLN_TARGETS]); } } synchronized (childTransformLinks) { for (i = 0; i < childTransformLinks.size(); i++) { obj = childTransformLinks.get(i); if (obj instanceof TransformGroupRetained) { tg = (TransformGroupRetained) obj; tg.updateChildLocalToVworld( tg.localToVworldKeys[index], index, dirtyTransformGroups, keySet, targets, blUsers); } else { // LinkRetained ln = (LinkRetained) obj; currentKey.set(key); currentKey.append(LinkRetained.plus).append(ln.nodeId); if (ln.sharedGroup.localToVworldKeys != null) { j = currentKey.equals( ln.sharedGroup.localToVworldKeys, 0, ln.sharedGroup.localToVworldKeys.length); if (j < 0) { System.err.println("SharedGroupRetained : Can't find hashKey"); } if (j < ln.sharedGroup.localToVworldKeys.length) { ln.sharedGroup.updateChildLocalToVworld( ln.sharedGroup.localToVworldKeys[j], j, dirtyTransformGroups, keySet, targets, blUsers); } } } } } }
/** Get the last child localToVworld transform for a node */ Transform3D getLastChildLocalToVworld(HashKey key) { if (!inSharedGroup) { return childLocalToVworld[0][childLocalToVworldIndex[0][NodeRetained.LAST_LOCAL_TO_VWORLD]]; } else { int i = key.equals(localToVworldKeys, 0, localToVworldKeys.length); if (i >= 0) { return childLocalToVworld[i][childLocalToVworldIndex[i][NodeRetained.LAST_LOCAL_TO_VWORLD]]; } } return new Transform3D(); }
int[] processViewSpecificInfo( int mode, HashKey key, View v, ArrayList vsgList, int[] keyList, ArrayList leaflist) { int hkIndex = 0; Integer hashInt = null; int[] newKeyList = null; // Get the intersection of the viewList with this view, if (source.isLive()) { if (inSharedGroup) { hkIndex = key.equals(localToVworldKeys, 0, localToVworldKeys.length); } if (mode == ADD_VIEW) { ArrayList parentList = (ArrayList) parentLists.get(hkIndex); parentList.add(v); } else if (mode == REMOVE_VIEW) { ArrayList parentList = (ArrayList) parentLists.get(hkIndex); parentList.remove(v); } if (apiViewList.contains(v)) { // System.err.println("processViewSpecificInfo, this = "+this+" key = "+key); vsgList.add(this); if (keyList.length < vsgList.size()) { // System.err.println("====> allocating new array"); newKeyList = new int[keyList.length + 20]; System.arraycopy(keyList, 0, newKeyList, 0, keyList.length); keyList = newKeyList; } if (mode == ADD_VIEW) { if (inSharedGroup) { keyList[vsgList.size() - 1] = hkIndex; } else { keyList[vsgList.size() - 1] = 0; } } else if (mode == REMOVE_VIEW) { if (inSharedGroup) { keyList[vsgList.size() - 1] = hkIndex; } else { keyList[vsgList.size() - 1] = 0; } } return super.processViewSpecificInfo(mode, key, v, vsgList, keyList, leaflist); } } return keyList; }
// for non-shared case void updateChildLocalToVworld( ArrayList dirtyTransformGroups, ArrayList keySet, UpdateTargets targets, ArrayList blUsers) { int i, j; Object obj; Transform3D lToVw, childLToVw; TransformGroupRetained tg; LinkRetained ln; CachedTargets ct; synchronized (this) { // sync with setLive/clearLive if (localToVworld != null) { perPathData[0].markedDirty = false; // update immediate child's localToVworld if (perPathData[0].switchState.currentSwitchOn) { lToVw = getCurrentLocalToVworld(0); childLToVw = getUpdateChildLocalToVworld(0); childLToVw.mul(lToVw, currentTransform); dirtyTransformGroups.add(this); ct = j3dCTs[0]; if (ct != null) { targets.addCachedTargets(ct); if (ct.targetArr[Targets.BLN_TARGETS] != null) { gatherBlUsers(blUsers, ct.targetArr[Targets.BLN_TARGETS]); } } } else { perPathData[0].switchDirty = true; // System.err.println("tg.updateChild skip"); } // update child's localToVworld of its children // transformLink contains top level transform group nodes // and link nodes synchronized (childTransformLinks) { for (i = 0; i < childTransformLinks.size(); i++) { obj = childTransformLinks.get(i); if (obj instanceof TransformGroupRetained) { tg = (TransformGroupRetained) obj; tg.updateChildLocalToVworld(dirtyTransformGroups, keySet, targets, blUsers); } else { // LinkRetained ln = (LinkRetained) obj; currentKey.reset(); currentKey.append(locale.nodeId); currentKey.append(LinkRetained.plus).append(ln.nodeId); if ((ln.sharedGroup != null) && (ln.sharedGroup.localToVworldKeys != null)) { j = currentKey.equals( ln.sharedGroup.localToVworldKeys, 0, ln.sharedGroup.localToVworldKeys.length); if (j < 0) { System.err.println("TransformGroupRetained : Can't find hashKey"); } if (j < ln.sharedGroup.localToVworldKeys.length) { ln.sharedGroup.updateChildLocalToVworld( ln.sharedGroup.localToVworldKeys[j], j, dirtyTransformGroups, keySet, targets, blUsers); } } } } } } } }