private static void SetPointScale(Vector3 handlePos, PathPoint point) { Vector3 tangentDir = point.GetPointSpaceTangent(PathTangentType.Out); Quaternion pivotRotation = Quaternion.LookRotation(tangentDir); Quaternion roll = Quaternion.AngleAxis(point.normalAngle, Vector3.back); float handleSize = HandleUtility.GetHandleSize(handlePos); EditorGUI.BeginChangeCheck(); Vector2 scale = Handles.ScaleHandle(point.scale, handlePos, _currentPath.transform.rotation * pivotRotation * roll, handleSize); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_currentPath, "Scale Path Point"); EditorUtility.SetDirty(_currentPath); point.scale = scale; } }
private static void SetPointRotation(PathPoint point) { EditorGUI.BeginChangeCheck(); Vector3 tangentDir = _currentPath.transform.rotation * point.GetPointSpaceTangent(PathTangentType.Out); Quaternion pivotRotation = Quaternion.LookRotation(tangentDir); Quaternion roll = Quaternion.AngleAxis(point.normalAngle, Vector3.back); Vector3 pointWorldPos = CurveSpaceToWorldSpace(point.position); float handleSize = HandleUtility.GetHandleSize(pointWorldPos); Quaternion newRot = Handles.Disc(pivotRotation * roll, pointWorldPos, tangentDir, handleSize, false, 0.0f); //Line rotation Quaternion lineRot = newRot * Quaternion.Inverse(pivotRotation) * Quaternion.LookRotation(tangentDir, _currentPath.transform.up); Handles.DrawLine(pointWorldPos + lineRot * Vector3.left * handleSize, pointWorldPos + lineRot * Vector3.right * handleSize); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_currentPath, "Rotate Point"); EditorUtility.SetDirty(_currentPath); float deltaRot = -((point.normalAngle % 360) + newRot.eulerAngles.z); /*if (_lastDeltaRotation * (deltaRot) < 0.0f && Mathf.Abs(deltaRot) > 180.0f) * { * Debug.Log(deltaRot); * if(deltaRot > 0) * { * deltaRot -= 360.0f; * } * else * { * deltaRot += 360.0f; * } * * Debug.Log("Loop"); * }*/ //Debug.Log("Delta Rotation : " + (-(point.normalAngle + newRot.eulerAngles.z))); //float point.normalAngle += deltaRot; _lastDeltaRotation = deltaRot; } }