Пример #1
0
  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);
            }
          }
        }
      }
    }
  }
  void processChildLocalToVworld(
      ArrayList dirtyTransformGroups, ArrayList keySet, UpdateTargets targets, ArrayList blUsers) {

    synchronized (this) { // sync with setLive/clearLive
      if (inSharedGroup) {
        if (localToVworldKeys != null) {
          for (int j = 0; j < localToVworldKeys.length; j++) {
            if (perPathData[j].markedDirty) {
              updateChildLocalToVworld(
                  localToVworldKeys[j], j, dirtyTransformGroups, keySet, targets, blUsers);
            } else {
              // System.err.println("tg.procChild markedDiry skip");
            }
          }
        }
      } else {
        if (perPathData != null && perPathData[0].markedDirty) {
          updateChildLocalToVworld(dirtyTransformGroups, keySet, targets, blUsers);
        } else {
          // System.err.println("tg.procChild markedDiry skip");
        }
      }
    }
  }
  // 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);
                }
              }
            }
          }
        }
      }
    }
  }