📄 noderetained.java
字号:
return new Transform3D(); } /** * Get the last localToVworld transform for a node */ Transform3D getLastLocalToVworld() { if (localToVworld != null) { return localToVworld[0][localToVworldIndex[0][LAST_LOCAL_TO_VWORLD]]; } else { return new Transform3D(); } } Transform3D getLastLocalToVworld(int index) { return localToVworld[index][localToVworldIndex[index][LAST_LOCAL_TO_VWORLD]]; } Transform3D getLastLocalToVworld(HashKey key) { if (localToVworld != null) { if (!inSharedGroup) { return localToVworld[0][localToVworldIndex[0][LAST_LOCAL_TO_VWORLD]]; } else { int i = key.equals(localToVworldKeys, 0, localToVworldKeys.length); if(i>= 0) { return localToVworld[i][localToVworldIndex[i][LAST_LOCAL_TO_VWORLD]]; } } } return new Transform3D(); } // Do nothing for NodeRetained. void setAuxData(SetLiveState s, int index, int hkIndex) { } void setNodeData(SetLiveState s) { localToVworld = s.localToVworld; localToVworldIndex = s.localToVworldIndex; localToVworldKeys = s.localToVworldKeys; // reference to the last branchGroupPaths branchGroupPaths = s.parentBranchGroupPaths; parentTransformLink = s.parentTransformLink; parentSwitchLink = s.parentSwitchLink; } // set pickable, recursively update cache result void setPickable(boolean pickable) { if (this.pickable == pickable) return; this.pickable = pickable; if (source.isLive()) { synchronized(universe.sceneGraphLock) { boolean pick[]; if (!inSharedGroup) { pick = new boolean[1]; } else { pick = new boolean[localToVworldKeys.length]; } findPickableFlags(pick); updatePickable(localToVworldKeys, pick); } } } void updatePickable(HashKey pickKeys[], boolean pick[]) { for (int i=0; i < pick.length; i++) { if (!pickable) { pick[i] = false; } } } // get pickable boolean getPickable() { return pickable; } // set collidable, recursively update cache result void setCollidable(boolean collidable) { if (this.collidable == collidable) return; this.collidable = collidable; if (source.isLive()) { synchronized(universe.sceneGraphLock) { boolean collide[]; if (!inSharedGroup) { collide = new boolean[1]; } else { collide = new boolean[localToVworldKeys.length]; } findCollidableFlags(collide); updateCollidable(localToVworldKeys, collide); } } } // get collidable boolean getCollidable() { return collidable; } void updateCollidable(HashKey keys[], boolean collide[]) { for (int i=0; i < collide.length; i++) { if (!collidable) { collide[i] = false; } } } /** * For the default, just pass up to parent */ void notifySceneGraphChanged(boolean globalTraverse){} void recombineAbove() {} synchronized void updateLocalToVworld() {} void setLive(SetLiveState s) { int oldrefCount = refCount; doSetLive(s); if (oldrefCount <= 0) super.markAsLive(); } // The default set of setLive actions. void doSetLive(SetLiveState s) { int i; int oldrefCount = refCount; refCount += s.refCount; if(!(locale == null || universe == s.universe)) throw new IllegalSharingException(J3dI18N.getString("NodeRetained3")); if(s.locale == null) System.err.println("NodeRetained.setLive() locale is null"); locale = s.locale; inSharedGroup = s.inSharedGroup; if (oldrefCount <= 0) { if (listIdx == null) { universe = s.universe; } else { // sync with getIdxUsed() if (s.universe != universe) { synchronized (this) { universe = s.universe; incIdxUsed(); } } } } s.universe.numNodes++; // pickable & collidable array have the same length for (i=0; i < s.pickable.length; i++) { if (!pickable) { s.pickable[i] = false; } if (!collidable) { s.collidable[i] = false; } } if (oldrefCount <= 0) super.doSetLive(s); if (inBackgroundGroup) { geometryBackground = s.geometryBackground; } setNodeData(s); } /** * remove the localToVworld transform for this node. */ void removeNodeData(SetLiveState s) { if (refCount <= 0) { localToVworld = null; localToVworldIndex = null; localToVworldKeys = null; // restore to default and avoid calling clear() // that may clear parent reference branchGroupPaths branchGroupPaths = new ArrayList(1); parentTransformLink = null; parentSwitchLink = null; } else { // Set it back to its parent localToVworld data. This is b/c the parent has // changed it localToVworld data arrays. localToVworld = s.localToVworld; localToVworldIndex = s.localToVworldIndex; localToVworldKeys = s.localToVworldKeys; // Reference of parent branchGroupPaths will not change // no need to reset parentSwitchLink or parentTransformLink // because there are not per path data } } // The default set of clearLive actions void clearLive(SetLiveState s) { refCount-=s.refCount; if (refCount <= 0) { super.clearLive(); // don't remove the nodeId unless there are no more references if (nodeId != null) { universe.nodeIdFreeList.addElement(nodeId); nodeId = null; } } universe.numNodes--; removeNodeData(s); if(refCount <= 0) { locale = null; geometryBackground = null; } } // search up the parent to determine if this node is pickable void findPickableFlags(boolean pick[]) { NodeRetained nodeR = this; if (!inSharedGroup) { pick[0] = true; nodeR = nodeR.parent; while (nodeR != null) { if (!nodeR.pickable) { pick[0] = false; break; } nodeR = nodeR.parent; } } else { HashKey key; for (int i=0; i < pick.length; i++) { nodeR = this; pick[i] = true; key = new HashKey(localToVworldKeys[i]); do { if (nodeR instanceof SharedGroupRetained) { String nodeId = key.getLastNodeId(); Vector parents = ((SharedGroupRetained) nodeR).parents; int sz = parents.size(); NodeRetained prevNodeR = nodeR; for(int j=0; j< sz; j++) { NodeRetained linkR = (NodeRetained) parents.elementAt(j); if (linkR.nodeId.equals(nodeId)) { nodeR = linkR; break; } } if (prevNodeR == nodeR) { // branch is already detach return; } } else { nodeR = nodeR.parent; } if (nodeR == null) break; if (!nodeR.pickable) { pick[i] = false; break; } } while (true); } } } // search up the parent to determine if this node is collidable void findCollidableFlags(boolean collide[]) { NodeRetained nodeR = this; if (!inSharedGroup) { collide[0] = true; nodeR = nodeR.parent; while (nodeR != null) { if (!nodeR.collidable) { collide[0] = false; break; } nodeR = nodeR.parent; } } else { HashKey key; for (int i=0; i < collide.length; i++) { nodeR = this; collide[i] = true; key = new HashKey(localToVworldKeys[i]); do { if (nodeR instanceof SharedGroupRetained) { String nodeId = key.getLastNodeId(); Vector parents = ((SharedGroupRetained) nodeR).parents; int sz = parents.size(); NodeRetained prevNodeR = nodeR; for(int j=0; j< sz; j++) { NodeRetained linkR = (NodeRetained) parents.elementAt(j); if (linkR.nodeId.equals(nodeId)) { nodeR = linkR; break; } } if (nodeR == prevNodeR) { return; } } else { nodeR = nodeR.parent; } if (nodeR == null) break; if (!nodeR.collidable) { collide[i] = false; break; } } while (true); } } } void findTransformLevels(int transformLevels[]) { NodeRetained nodeR = this; TransformGroupRetained tg; if (!inSharedGroup) { transformLevels[0] = -1; while (nodeR != null) { if (nodeR.nodeType == NodeRetained.TRANSFORMGROUP) { tg = (TransformGroupRetained)nodeR; transformLevels[0] = tg.transformLevels[0]; break; } nodeR = nodeR.parent; } } else { HashKey key; int i,j; for (i=0; i < transformLevels.length; i++) { nodeR = this; transformLevels[i] = -1; key = new HashKey(localToVworldKeys[i]); do { if (nodeR == null) break; else if (nodeR instanceof SharedGroupRetained) { // note that key is truncated after getLastNodeId String nodeId = key.getLastNodeId(); Vector parents = ((SharedGroupRetained) nodeR).parents; int sz = parents.size(); NodeRetained prevNodeR = nodeR; for (j=0; j< sz; j++) { NodeRetained linkR = (NodeRetained) parents.elementAt(j); if (linkR.nodeId.equals(nodeId)) { nodeR = linkR; break; } } if (prevNodeR == nodeR) { // branch is already detach return; } } else if (nodeR.nodeType == NodeRetained.TRANSFORMGROUP) { tg = (TransformGroupRetained)nodeR; if (tg.inSharedGroup) { j = key.equals(tg.localToVworldKeys, 0, tg.localToVworldKeys.length); transformLevels[i] = tg.transformLevels[j]; } else { transformLevels[i] = tg.transformLevels[0]; } break; } nodeR = nodeR.parent; } while (true); } } } boolean isStatic() { if (source.getCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ) || source.getCapability(Node.ALLOW_PARENT_READ) || source.getCapability(Node.ENABLE_PICK_REPORTING) || source.getCapability(Node.ENABLE_COLLISION_REPORTING) || source.getCapability(Node.ALLOW_BOUNDS_READ) || source.getCapability(Node.ALLOW_BOUNDS_WRITE) || source.getCapability(Node.ALLOW_PICKABLE_READ) || source.getCapability(Node.ALLOW_PICKABLE_WRITE) || source.getCapability(Node.ALLOW_COLLIDABLE_READ) || source.getCapability(Node.ALLOW_COLLIDABLE_WRITE) || source.getCapability(Node.ALLOW_AUTO_COMPUTE_BOUNDS_READ) || source.getCapability(Node.ALLOW_AUTO_COMPUTE_BOUNDS_WRITE)) { return false; } return true; } void merge(CompileState compState) { staticTransform = compState.staticTransform; if (compState.parentGroup != null) { compState.parentGroup.compiledChildrenList.add(this); } parent = compState.parentGroup; if (staticTransform != null) { mergeTransform(staticTransform); } } void mergeTransform(TransformGroupRetained xform) { if (localBounds != null) { localBounds.transform(xform.transform); } } int[] processViewSpecificInfo(int mode, HashKey k, View v, ArrayList vsgList, int[] keyList, ArrayList leafList) { return keyList; } VirtualUniverse getVirtualUniverse() { return universe; } void searchGeometryAtoms(UnorderList list) {} /** * Make the boundsCache of this node and all its parents dirty */ void dirtyBoundsCache() { // Possible optimisation is to not traverse up the tree // if the cachedBounds==null. However this is not the case // if the node is the child of a SharedGroup if (VirtualUniverse.mc.cacheAutoComputedBounds) { cachedBounds = null; if (parent!=null) { parent.dirtyBoundsCache(); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -