Ejemplo n.º 1
0
  public bool RemoveKnotAtPosition(Vector3 pos) {
    CameraPathKnot removeKnot = m_Path.GetKnotAtPosition(pos);
    if (removeKnot != null) {
      // If we're removing the last position knot, just destroy the whole path.
      if (removeKnot is CameraPathPositionKnot && m_Path.NumPositionKnots == 1) {
        WidgetManager.m_Instance.DeleteCameraPath(this);
      } else {
        TrTransform knotXf = TrTransform.TR(pos, removeKnot.transform.rotation);

        // Gather all the knots affected by this removal.
        List<CameraPathKnot> pks = m_Path.GetKnotsOrphanedByKnotRemoval(removeKnot);
        // If we have any knots affected by this change, we need to remove those first, before
        // we remove the original knot.  This is because, on undo, we need to add the parent
        // first, before adding all the orphaned knots.
        if (pks.Count > 0) {
          BaseCommand parent = new BaseCommand();
          for (int i = 0; i < pks.Count; ++i) {
            TrTransform childXf = TrTransform.TR(pos, pks[i].transform.rotation);
            new RemovePathKnotCommand(this, pks[i], childXf, parent);
          }
          new RemovePathKnotCommand(this, removeKnot, knotXf, parent);
          SketchMemoryScript.m_Instance.PerformAndRecordCommand(parent);
        } else {
          SketchMemoryScript.m_Instance.PerformAndRecordCommand(
              new RemovePathKnotCommand(this, removeKnot, knotXf));
        }
      }

      // Reset collision results after a delete.
      for (int i = 0; i < m_LastCollisionResults.Length; ++i) {
        m_LastCollisionResults[i].Set(null, CameraPathKnot.kDefaultControl, null, null);
      }
    }
    return removeKnot != null;
  }