示例#1
0
        public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount)
        {
            base.PerformRelevantOperation(name, iShapeIndex, iShapeCount);


            if (name == RO_ADJUST_BBOX)
            {
                ShapeLink src = GetVisibilityLinkSource();
                if (src == null || src.Links.Count == 0)
                {
                    return;
                }

                BoundingBox newbbox = new BoundingBox();
                foreach (LinkTarget tgt in src.Links)
                {
                    BoundingBox bbox = tgt.OwnerShape.AbsoluteBoundingBox;
                    if (bbox != null && bbox.Valid)
                    {
                        newbbox.AddBox(bbox);
                    }
                }
                if (newbbox.Valid)
                {
                    EditorManager.Actions.StartGroup(RO_ADJUST_BBOX);
                    Vector3F size = new Vector3F(newbbox.SizeX, newbbox.SizeY, newbbox.SizeZ);
                    EditorManager.Actions.Add(new MoveShapeAction(this, this.Position, newbbox.Center));
                    EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSize", size));

                    EditorManager.Actions.EndGroup();
                }
            }

            if (name == RO_LINK_TO_TOUCHING_SHAPES || name == RO_LINK_TO_SHAPES_INSIDE)
            {
                EvaluateBBoxLinksVisitor visitor = new EvaluateBBoxLinksVisitor(this, name == RO_LINK_TO_TOUCHING_SHAPES);
                foreach (Layer layer in EditorManager.Scene.Layers)
                {
                    if (layer.Modifiable)
                    {
                        layer.Root.RunVisitor(visitor);
                    }
                }

                if (visitor.RelevantTargets.Count > 0)
                {
                    LinkSource linkSrc = GetVisibilityLinkSource();
                    EditorManager.Actions.StartGroup(name);
                    foreach (LinkTarget target in visitor.RelevantTargets)
                    {
                        EditorManager.Actions.Add(new LinkAction(linkSrc, target));
                    }

                    EditorManager.Actions.EndGroup();
                }
            }
        }
    public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount)
    {
      base.PerformRelevantOperation(name, iShapeIndex, iShapeCount);

      if (name == RO_RECENTER)
      {
        ShapeCollection shapes = GetRelevantShapes();
        TriggerRecenterPosition(shapes);
        return;
      }

     #if (MESHGROUP_USE_LINKING)
      if (name == RO_ADJUST_BBOX)
      {
        ShapeLink src = GetGroupStaticMeshesLinkSource();
        if (src == null || src.Links.Count == 0)
          return;

        BoundingBox newbbox = new BoundingBox();
        foreach (LinkTarget tgt in src.Links)
        {
          BoundingBox bbox = tgt.OwnerShape.AbsoluteBoundingBox;
          if (bbox != null && bbox.Valid)
            newbbox.AddBox(bbox);
        }
        if (newbbox.Valid)
        {
          EditorManager.Actions.StartGroup(RO_ADJUST_BBOX);
          Vector3F size = new Vector3F(newbbox.SizeX,newbbox.SizeY,newbbox.SizeZ);
          EditorManager.Actions.Add(new MoveShapeAction(this,this.Position,newbbox.Center));
          EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSize", size));

          EditorManager.Actions.EndGroup();
        }
      }

      if (name == RO_LINK_TO_TOUCHING_SHAPES || name == RO_LINK_TO_SHAPES_INSIDE)
      {
        EvaluateBBoxLinksVisitor visitor = new EvaluateBBoxLinksVisitor(this, name == RO_LINK_TO_TOUCHING_SHAPES);
        foreach (Layer layer in EditorManager.Scene.Layers)
          if (layer.Modifiable)
            layer.Root.RunVisitor(visitor);

        if (visitor.RelevantTargets.Count > 0)
        {
          LinkSource linkSrc = GetGroupStaticMeshesLinkSource();
          EditorManager.Actions.StartGroup(name);
          foreach (LinkTarget target in visitor.RelevantTargets)
            EditorManager.Actions.Add(new LinkAction(linkSrc, target));

          EditorManager.Actions.EndGroup();
        }
      }
     #endif
    }