/// <summary> /// Finds a set of predefined points on an edge. Normally it's only /// three - start, middle and end. If the edge type is "principal" /// and the target has a Collide.Shape, additional points at the surface /// of the shape may appear. /// </summary> /// <param name="edge">Edge to find predefined points on.</param> /// <returns>Iterator to point on the edge.</returns> private IEnumerable <Vector3> FindPredefinedEdgePoints(MeshUtils.Edge edge) { yield return(edge.Start); yield return(edge.Center); yield return(edge.End); if (edge.Type == MeshUtils.Edge.EdgeType.Triangle || m_collectedData == null || m_collectedData.Target == null || m_collectedData.Target.GetComponent <Shape>() == null) { yield break; } ShapeUtils utils = m_collectedData.Target.GetComponent <Shape>().GetUtils(); if (utils == null) { yield break; } ShapeUtils.Direction[] edgeDirections = ShapeUtils.ToDirection(ShapeUtils.ToPrincipal(utils.FindDirectionGivenWorldEdge(edge))); yield return(utils.GetWorldFace(edgeDirections[0])); yield return(utils.GetWorldFace(edgeDirections[1])); }
private void Update(bool symmetricScale) { if (Shape == null) { return; } ShapeUtils utils = Shape.GetUtils(); if (utils == null) { return; } Undo.RecordObject(Shape, "ShapeResizeTool"); Undo.RecordObject(Shape.transform, "ShapeResizeToolTransform"); Color color = Color.gray; float scale = 0.35f; foreach (ShapeUtils.Direction dir in System.Enum.GetValues(typeof(ShapeUtils.Direction))) { Vector3 delta = DeltaSliderTool(utils.GetWorldFace(dir), utils.GetWorldFaceDirection(dir), color, scale); if (delta.magnitude > 1.0E-5f) { Vector3 localSizeChange = Shape.transform.InverseTransformDirection(delta); Vector3 localPositionDelta = 0.5f * localSizeChange; if (!symmetricScale && utils.IsHalfSize(dir)) { localSizeChange *= 0.5f; } utils.UpdateSize(localSizeChange, dir); if (!symmetricScale) { Shape.transform.position += Shape.transform.TransformDirection(localPositionDelta); } } } }