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); } } } } } }
public boolean equals(Object object) { boolean isEqual = false; HashKey hashKey; if (object instanceof HashKey) { hashKey = (HashKey) object; ConnectionAnchor hkA1 = hashKey.getFirstAnchor(); ConnectionAnchor hkA2 = hashKey.getSecondAnchor(); isEqual = (hkA1.equals(anchor1) && hkA2.equals(anchor2)) || (hkA1.equals(anchor2) && hkA2.equals(anchor1)); } return isEqual; }
public ObjectSink[] getSinks() { if (this.sinks != null) { return sinks; } ObjectSink[] sinks = new ObjectSink[size()]; int at = 0; if (this.hashedFieldIndexes != null) { // Iterate the FieldIndexes to see if any are hashed for (FieldIndex fieldIndex = this.hashedFieldIndexes.getFirst(); fieldIndex != null; fieldIndex = fieldIndex.getNext()) { if (!fieldIndex.isHashed()) { continue; } // this field is hashed so set the existing hashKey and see if there is a sink for it final int index = fieldIndex.getIndex(); final Iterator it = this.hashedSinkMap.newIterator(); for (ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next()) { HashKey hashKey = (HashKey) entry.getKey(); if (hashKey.getIndex() == index) { sinks[at++] = (ObjectSink) entry.getValue(); } } } } if (this.hashableSinks != null) { for (ObjectSinkNode sink = this.hashableSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode()) { sinks[at++] = sink; } } if (this.otherSinks != null) { for (ObjectSinkNode sink = this.otherSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode()) { sinks[at++] = sink; } } this.sinks = sinks; return sinks; }
/** 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(); }
public boolean equals(final Object object) { final HashKey other = (HashKey) object; if (this.isNull) { return (other.isNull); } if (this.index != other.index) { return false; } switch (this.type) { case BOOL: return this.bvalue == other.getBooleanValue(); case LONG: return this.lvalue == other.getLongValue(); case DOUBLE: return this.dvalue == other.getDoubleValue(); case OBJECT: final Object otherValue = other.getObjectValue(); return this.ovalue == null ? otherValue == null : this.ovalue.equals(otherValue); } return false; }
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; }
void addView(View view) { int i; Integer mtype = new Integer(ADD_VIEW); apiViewList.add(view); if (source.isLive() && view != null) { // Gather all affected leaf nodes and send a message to // RenderingEnv and RenderBin if (inSharedGroup) { ArrayList parentList; for (int k = 0; k < localToVworldKeys.length; k++) { parentList = (ArrayList) parentLists.get(k); // If the parentList contains this view or if this is the // first VSG then .. if (parentList == null || parentList.contains(view)) { Object[] objAry = new Object[4]; ArrayList addVsgList = new ArrayList(); ArrayList addLeafList = new ArrayList(); int[] addKeyList = new int[10]; HashKey key = localToVworldKeys[k]; addVsgList.add(this); addKeyList[0] = k; objAry[0] = view; objAry[1] = addVsgList; objAry[2] = addLeafList; /* for (int n = 0; n < addLeafList.size(); n++) { System.err.println("Shared:n = "+n+" addLeafList = "+addLeafList.get(n)); } */ objAry[3] = super.processViewSpecificInfo( ADD_VIEW, (HashKey) key, view, addVsgList, addKeyList, addLeafList); J3dMessage message = new J3dMessage(); message.type = J3dMessage.VIEWSPECIFICGROUP_CHANGED; message.threads = (J3dThread.UPDATE_RENDERING_ENVIRONMENT | J3dThread.UPDATE_RENDER | J3dThread.UPDATE_SOUND | J3dThread.SOUND_SCHEDULER); message.universe = universe; message.args[0] = mtype; message.args[1] = objAry; VirtualUniverse.mc.processMessage(message); } } } else { ArrayList parentList = (ArrayList) parentLists.get(0); // If the parentList contains this view or if this is the // first VSG then .. if (parentList == null || parentList.contains(view)) { Object[] objAry = new Object[4]; ArrayList addVsgList = new ArrayList(); ArrayList addLeafList = new ArrayList(); int[] addKeyList = new int[10]; objAry[0] = view; objAry[1] = addVsgList; objAry[2] = addLeafList; addVsgList.add(this); addKeyList[0] = 0; tempKey.reset(); objAry[3] = super.processViewSpecificInfo( ADD_VIEW, tempKey, view, addVsgList, addKeyList, addLeafList); /* for (int n = 0; n < addLeafList.size(); n++) { System.err.println("n = "+n+" addLeafList = "+addLeafList.get(n)); } */ J3dMessage message = new J3dMessage(); message.type = J3dMessage.VIEWSPECIFICGROUP_CHANGED; message.threads = (J3dThread.UPDATE_RENDERING_ENVIRONMENT | J3dThread.UPDATE_RENDER | J3dThread.UPDATE_SOUND | J3dThread.SOUND_SCHEDULER); message.universe = universe; message.args[0] = mtype; message.args[1] = objAry; VirtualUniverse.mc.processMessage(message); } } } }
void setView(View view, int index) { int i; View oldView = (View) apiViewList.get(index); Integer mtype = new Integer(SET_VIEW); if (oldView == view) return; apiViewList.set(index, view); if (source.isLive()) { // Gather all affected leaf nodes and send a message to // RenderingEnv and RenderBin if (inSharedGroup) { ArrayList parentList; for (int k = 0; k < localToVworldKeys.length; k++) { parentList = (ArrayList) parentLists.get(k); Object[] objAry = new Object[8]; ArrayList addVsgList = new ArrayList(); ArrayList removeVsgList = new ArrayList(); ArrayList addLeafList = new ArrayList(); ArrayList removeLeafList = new ArrayList(); int[] addKeyList = new int[10]; int[] removeKeyList = new int[10]; objAry[0] = view; objAry[1] = addVsgList; objAry[2] = addLeafList; objAry[4] = oldView; objAry[5] = removeVsgList; objAry[6] = removeLeafList; HashKey key = localToVworldKeys[k]; if (oldView != null && (parentList == null || parentList.contains(oldView))) { removeVsgList.add(this); removeKeyList[0] = k; objAry[7] = super.processViewSpecificInfo( REMOVE_VIEW, (HashKey) key, oldView, removeVsgList, removeKeyList, removeLeafList); } if (view != null && (parentList == null || parentList.contains(view))) { addVsgList.add(this); addKeyList[0] = k; objAry[3] = super.processViewSpecificInfo( ADD_VIEW, (HashKey) key, view, addVsgList, addKeyList, addLeafList); } J3dMessage message = new J3dMessage(); message.type = J3dMessage.VIEWSPECIFICGROUP_CHANGED; message.threads = (J3dThread.UPDATE_RENDERING_ENVIRONMENT | J3dThread.UPDATE_RENDER | J3dThread.UPDATE_SOUND | J3dThread.SOUND_SCHEDULER); message.universe = universe; message.args[0] = mtype; message.args[1] = objAry; VirtualUniverse.mc.processMessage(message); } } else { ArrayList parentList = (ArrayList) parentLists.get(0); Object[] objAry = new Object[8]; ArrayList addVsgList = new ArrayList(); ArrayList removeVsgList = new ArrayList(); ArrayList addLeafList = new ArrayList(); ArrayList removeLeafList = new ArrayList(); int[] addKeyList = new int[10]; int[] removeKeyList = new int[10]; objAry[0] = view; objAry[1] = addVsgList; objAry[2] = addLeafList; objAry[4] = oldView; objAry[5] = removeVsgList; objAry[6] = removeLeafList; tempKey.reset(); if (oldView != null && (parentList == null || parentList.contains(oldView))) { removeVsgList.add(this); removeKeyList[0] = 0; objAry[7] = super.processViewSpecificInfo( REMOVE_VIEW, (HashKey) tempKey, oldView, removeVsgList, removeKeyList, removeLeafList); } if (view != null && (parentList == null || parentList.contains(view))) { tempKey.reset(); addVsgList.add(this); addKeyList[0] = 0; objAry[3] = super.processViewSpecificInfo( ADD_VIEW, (HashKey) tempKey, view, addVsgList, addKeyList, addLeafList); } J3dMessage message = new J3dMessage(); message.type = J3dMessage.VIEWSPECIFICGROUP_CHANGED; message.threads = (J3dThread.UPDATE_RENDERING_ENVIRONMENT | J3dThread.UPDATE_RENDER | J3dThread.UPDATE_SOUND | J3dThread.SOUND_SCHEDULER); message.universe = universe; message.args[0] = mtype; message.args[1] = objAry; VirtualUniverse.mc.processMessage(message); } } }
// 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); } } } } } } } }