diff --git a/Assets/ModuleCore.meta b/Assets/ModuleCore.meta index 30b63dc..565e233 100644 --- a/Assets/ModuleCore.meta +++ b/Assets/ModuleCore.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cdc05b7235085b54c80ff09c008ac6ad +guid: 7f0d0a697d5393b45817a072ec3776bd folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmEdge.cs b/Assets/ModuleCore/ModuleAlgorithm/AlgorithmEdge.cs deleted file mode 100644 index 36ecf9a..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmEdge.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -/// -/// 算法:中心角度排序法 -/// 依据:??? -/// -public class AlgorithmEdge : ModuleAlgorithm { - /// 算法:中心角度排序法 - public AlgorithmEdge() { } - - public class EdgeAngle { - public float angle; - public Vector3 position; - } - - public override void Compute(DataPlate data) { - //List edgePoints = data.edgePoints; - ////计算多边形中心点 - //float x = edgePoints.Average((v3) => v3.x); - //float y = edgePoints.Average((v3) => v3.y); - //Vector2 center = new Vector2(x, y); - ////计算所有点的夹角 - //Vector3 direction = edgePoints[0] - center; - //List angleList = new List(); - //for (int i = 0; i < edgePoints.Count; i++) { - // Vector3 normal = edgePoints[i] - center; - // EdgeAngle edgeAngle = new EdgeAngle(); - // edgeAngle.angle = Angle(direction, normal); - // edgeAngle.position = normal; - // angleList.Add(edgeAngle); - //} - //data.centerOffset = center; - ////排序 - //angleList.Sort((x, y) => x.angle.CompareTo(y.angle)); - ////把排序好的边缘点重新添加 - //data.edgePoints = new List(); - //for (int i = 0; i < angleList.Count; i++) { - // data.edgePoints.Add(angleList[i].position); - //} - } - /// - /// 计算两点夹角 - /// - /// 0度点位置 - /// 目标点 - /// - private float Angle(Vector3 direction, Vector3 position) { - float angle = Vector2.SignedAngle(direction, position); - return angle; - } - - protected override void Awake() { - throw new System.NotImplementedException(); - } -} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSidePoint.cs b/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSidePoint.cs deleted file mode 100644 index 769e6ba..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSidePoint.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 计算位置到边上最近的点 -/// -//public class AlgorithmSidePoint : ModuleAlgorithm { - -// protected override void Awake() => ModuleCore.AlgorithmSidePoint = this; - -// public override void Compute(DataIntersect data) { -// Vector3 position = data.position - data.side.plate.designPosition; -// for (int i = 0; i < data.side.lines.Length; i++) { -// DataLine line = data.side.lines[i]; -// if (!Compute(line, position, out Vector3 intersectPoint)) { continue; } -// data.isIntersect = true; -// data.intersectPoint = intersectPoint + data.side.plate.designPosition; -// return; -// } -// } - -// /// 查询匹配的边 -// private bool Compute(DataLine line, Vector3 position, out Vector3 intersectPoint) { -// return ProjectDistance(line.a, line.b, position, out intersectPoint); -// } - -// /// -// /// 向量投影法 -// /// 计算点c到线段ab最近的点 -// /// -// /// -// /// -// /// -// /// 如果不在线段上返回 false -// public static bool ProjectDistance(Vector3 a, Vector3 b, Vector3 c, out Vector3 intersectPoint) { -// Vector3 ab = b - a; -// Vector3 ac = c - a; -// Vector3 p = Vector3.Project(ac, ab.normalized); -// intersectPoint = p + a; -// if (ab.normalized != p.normalized) { return false; } -// if (ab.magnitude < p.magnitude) { return false; } -// return true; -// } -//} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSimplePolygon.cs b/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSimplePolygon.cs deleted file mode 100644 index b2adec3..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSimplePolygon.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 散列点生成简单多边形算法 -/// -public class AlgorithmSimplePolygon : ModuleAlgorithm { - private UnitAlgorithm AlgorithmSideSubdivision = new UnitAlgorithmJobsSideSubdivision(); - private UnitAlgorithm AlgorithmTriangle = new UnitAlgorithmEarCutting(); - private UnitAlgorithm AlgorithmMergeTriangle = new UnitAlgorithmMergeTriangle(); - - protected override void Awake() => ModuleCore.AlgorithmSimplePolygon = this; - - public override void Compute(DataPlate plate) { - //遍历计算边(DataSide)上的细分点(positions)和线(lines) - AlgorithmSideSubdivision.Compute(plate.dataDesign); - //计算三角面 - AlgorithmTriangle.Compute(plate.dataDesign); - //三角面列表转换网格 - AlgorithmMergeTriangle.Compute(plate.dataDesign); - } -} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSubdivisionPolygon.cs b/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSubdivisionPolygon.cs deleted file mode 100644 index 594f235..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSubdivisionPolygon.cs +++ /dev/null @@ -1,1188 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Unity.Burst; -using Unity.Collections; -using Unity.Jobs; -using UnityEngine; - -/// -/// 细分多边形算法 -/// -public class AlgorithmSubdivisionPolygon : ModuleAlgorithm { - private static readonly float Subdivide = 0.1f; - private UnitAlgorithm bezierPolygonSide = new BezierPolygonSide(); - - private UnitAlgorithm Boundary = new PolygonalBoundary(); - private UnitAlgorithm Vertex = new VertexSubdivision(); - //private UnitAlgorithm sideVertex = new SideSubdivision(); - private UnitAlgorithm Triangle = new DrawTriangle(); - - protected override void Awake() => ModuleCore.AlgorithmSubdivisionPolygon = this; - - public override void Compute(DataPlate plate) { - Polygon polygon = To(plate); - //第一次计算边长 - bezierPolygonSide.Compute(polygon); - //第二次计算细分边长 - bezierPolygonSide.Compute(polygon); - - //Chronoscope("细分多边形计算耗时:", () => { - // //粗糙细分,生成边界 - // Boundary.Compute(plate); - // //计算顶点 - // Vertex.Compute(plate); - // //计算边点 - // SideVertex.Compute(plate); - // //计算三角面 - // Triangle.Compute(plate); - //}); - } - - #region 数据转换 - public Polygon To(DataPlate plate) { - Polygon polygon = new Polygon(); - polygon.sides = new PolygonSide[plate.plateSides.Count]; - for (int i = 0; i < plate.plateSides.Count; i++) { - polygon.sides[i] = To(plate.plateSides[i]); - } - return polygon; - } - public PolygonSide To(DataPlateSide plateSide) { - PolygonSide polygonSide = new PolygonSide(); - polygonSide.quotient = 20; - polygonSide.bezier = plateSide.bezier; - polygonSide.aPoint = plateSide.aPoint.position; - polygonSide.bPoint = plateSide.bPoint.position; - polygonSide.aBezier = plateSide.aBezier; - polygonSide.bBezier = plateSide.bBezier; - return polygonSide; - } - #endregion - - #region 数据结构 - public struct Polygon { - /// 多边形边 - public PolygonSide[] sides; - /// 多边形边界 - public PolygonBorder border; - } - public struct PolygonBorder { - /// minX - public float minX; - /// maxX - public float maxX; - /// minY - public float minY; - /// maxY - public float maxY; - /// 多边形边界点 - public Vector3[] positions; - - /// 边界宽 - public float Wide => maxX - minX; - /// 边界高 - public float High => maxY - minY; - /// 网格宽 - public int GridWide => Mathf.FloorToInt(Wide / Subdivide) + 1; - /// 网格高 - public int GridHigh => Mathf.FloorToInt(High / Subdivide) + 1; - /// 最小点 - public Vector3 MinPoint => new Vector3(minX, minY, 0); - /// 最大点 - public Vector3 MaxPoint => new Vector3(maxX, maxY, 0); - } - public struct PolygonSide { - /// 细分数 - public int quotient; - /// 长度 - public float length; - /// 贝塞尔类型 - public Bezier bezier; - /// a点 - public Vector3 aPoint; - /// b点 - public Vector3 bPoint; - /// a点贝塞尔点 - public Vector3 aBezier; - /// b点贝塞尔点 - public Vector3 bBezier; - - /// - public Vector3[] positions; - /// 线 - public PolygonLine[] lines; - /// 边点 - public PolygonSideVertex[] vertexs; - } - public struct PolygonSideVertex { - /// 到边起点的距离 - public float origin; - /// 位置 - public Vector3 position; - } - public struct PolygonLine { - /// 线段起点a - public Vector3 a; - /// 线段终点b - public Vector3 b; - /// 到边起点的距离 - public float origin; - } - #endregion - - #region 计时器 - /// 是否启用计时器 - public static readonly bool isEnableTimer = true; - /// 计时器 - public static void Chronoscope(string content, Action action) { - if (!isEnableTimer) { action?.Invoke(); return; } - float time = Time.realtimeSinceStartup; - action?.Invoke(); - float consumed = Time.realtimeSinceStartup - time; - Debug.Log($"{content}{consumed * 1000}"); - } - #endregion - - #region 算法函数 - /// - /// 一阶贝塞尔算法 - /// - /// 起点 - /// 终点 - /// 进度 - /// - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, float t) { - return a + (b - a) * t; - } - /// - /// 二阶贝塞尔算法 - /// - /// 起点 - /// 贝塞尔点 - /// 终点 - /// 进度 - /// 当前进度的曲线点 - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, float t) { - Vector3 aa = a + (b - a) * t; - Vector3 bb = b + (c - b) * t; - return aa + (bb - aa) * t; - } - /// - /// 三阶贝塞尔算法 - /// - /// 起点 - /// 起点的贝塞尔点 - /// 终点的贝塞尔点 - /// 终点 - /// 进度 - /// 当前进度的曲线点 - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float t) { - Vector3 aa = a + (b - a) * t; - Vector3 bb = b + (c - b) * t; - Vector3 cc = c + (d - c) * t; - - Vector3 aaa = aa + (bb - aa) * t; - Vector3 bbb = bb + (cc - bb) * t; - return aaa + (bbb - aaa) * t; - } - /// - /// 边界数据 - /// - /// 边界点数组 - /// - public static DataBorder Border(Vector3[] points) { - float minX = 0; float minY = 0; - float maxX = 0; float maxY = 0; - for (int i = 0; i < points.Length; i++) { - if (points[i].x < minX) { minX = points[i].x; } - if (points[i].x > maxX) { maxX = points[i].x; } - if (points[i].y < minY) { minY = points[i].y; } - if (points[i].y > maxY) { maxY = points[i].y; } - } - return new DataBorder(minX, maxX, minY, maxY, points); - } - /// - /// 数组索引转换网格xy - /// - /// - /// - /// - /// - public static Vector2Int IndexToXY(int index, int wide) { - int y = Math.DivRem(index, wide, out int x); - return new Vector2Int(x, y); - } - /// - /// 网格xy转换数组索引 - /// - /// - /// - public static int XYToIndex(Vector2Int v2, int wide) { - return v2.y * wide + v2.x; - } - /// - /// 校验xy是否超限 - /// - /// - /// - /// - /// - /// - public static bool TryXY(int x, int y, int wide, int high) { - return x >= 0 && x < wide && y >= 0 && y < high; - } - /// - /// 转角法查询位置是否在板片内 - /// - /// 按顺序组成多边形的顶点 - /// 位置 - /// - public static bool FindPlateInside(NativeArray points, Vector3 position) { - double angles = 0; - for (int i = 0; i < points.Length; i++) { - Vector3 a = points[LoopIndexTool.LoopIndex(i + 0, points.Length)] - position; - Vector3 b = points[LoopIndexTool.LoopIndex(i + 1, points.Length)] - position; - float angle = Vector2.SignedAngle(a, b); - angles += angle; - } - int normal = (int)(angles * 1000); - return normal > 1000; - } - /// - /// 计算AB与CD两条线段的交点. - /// - /// A点 - /// B点 - /// C点 - /// D点 - /// AB与CD的交点 - /// 是否相交 true:相交 false:未相交 - public static bool TryGetIntersectPoint(Vector3 a, Vector3 b, Vector3 c, Vector3 d, out Vector3 intersectPos) { - intersectPos = Vector3.zero; - - Vector3 ab = b - a; - Vector3 ca = a - c; - Vector3 cd = d - c; - - Vector3 v1 = Vector3.Cross(ca, cd); - // 不共面 - if (Mathf.Abs(Vector3.Dot(v1, ab)) > 1e-6) { return false; } - // 平行 - if (Vector3.Cross(ab, cd).sqrMagnitude <= 1e-6) { return false; } - - Vector3 ad = d - a; - Vector3 cb = b - c; - // 快速排斥 - if (Mathf.Min(a.x, b.x) > Mathf.Max(c.x, d.x) || Mathf.Max(a.x, b.x) < Mathf.Min(c.x, d.x) - || Mathf.Min(a.y, b.y) > Mathf.Max(c.y, d.y) || Mathf.Max(a.y, b.y) < Mathf.Min(c.y, d.y) - || Mathf.Min(a.z, b.z) > Mathf.Max(c.z, d.z) || Mathf.Max(a.z, b.z) < Mathf.Min(c.z, d.z)) { - return false; - } - - // 跨立试验 - if (Vector3.Dot(Vector3.Cross(-ca, ab), Vector3.Cross(ab, ad)) > 0 - && Vector3.Dot(Vector3.Cross(ca, cd), Vector3.Cross(cd, cb)) > 0) { - Vector3 v2 = Vector3.Cross(cd, ab); - float ratio = Vector3.Dot(v1, v2) / v2.sqrMagnitude; - intersectPos = a + ab * ratio; - return true; - } - - return false; - } - #endregion - - #region 贝塞尔曲线化多边形的边 - public class BezierPolygonSide : UnitAlgorithm { - - #region 执行 - public void Compute(Polygon polygon) { - //创建作业任务 - int count = polygon.sides.Length; - NativeArray jobs = new NativeArray(count, Allocator.Temp); - NativeArray handles = new NativeArray(count, Allocator.Temp); - for (int i = 0; i < count; i++) { - jobs[i] = To(polygon.sides[i]); - handles[i] = jobs[i].Schedule(); - } - //执行作业 - JobHandle.CompleteAll(handles); - //转换数据 - for (int i = 0; i < count; i++) { To(jobs[i], polygon.sides[i]); } - } - #endregion - - #region 转换 - /// 转换作业数据 - private JobBezierPolygonSide To(PolygonSide polygonSide) { - JobBezierPolygonSide jobBezierPolygonSide = new JobBezierPolygonSide(); - jobBezierPolygonSide.quotient = polygonSide.quotient; - jobBezierPolygonSide.bezier = polygonSide.bezier; - jobBezierPolygonSide.aPoint = polygonSide.aPoint; - jobBezierPolygonSide.bPoint = polygonSide.bPoint; - jobBezierPolygonSide.aBezier = polygonSide.aBezier; - jobBezierPolygonSide.bBezier = polygonSide.bBezier; - - int quotient = polygonSide.quotient; - jobBezierPolygonSide.length = new NativeArray(1, Allocator.TempJob); - jobBezierPolygonSide.positions = new NativeArray(quotient, Allocator.TempJob); - jobBezierPolygonSide.lines = new NativeArray(quotient - 1, Allocator.TempJob); - return jobBezierPolygonSide; - } - /// 转换托管数据 - private void To(JobBezierPolygonSide job, PolygonSide polygonSide) { - polygonSide.quotient = (int)(Subdivide / job.length[0]); - polygonSide.length = job.length[0]; - polygonSide.positions = job.positions.ToArray(); - polygonSide.lines = job.lines.ToArray(); - job.length.Dispose(); - job.positions.Dispose(); - job.lines.Dispose(); - } - #endregion - - #region Jobs - [BurstCompile] - public struct JobBezierPolygonSide : IJob { - /// 细分数 - public int quotient; - /// 贝塞尔类型 - public Bezier bezier; - /// a点 - public Vector3 aPoint; - /// b点 - public Vector3 bPoint; - /// a点贝塞尔点 - public Vector3 aBezier; - /// b点贝塞尔点 - public Vector3 bBezier; - - /// 长度 - public NativeArray length; - /// - public NativeArray positions; - /// 线 - public NativeArray lines; - - public void Execute() { - //细分点 - if (bezier == Bezier.一阶) { ComputeBezierA(); } - if (bezier == Bezier.二阶) { ComputeBezierB(); } - if (bezier == Bezier.三阶) { ComputeBezierC(); } - //线段 - for (int i = 0; i < quotient - 1; i++) { - PolygonLine line = new PolygonLine(); - line.a = positions[i]; - line.b = positions[i + 1]; - line.origin = length[0]; - lines[i] = line; - length[0] += Vector3.Distance(line.a, line.b); - } - } - public void ComputeBezierA() { - Vector3 a = aPoint; - Vector3 b = bPoint; - for (int i = 0; i < quotient; i++) { - float t = i / (float)(quotient - 1); - positions[i] = ComputeBezier(a, b, t); - } - } - public void ComputeBezierB() { - Vector3 a = aPoint; - Vector3 b = aBezier; - Vector3 c = bPoint; - for (int i = 0; i < quotient; i++) { - float t = i / (float)(quotient - 1); - positions[i] = ComputeBezier(a, b, c, t); - } - } - public void ComputeBezierC() { - Vector3 a = aPoint; - Vector3 b = aBezier; - Vector3 c = bBezier; - Vector3 d = bPoint; - for (int i = 0; i < quotient; i++) { - float t = i / (float)(quotient - 1); - positions[i] = ComputeBezier(a, b, c, d, t); - } - } - } - #endregion - - } - - #endregion - - #region 多边形边界 - public class PolygonalBorder : UnitAlgorithm { - - #region 执行 - public void Compute(Polygon polygon) { - int count = polygon.sides.Length; - //创建作业任务 - JobPolygonalBorder job = To(polygon); - //执行作业 - JobHandle dependency = new JobHandle(); - JobHandle handle = job.Schedule(count, dependency); - handle.Complete(); - //转换数据 - polygon.border = To(job); - //释放 - job.border.Dispose(); - job.positions.Dispose(); - } - #endregion - - #region 转换 - private JobPolygonalBorder To(Polygon polygon) { - List positions = new List(); - for (int i = 0; i < polygon.sides.Length; i++) { - positions.AddRange(polygon.sides[i].positions); - } - - JobPolygonalBorder jobPolygonalBorder = new JobPolygonalBorder(); - jobPolygonalBorder.border = new NativeArray(4, Allocator.TempJob); - jobPolygonalBorder.positions = new NativeArray(positions.ToArray(), Allocator.TempJob); - return jobPolygonalBorder; - } - private PolygonBorder To(JobPolygonalBorder job) { - PolygonBorder border = new PolygonBorder(); - border.minX = job.border[0]; - border.maxX = job.border[1]; - border.minY = job.border[2]; - border.maxY = job.border[3]; - border.positions = job.positions.ToArray(); - return border; - } - #endregion - - #region Jobs - [BurstCompile] - public struct JobPolygonalBorder : IJobFor { - /// 0 = minX , 1 = MaxX , 2 = minY, 3 = MaxY - public NativeArray border; - /// - public NativeArray positions; - - public void Execute(int index) { - Vector3 position = positions[index]; - if (position.x < border[0]) { border[0] = position.x; } - if (position.x > border[1]) { border[1] = position.x; } - if (position.y < border[2]) { border[2] = position.y; } - if (position.y > border[3]) { border[3] = position.y; } - } - } - #endregion - - } - #endregion - - #region 边缘细分顶点 - public class SideSubdivisionVertex : UnitAlgorithm { - - #region 执行 - public void Compute(Polygon polygon) { - //创建作业任务 - int count = polygon.sides.Length; - NativeArray jobs = new NativeArray(count, Allocator.Temp); - NativeArray handles = new NativeArray(count, Allocator.Temp); - for (int i = 0; i < count; i++) { - jobs[i] = To(polygon, polygon.sides[i]); - handles[i] = jobs[i].Schedule(); - } - //执行作业 - JobHandle.CompleteAll(handles); - //转换数据 - for (int i = 0; i < count; i++) { To(jobs[i], polygon.sides[i]); } - } - #endregion - - #region 转换 - private JobSideVertex To(Polygon polygon, PolygonSide polygonSide) { - JobSideVertex jobSideVertex = new JobSideVertex(); - jobSideVertex.gridWide = polygon.border.GridWide; - jobSideVertex.gridHigh = polygon.border.GridHigh; - jobSideVertex.interval = Subdivide; - jobSideVertex.minX = polygon.border.minX; - jobSideVertex.maxX = polygon.border.maxX; - jobSideVertex.minY = polygon.border.minY; - jobSideVertex.maxY = polygon.border.maxY; - jobSideVertex.minPoint = polygon.border.MinPoint; - jobSideVertex.lines = new NativeArray(polygonSide.lines, Allocator.TempJob); - jobSideVertex.vertexs = new NativeList(Allocator.TempJob); - return jobSideVertex; - } - /// 转换托管数据 - private void To(JobSideVertex job, PolygonSide polygonSide) { - polygonSide.vertexs = job.vertexs.ToArray(); - job.lines.Dispose(); - job.vertexs.Dispose(); - } - #endregion - - #region Jobs - [BurstCompile] - public struct JobSideVertex : IJob { - /// 网格宽 - public int gridWide; - /// 网格高 - public int gridHigh; - /// 网格间隔 - public float interval; - /// minX - public float minX; - /// maxX - public float maxX; - /// minY - public float minY; - /// maxY - public float maxY; - /// 原点 - public Vector3 minPoint; - /// 输入边线 - public NativeArray lines; - - /// 输出边点 - public NativeList vertexs; - - public void Execute() { - for (int x = 0; x < gridWide; x++) { - Vector3 a = new Vector3(minX + x * interval, minY - 1); - Vector3 b = new Vector3(minX + x * interval, maxY + 1); - Subdivision(a, b); - } - for (int y = 0; y < gridHigh; y++) { - Vector3 a = new Vector3(minX - 1, minY + y * interval); - Vector3 b = new Vector3(maxX + 1, minY + y * interval); - Subdivision(a, b); - } - } - public void Subdivision(Vector3 a, Vector3 b) { - for (int i = 0; i < lines.Length; i++) { - PolygonLine line = lines[i]; - if (!TryGetIntersectPoint(a, b, line.a, line.b, out Vector3 intersectPoint)) { continue; } - float distance = Vector3.Distance(line.a, intersectPoint) + line.origin; - PolygonSideVertex sideVertex = new PolygonSideVertex(); - sideVertex.origin = distance; - sideVertex.position = intersectPoint; - vertexs.Add(sideVertex); - } - } - } - #endregion - - } - #endregion - - #region 内部细分顶点 - public class InsideSubdivisionVertex : UnitAlgorithm { - - #region 执行 - public void Compute(Polygon data) { - throw new NotImplementedException(); - } - #endregion - - #region 转换 - - #endregion - - #region Jobs - - #endregion - - } - #endregion - - #region 多边形边界 - public class PolygonalBoundary : UnitAlgorithm { - - #region 执行 - public void Compute(DataPlate plate) { - int count = plate.plateSides.Count; - List plateSides = plate.plateSides; - //创建作业任务 - NativeArray jobs = new NativeArray(count, Allocator.Temp); - NativeArray handles = new NativeArray(count, Allocator.Temp); - for (int i = 0; i < count; i++) { - jobs[i] = DataPlateSideToJobSideSubdivision(plateSides[i], 10); - handles[i] = jobs[i].Schedule(); - } - //执行作业 - JobHandle.CompleteAll(handles); - //转换数据 - List points = new List(); - for (int i = 0; i < count; i++) { - OutputSideToDataPlateSide(jobs[i].outputSide, plateSides[i]); - points.AddRange(plateSides[i].dataBaking.positions); - } - plate.dataBaking.border = Border(points.Distinct().ToArray()); - } - #endregion - - #region Jobs - [BurstCompile] - public struct JobPolygonalBoundary : IJob { - /// 输入 - public InputSide inputSide; - /// 输出 - public OutputSide outputSide; - - public void Execute() { - //细分点 - for (int i = 0; i < inputSide.quotient; i++) { - float t = i / (float)(inputSide.quotient - 1); - if (inputSide.bezier == Bezier.一阶) { - outputSide.positions[i] = ComputeBezier(inputSide.aPoint, inputSide.bPoint, t); - } - if (inputSide.bezier == Bezier.二阶) { - outputSide.positions[i] = ComputeBezier(inputSide.aPoint, inputSide.aBezier, inputSide.bPoint, t); - } - if (inputSide.bezier == Bezier.三阶) { - outputSide.positions[i] = ComputeBezier(inputSide.aPoint, inputSide.aBezier, inputSide.bBezier, inputSide.bPoint, t); - } - } - - //线段 - for (int i = 0; i < inputSide.quotient - 1; i++) { - OutputLine line = new OutputLine(); - line.a = outputSide.positions[i]; - line.b = outputSide.positions[i + 1]; - line.origin = outputSide.length; - outputSide.lines[i] = line; - outputSide.length += Vector3.Distance(line.a, line.b); - } - } - } - #endregion - - #region 转换 - /// 转换作业数据 - private JobPolygonalBoundary DataPlateSideToJobSideSubdivision(DataPlateSide plateSide, int quotient) { - InputSide inputSide = new InputSide(); - inputSide.bezier = plateSide.bezier; - inputSide.aPoint = plateSide.aPoint.position; - inputSide.bPoint = plateSide.bPoint.position; - inputSide.aBezier = plateSide.aBezier; - inputSide.bBezier = plateSide.bBezier; - inputSide.quotient = quotient; - - OutputSide outputSide = new OutputSide(); - outputSide.positions = new NativeArray(quotient, Allocator.TempJob); - outputSide.lines = new NativeArray(quotient - 1, Allocator.TempJob); - - JobPolygonalBoundary jobPolygonalBoundary = new JobPolygonalBoundary(); - jobPolygonalBoundary.inputSide = inputSide; - jobPolygonalBoundary.outputSide = outputSide; - return jobPolygonalBoundary; - } - /// 转换托管数据 - private void OutputSideToDataPlateSide(OutputSide output, DataPlateSide plateSide) { - DataPlateSideBaking baking = plateSide.dataBaking; - baking.length = output.length; - baking.positions = output.positions.ToArray(); - DataPlateLine[] lines = new DataPlateLine[output.lines.Length]; - for (int i = 0; i < output.lines.Length; i++) { - lines[i] = OutputLineToDataPlateLine(output.lines[i]); - } - baking.lines = lines; - output.positions.Dispose(); - output.lines.Dispose(); - } - /// 转换托管数据 - public DataPlateLine OutputLineToDataPlateLine(OutputLine output) { - DataPlateLine line = new DataPlateLine(); - line.a = output.a; - line.b = output.b; - line.origin = output.origin; - return line; - } - #endregion - - #region 输入 - public struct InputSide { - /// 贝塞尔类型 - public Bezier bezier; - /// a点 - public Vector3 aPoint; - /// b点 - public Vector3 bPoint; - /// a点贝塞尔点 - public Vector3 aBezier; - /// b点贝塞尔点 - public Vector3 bBezier; - /// 细分数 - public int quotient; - } - #endregion - - #region 输出 - public struct OutputSide { - /// 总长度 - public float length; - /// - public NativeArray positions; - /// 线 - public NativeArray lines; - } - public struct OutputLine { - /// 线段起点a - public Vector3 a; - /// 线段终点b - public Vector3 b; - /// 边原点距离 - public float origin; - } - #endregion - - } - #endregion - - #region 顶点细分 - public class VertexSubdivision : UnitAlgorithm { - - #region 执行 - public void Compute(DataPlate plate) { - DataBorder border = plate.dataBaking.border; - //创建作业任务 - int maxIndex = border.GridWide * border.GridHigh; - JobVertex job = new JobVertex(); - job.input = DataPlateToInputInitialize(plate); - job.outputVertices = new NativeArray(maxIndex, Allocator.TempJob); - //执行作业 - JobHandle handle = job.Schedule(maxIndex, 32); - handle.Complete(); - //转换数据 - plate.dataBaking.vertexs = OutputVertexToDataPlateVertex(job.outputVertices); - //释放 - job.input.points.Dispose(); - job.outputVertices.Dispose(); - } - #endregion - - #region Jobs - [BurstCompile] - public struct JobVertex : IJobParallelFor { - /// 输入 - [ReadOnly] public InputInitialize input; - /// 输出 - public NativeArray outputVertices; - - public void Execute(int index) { - Vector2Int v2 = IndexToXY(index, input.wide); - Vector3 position = new Vector3(v2.x, v2.y) * input.interval + input.origin; - OutputVertex vertex = new OutputVertex(); - vertex.isValid = FindPlateInside(input.points, position); - vertex.position = position; - outputVertices[index] = vertex; - } - } - #endregion - - #region 转换 - private InputInitialize DataPlateToInputInitialize(DataPlate plate) { - DataBorder border = plate.dataBaking.border; - InputInitialize inputInitialize = new InputInitialize(); - inputInitialize.wide = border.GridWide; - inputInitialize.interval = border.smooth; - inputInitialize.origin = border.MinPoint; - inputInitialize.points = new NativeArray(border.points, Allocator.TempJob); - return inputInitialize; - } - private DataPlateVertex[] OutputVertexToDataPlateVertex(NativeArray outputVertices) { - DataPlateVertex[] array = new DataPlateVertex[outputVertices.Length]; - for (int i = 0; i < outputVertices.Length; i++) { - DataPlateVertex vertex = new DataPlateVertex(); - vertex.isValid = outputVertices[i].isValid; - vertex.position = outputVertices[i].position; - array[i] = vertex; - } - return array; - } - #endregion - - #region 输入 - public struct InputInitialize { - /// 网格宽 - public int wide; - /// 网格间隔 - public float interval; - /// 原点 - public Vector3 origin; - /// 多边形边缘点 - public NativeArray points; - } - #endregion - - #region 输出 - public struct OutputVertex { - /// 是否是有效顶点 - public bool isValid; - /// 位置 - public Vector3 position; - } - #endregion - - } - #endregion - - #region 边缘细分 - public class SideSubdivision : UnitAlgorithm { - - #region 执行 - public void Compute(DataPlate plate) { - int count = plate.plateSides.Count; - List plateSides = plate.plateSides; - //创建作业任务 - InputBorder border = DataPlateToInputBorder(plate); - NativeArray jobs = new NativeArray(count, Allocator.Temp); - NativeArray handles = new NativeArray(count, Allocator.Temp); - for (int i = 0; i < count; i++) { - jobs[i] = DataPlateSideToJobSideSubdivision(plateSides[i], border); - handles[i] = jobs[i].Schedule(); - } - //执行作业 - JobHandle.CompleteAll(handles); - //转换数据 - for (int i = 0; i < jobs.Length; i++) { - MergeSideVertex(jobs[i], plate); - } - } - #endregion - - #region Jobs - public struct JobSideSubdivision : IJob { - /// 输入边界 - [ReadOnly] public InputBorder inputBorder; - /// 输入边线 - [ReadOnly] public NativeArray inputLines; - /// 输出边点 - public NativeList outputSideVertexs; - - public void Execute() { - for (int x = 0; x < inputBorder.wide; x++) { - Vector3 a = new Vector3(inputBorder.minX + x * inputBorder.interval, inputBorder.minY - 1); - Vector3 b = new Vector3(inputBorder.minX + x * inputBorder.interval, inputBorder.maxY + 1); - Subdivision(a, b); - } - for (int y = 0; y < inputBorder.high; y++) { - Vector3 a = new Vector3(inputBorder.minX - 1, inputBorder.minY + y * inputBorder.interval); - Vector3 b = new Vector3(inputBorder.maxX + 1, inputBorder.minY + y * inputBorder.interval); - Subdivision(a, b); - } - } - public void Subdivision(Vector3 a, Vector3 b) { - for (int i = 0; i < inputLines.Length; i++) { - InputLine line = inputLines[i]; - if (!TryGetIntersectPoint(a, b, line.a, line.b, out Vector3 intersectPoint)) { continue; } - float distance = Vector3.Distance(line.a, intersectPoint) + line.origin; - OutputSideVertex sideVertex = new OutputSideVertex(); - sideVertex.origin = distance; - sideVertex.position = intersectPoint; - outputSideVertexs.Add(sideVertex); - } - } - } - #endregion - - #region 转换 - private InputBorder DataPlateToInputBorder(DataPlate plate) { - InputBorder inputBorder = new InputBorder(); - inputBorder.wide = plate.dataBaking.border.GridWide; - inputBorder.high = plate.dataBaking.border.GridHigh; - inputBorder.interval = plate.dataBaking.border.smooth; - inputBorder.minX = plate.dataBaking.border.minX; - inputBorder.maxX = plate.dataBaking.border.maxX; - inputBorder.minY = plate.dataBaking.border.minY; - inputBorder.maxY = plate.dataBaking.border.maxY; - inputBorder.origin = plate.dataBaking.border.MinPoint; - return inputBorder; - } - private JobSideSubdivision DataPlateSideToJobSideSubdivision(DataPlateSide plateSide, InputBorder border) { - DataPlateLine[] lines = plateSide.dataBaking.lines; - NativeArray inputLines = new NativeArray(lines.Length, Allocator.TempJob); - for (int i = 0; i < lines.Length; i++) { - InputLine line = new InputLine(); - line.a = lines[i].a; - line.b = lines[i].b; - line.origin = lines[i].origin; - inputLines[i] = line; - } - - JobSideSubdivision jobSideSubdivision = new JobSideSubdivision(); - jobSideSubdivision.inputBorder = border; - jobSideSubdivision.inputLines = inputLines; - jobSideSubdivision.outputSideVertexs = new NativeList(Allocator.TempJob); - return jobSideSubdivision; - } - private void MergeSideVertex(JobSideSubdivision job, DataPlate plate) { - DataPlateVertex[] plateVertexs = plate.dataBaking.vertexs; - float interval = job.inputBorder.interval; - Vector3 offset = job.inputBorder.origin - new Vector3(interval, interval, 0) * 0.1f; - for (int i = 0; i < job.outputSideVertexs.Length; i++) { - Vector3 position = job.outputSideVertexs[i].position; - Vector3 gridPosition = position - offset; - int vertexX = Mathf.FloorToInt(gridPosition.x / interval); - int vertexY = Mathf.FloorToInt(gridPosition.y / interval); - vertexX = Math.Clamp(vertexX, 0, job.inputBorder.wide - 1); - vertexY = Math.Clamp(vertexY, 0, job.inputBorder.high - 1); - int index = XYToIndex(new Vector2Int(vertexX, vertexY), job.inputBorder.wide); - - plateVertexs[index].isValid = true; - plateVertexs[index].position = position; - } - job.inputLines.Dispose(); - job.outputSideVertexs.Dispose(); - } - #endregion - - #region 输入 - public struct InputBorder { - /// 网格宽 - public int wide; - /// 网格高 - public int high; - /// 网格间隔 - public float interval; - /// minX - public float minX; - /// maxX - public float maxX; - /// minY - public float minY; - /// maxY - public float maxY; - /// 原点 - public Vector3 origin; - } - public struct InputLine { - /// 线段起点a - public Vector3 a; - /// 线段终点b - public Vector3 b; - /// 原始距离 - public float origin; - } - #endregion - - #region 输出 - public struct OutputSideVertex { - /// 到边起点的距离 - public float origin; - /// 位置 - public Vector3 position; - } - #endregion - - } - #endregion - - #region 绘制三角形 - public class DrawTriangle : UnitAlgorithm { - - #region 执行 - public void Compute(DataPlate plate) { - DataPlateVertex[] vertexs = plate.dataBaking.vertexs; - int maxIndex = vertexs.Length; - DataBorder border = plate.dataBaking.border; - //创建作业任务 - JobRhombus job = new JobRhombus(); - job.inputBorder = new InputBorder() { wide = border.GridWide, high = border.GridHigh }; - job.inputVertexs = DataPlateToInputVertex(vertexs); - job.outputVertexs = new NativeArray(maxIndex, Allocator.TempJob); - //执行作业 - JobHandle handle = job.Schedule(maxIndex, 32); - handle.Complete(); - //三角形合并 - plate.dataBaking.mesh = new Mesh(); - plate.dataBaking.mesh.vertices = Vertices(job.outputVertexs); - plate.dataBaking.mesh.uv = UV(job.outputVertexs); - plate.dataBaking.mesh.triangles = Triangles(job.outputVertexs); - plate.dataBaking.mesh.RecalculateBounds(); - plate.dataBaking.mesh.RecalculateNormals(); - //释放 - job.inputVertexs.Dispose(); - job.outputVertexs.Dispose(); - } - #endregion - - #region Jobs - [BurstCompile] - public struct JobRhombus : IJobParallelFor { - /// 输入边界 - public InputBorder inputBorder; - /// 输入网格 - [ReadOnly] public NativeArray inputVertexs; - /// 输出顶点 - public NativeArray outputVertexs; - - public struct ValidVertex { - /// 数组索引 - public int index; - /// 是否是有效顶点 - public bool isValid; - } - - public void Execute(int index) { - InputVertex input = inputVertexs[index]; - - Vector2Int xy = IndexToXY(index, inputBorder.wide); - - ValidVertex above = TryVertex(xy.x, xy.y + 1, inputBorder.wide, inputBorder.high); - ValidVertex below = TryVertex(xy.x, xy.y - 1, inputBorder.wide, inputBorder.high); - ValidVertex lefts = TryVertex(xy.x - 1, xy.y, inputBorder.wide, inputBorder.high); - ValidVertex right = TryVertex(xy.x + 1, xy.y, inputBorder.wide, inputBorder.high); - - ValidVertex leftsAbove = TryVertex(xy.x - 1, xy.y + 1, inputBorder.wide, inputBorder.high); - ValidVertex leftsBelow = TryVertex(xy.x - 1, xy.y - 1, inputBorder.wide, inputBorder.high); - ValidVertex rightAbove = TryVertex(xy.x + 1, xy.y + 1, inputBorder.wide, inputBorder.high); - ValidVertex rightBelow = TryVertex(xy.x + 1, xy.y - 1, inputBorder.wide, inputBorder.high); - - OutputVertex output = new OutputVertex { - isValid = input.isValid, - position = input.position - }; - - //默认绘制左上角 - output.a = new OutputTriangle { - isValid = above.isValid && lefts.isValid, - a = input.index, - c = lefts.index, - b = above.index - }; - //默认绘制右下角 - output.b = new OutputTriangle { - isValid = below.isValid && right.isValid, - a = input.index, - c = right.index, - b = below.index - }; - //如果右上角点不存在,则尝试绘制右上角 - output.c = new OutputTriangle { - isValid = !rightAbove.isValid && above.isValid && right.isValid, - a = input.index, - c = above.index, - b = right.index - }; - //如果左下角点不存在,则尝试绘制左下角 - output.d = new OutputTriangle { - isValid = !leftsBelow.isValid && below.isValid && lefts.isValid, - a = input.index, - c = below.index, - b = lefts.index - }; - outputVertexs[index] = output; - } - public ValidVertex TryVertex(int x, int y, int wide, int high) { - ValidVertex vertex = new ValidVertex() { index = -1, isValid = false }; - if (!TryXY(x, y, wide, high)) { return vertex; } - int index = XYToIndex(new Vector2Int(x, y), wide); - InputVertex input = inputVertexs[index]; - vertex.index = input.index; - vertex.isValid = input.isValid; - return vertex; - } - } - #endregion - - #region 转换 - private NativeArray DataPlateToInputVertex(DataPlateVertex[] vertexs) { - NativeArray InputVertexs = new NativeArray(vertexs.Length, Allocator.TempJob); - int index = 0; - for (int i = 0; i < vertexs.Length; i++) { - InputVertex vertex = new InputVertex(); - vertex.index = vertexs[i].isValid ? index : -1; - vertex.isValid = vertexs[i].isValid; - vertex.position = vertexs[i].position; - InputVertexs[i] = vertex; - if (vertexs[i].isValid) { index++; } - } - return InputVertexs; - } - private Vector3[] Vertices(NativeArray outputVertexs) { - List Vertices = new List(); - for (int i = 0; i < outputVertexs.Length; i++) { - if (!outputVertexs[i].isValid) { continue; } - Vertices.Add(outputVertexs[i].position); - } - return Vertices.ToArray(); - } - private Vector2[] UV(NativeArray outputVertexs) { - //展开uv (顶点去掉z坐标就是未缩放的平面UV) - List uv = new List(); - for (int i = 0; i < outputVertexs.Length; i++) { - if (!outputVertexs[i].isValid) { continue; } - uv.Add(new Vector2(outputVertexs[i].position.x, outputVertexs[i].position.y)); - } - return uv.ToArray(); - } - private int[] Triangles(NativeArray outputVertexs) { - List triangles = new List(); - for (int i = 0; i < outputVertexs.Length; i++) { - if (!outputVertexs[i].isValid) { continue; } - triangles.AddRange(Triangles(outputVertexs[i])); - } - return triangles.ToArray(); - } - private List Triangles(OutputVertex vertex) { - List triangles = new List(); - if (vertex.a.isValid) { triangles.AddRange(Triangles(vertex.a)); } - if (vertex.b.isValid) { triangles.AddRange(Triangles(vertex.b)); } - if (vertex.c.isValid) { triangles.AddRange(Triangles(vertex.c)); } - if (vertex.d.isValid) { triangles.AddRange(Triangles(vertex.d)); } - return triangles; - } - private List Triangles(OutputTriangle triangle) { - return new List() { triangle.a, triangle.b, triangle.c }; - } - #endregion - - #region 输入 - public struct InputBorder { - /// 网格宽 - public int wide; - /// 网格高 - public int high; - } - public struct InputVertex { - /// 数组索引 - public int index; - /// 是否是有效顶点 - public bool isValid; - /// 设计视图中位置 - public Vector3 position; - } - #endregion - - #region 输出 - public struct OutputVertex { - /// 是否是有效 - public bool isValid; - /// 顶点位置 - public Vector3 position; - /// 左上角 - public OutputTriangle a; - /// 右下角 - public OutputTriangle b; - /// 右上角 - public OutputTriangle c; - /// 左下角 - public OutputTriangle d; - } - public struct OutputTriangle { - /// 是否是有效 - public bool isValid; - /// a点索引 - public int a; - /// b点索引 - public int b; - /// c点索引 - public int c; - } - #endregion - - } - #endregion -} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSuture.cs b/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSuture.cs deleted file mode 100644 index 017bb67..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSuture.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -/// -/// 缝合边算法模块 -/// -public class AlgorithmSuture : ModuleAlgorithm { - /// 设计的缝合线 - public UnitAlgorithm SutureDesign = new UnitAlgorithmSutureDesign(); - /// 烘焙的缝合线 - public UnitAlgorithm SutureBaking = new UnitAlgorithmSutureBaking(); - - protected override void Awake() => ModuleCore.AlgorithmSuture = this; - - public override void Compute(DataSuture suture) { - //缝合边长 - float aLength = suture.a.plateSide.dataDesign.length; - float bLength = suture.b.plateSide.dataDesign.length; - suture.length = aLength < bLength ? aLength : bLength; - //设计缝合顶点 - SutureDesign.Compute(suture.a); - SutureDesign.Compute(suture.b); - //烘焙缝合顶点 - SutureBaking.Compute(suture.a); - SutureBaking.Compute(suture.b); - //缝合锚点 - suture.points = new List(); - suture.points.AddRange(Compute(suture.a, suture.b)); - suture.points.AddRange(Compute(suture.b, suture.a)); - } - private List Compute(DataSutureSide a, DataSutureSide b) { - DataSutureSideVertex[] vertexs = a.dataBaking.vertexs; - DataSutureSideVertex[] allVertexs = b.dataBaking.allVertexs; - List suturePoints = new List(); - for (int i = 0; i < vertexs.Length; i++) { - DataSutureSideVertex vertex = vertexs[i]; - for (int j = 0; j < allVertexs.Length; j++) { - DataSutureSideVertex anchor = allVertexs[j]; - if (anchor.MaxDistance < vertex.origin) { continue; } - DataSuturePoint suturePoint = new DataSuturePoint(); - suturePoint.distance = vertex.origin - anchor.origin; - suturePoint.vertex = vertex.a; - suturePoint.aAnchor = anchor.a; - suturePoint.bAnchor = anchor.b; - suturePoints.Add(suturePoint); - } - } - return suturePoints; - } -} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSuture.cs.meta b/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSuture.cs.meta deleted file mode 100644 index dbdf29d..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSuture.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bc0a831375a5abe418c790ae74a19376 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSutureSide.cs b/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSutureSide.cs deleted file mode 100644 index 222d070..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSutureSide.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 缝合边算法模块 -/// -//public class AlgorithmSutureSide : ModuleAlgorithm { -// public class VertexPosition : IComparable { -// public Vector3 designPosition; -// public Vector3 bakingPosition; -// public float distance; -// public int CompareTo(VertexPosition other) { -// return other.distance >= distance ? 1 : -1; -// } -// } - -// protected override void Awake() => ModuleCore.AlgorithmSutureSide = this; - -// public override void Compute(DataSutureSide data) { -// //List vertexPositions = VertexPositions(data); -// data.designPositions = VertexToDesignPositions(data).ToArray(); -// data.bakingPositions = VertexToBakingPositions(data).ToArray(); -// } - -// private List VertexPositions(DataSutureSide sutureSide) { -// List vertexPositions = new List(); -// for (int i = 0; i < sutureSide.Vertices.Length; i++) { -// Vector3 design = sutureSide.Vertices[i].design; -// Quaternion quaternion = Quaternion.Euler(sutureSide.PlateBakingEulerAngles); -// Vector3 baking = quaternion * sutureSide.Vertices[i].design; -// VertexPosition vertexPosition = new VertexPosition(); -// vertexPosition.designPosition = design + sutureSide.PlateDesignPosition; -// vertexPosition.bakingPosition = baking + sutureSide.PlateBakingPosition; -// vertexPosition.distance = Vector3.Distance(design, sutureSide.side.aPoint.position); -// vertexPositions.Add(vertexPosition); -// } -// //按距离从小到大排序 -// vertexPositions.Sort(); -// //是否颠倒 -// if (sutureSide.isReversal) { vertexPositions.Reverse(); } -// return vertexPositions; -// } -// private List VertexToDesignPositions(DataSutureSide data) { -// //转换列表 -// List positions = new List(); -// for (int i = 0; i < data.Vertices.Length; i++) { -// Vector3 position = data.Vertices[i].design + data.PlateDesignPosition; -// positions.Add(position); -// } -// if (data.isReversal) { positions.Reverse(); } -// return positions; -// } -// private List VertexToBakingPositions(DataSutureSide data) { -// //转换列表 -// List positions = new List(); -// for (int i = 0; i < data.Vertices.Length; i++) { -// Quaternion quaternion = Quaternion.Euler(data.PlateBakingEulerAngles); -// Vector3 baking = quaternion * data.Vertices[i].design; -// Vector3 position = baking + data.PlateBakingPosition; -// positions.Add(position); -// } -// if (data.isReversal) { positions.Reverse(); } -// return positions; -// } -//} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSutureSide.cs.meta b/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSutureSide.cs.meta deleted file mode 100644 index d457fb1..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSutureSide.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2883f9190b57bdc41a4458a5c9e16f53 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleAlgorithm/ModuleAlgorithm.cs b/Assets/ModuleCore/ModuleAlgorithm/ModuleAlgorithm.cs deleted file mode 100644 index 414c14f..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/ModuleAlgorithm.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 算法模块 -/// -/// -public abstract class ModuleAlgorithm : MonoBehaviour { - /// 必须要初始化 - protected abstract void Awake(); - /// 核心模块 - protected virtual ModuleCore ModuleCore => ModuleCore.I; - - /// 执行算法 - public abstract void Compute(Data data); -} \ No newline at end of file diff --git a/Assets/ModuleCore/ModuleAlgorithm/ModuleAlgorithm.cs.meta b/Assets/ModuleCore/ModuleAlgorithm/ModuleAlgorithm.cs.meta deleted file mode 100644 index c103c3b..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/ModuleAlgorithm.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 080083324a409f24788f08ea7c670304 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleAlgorithm/ResetBakingPolygon.cs b/Assets/ModuleCore/ModuleAlgorithm/ResetBakingPolygon.cs deleted file mode 100644 index 54767bd..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/ResetBakingPolygon.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class ResetBakingPolygon : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/Assets/ModuleCore/ModuleAlgorithm/ResetBakingPolygon.cs.meta b/Assets/ModuleCore/ModuleAlgorithm/ResetBakingPolygon.cs.meta deleted file mode 100644 index acb0222..0000000 --- a/Assets/ModuleCore/ModuleAlgorithm/ResetBakingPolygon.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f24a4f73b9925a9478f58b089059ef1e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleAssets.meta b/Assets/ModuleCore/ModuleAssets.meta index f76d037..864bc85 100644 --- a/Assets/ModuleCore/ModuleAssets.meta +++ b/Assets/ModuleCore/ModuleAssets.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 485602713f4e17344b5dc7f627ed1a81 +guid: 66fc15151bdec0642aa0d9f313f50e72 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleAssets/AssetsOutline.cs b/Assets/ModuleCore/ModuleAssets/AssetsOutline.cs deleted file mode 100644 index e568610..0000000 --- a/Assets/ModuleCore/ModuleAssets/AssetsOutline.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using UnityEngine.Rendering.Universal; - -/// -/// 轮廓渲染资源模块 -/// -public class AssetsOutline : ModuleAssets { - public UniversalRendererData rendererData; - private OutlineRendererFeature rendererFeature; - - public override int Count => rendererFeature.settings.RenderObjs.Count; - public override List Datas => rendererFeature.settings.RenderObjs; - - protected override void Awake() { - ModuleCore.AssetsOutline = this; - rendererFeature = rendererData.rendererFeatures.OfType().FirstOrDefault(); - } - - public override void Add(Transform data) { - if (Datas.Contains(data)) { return; } - Datas.Add(data); - } - public override void Remove(Transform data) { - if (!Datas.Contains(data)) { return; } - Datas.Remove(data); - } - public override Transform Find(int index) { - return Datas.LoopIndex(index); - } - public override void ForEach(Action action) { - Datas.ForEach(action); - } -} diff --git a/Assets/ModuleCore/ModuleAssets/AssetsOutline.cs.meta b/Assets/ModuleCore/ModuleAssets/AssetsOutline.cs.meta deleted file mode 100644 index c8ad728..0000000 --- a/Assets/ModuleCore/ModuleAssets/AssetsOutline.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe3a6923b67b64741aab806825b12c16 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleAssets/AssetsPlate.cs b/Assets/ModuleCore/ModuleAssets/AssetsPlate.cs deleted file mode 100644 index ef90893..0000000 --- a/Assets/ModuleCore/ModuleAssets/AssetsPlate.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 板片管理模块 -/// -public class AssetsPlate : ModuleAssets { - private List dataPlates = new List(); - - /// 视图相机模块 - private ModuleViewCamera ViewCameraDesign => ModuleCore.ViewCameraDesign; - - public override int Count => dataPlates.Count; - public override List Datas => dataPlates; - - protected override void Awake() => ModuleCore.AssetsPlate = this; - - public override void Add(DataPlate plate) { - if (dataPlates.Contains(plate)) { return; } - dataPlates.Add(plate); - //初始化参数 - plate.dataDesign.position = ViewCameraDesign.CameraPosition; - plate.dataBaking.position = ViewCameraDesign.CameraPosition; - //生成可视化内容 - plate.UpdateVisual(); - } - public override void Remove(DataPlate data) { - if (!dataPlates.Contains(data)) { return; } - dataPlates.Remove(data); - } - public override DataPlate Find(int index) { - return dataPlates.LoopIndex(index); - } - public override void ForEach(Action action) { - dataPlates.ForEach(action); - } -} diff --git a/Assets/ModuleCore/ModuleAssets/AssetsPlate.cs.meta b/Assets/ModuleCore/ModuleAssets/AssetsPlate.cs.meta deleted file mode 100644 index 6888932..0000000 --- a/Assets/ModuleCore/ModuleAssets/AssetsPlate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f1f4341af37c4904b8274f65dd58e837 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleAssets/AssetsPlatePresets.cs b/Assets/ModuleCore/ModuleAssets/AssetsPlatePresets.cs deleted file mode 100644 index 604b36a..0000000 --- a/Assets/ModuleCore/ModuleAssets/AssetsPlatePresets.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class AssetsPlatePresets : ModuleAssets { - [SerializeField] private List assets; - - public override int Count => assets.Count; - public override List Datas => assets; - - protected override void Awake() => ModuleCore.AssetsPlatePresets = this; - - public override void Add(DataPlatePresets data) => assets.Add(data); - public override void Remove(DataPlatePresets data) => assets.Remove(data); - public override DataPlatePresets Find(int index) => assets.LoopIndex(index); - public override void ForEach(Action action) => assets.ForEach(action); -} diff --git a/Assets/ModuleCore/ModuleAssets/AssetsPlatePresets.cs.meta b/Assets/ModuleCore/ModuleAssets/AssetsPlatePresets.cs.meta deleted file mode 100644 index 1196253..0000000 --- a/Assets/ModuleCore/ModuleAssets/AssetsPlatePresets.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8198c73995924524d985c3beb338f033 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleAssets/ModuleAssets.cs b/Assets/ModuleCore/ModuleAssets/ModuleAssets.cs index 26cdc2f..95b1740 100644 --- a/Assets/ModuleCore/ModuleAssets/ModuleAssets.cs +++ b/Assets/ModuleCore/ModuleAssets/ModuleAssets.cs @@ -17,7 +17,7 @@ public abstract class ModuleAssets : MonoBehaviour { public abstract int Count { get; } /// 数据列表 public abstract List Datas { get; } - + /// 添加数据 public abstract void Add(Data data); /// 删除数据 diff --git a/Assets/ModuleCore/ModuleAssets/ModuleAssets.cs.meta b/Assets/ModuleCore/ModuleAssets/ModuleAssets.cs.meta index e8d77c7..4d4cc93 100644 --- a/Assets/ModuleCore/ModuleAssets/ModuleAssets.cs.meta +++ b/Assets/ModuleCore/ModuleAssets/ModuleAssets.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 424b00686a91cd64989e546f204155a5 +guid: 96fa067856f57984e975772061a248ca MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleBuilder/BuilderInsertPointToPoint.cs b/Assets/ModuleCore/ModuleBuilder/BuilderInsertPointToPoint.cs deleted file mode 100644 index c5d862e..0000000 --- a/Assets/ModuleCore/ModuleBuilder/BuilderInsertPointToPoint.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 插入点(DataInsertPoint) 转换 点(DataPoint) -/// -//public class BuilderInsertPointToPoint : ModuleBuilder { - -// protected override void Awake() => ModuleCore.InsertPointToPoint = this; - -// public override DataPoint To(DataInsertPoint insertPoint) { -// DataPlate plate = insertPoint.plate; -// Vector3 position = insertPoint.position; -// //创建新的点 -// DataPoint point = new DataPoint(insertPoint.plate); -// point.position = position; -// //改变关联的边B点,重置贝塞尔曲线 -// insertPoint.side.bPoint = point; -// insertPoint.side.OneRankBezier(); -// //创建新的边 -// DataSide side = CreateDataSide(plate, point, insertPoint.bPoint); -// //插入边 -// int sideIndex = plate.sides.IndexOf(insertPoint.side); -// plate.sides.Insert(sideIndex + 1, side); -// //插入点 -// int pointIndex = plate.points.IndexOf(insertPoint.aPoint); -// plate.points.Insert(pointIndex + 1, point); -// //更新数据 -// plate.UpdateVisual(); -// return point; -// } - -// private DataSide CreateDataSide(DataPlate plate, DataPoint a, DataPoint b) { -// DataSide side = new DataSide(plate); -// side.aPoint = a; -// side.bPoint = b; -// side.OneRankBezier(); -// return side; -// } -//} diff --git a/Assets/ModuleCore/ModuleBuilder/BuilderInsertPointToPoint.cs.meta b/Assets/ModuleCore/ModuleBuilder/BuilderInsertPointToPoint.cs.meta deleted file mode 100644 index e06afca..0000000 --- a/Assets/ModuleCore/ModuleBuilder/BuilderInsertPointToPoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 992dfa55aae34c040a024d7743bb1a8c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleBuilder/BuilderPlatePresetsToPlate.cs b/Assets/ModuleCore/ModuleBuilder/BuilderPlatePresetsToPlate.cs deleted file mode 100644 index b814154..0000000 --- a/Assets/ModuleCore/ModuleBuilder/BuilderPlatePresetsToPlate.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 板片预设数据(DataPlatePresets) 转换 板片数据(DataPlate) -/// -public class BuilderPlatePresetsToPlate : ModuleBuilder { - - protected override void Awake() => ModuleCore.PlatePresetsToPlate = this; - - public override DataPlate To(DataPlatePresets origin) { - DataPlate dataPlate = new DataPlate(); - dataPlate.platePoints = ToDataPoint(dataPlate, origin.designPoints); - dataPlate.plateSides = ToDataSide(dataPlate, dataPlate.platePoints); - return dataPlate; - } - - private List ToDataPoint(DataPlate dataPlate, List list) { - List points = new List(); - for (int i = 0; i < list.Count; i++) { - DataPlatePoint point = new DataPlatePoint(dataPlate); - point.position = list[i]; - points.Add(point); - } - return points; - } - private List ToDataSide(DataPlate dataPlate, List list) { - List sides = new List(); - for (int i = 0; i < list.Count; i++) { - DataPlateSide side = new DataPlateSide(dataPlate); - side.aPoint = list.LoopIndex(i + 0); - side.bPoint = list.LoopIndex(i + 1); - side.OneRankBezier(); - sides.Add(side); - } - return sides; - } -} diff --git a/Assets/ModuleCore/ModuleBuilder/BuilderPlatePresetsToPlate.cs.meta b/Assets/ModuleCore/ModuleBuilder/BuilderPlatePresetsToPlate.cs.meta deleted file mode 100644 index 4bf8450..0000000 --- a/Assets/ModuleCore/ModuleBuilder/BuilderPlatePresetsToPlate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 476a9d6720db7284fae46d62e046095d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleBuilder/ModuleBuilder.cs b/Assets/ModuleCore/ModuleBuilder/ModuleBuilder.cs deleted file mode 100644 index c30b7bb..0000000 --- a/Assets/ModuleCore/ModuleBuilder/ModuleBuilder.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 构造器 -/// 根据原型构造数据 -/// -/// -/// -public abstract class ModuleBuilder : MonoBehaviour { - /// 必须要初始化 - protected abstract void Awake(); - /// 核心模块 - protected virtual ModuleCore ModuleCore => ModuleCore.I; - - /// 根据原型构造数据 - public abstract Data To(Origin origin); -} diff --git a/Assets/ModuleCore/ModuleBuilder/ModuleBuilder.cs.meta b/Assets/ModuleCore/ModuleBuilder/ModuleBuilder.cs.meta deleted file mode 100644 index 8c7437e..0000000 --- a/Assets/ModuleCore/ModuleBuilder/ModuleBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 37fd3673cacd6294f8a1de0ddc48768a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleAlgorithm.meta b/Assets/ModuleCore/ModuleCamera.meta similarity index 77% rename from Assets/ModuleCore/ModuleAlgorithm.meta rename to Assets/ModuleCore/ModuleCamera.meta index 31f3e44..cb520ab 100644 --- a/Assets/ModuleCore/ModuleAlgorithm.meta +++ b/Assets/ModuleCore/ModuleCamera.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: eda56199f140e8e41bde06c79efd4b8e +guid: e145339febf0e6f469eb3a650e52f3d9 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleViewCamera/ModuleViewCamera.cs b/Assets/ModuleCore/ModuleCamera/ModuleCamera.cs similarity index 59% rename from Assets/ModuleCore/ModuleViewCamera/ModuleViewCamera.cs rename to Assets/ModuleCore/ModuleCamera/ModuleCamera.cs index 4163c87..7156165 100644 --- a/Assets/ModuleCore/ModuleViewCamera/ModuleViewCamera.cs +++ b/Assets/ModuleCore/ModuleCamera/ModuleCamera.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using UnityEngine; /// -/// 视图相机,把内容渲染到渲染纹理上 +/// 相机模块 /// -public abstract class ModuleViewCamera : MonoBehaviour { +public abstract class ModuleCamera : MonoBehaviour { /// 默认图层遮罩 public static readonly LayerMask DefaultLayerMask = ~(1 << 0) | 1 << 0; /// 必须要初始化 @@ -13,20 +13,12 @@ public abstract class ModuleViewCamera : MonoBehaviour { /// 核心模块 protected virtual ModuleCore ModuleCore => ModuleCore.I; - /// 视图位置 + /// 相机位置 public abstract Vector3 Position { get; set; } - /// 视图旋转 + /// 相机旋转 public abstract Vector3 EulerAngles { get; set; } - /// 视图缩放 - public abstract float Scale { get; set; } - /// 视图绿轴 - public abstract Vector3 Up { get; } - /// 视图红轴 - public abstract Vector3 Right { get; } - /// 视图蓝轴 - public abstract Vector3 Forward { get; } - /// 当前相机位置 - public abstract Vector3 CameraPosition { get; } + /// 相机视野 + public abstract float VisualField { get; set; } /// 渲染纹理 public abstract RenderTexture RenderTexture { get; } @@ -36,14 +28,6 @@ public abstract class ModuleViewCamera : MonoBehaviour { public abstract Vector3 ScreenToViewPosition(Vector3 screenPosition); /// 屏幕坐标转换世界坐标 public abstract Vector3 ScreenToWorldPosition(Vector3 screenPosition); - /// 视图坐标(0-1)转换屏幕坐标 - //public abstract Vector3 ViewToScreenPosition(Vector3 screenPosition); - ///// 视图坐标(0-1)转换世界坐标 - //public abstract Vector3 ViewToWorldPosition(Vector3 screenPosition); - ///// 世界坐标转换屏幕坐标 - //public abstract Vector3 WorldToScreenPosition(Vector3 screenPosition); - ///// 世界坐标转换视图坐标(0-1) - //public abstract Vector3 WorldToViewPosition(Vector3 screenPosition); /// 屏幕坐标获取世界对象 public abstract bool ScreenToWorldObject(Vector3 screenPosition, out T value) where T : Object; diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSubdivisionPolygon.cs.meta b/Assets/ModuleCore/ModuleCamera/ModuleCamera.cs.meta similarity index 83% rename from Assets/ModuleCore/ModuleAlgorithm/AlgorithmSubdivisionPolygon.cs.meta rename to Assets/ModuleCore/ModuleCamera/ModuleCamera.cs.meta index 43479ea..ff5bffd 100644 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSubdivisionPolygon.cs.meta +++ b/Assets/ModuleCore/ModuleCamera/ModuleCamera.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2414983cb247d574fad8f47f71c42fdb +guid: 8f795d0a53fb35641be9b8bc9aab0f58 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleCore.cs b/Assets/ModuleCore/ModuleCore.cs index 984e710..3b2ae4f 100644 --- a/Assets/ModuleCore/ModuleCore.cs +++ b/Assets/ModuleCore/ModuleCore.cs @@ -1,95 +1,10 @@ -using System; using System.Collections; using System.Collections.Generic; using UnityEngine; -using MuHua; /// /// 核心模块,实现业务逻辑 /// public class ModuleCore : Module { - #region 资产模块 - /// 板片资源管理模块 - public ModuleAssets AssetsPlate; - /// 预设板片资产 - public ModuleAssets AssetsPlatePresets; - /// 轮廓渲染资源模块 - public ModuleAssets AssetsOutline; - #endregion - - #region 页面模块 - /// 不会被销毁的全局唯一页面模块 (UIDocument) - public ModuleUIPage GlobalPage; - /// 当前的主要页面模块 (UIDocument) - public ModuleUIPage CurrentPage; - /// 预设模板窗口 (回调Action) - public ModuleUIWindow PresetsPlateWindow; - #endregion - - #region 视图模块 - /// 设计视图相机模块 - public ModuleViewCamera ViewCameraDesign; - /// 板片烘焙相机视图 - public ModuleViewCamera ViewCameraBaking; - #endregion - - #region 输入模块 - /// 设计UI输入模块 - public ModuleUIInput UIInputDesign; - /// 烘焙UI输入模块 - public ModuleUIInput UIInputBaking; - #endregion - - #region 转换模块 - /// 板片预设数据(DataPlatePresets) 转换 板片数据(DataPlate) - public ModuleBuilder PlatePresetsToPlate; - /// 板片数据(DataPlate) 转换 多边形数据(DataPolygon) - public ModuleBuilder PlateToPolygon; - #endregion - - #region 可视模块 - /// 板片设计 可视化内容生成模块 - public ModuleVisual VisualPlateDesign; - /// 板片烘焙 可视化内容生成模块 - public ModuleVisual VisualPlateBaking; - /// 缝合设计 可视化内容生成模块 - public ModuleVisual VisualSutureDesign; - /// 缝合烘焙 可视化内容生成模块 - public ModuleVisual VisualSutureBaking; - /// 连接器 可视化内容生成模块 - public ModuleVisual VisualConnector; - #endregion - - #region 查询模块 - /// 查询点模块 - public ModuleFind FindPoint; - /// 查询边模块 - public ModuleFind FindSide; - /// 查询贝塞尔点模块 - public ModuleFind FindBezier; - #endregion - - #region 算法模块 - /// 简单多边形算法模块 - public ModuleAlgorithm AlgorithmSimplePolygon; - /// 细分多边形算法模块 - public ModuleAlgorithm AlgorithmSubdivisionPolygon; - /// 缝合边算法模块 - public ModuleAlgorithm AlgorithmSuture; - #endregion - - #region 事件定义 - /// 标记数据Event - public event Action OnMark; - /// 移动烘焙视图的板片Event - public event Action OnBakingMobilePlate; - #endregion - - #region 事件触发 - /// 触发标记数据Event - public void Mark(DataMark data) => OnMark?.Invoke(data); - /// 触发移动烘焙视图的板片Event - public void BakingMobilePlate(DataPlate data) => OnBakingMobilePlate?.Invoke(data); - #endregion } diff --git a/Assets/ModuleCore/ModuleCore.cs.meta b/Assets/ModuleCore/ModuleCore.cs.meta index 825325d..393d01d 100644 --- a/Assets/ModuleCore/ModuleCore.cs.meta +++ b/Assets/ModuleCore/ModuleCore.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8b523f207d584d649bb29f4a06b5428d +guid: 831967c83916dda4a9cc48e672e4599c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleFind/FindBezier.cs b/Assets/ModuleCore/ModuleFind/FindBezier.cs deleted file mode 100644 index 06e1482..0000000 --- a/Assets/ModuleCore/ModuleFind/FindBezier.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 查询贝塞尔点 -/// -public class FindBezier : ModuleFind { - public readonly float FindRange = 0.02f; - /// 板片资产 - public ModuleAssets AssetsPlate => ModuleCore.AssetsPlate; - - protected override void Awake() => ModuleCore.FindBezier = this; - - public override bool Find(Vector3 position, out DataBezier bezier) { - List plates = AssetsPlate.Datas; - for (int i = 0; i < plates.Count; i++) { - Vector3 localPosition = position - plates[i].dataDesign.position; - bezier = Find(plates[i], localPosition); - if (bezier != null) { return true; } - } - bezier = null; return false; - } - - /// 查询匹配的边 - private DataBezier Find(DataPlate plate, Vector3 localPosition) { - for (int i = 0; i < plate.plateSides.Count; i++) { - DataBezier bezier = Find(plate.plateSides[i], localPosition); - if (bezier != null) { return bezier; } - } - return null; - } - /// 查询匹配的边 - private DataBezier Find(DataPlateSide side, Vector3 localPosition) { - if (side.bezier == Bezier.一阶) { return null; } - float aDis = Vector3.Distance(side.aBezier, localPosition); - if (aDis < FindRange) { return new DataBezier() { isA = true, side = side }; } - float bDis = Vector3.Distance(side.bBezier, localPosition); - if (bDis < FindRange) { return new DataBezier() { isA = false, side = side }; } - return null; - } -} diff --git a/Assets/ModuleCore/ModuleFind/FindBezier.cs.meta b/Assets/ModuleCore/ModuleFind/FindBezier.cs.meta deleted file mode 100644 index 500e60b..0000000 --- a/Assets/ModuleCore/ModuleFind/FindBezier.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5ea40ae623c1a974fa852f60e22f5a37 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleFind/FindPoint.cs b/Assets/ModuleCore/ModuleFind/FindPoint.cs deleted file mode 100644 index f91e78f..0000000 --- a/Assets/ModuleCore/ModuleFind/FindPoint.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 查找点 -/// -public class FindPoint : ModuleFind { - public readonly float FindRange = 0.01f; - /// 板片资产 - public ModuleAssets AssetsPlate => ModuleCore.AssetsPlate; - - protected override void Awake() => ModuleCore.FindPoint = this; - - public override bool Find(Vector3 position, out DataPlatePoint point) { - List plates = AssetsPlate.Datas; - for (int i = 0; i < plates.Count; i++) { - Vector3 localPosition = position - plates[i].dataDesign.position; - point = Find(plates[i], localPosition); - if (point != null) { return true; } - } - point = null; return false; - } - - /// 查询匹配的点 - private DataPlatePoint Find(DataPlate plate, Vector3 localPosition) { - List points = plate.platePoints; - for (int i = 0; i < points.Count; i++) { - float distance = Vector3.Distance(points[i].position, localPosition); - if (distance > FindRange) { continue; } - return points[i]; - } - return null; - } -} diff --git a/Assets/ModuleCore/ModuleFind/FindPoint.cs.meta b/Assets/ModuleCore/ModuleFind/FindPoint.cs.meta deleted file mode 100644 index 8cf0fb5..0000000 --- a/Assets/ModuleCore/ModuleFind/FindPoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1da1d6857fa49af4dbe4dd67998f54f1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleFind/FindSide.cs b/Assets/ModuleCore/ModuleFind/FindSide.cs deleted file mode 100644 index 8874bb8..0000000 --- a/Assets/ModuleCore/ModuleFind/FindSide.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 查找边 -/// -public class FindSide : ModuleFind { - public readonly float FindRange = 0.01f; - /// 板片资产 - public ModuleAssets AssetsPlate => ModuleCore.AssetsPlate; - - protected override void Awake() => ModuleCore.FindSide = this; - - public override bool Find(Vector3 position, out DataPlateSide side) { - List plates = AssetsPlate.Datas; - for (int i = 0; i < plates.Count; i++) { - Vector3 localPosition = position - plates[i].dataDesign.position; - side = Find(plates[i], localPosition); - if (side != null) { return true; } - } - side = null; return false; - } - - /// 查询匹配的边 - private DataPlateSide Find(DataPlate plate, Vector3 localPosition) { - for (int i = 0; i < plate.plateSides.Count; i++) { - DataPlateSide side = Find(plate.plateSides[i], localPosition); - if (side != null) { return side; } - } - return null; - } - /// 查询匹配的边 - private DataPlateSide Find(DataPlateSide side, Vector3 localPosition) { - DataPlateSideDesign design = side.dataDesign; - for (int i = 0; i < design.lines.Length; i++) { - Vector3 a = design.lines[i].a; - Vector3 b = design.lines[i].b; - float distance = ProjectDistance(a, b, localPosition); - if (distance < FindRange) { return side; } - } - return null; - } - - /// - /// 向量投影法 - /// 计算点c到线段ab最近的点 - /// - /// - /// - /// - /// 如果不在线段上返回 float.MaxValue - public static float ProjectDistance(Vector3 a, Vector3 b, Vector3 c) { - Vector3 ab = b - a; - Vector3 ac = c - a; - Vector3 p = Vector3.Project(ac, ab); - if (ab.normalized != p.normalized) { return float.MaxValue; } - if (ab.magnitude < p.magnitude) { return float.MaxValue; } - return Vector3.Distance(c, p + a); - } -} diff --git a/Assets/ModuleCore/ModuleFind/FindSide.cs.meta b/Assets/ModuleCore/ModuleFind/FindSide.cs.meta deleted file mode 100644 index 7763db8..0000000 --- a/Assets/ModuleCore/ModuleFind/FindSide.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f9b522b1c221a4643b94ce865ac8ecaa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleFind/ModuleFind.cs b/Assets/ModuleCore/ModuleFind/ModuleFind.cs deleted file mode 100644 index 2a8dfd4..0000000 --- a/Assets/ModuleCore/ModuleFind/ModuleFind.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 查找模块 -/// -public abstract class ModuleFind : MonoBehaviour { - /// 必须要初始化 - protected abstract void Awake(); - /// 核心模块 - protected virtual ModuleCore ModuleCore => ModuleCore.I; - - /// 查询 - public abstract bool Find(Vector3 position, out Data data); -} diff --git a/Assets/ModuleCore/ModuleFind/ModuleFind.cs.meta b/Assets/ModuleCore/ModuleFind/ModuleFind.cs.meta deleted file mode 100644 index ce44965..0000000 --- a/Assets/ModuleCore/ModuleFind/ModuleFind.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b7a6d69ae9d8c86438ea713a619b8afe -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleInput.meta b/Assets/ModuleCore/ModuleInput.meta index ebe9b94..4a78940 100644 --- a/Assets/ModuleCore/ModuleInput.meta +++ b/Assets/ModuleCore/ModuleInput.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 930f92d77ec6d97418874f1951013093 +guid: 9939a58498acfda448d6f494f52e8da4 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleInput/ModuleInput.cs b/Assets/ModuleCore/ModuleInput/ModuleInput.cs index 962ae83..cecc06c 100644 --- a/Assets/ModuleCore/ModuleInput/ModuleInput.cs +++ b/Assets/ModuleCore/ModuleInput/ModuleInput.cs @@ -2,17 +2,14 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class ModuleInput : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - - } +/// +/// 输入模块 +/// +public abstract class ModuleInput : MonoBehaviour { + /// 必须要初始化 + protected abstract void Awake(); + /// 核心模块 + protected virtual ModuleCore ModuleCore => ModuleCore.I; - // Update is called once per frame - void Update() - { - - } + public abstract Vector2 MousePosition { get; } } diff --git a/Assets/ModuleCore/ModuleInput/ModuleInput.cs.meta b/Assets/ModuleCore/ModuleInput/ModuleInput.cs.meta index 5ae40de..36e32bb 100644 --- a/Assets/ModuleCore/ModuleInput/ModuleInput.cs.meta +++ b/Assets/ModuleCore/ModuleInput/ModuleInput.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 890a3e1c641efcb418cc76bfb893d22e +guid: 4661df0b8dac9f640a09daa01cac9ea1 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleBuilder.meta b/Assets/ModuleCore/ModuleSingle.meta similarity index 77% rename from Assets/ModuleCore/ModuleBuilder.meta rename to Assets/ModuleCore/ModuleSingle.meta index ab7ecab..cf4183e 100644 --- a/Assets/ModuleCore/ModuleBuilder.meta +++ b/Assets/ModuleCore/ModuleSingle.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f005f421868c2084baf399dc6a42a60b +guid: b6ef7cc76b1474a498a5995587aeac6f folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleSingle/ModuleSingle.cs b/Assets/ModuleCore/ModuleSingle/ModuleSingle.cs new file mode 100644 index 0000000..f679fd1 --- /dev/null +++ b/Assets/ModuleCore/ModuleSingle/ModuleSingle.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 单个独立模块 +/// +public abstract class ModuleSingle : MonoBehaviour { + /// 必须要初始化 + protected abstract void Awake(); + /// 核心模块 + protected virtual ModuleCore ModuleCore => ModuleCore.I; + + /// 打开 + public abstract void Open(Data data); + /// 完成 + public abstract void Complete(); + /// 关闭 + public abstract void Close(); +} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSidePoint.cs.meta b/Assets/ModuleCore/ModuleSingle/ModuleSingle.cs.meta similarity index 83% rename from Assets/ModuleCore/ModuleAlgorithm/AlgorithmSidePoint.cs.meta rename to Assets/ModuleCore/ModuleSingle/ModuleSingle.cs.meta index f914c4a..5f4cd9c 100644 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmSidePoint.cs.meta +++ b/Assets/ModuleCore/ModuleSingle/ModuleSingle.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a76476370cd578b489a2b37297d054f9 +guid: 121ca341c2100df4b94d707ed24452f5 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleUIInput.meta b/Assets/ModuleCore/ModuleUIInput.meta deleted file mode 100644 index c359610..0000000 --- a/Assets/ModuleCore/ModuleUIInput.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: db1ffe2c1120fec4c9509e838aebb89c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUIInput/ModuleUIInput.cs b/Assets/ModuleCore/ModuleUIInput/ModuleUIInput.cs deleted file mode 100644 index 559d824..0000000 --- a/Assets/ModuleCore/ModuleUIInput/ModuleUIInput.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UIElements; - -/// -/// UI输入模块 -/// -/// -public abstract class ModuleUIInput : MonoBehaviour { - /// 必须要初始化 - protected abstract void Awake(); - /// 核心模块 - protected virtual ModuleCore ModuleCore => ModuleCore.I; - - /// 当前输入单元 - public abstract T Current { get; } - /// 改变输入单元时触发 - public abstract event Action OnChangeInput; - /// 改变输入单元 - public abstract void ChangeInput(T input); - - /// 绑定UI - public abstract void Binding(VisualElement element); -} diff --git a/Assets/ModuleCore/ModuleUIInput/ModuleUIInput.cs.meta b/Assets/ModuleCore/ModuleUIInput/ModuleUIInput.cs.meta deleted file mode 100644 index 3fd17c8..0000000 --- a/Assets/ModuleCore/ModuleUIInput/ModuleUIInput.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 41107ff888d44274e9593642528ccdd6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUIInput/UIInputBaking.cs b/Assets/ModuleCore/ModuleUIInput/UIInputBaking.cs deleted file mode 100644 index 9e9460c..0000000 --- a/Assets/ModuleCore/ModuleUIInput/UIInputBaking.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UIElements; - -/// -/// 烘焙输入模块 -/// -public class UIInputBaking : ModuleUIInput { - private bool isDownMouseLeft; - private bool isDownMouseRight; - private UnitMouseInput leftInputUnit; - private UnitMouseInput rightInputUnit; - - /// 设计视图相机模块 - protected ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking; - - public override UnitMouseInput Current => leftInputUnit; - public override event Action OnChangeInput; - public override void ChangeInput(UnitMouseInput input) { - leftInputUnit = input; - OnChangeInput?.Invoke(input); - } - - protected override void Awake() { - ModuleCore.UIInputBaking = this; - rightInputUnit = new BakingRotate(); - } - - public override void Binding(VisualElement element) { - element.RegisterCallback(MouseDown); - element.RegisterCallback(MouseMove); - element.RegisterCallback(MouseRelease); - element.RegisterCallback(MouseRelease); - element.RegisterCallback(ScrollWheel); - } - - private void MouseDown(MouseDownEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, 0); - if (evt.button == 0) { leftInputUnit.MouseDown(data); isDownMouseLeft = true; } - if (evt.button == 1) { rightInputUnit.MouseDown(data); isDownMouseRight = true; } - } - private void MouseMove(MouseMoveEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, 0); - if (isDownMouseLeft) { leftInputUnit.MouseDrag(data); } - if (isDownMouseRight) { rightInputUnit.MouseDrag(data); } - if (evt.button == 0) { leftInputUnit.MouseMove(data); } - if (evt.button == 1) { rightInputUnit.MouseMove(data); } - } - private void MouseRelease(MouseUpEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, 0); - leftInputUnit.MouseRelease(data); isDownMouseLeft = false; - rightInputUnit.MouseRelease(data); isDownMouseRight = false; - } - private void MouseRelease(MouseOutEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, 0); - leftInputUnit.MouseRelease(data); isDownMouseLeft = false; - rightInputUnit.MouseRelease(data); isDownMouseRight = false; - } - private void ScrollWheel(WheelEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, evt.delta.y); - float size = ViewCamera.Scale + data.ScrollWheel; - size = Mathf.Clamp(size, -10f, -1f); - ViewCamera.Scale = Mathf.Lerp(ViewCamera.Scale, size, Time.deltaTime * 50); - } - - private DataMouseInput CreateData(Vector2 localMousePosition, float scrollWheel) { - DataMouseInput data = new DataMouseInput(); - data.ScrollWheel = scrollWheel; - data.ViewPosition = ViewCamera.ScreenToViewPosition(localMousePosition); - data.WorldPosition = ViewCamera.ScreenToWorldPosition(localMousePosition); - data.ScreenPosition = localMousePosition; - return data; - } -} diff --git a/Assets/ModuleCore/ModuleUIInput/UIInputBaking.cs.meta b/Assets/ModuleCore/ModuleUIInput/UIInputBaking.cs.meta deleted file mode 100644 index 455377c..0000000 --- a/Assets/ModuleCore/ModuleUIInput/UIInputBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2f4e648fd2afac64eb1a2a9fa2f82246 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUIInput/UIInputDesign.cs b/Assets/ModuleCore/ModuleUIInput/UIInputDesign.cs deleted file mode 100644 index fef28ba..0000000 --- a/Assets/ModuleCore/ModuleUIInput/UIInputDesign.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UIElements; - -/// -/// 设计输入模块 -/// -public class UIInputDesign : ModuleUIInput { - private bool isDownMouseLeft; - private bool isDownMouseRight; - private UnitMouseInput leftInputUnit; - private UnitMouseInput rightInputUnit; - - /// 设计视图相机模块 - protected ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign; - - public override UnitMouseInput Current => leftInputUnit; - public override event Action OnChangeInput; - public override void ChangeInput(UnitMouseInput input) { - leftInputUnit = input; - OnChangeInput?.Invoke(input); - } - - protected override void Awake() { - ModuleCore.UIInputDesign = this; - rightInputUnit = new DesignMobile(); - } - - public override void Binding(VisualElement element) { - element.RegisterCallback(MouseDown); - element.RegisterCallback(MouseMove); - element.RegisterCallback(MouseRelease); - element.RegisterCallback(MouseRelease); - element.RegisterCallback(ScrollWheel); - } - - private void MouseDown(MouseDownEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, 0); - if (evt.button == 0) { leftInputUnit.MouseDown(data); isDownMouseLeft = true; } - if (evt.button == 1) { rightInputUnit.MouseDown(data); isDownMouseRight = true; } - } - private void MouseMove(MouseMoveEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, 0); - if (isDownMouseLeft) { leftInputUnit.MouseDrag(data); } - if (isDownMouseRight) { rightInputUnit.MouseDrag(data); } - leftInputUnit.MouseMove(data); - rightInputUnit.MouseMove(data); - } - private void MouseRelease(MouseUpEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, 0); - leftInputUnit.MouseRelease(data); isDownMouseLeft = false; - rightInputUnit.MouseRelease(data); isDownMouseRight = false; - } - private void MouseRelease(MouseOutEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, 0); - leftInputUnit.MouseRelease(data); isDownMouseLeft = false; - rightInputUnit.MouseRelease(data); isDownMouseRight = false; - } - private void ScrollWheel(WheelEvent evt) { - DataMouseInput data = CreateData(evt.localMousePosition, evt.delta.y); - float size = ViewCamera.Scale + data.ScrollWheel; - size = Mathf.Clamp(size, 0.1f, 4); - ViewCamera.Scale = Mathf.Lerp(ViewCamera.Scale, size, Time.deltaTime * 20); - } - - private DataMouseInput CreateData(Vector2 localMousePosition, float scrollWheel) { - DataMouseInput data = new DataMouseInput(); - data.ScrollWheel = scrollWheel; - data.ViewPosition = ViewCamera.ScreenToViewPosition(localMousePosition); - data.WorldPosition = ViewCamera.ScreenToWorldPosition(localMousePosition); - data.ScreenPosition = localMousePosition; - return data; - } -} \ No newline at end of file diff --git a/Assets/ModuleCore/ModuleUIInput/UIInputDesign.cs.meta b/Assets/ModuleCore/ModuleUIInput/UIInputDesign.cs.meta deleted file mode 100644 index ee854d5..0000000 --- a/Assets/ModuleCore/ModuleUIInput/UIInputDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a9cf538c2c848fc4ca95d1f860f11acc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUIPage.meta b/Assets/ModuleCore/ModuleUIPage.meta index 7d4f39b..6bb1318 100644 --- a/Assets/ModuleCore/ModuleUIPage.meta +++ b/Assets/ModuleCore/ModuleUIPage.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aea30e84af7b7ad4ab623d28e7668fcb +guid: 1dd7861df30473e4380411dd72fc32c3 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleUIPage/ModuleUIPage.cs.meta b/Assets/ModuleCore/ModuleUIPage/ModuleUIPage.cs.meta index 1ffceff..3fe61a0 100644 --- a/Assets/ModuleCore/ModuleUIPage/ModuleUIPage.cs.meta +++ b/Assets/ModuleCore/ModuleUIPage/ModuleUIPage.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a81cd0646bee3624b941f3d0b2c272f4 +guid: 1fbdc8f1003e52b42b71c1679a3b8e3c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleUIPage/UIPageGarmentSewing.cs b/Assets/ModuleCore/ModuleUIPage/UIPageGarmentSewing.cs deleted file mode 100644 index 43f2957..0000000 --- a/Assets/ModuleCore/ModuleUIPage/UIPageGarmentSewing.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UIElements; - -public class UIPageGarmentSewing : ModuleUIPage { - private TopMenu topMenu; - private VisualElement TopMenuElement => Q("TopMenu"); - protected override void Awake() => ModuleCore.CurrentPage = this; - - private void Start() { - topMenu = new TopMenu(TopMenuElement); - topMenu.ClickTopMenu1 = () => { }; - topMenu.ClickTopMenu2 = () => { ModuleCore.PresetsPlateWindow.Open(null); }; - } -} diff --git a/Assets/ModuleCore/ModuleUIPage/UIPageGarmentSewing.cs.meta b/Assets/ModuleCore/ModuleUIPage/UIPageGarmentSewing.cs.meta deleted file mode 100644 index 077a4a4..0000000 --- a/Assets/ModuleCore/ModuleUIPage/UIPageGarmentSewing.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d436e806ac6755d4fb29cdb0f7208615 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUIPage/UIPageGlobal.cs b/Assets/ModuleCore/ModuleUIPage/UIPageGlobal.cs deleted file mode 100644 index 4efecda..0000000 --- a/Assets/ModuleCore/ModuleUIPage/UIPageGlobal.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class UIPageGlobal : ModuleUIPage { - protected override void Awake() => ModuleCore.GlobalPage = this; -} diff --git a/Assets/ModuleCore/ModuleUIPage/UIPageGlobal.cs.meta b/Assets/ModuleCore/ModuleUIPage/UIPageGlobal.cs.meta deleted file mode 100644 index b0828a2..0000000 --- a/Assets/ModuleCore/ModuleUIPage/UIPageGlobal.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b8b1855b5fed0e041878548696f2afbe -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUIWindow.meta b/Assets/ModuleCore/ModuleUIWindow.meta deleted file mode 100644 index c029d1a..0000000 --- a/Assets/ModuleCore/ModuleUIWindow.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9083014378a5c3e4caaddd160ff79450 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUIWindow/ModuleUIWindow.cs b/Assets/ModuleCore/ModuleUIWindow/ModuleUIWindow.cs deleted file mode 100644 index ec10b54..0000000 --- a/Assets/ModuleCore/ModuleUIWindow/ModuleUIWindow.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// UI窗口 -/// -/// 窗口需要的数据类型 -public abstract class ModuleUIWindow : MonoBehaviour { - /// 绑定的页面 - public ModuleUIPage ModuleUIPage; - /// 必须初始化 - public abstract void Awake(); - /// 核心模块 - protected virtual ModuleCore ModuleCore => ModuleCore.I; - /// 打开模块,并且传进参数 - public abstract void Open(Data data); - /// 关闭模块 - public abstract void Close(); -} diff --git a/Assets/ModuleCore/ModuleUIWindow/ModuleUIWindow.cs.meta b/Assets/ModuleCore/ModuleUIWindow/ModuleUIWindow.cs.meta deleted file mode 100644 index 3517b16..0000000 --- a/Assets/ModuleCore/ModuleUIWindow/ModuleUIWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 928a5dbb2497f0145b1da8645720ac89 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUIWindow/UIWindowPresetsPlate.cs b/Assets/ModuleCore/ModuleUIWindow/UIWindowPresetsPlate.cs deleted file mode 100644 index 63b7660..0000000 --- a/Assets/ModuleCore/ModuleUIWindow/UIWindowPresetsPlate.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UIElements; - -public class UIWindowPresetsPlate : ModuleUIWindow { - public VisualTreeAsset PresetsPlateUnitAsset; - private UIPresetsPlate presetsPlate; - private VisualElement element => ModuleUIPage.Q("PresetsPlate"); - - /// 资源模块 - private ModuleAssets AssetsPlate => ModuleCore.AssetsPlate; - /// 预设资源模块 - private ModuleAssets AssetsPlatePresets => ModuleCore.AssetsPlatePresets; - /// 转换模块 - private ModuleBuilder PlatePresetsToPlate => ModuleCore.PlatePresetsToPlate; - - public override void Awake() { - ModuleCore.PresetsPlateWindow = this; - presetsPlate = new UIPresetsPlate(element); - - presetsPlate.ClickClose = Close; - } - public override void Open(Action data) { - element.style.display = DisplayStyle.Flex; - presetsPlate.Clear(); - AssetsPlatePresets.ForEach(Create); - } - public override void Close() { - presetsPlate.Clear(); - element.style.display = DisplayStyle.None; - } - private void Create(DataPlatePresets data) { - VisualElement temp = PresetsPlateUnitAsset.Instantiate(); - UIPresetsPlateUnit unit = new UIPresetsPlateUnit(temp, data); - unit.Click = () => { CreateTemplate(data); }; - presetsPlate.Add(unit); - } - private void CreateTemplate(DataPlatePresets data) { - DataPlate dataPlate = PlatePresetsToPlate.To(data); - AssetsPlate.Add(dataPlate); - Close(); - } -} diff --git a/Assets/ModuleCore/ModuleUIWindow/UIWindowPresetsPlate.cs.meta b/Assets/ModuleCore/ModuleUIWindow/UIWindowPresetsPlate.cs.meta deleted file mode 100644 index f5f03c8..0000000 --- a/Assets/ModuleCore/ModuleUIWindow/UIWindowPresetsPlate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a930d912222858846a23606c170a59d8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleViewCamera.meta b/Assets/ModuleCore/ModuleViewCamera.meta deleted file mode 100644 index 37e58d5..0000000 --- a/Assets/ModuleCore/ModuleViewCamera.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8c1f6f992590ee740829401bdf9c7486 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleViewCamera/ModuleViewCamera.cs.meta b/Assets/ModuleCore/ModuleViewCamera/ModuleViewCamera.cs.meta deleted file mode 100644 index c877ebd..0000000 --- a/Assets/ModuleCore/ModuleViewCamera/ModuleViewCamera.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 93bd8c351a140654da540f55d0d7091f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleViewCamera/ViewCameraBaking.cs b/Assets/ModuleCore/ModuleViewCamera/ViewCameraBaking.cs deleted file mode 100644 index d41acff..0000000 --- a/Assets/ModuleCore/ModuleViewCamera/ViewCameraBaking.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class ViewCameraBaking : ModuleViewCamera { - public readonly Vector3 CameraOffset = new Vector3(0, 0, -1.5f); - public Camera viewCamera; - public Transform viewOrigin; - public Transform viewSpace; - private RaycastHit hitInfo; - private RenderTexture renderTexture; - - protected override void Awake() => ModuleCore.ViewCameraBaking = this; - - public override Vector3 Position { - get => viewOrigin.localPosition; - set => viewOrigin.localPosition = value; - } - public override Vector3 EulerAngles { - get => viewOrigin.eulerAngles; - set => viewOrigin.eulerAngles = value; - } - public override float Scale { - get => viewCamera.transform.localPosition.z; - set => viewCamera.transform.localPosition = new Vector3(0, 0, value); - } - public override Vector3 Up { - get => viewOrigin.up; - } - public override Vector3 Right { - get => viewOrigin.right; - } - public override Vector3 Forward { - get => viewOrigin.forward; - } - public override Vector3 CameraPosition { - get => viewOrigin.localPosition; - } - public override RenderTexture RenderTexture { - get => renderTexture; - } - - public override void UpdateRenderTexture(int x, int y) { - renderTexture = new RenderTexture(x, y, 0); - viewCamera.targetTexture = renderTexture; - } - public override Vector3 ScreenToViewPosition(Vector3 screenPosition) { - float x = screenPosition.x / viewCamera.pixelWidth; - float y = 1 - screenPosition.y / viewCamera.pixelHeight; - Vector3 viewPosition = new Vector3(x, y); - return viewPosition; - } - public override Vector3 ScreenToWorldPosition(Vector3 screenPosition) { - Vector3 viewPosition = ScreenToViewPosition(screenPosition); - float aspectRatio = (float)viewCamera.pixelWidth / viewCamera.pixelHeight; - Vector3 ratio = viewPosition - new Vector3(0.5f, 0.5f); - return new Vector3(ratio.x * aspectRatio, ratio.y) * Scale + viewOrigin.position; - } - //public override Vector3 ViewToScreenPosition(Vector3 screenPosition) { - // throw new System.NotImplementedException(); - //} - //public override Vector3 ViewToWorldPosition(Vector3 screenPosition) { - // throw new System.NotImplementedException(); - //} - //public override Vector3 WorldToScreenPosition(Vector3 screenPosition) { - // throw new System.NotImplementedException(); - //} - //public override Vector3 WorldToViewPosition(Vector3 screenPosition) { - // throw new System.NotImplementedException(); - //} - - public override bool ScreenToWorldObject(Vector3 screenPosition, out T value) { - return ScreenToWorldObject(screenPosition, out value, DefaultLayerMask); - } - public override bool ScreenToWorldObject(Vector3 screenPosition, out T value, LayerMask planeLayerMask) { - Vector3 viewPosition = ScreenToViewPosition(screenPosition); - Ray ray = viewCamera.ViewportPointToRay(viewPosition); - Physics.Raycast(ray, out hitInfo, 200, planeLayerMask); - value = hitInfo.transform?.GetComponent(); - return value != null; - } - public override bool ScreenToWorldObjectParent(Vector3 screenPosition, out T value) { - return ScreenToWorldObjectParent(screenPosition, out value, DefaultLayerMask); - } - public override bool ScreenToWorldObjectParent(Vector3 screenPosition, out T value, LayerMask planeLayerMask) { - Vector3 viewPosition = ScreenToViewPosition(screenPosition); - Ray ray = viewCamera.ViewportPointToRay(viewPosition); - Physics.Raycast(ray, out hitInfo, 200, planeLayerMask); - value = hitInfo.transform?.GetComponentInParent(); - return value != null; - } -} diff --git a/Assets/ModuleCore/ModuleViewCamera/ViewCameraBaking.cs.meta b/Assets/ModuleCore/ModuleViewCamera/ViewCameraBaking.cs.meta deleted file mode 100644 index f3df246..0000000 --- a/Assets/ModuleCore/ModuleViewCamera/ViewCameraBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 802326651d2bc7442aa201a7859a30e2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleViewCamera/ViewCameraDesign.cs b/Assets/ModuleCore/ModuleViewCamera/ViewCameraDesign.cs deleted file mode 100644 index ef852c8..0000000 --- a/Assets/ModuleCore/ModuleViewCamera/ViewCameraDesign.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class ViewCameraDesign : ModuleViewCamera { - public Camera viewCamera; - public Transform viewSpace; - private RaycastHit hitInfo; - private RenderTexture renderTexture; - private readonly Vector3 CameraOffset = new Vector3(0, 0, -1.5f); - - protected override void Awake() => ModuleCore.ViewCameraDesign = this; - - public override Vector3 Position { - get => viewCamera.transform.localPosition - CameraOffset; - set => viewCamera.transform.localPosition = value + CameraOffset; - } - public override Vector3 EulerAngles { - get => viewCamera.transform.eulerAngles; - set => viewCamera.transform.eulerAngles = value; - } - public override float Scale { - get => viewCamera.orthographicSize; - set => viewCamera.orthographicSize = value; - } - public override Vector3 Up { - get => viewCamera.transform.up; - } - public override Vector3 Right { - get => viewCamera.transform.right; - } - public override Vector3 Forward { - get => viewCamera.transform.forward; - } - public override Vector3 CameraPosition { - get => viewCamera.transform.localPosition - CameraOffset; - } - public override RenderTexture RenderTexture { - get => renderTexture; - } - - public override void UpdateRenderTexture(int x, int y) { - renderTexture = new RenderTexture(x, y, 0); - viewCamera.targetTexture = renderTexture; - } - public override Vector3 ScreenToViewPosition(Vector3 screenPosition) { - float x = screenPosition.x / viewCamera.pixelWidth; - float y = 1 - screenPosition.y / viewCamera.pixelHeight; - Vector3 mouseRatio = new Vector3(x - 0.5f, y - 0.5f); - float aspectRatio = (float)viewCamera.pixelWidth / viewCamera.pixelHeight; - return new Vector3(mouseRatio.x * aspectRatio, mouseRatio.y) * 2; - } - public override Vector3 ScreenToWorldPosition(Vector3 screenPosition) { - return ScreenToViewPosition(screenPosition) * Scale + Position; - } - - public override bool ScreenToWorldObject(Vector3 screenPosition, out T value) { - return ScreenToWorldObject(screenPosition, out value, DefaultLayerMask); - } - public override bool ScreenToWorldObject(Vector3 screenPosition, out T value, LayerMask planeLayerMask) { - Vector3 viewPosition = ScreenToViewPosition(screenPosition); - Vector3 worldPosition = viewPosition * Scale + viewCamera.transform.position; - Ray ray = new Ray(worldPosition, viewCamera.transform.forward); - Physics.Raycast(ray, out hitInfo, 200, planeLayerMask); - value = hitInfo.transform?.GetComponent(); - return value != null; - } - public override bool ScreenToWorldObjectParent(Vector3 screenPosition, out T value) { - return ScreenToWorldObjectParent(screenPosition, out value, DefaultLayerMask); - } - public override bool ScreenToWorldObjectParent(Vector3 screenPosition, out T value, LayerMask planeLayerMask) { - Vector3 viewPosition = ScreenToViewPosition(screenPosition); - Vector3 worldPosition = viewPosition * Scale + viewCamera.transform.position; - Ray ray = new Ray(worldPosition, viewCamera.transform.forward); - Physics.Raycast(ray, out hitInfo, 200, planeLayerMask); - value = hitInfo.transform?.GetComponentInParent(); - return value != null; - } - //public override Vector3 ViewToScreenPosition(Vector3 screenPosition) { - // throw new System.NotImplementedException(); - //} - //public override Vector3 ViewToWorldPosition(Vector3 screenPosition) { - // throw new System.NotImplementedException(); - //} - //public override Vector3 WorldToScreenPosition(Vector3 screenPosition) { - // throw new System.NotImplementedException(); - //} - //public override Vector3 WorldToViewPosition(Vector3 screenPosition) { - // throw new System.NotImplementedException(); - //} -} diff --git a/Assets/ModuleCore/ModuleViewCamera/ViewCameraDesign.cs.meta b/Assets/ModuleCore/ModuleViewCamera/ViewCameraDesign.cs.meta deleted file mode 100644 index a2e3980..0000000 --- a/Assets/ModuleCore/ModuleViewCamera/ViewCameraDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c639043240fd73545af704b1a6b52895 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleVisual.meta b/Assets/ModuleCore/ModuleVisual.meta index aee247e..8bad160 100644 --- a/Assets/ModuleCore/ModuleVisual.meta +++ b/Assets/ModuleCore/ModuleVisual.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6f8f76170dafc9549adcb43c6b78e751 +guid: 6f35188dbbe4cee4b823e88d78deef5a folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleVisual/ModuleVisual.cs b/Assets/ModuleCore/ModuleVisual/ModuleVisual.cs index 22f336c..f7f267d 100644 --- a/Assets/ModuleCore/ModuleVisual/ModuleVisual.cs +++ b/Assets/ModuleCore/ModuleVisual/ModuleVisual.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; /// -/// 生成可视化内容模块 +/// 可视化内容生成模块 /// public abstract class ModuleVisual : MonoBehaviour { /// 必须要初始化 @@ -11,7 +11,7 @@ public abstract class ModuleVisual : MonoBehaviour { /// 核心模块 protected virtual ModuleCore ModuleCore => ModuleCore.I; - /// 更新可视化内容 + /// 更新可视化 public abstract void UpdateVisual(Data data); /// 释放可视化内容 public abstract void ReleaseVisual(Data data); diff --git a/Assets/ModuleCore/ModuleVisual/ModuleVisual.cs.meta b/Assets/ModuleCore/ModuleVisual/ModuleVisual.cs.meta index 3a94ad9..bb9c1a5 100644 --- a/Assets/ModuleCore/ModuleVisual/ModuleVisual.cs.meta +++ b/Assets/ModuleCore/ModuleVisual/ModuleVisual.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 32a3e92bdd9f12a4dbaeadda30a66075 +guid: 1681bcfa66dacbd4e810d15939fa7e04 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleVisual/VisualBaking.cs b/Assets/ModuleCore/ModuleVisual/VisualBaking.cs deleted file mode 100644 index c8bb3d9..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualBaking.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -//public class VisualBaking : ModuleVisual { -// public Transform viewSpace; -// public Transform platePrefab;//板片 -// public Transform suturePrefab;//缝合 -// public Transform sutureSidePrefab;//缝合边 - -// protected override void Awake() => ModuleCore.VisualBaking = this; - -// public override void UpdateVisual(DataPlate plate) { -// //更新板片 -// Create(ref plate.baking, platePrefab, viewSpace); -// plate.baking.UpdateVisual(plate); -// //子数据父对象 -// Transform parent = plate.design.transform; -// //更新线段 -// plate.sides.ForEach(obj => UpdateVisual(obj, parent)); -// } -// public override void ReleaseVisual(DataPlate data) { -// throw new System.NotImplementedException(); -// } - -// private void UpdateVisual(DataSide side, Transform parent) { -// //Create(ref side.design, sidePrefab, parent); -// //side.design.UpdateVisual(side); -// //更新缝合线 -// if (side.suture == null) { return; } -// //side.suture.Update(); -// UpdateVisual(side.suture, viewSpace); -// } -// /// 更新缝合数据 -// private void UpdateVisual(DataSuture suture, Transform parent) { -// Create(ref suture.baking, suturePrefab, parent); -// UpdateVisual(suture.a, suture.baking.transform); -// UpdateVisual(suture.b, suture.baking.transform); -// suture.baking.UpdateVisual(suture); -// } -// /// 更新缝合边 -// private void UpdateVisual(DataSutureSide sutureSide, Transform parent) { -// Create(ref sutureSide.baking, sutureSidePrefab, parent); -// sutureSide.baking.UpdateVisual(sutureSide); -// } -//} diff --git a/Assets/ModuleCore/ModuleVisual/VisualBaking.cs.meta b/Assets/ModuleCore/ModuleVisual/VisualBaking.cs.meta deleted file mode 100644 index 7757c89..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 545b7804867d268448f7089215e20f39 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleVisual/VisualConnector.cs b/Assets/ModuleCore/ModuleVisual/VisualConnector.cs deleted file mode 100644 index c5e4d55..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualConnector.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 连接可视化模块 -/// -public class VisualConnector : ModuleVisual { - public Transform viewSpace; - public Transform connectorPrefab;//板片 - - protected override void Awake() => ModuleCore.VisualConnector = this; - - public override void UpdateVisual(DataConnector data) { - //更新板片 - Create(ref data.visual, connectorPrefab, viewSpace); - data.visual.UpdateVisual(data); - } - public override void ReleaseVisual(DataConnector data) { - if (data.visual != null) { - Destroy(data.visual.gameObject); - } - } -} diff --git a/Assets/ModuleCore/ModuleVisual/VisualConnector.cs.meta b/Assets/ModuleCore/ModuleVisual/VisualConnector.cs.meta deleted file mode 100644 index b572d24..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualConnector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ea4effe5ac0300348b249f05af7bf201 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleVisual/VisualDesign.cs b/Assets/ModuleCore/ModuleVisual/VisualDesign.cs deleted file mode 100644 index 925d22e..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualDesign.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 版片可视化模块 -/// -//public class VisualDesign : ModuleVisual { -// public Transform viewSpace; -// public Transform platePrefab;//板片 -// public Transform pointPrefab;//点 -// public Transform sidePrefab;//边 -// public Transform suturePrefab;//缝合 -// public Transform sutureSidePrefab;//缝合边 - -// protected override void Awake() => ModuleCore.VisualDesign = this; - -// public override void UpdateVisual(DataPlate plate) { -// //更新板片 -// Create(ref plate.design, platePrefab, viewSpace); -// plate.design.UpdateVisual(plate); -// //子数据父对象 -// Transform parent = plate.design.transform; -// //更新点 -// plate.points.ForEach(obj => UpdateVisual(obj, parent)); -// //更新线段 -// plate.sides.ForEach(obj => UpdateVisual(obj, parent)); -// } -// public override void ReleaseVisual(DataPlate data) { -// throw new System.NotImplementedException(); -// } - -// private void UpdateVisual(DataPoint point, Transform parent) { -// Create(ref point.visual, pointPrefab, parent); -// point.visual.UpdateVisual(point); -// } -// private void UpdateVisual(DataSide side, Transform parent) { -// Create(ref side.design, sidePrefab, parent); -// side.design.UpdateVisual(side); -// //更新缝合线 -// if (side.suture == null) { return; } -// side.suture.Update(); -// UpdateVisual(side.suture, viewSpace); -// } -// /// 更新缝合数据 -// private void UpdateVisual(DataSuture suture, Transform parent) { -// Create(ref suture.design, suturePrefab, parent); -// UpdateVisual(suture.a, suture.design.transform); -// UpdateVisual(suture.b, suture.design.transform); -// suture.design.UpdateVisual(suture); -// } -// /// 更新缝合边 -// private void UpdateVisual(DataSutureSide sutureSide, Transform parent) { -// Create(ref sutureSide.design, sutureSidePrefab, parent); -// sutureSide.design.UpdateVisual(sutureSide); -// } -//} diff --git a/Assets/ModuleCore/ModuleVisual/VisualDesign.cs.meta b/Assets/ModuleCore/ModuleVisual/VisualDesign.cs.meta deleted file mode 100644 index 1ae79cd..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ce128d679e2869147a5b5306cef090e3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleVisual/VisualPlateBaking.cs b/Assets/ModuleCore/ModuleVisual/VisualPlateBaking.cs deleted file mode 100644 index 41db98c..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualPlateBaking.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class VisualPlateBaking : ModuleVisual { - public Transform viewSpace; - public Transform platePrefab;//板片 - public Transform suturePrefab;//缝合 - public Transform sutureSidePrefab;//缝合边 - - protected override void Awake() => ModuleCore.VisualPlateBaking = this; - - public override void UpdateVisual(DataPlate plate) { - //更新板片 - Create(ref plate.bakingPrefab, platePrefab, viewSpace); - plate.bakingPrefab.UpdateVisual(plate); - //子数据父对象 - Transform parent = plate.designPrefab.transform; - //更新线段 - plate.plateSides.ForEach(obj => UpdateVisual(obj, parent)); - } - public override void ReleaseVisual(DataPlate data) { - throw new System.NotImplementedException(); - } - - private void UpdateVisual(DataPlateSide side, Transform parent) { - //Create(ref side.design, sidePrefab, parent); - //side.design.UpdateVisual(side); - //更新缝合线 - //if (side.suture == null) { return; } - //side.suture.Update(); - //UpdateVisual(side.suture, viewSpace); - } - /// 更新缝合数据 - private void UpdateVisual(DataSuture suture, Transform parent) { - Create(ref suture.baking, suturePrefab, parent); - UpdateVisual(suture.a, suture.baking.transform); - UpdateVisual(suture.b, suture.baking.transform); - suture.baking.UpdateVisual(suture); - } - /// 更新缝合边 - private void UpdateVisual(DataSutureSide sutureSide, Transform parent) { - Create(ref sutureSide.baking, sutureSidePrefab, parent); - sutureSide.baking.UpdateVisual(sutureSide); - } -} diff --git a/Assets/ModuleCore/ModuleVisual/VisualPlateBaking.cs.meta b/Assets/ModuleCore/ModuleVisual/VisualPlateBaking.cs.meta deleted file mode 100644 index 804c964..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualPlateBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ef4a839345dfb344382e257d374ca3ed -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleVisual/VisualPlateDesign.cs b/Assets/ModuleCore/ModuleVisual/VisualPlateDesign.cs deleted file mode 100644 index e9a4740..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualPlateDesign.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 版片可视化模块 -/// -public class VisualPlateDesign : ModuleVisual { - public Transform viewSpace; - public Transform platePrefab;//板片 - public Transform pointPrefab;//点 - public Transform sidePrefab;//边 - - protected override void Awake() => ModuleCore.VisualPlateDesign = this; - - public override void UpdateVisual(DataPlate plate) { - //更新板片 - Create(ref plate.designPrefab, platePrefab, viewSpace); - plate.designPrefab.UpdateVisual(plate); - //子数据父对象 - Transform parent = plate.designPrefab.transform; - //更新点 - plate.platePoints.ForEach(obj => UpdateVisual(obj, parent)); - //更新线段 - plate.plateSides.ForEach(obj => UpdateVisual(obj, parent)); - } - public override void ReleaseVisual(DataPlate data) { - throw new System.NotImplementedException(); - } - - private void UpdateVisual(DataPlatePoint point, Transform parent) { - Create(ref point.visual, pointPrefab, parent); - point.visual.UpdateVisual(point); - } - private void UpdateVisual(DataPlateSide side, Transform parent) { - Create(ref side.designPrefab, sidePrefab, parent); - side.designPrefab.UpdateVisual(side); - //更新缝合线 - if (side.suture != null) { side.suture.UpdateVisual(); } - } -} diff --git a/Assets/ModuleCore/ModuleVisual/VisualPlateDesign.cs.meta b/Assets/ModuleCore/ModuleVisual/VisualPlateDesign.cs.meta deleted file mode 100644 index 5dcd794..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualPlateDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f9827f83f79c2af42b2a06bdc3c80719 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleVisual/VisualSutureBaking.cs b/Assets/ModuleCore/ModuleVisual/VisualSutureBaking.cs deleted file mode 100644 index 63f9153..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualSutureBaking.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 缝合烘焙可视化模块 -/// -public class VisualSutureBaking : ModuleVisual { - public Transform viewSpace; - public Transform suturePrefab;//缝合 - public Transform sutureSidePrefab;//缝合边 - - protected override void Awake() => ModuleCore.VisualSutureBaking = this; - - public override void UpdateVisual(DataSuture suture) { - Create(ref suture.baking, suturePrefab, viewSpace); - suture.baking.UpdateVisual(suture); - - UpdateVisual(suture.a, suture.baking.transform); - UpdateVisual(suture.b, suture.baking.transform); - } - public override void ReleaseVisual(DataSuture data) { - throw new System.NotImplementedException(); - } - - /// 更新缝合边 - private void UpdateVisual(DataSutureSide sutureSide, Transform parent) { - Create(ref sutureSide.baking, sutureSidePrefab, parent); - sutureSide.baking.UpdateVisual(sutureSide); - } -} diff --git a/Assets/ModuleCore/ModuleVisual/VisualSutureBaking.cs.meta b/Assets/ModuleCore/ModuleVisual/VisualSutureBaking.cs.meta deleted file mode 100644 index 462bb67..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualSutureBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 06ff2a0f351be2d41aa7c8dfc23798e0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleVisual/VisualSutureDesign.cs b/Assets/ModuleCore/ModuleVisual/VisualSutureDesign.cs deleted file mode 100644 index 4114827..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualSutureDesign.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 缝合设计可视化模块 -/// -public class VisualSutureDesign : ModuleVisual { - public Transform viewSpace; - public Transform suturePrefab;//缝合 - public Transform sutureSidePrefab;//缝合边 - - protected override void Awake() => ModuleCore.VisualSutureDesign = this; - - public override void UpdateVisual(DataSuture suture) { - Create(ref suture.design, suturePrefab, viewSpace); - suture.design.UpdateVisual(suture); - - UpdateVisual(suture.a, suture.design.transform); - UpdateVisual(suture.b, suture.design.transform); - } - public override void ReleaseVisual(DataSuture data) { - throw new System.NotImplementedException(); - } - - /// 更新缝合边 - private void UpdateVisual(DataSutureSide sutureSide, Transform parent) { - Create(ref sutureSide.design, sutureSidePrefab, parent); - sutureSide.design.UpdateVisual(sutureSide); - } -} diff --git a/Assets/ModuleCore/ModuleVisual/VisualSutureDesign.cs.meta b/Assets/ModuleCore/ModuleVisual/VisualSutureDesign.cs.meta deleted file mode 100644 index 2cc63d1..0000000 --- a/Assets/ModuleCore/ModuleVisual/VisualSutureDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a43eabbe6a52df943b5157da8933dd33 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData.meta b/Assets/ModuleData.meta index 1c2f657..edff7c8 100644 --- a/Assets/ModuleData.meta +++ b/Assets/ModuleData.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2857d590c8aa00b41850f9d7eb170b60 +guid: 56476dea62b51fc41b2a53b9bdfaa56f folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleData/DataBezier.cs b/Assets/ModuleData/DataBezier.cs deleted file mode 100644 index cae4675..0000000 --- a/Assets/ModuleData/DataBezier.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataBezier { - /// 是否是a - public bool isA; - /// 关联的边 - public DataPlateSide side; - /// 位置 - public Vector3 position => isA ? side.aBezier : side.bBezier; - - public void SetBezierPosition(Vector3 value) { - if (isA) { side.SetBezierPositionA(value); } - else { side.SetBezierPositionB(value); } - side.plate.UpdateVisual(); - } -} diff --git a/Assets/ModuleData/DataBezier.cs.meta b/Assets/ModuleData/DataBezier.cs.meta deleted file mode 100644 index cd27f81..0000000 --- a/Assets/ModuleData/DataBezier.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 72061d1b84a6a8b41978089a92f87ccb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataBorder.cs b/Assets/ModuleData/DataBorder.cs deleted file mode 100644 index 8298a84..0000000 --- a/Assets/ModuleData/DataBorder.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// 边界数据 -public class DataBorder { - /// 网格细分 - public readonly float smooth = 0.01f; - /// minX - public readonly float minX = 0; - /// maxX - public readonly float maxX = 0; - /// minY - public readonly float minY = 0; - /// maxY - public readonly float maxY = 0; - /// 多边形边缘点 - public readonly Vector3[] points; - /// 边界数据 - public DataBorder(float minX, float maxX, float minY, float maxY, Vector3[] points) { - this.minX = minX; this.maxX = maxX; - this.minY = minY; this.maxY = maxY; - this.points = points; - } - /// 边界宽 - public float Wide => maxX - minX; - /// 边界高 - public float High => maxY - minY; - /// 网格宽 - public int GridWide => Mathf.FloorToInt(Wide / smooth) + 1; - /// 网格高 - public int GridHigh => Mathf.FloorToInt(High / smooth) + 1; - /// 最小点 - public Vector3 MinPoint => new Vector3(minX, minY, 0); - /// 最大点 - public Vector3 MaxPoint => new Vector3(maxX, maxY, 0); -} diff --git a/Assets/ModuleData/DataBorder.cs.meta b/Assets/ModuleData/DataBorder.cs.meta deleted file mode 100644 index 7de7431..0000000 --- a/Assets/ModuleData/DataBorder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 402c90a27e984c3448d7d1aec8ea3e78 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataConnector.cs b/Assets/ModuleData/DataConnector.cs deleted file mode 100644 index 642176e..0000000 --- a/Assets/ModuleData/DataConnector.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataConnector { - - #region 核心数据 - public Vector3 aPoint; - public Vector3 bPoint; - #endregion - - #region 可视化数据 - /// 可视化对象 - public PrefabConnector visual; - #endregion -} diff --git a/Assets/ModuleData/DataConnector.cs.meta b/Assets/ModuleData/DataConnector.cs.meta deleted file mode 100644 index 6f95d74..0000000 --- a/Assets/ModuleData/DataConnector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2aa5648d6f9298f4ab08f95a6cf4927a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataInsertPoint.cs b/Assets/ModuleData/DataInsertPoint.cs deleted file mode 100644 index 918dd40..0000000 --- a/Assets/ModuleData/DataInsertPoint.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataInsertPoint { - /// 位置 (需要和点同一个坐标系) - public Vector3 position; - /// 执行操作的板片 - public DataPlate plate; - /// A点 - public DataPoint aPoint; - /// B点 - public DataPoint bPoint; - /// 关联的线段 - public DataSide side; -} diff --git a/Assets/ModuleData/DataInsertPoint.cs.meta b/Assets/ModuleData/DataInsertPoint.cs.meta deleted file mode 100644 index c1f179c..0000000 --- a/Assets/ModuleData/DataInsertPoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 25155dff8d9629a46a71219ab08dd82a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataIntersect.cs b/Assets/ModuleData/DataIntersect.cs deleted file mode 100644 index d832758..0000000 --- a/Assets/ModuleData/DataIntersect.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// 交点信息 -public class DataIntersect { - public readonly DataSide side; - public readonly Vector3 position; - /// 交点信息 - public DataIntersect(DataSide side, Vector3 position) { - this.side = side; - this.position = position; - } - /// 是否相交 - public bool isIntersect; - /// 交点 - public Vector3 intersectPoint; -} diff --git a/Assets/ModuleData/DataIntersect.cs.meta b/Assets/ModuleData/DataIntersect.cs.meta deleted file mode 100644 index b128265..0000000 --- a/Assets/ModuleData/DataIntersect.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a8a4a29bf6f0fa14294e815ac39c81ad -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataMark.cs b/Assets/ModuleData/DataMark.cs deleted file mode 100644 index 6e8f10b..0000000 --- a/Assets/ModuleData/DataMark.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 标记数据 -/// -public class DataMark { - -} diff --git a/Assets/ModuleData/DataMark.cs.meta b/Assets/ModuleData/DataMark.cs.meta deleted file mode 100644 index 47888f0..0000000 --- a/Assets/ModuleData/DataMark.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 61c3a2815406bfa4190a319d431b8fc5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataMouseInput.cs.meta b/Assets/ModuleData/DataMouseInput.cs.meta index a17b262..4db797f 100644 --- a/Assets/ModuleData/DataMouseInput.cs.meta +++ b/Assets/ModuleData/DataMouseInput.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b9de608d5b0294a4a88d16ba5fdabfdc +guid: a8717da59b9a2e04ca682f70aaabee0e MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleData/DataPlate.meta b/Assets/ModuleData/DataPlate.meta deleted file mode 100644 index 9d155b9..0000000 --- a/Assets/ModuleData/DataPlate.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a9716b7730eb4544cae971a8de6cf9d4 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataLine.cs b/Assets/ModuleData/DataPlate/DataLine.cs deleted file mode 100644 index f7d715f..0000000 --- a/Assets/ModuleData/DataPlate/DataLine.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataLine { - public Vector3 a; - public Vector3 b; - - /// 曲线起点的距离 - public float origin; - - /// 线段距离 - public float Distance => Vector3.Distance(a, b); - /// 线段方向 - public Vector3 Direction => b - a; -} diff --git a/Assets/ModuleData/DataPlate/DataLine.cs.meta b/Assets/ModuleData/DataPlate/DataLine.cs.meta deleted file mode 100644 index 370c090..0000000 --- a/Assets/ModuleData/DataPlate/DataLine.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cb5a40cc1c1a0ed478a2b46bec653c2c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataPlate.cs b/Assets/ModuleData/DataPlate/DataPlate.cs deleted file mode 100644 index 33aaebf..0000000 --- a/Assets/ModuleData/DataPlate/DataPlate.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataPlate { - /// 核心模块 - private ModuleCore ModuleCore => ModuleCore.I; - /// 设计可视化模块 - private ModuleVisual VisualDesign => ModuleCore.VisualPlateDesign; - /// 烘焙可视化模块 - private ModuleVisual VisualBaking => ModuleCore.VisualPlateBaking; - /// 简单多边形算法模块 - private ModuleAlgorithm AlgorithmSimplePolygon => ModuleCore.AlgorithmSimplePolygon; - /// 细分多边形算法模块 - private ModuleAlgorithm AlgorithmSubdivisionPolygon => ModuleCore.AlgorithmSubdivisionPolygon; - - public DataPlate() { - dataDesign = new DataPlateDesign(this); - } - - public void UpdateVisual(bool recalculate = true) { - if (recalculate) { - //简单多边形计算 - AlgorithmSimplePolygon.Compute(this); - //细分多边形计算 - AlgorithmSubdivisionPolygon.Compute(this); - } - //生成可视化内容 - VisualDesign.UpdateVisual(this); - //生成烘焙内容 - VisualBaking.UpdateVisual(this); - } - - #region 核心数据 - /// - public List platePoints = new List(); - /// - public List plateSides = new List(); - #endregion - - #region 次要数据 - /// 设计缓存数据 - public DataPlateDesign dataDesign; - /// 烘焙缓存数据 - public DataPlateBaking dataBaking = new DataPlateBaking(); - #endregion - - #region 可视化数据 - /// 可视化对象 - public ModulePrefab designPrefab; - /// 可视化对象 - public ModulePrefab bakingPrefab; - /// 安排点 - public FixedArrange arrange; - #endregion - -} -/// 设计缓存数据 -public class DataPlateDesign { - /// 板片 - public readonly DataPlate plate; - /// 设计缓存数据 - public DataPlateDesign(DataPlate plate) => this.plate = plate; - - /// 板片的位置 - public Vector3 position; - /// 网格 - public Mesh mesh; - /// 边缘点 - public Vector3[] points; - /// 三角形数据 - public List triangles; -} -/// 烘焙缓存数据 -public class DataPlateBaking { - /// 网格 - public Mesh mesh; - /// 板片的位置 - public Vector3 position; - /// 板片的旋转 - public Vector3 eulerAngles; - /// 边界数据 - public DataBorder border; - /// 全部顶点 - public DataPlateVertex[] vertexs; -} \ No newline at end of file diff --git a/Assets/ModuleData/DataPlate/DataPlate.cs.meta b/Assets/ModuleData/DataPlate/DataPlate.cs.meta deleted file mode 100644 index 20e1cff..0000000 --- a/Assets/ModuleData/DataPlate/DataPlate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7f57f20fad19ed740adccdb0da9c4469 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataPlateLine.cs b/Assets/ModuleData/DataPlate/DataPlateLine.cs deleted file mode 100644 index 07b3c71..0000000 --- a/Assets/ModuleData/DataPlate/DataPlateLine.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// 线段 -public class DataPlateLine { - /// 线段起点a - public Vector3 a; - /// 线段终点b - public Vector3 b; - /// 原始距离 - public float origin; - /// 线段距离 - public float Distance => Vector3.Distance(a, b); - /// 线段方向 - public Vector3 Direction => b - a; -} diff --git a/Assets/ModuleData/DataPlate/DataPlateLine.cs.meta b/Assets/ModuleData/DataPlate/DataPlateLine.cs.meta deleted file mode 100644 index 7baaa57..0000000 --- a/Assets/ModuleData/DataPlate/DataPlateLine.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c7e8d3e741e703d49b33431b75a3a001 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataPlatePoint.cs b/Assets/ModuleData/DataPlate/DataPlatePoint.cs deleted file mode 100644 index 4411cc7..0000000 --- a/Assets/ModuleData/DataPlate/DataPlatePoint.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataPlatePoint { - /// 绑定的板片 - public readonly DataPlate plate; - /// 初始化 - public DataPlatePoint(DataPlate plate) => this.plate = plate; - - #region 核心数据 - /// 设计点位置(本地坐标系) - public Vector3 position; - #endregion - - #region 可视化数据 - /// 可视化对象 - public ModulePrefab visual; - #endregion -} diff --git a/Assets/ModuleData/DataPlate/DataPlatePoint.cs.meta b/Assets/ModuleData/DataPlate/DataPlatePoint.cs.meta deleted file mode 100644 index 494e3e4..0000000 --- a/Assets/ModuleData/DataPlate/DataPlatePoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6c2af0d32eea37f408900226b81e8e8a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataPlateSide.cs b/Assets/ModuleData/DataPlate/DataPlateSide.cs deleted file mode 100644 index 5e7f689..0000000 --- a/Assets/ModuleData/DataPlate/DataPlateSide.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using Unity.Collections; -using UnityEngine; - -public enum Bezier { - 一阶 = 0, 二阶 = 1, 三阶 = 2 -} -/// -public class DataPlateSide { - /// 绑定的板片 - public readonly DataPlate plate; - /// 初始化 - public DataPlateSide(DataPlate plate) => this.plate = plate; - - #region 核心数据 - /// 贝塞尔曲线阶数 - public Bezier bezier; - /// 起点 - public DataPlatePoint aPoint; - /// 终点 - public DataPlatePoint bPoint; - /// 贝塞尔曲线前(-) - public Vector3 aBezier; - /// 贝塞尔曲线后(+) - public Vector3 bBezier; - #endregion - - #region 次要数据 - /// 缝合数据 - public DataSuture suture; - /// 设计缓存数据 - public DataPlateSideDesign dataDesign = new DataPlateSideDesign(); - /// 烘焙缓存数据 - public DataPlateSideBaking dataBaking = new DataPlateSideBaking(); - #endregion - - #region 可视化内容 - /// 可视化边缘线 - public ModulePrefab designPrefab; - #endregion -} -/// 设计缓存数据 -public class DataPlateSideDesign { - /// 总长度 - public float length; - /// - public Vector3[] positions = new Vector3[0]; - /// 线 - public DataPlateLine[] lines = new DataPlateLine[0]; -} -/// 烘焙缓存数据 -public class DataPlateSideBaking { - /// 总长度 - public float length; - /// - public Vector3[] positions = new Vector3[0]; - /// 线 - public DataPlateLine[] lines = new DataPlateLine[0]; - /// 关联的网格顶点 - public DataPlateVertex[] vertexs = new DataPlateVertex[0]; -} \ No newline at end of file diff --git a/Assets/ModuleData/DataPlate/DataPlateSide.cs.meta b/Assets/ModuleData/DataPlate/DataPlateSide.cs.meta deleted file mode 100644 index 5b0bc68..0000000 --- a/Assets/ModuleData/DataPlate/DataPlateSide.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d0a57f0098d07ca4da0ca6e08c25662c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataPlateVertex.cs b/Assets/ModuleData/DataPlate/DataPlateVertex.cs deleted file mode 100644 index 5dd55e3..0000000 --- a/Assets/ModuleData/DataPlate/DataPlateVertex.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataPlateVertex { - /// 是否是有效顶点 - public bool isValid; - /// 设计视图中位置 - public Vector3 position; - - /// - public DataPlateVertex above; - /// - public DataPlateVertex below; - /// - public DataPlateVertex left; - /// - public DataPlateVertex right; - - /// 左上 - public DataPlateVertex leftAbove; - /// 左下 - public DataPlateVertex leftBelow; - /// 右上 - public DataPlateVertex rightAbove; - /// 右下 - public DataPlateVertex rightBelow; -} diff --git a/Assets/ModuleData/DataPlate/DataPlateVertex.cs.meta b/Assets/ModuleData/DataPlate/DataPlateVertex.cs.meta deleted file mode 100644 index 5a6ab0b..0000000 --- a/Assets/ModuleData/DataPlate/DataPlateVertex.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9842037a7f0169b4bb8a4b70047f7739 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataPoint.cs b/Assets/ModuleData/DataPlate/DataPoint.cs deleted file mode 100644 index 01ef05c..0000000 --- a/Assets/ModuleData/DataPlate/DataPoint.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataPoint { - /// 绑定的板片 - public readonly DataPlate plate; - /// 初始化 - public DataPoint(DataPlate plate) => this.plate = plate; - - #region 核心数据 - /// 设计点位置(本地坐标系) - public Vector3 position; - #endregion - - #region 可视化数据 - /// 可视化对象 - public ModulePrefab visual; - #endregion -} diff --git a/Assets/ModuleData/DataPlate/DataPoint.cs.meta b/Assets/ModuleData/DataPlate/DataPoint.cs.meta deleted file mode 100644 index e74963c..0000000 --- a/Assets/ModuleData/DataPlate/DataPoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 753c1b80d6d80af4baaa095760bdc3f5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataSide.cs b/Assets/ModuleData/DataPlate/DataSide.cs deleted file mode 100644 index b1cbfaf..0000000 --- a/Assets/ModuleData/DataPlate/DataSide.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -//public enum Bezier { -// 一阶 = 0, 二阶 = 1, 三阶 = 2 -//} -public class DataSide { - /// 绑定的板片 - public readonly DataPlate plate; - /// 初始化 - public DataSide(DataPlate plate) => this.plate = plate; - - #region 核心数据 - /// 贝塞尔曲线阶数 - public Bezier bezier; - /// 起点 - public DataPoint aPoint; - /// 终点 - public DataPoint bPoint; - /// 贝塞尔曲线前(-) - public Vector3 aBezier; - /// 贝塞尔曲线后(+) - public Vector3 bBezier; - #endregion - - #region 次要数据 - /// 边长度 - public float length; - /// 缝合数据 - public DataSuture suture; - /// 边缘点 - public Vector3[] positions = new Vector3[0]; - /// 边缘线 - public DataLine[] lines = new DataLine[0]; - /// 边缘顶点数据 - public DataVertex[] vertices = new DataVertex[0]; - #endregion - - #region 可视化内容 - /// 可视化边缘线 - public ModulePrefab design; - #endregion -} diff --git a/Assets/ModuleData/DataPlate/DataSide.cs.meta b/Assets/ModuleData/DataPlate/DataSide.cs.meta deleted file mode 100644 index 127963a..0000000 --- a/Assets/ModuleData/DataPlate/DataSide.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d40ac12110b85ce4daf740db4dd0a5ef -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlate/DataVertex.cs b/Assets/ModuleData/DataPlate/DataVertex.cs deleted file mode 100644 index b7f6402..0000000 --- a/Assets/ModuleData/DataPlate/DataVertex.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataVertex { - /// 是否是有效顶点 - public bool isValid; - /// 设计视图中位置 - public Vector3 design; - /// 烘焙视图中位置 - public Vector3 baking; - - /// - public DataVertex above; - /// - public DataVertex below; - /// - public DataVertex left; - /// - public DataVertex right; - - /// 左上 - public DataVertex leftAbove; - /// 左下 - public DataVertex leftBelow; - /// 右上 - public DataVertex rightAbove; - /// 右下 - public DataVertex rightBelow; -} diff --git a/Assets/ModuleData/DataPlate/DataVertex.cs.meta b/Assets/ModuleData/DataPlate/DataVertex.cs.meta deleted file mode 100644 index 7e237e4..0000000 --- a/Assets/ModuleData/DataPlate/DataVertex.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: de6bdf5f7fa27c4409fa7179f281284d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPlatePresets.cs b/Assets/ModuleData/DataPlatePresets.cs deleted file mode 100644 index ed553b0..0000000 --- a/Assets/ModuleData/DataPlatePresets.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[CreateAssetMenu(fileName = "PresetsPlate", menuName = "数据模块/预设模板")] -public class DataPlatePresets : ScriptableObject { - public List designPoints; -} diff --git a/Assets/ModuleData/DataPlatePresets.cs.meta b/Assets/ModuleData/DataPlatePresets.cs.meta deleted file mode 100644 index 3abaa47..0000000 --- a/Assets/ModuleData/DataPlatePresets.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: de9e8e0217c52a447a49c55f818131ef -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataPolygon.cs b/Assets/ModuleData/DataPolygon.cs deleted file mode 100644 index 84eece6..0000000 --- a/Assets/ModuleData/DataPolygon.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataPolygon { - - #region 次要数据 - /// 平面网格 - public Mesh mesh; - /// 三角形数据 - public List triangles; - #endregion - - #region 可视化数据 - /// 可视化对象 - public MeshFilter meshFilter; - #endregion - -} diff --git a/Assets/ModuleData/DataPolygon.cs.meta b/Assets/ModuleData/DataPolygon.cs.meta deleted file mode 100644 index 1f54e21..0000000 --- a/Assets/ModuleData/DataPolygon.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3de8098a0297b56429874d2696f59d43 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataSuture.meta b/Assets/ModuleData/DataSuture.meta deleted file mode 100644 index e79e12c..0000000 --- a/Assets/ModuleData/DataSuture.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 90a78d920e0cdd4458a7c0c93646c461 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataSuture/DataSuture.cs b/Assets/ModuleData/DataSuture/DataSuture.cs deleted file mode 100644 index 53442fd..0000000 --- a/Assets/ModuleData/DataSuture/DataSuture.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataSuture { - /// 核心模块 - private ModuleCore ModuleCore => ModuleCore.I; - /// 设计可视化模块 - private ModuleVisual VisualDesign => ModuleCore.VisualSutureDesign; - /// 烘焙可视化模块 - private ModuleVisual VisualBaking => ModuleCore.VisualSutureBaking; - /// 缝合线算法模块 - private ModuleAlgorithm AlgorithmSuture => ModuleCore.AlgorithmSuture; - - public readonly DataSutureSide a; - public readonly DataSutureSide b; - public DataSuture(DataPlateSide aSide, DataPlateSide bSide) { - a = new DataSutureSide(aSide, this); - b = new DataSutureSide(bSide, this); - UpdateVisual(); - } - - public void UpdateVisual() { - AlgorithmSuture.Compute(this); - VisualDesign.UpdateVisual(this); - VisualBaking.UpdateVisual(this); - } - - #region 次要数据 - /// 缝合长度 - public float length; - /// 缝合点 - public List points; - #endregion - - #region 可视化内容 - /// 可视化内容 - public ModulePrefab design; - /// 可视化对象 - public ModulePrefab baking; - #endregion - -} diff --git a/Assets/ModuleData/DataSuture/DataSuture.cs.meta b/Assets/ModuleData/DataSuture/DataSuture.cs.meta deleted file mode 100644 index b1d6114..0000000 --- a/Assets/ModuleData/DataSuture/DataSuture.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: db7180cdc51fba54ebc54927eaa2c246 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataSuture/DataSuturePoint.cs b/Assets/ModuleData/DataSuture/DataSuturePoint.cs deleted file mode 100644 index 6378f69..0000000 --- a/Assets/ModuleData/DataSuture/DataSuturePoint.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataSuturePoint { - /// aAnchor到vertex的距离 - public float distance; - /// 绑定的顶点 - public DataPlateVertex vertex; - /// 锚点a - public DataPlateVertex aAnchor; - /// 锚点b - public DataPlateVertex bAnchor; -} diff --git a/Assets/ModuleData/DataSuture/DataSuturePoint.cs.meta b/Assets/ModuleData/DataSuture/DataSuturePoint.cs.meta deleted file mode 100644 index a36a95c..0000000 --- a/Assets/ModuleData/DataSuture/DataSuturePoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fab08a6f4689d1c4b94d2fd7f05fedbe -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataSuture/DataSutureSide.cs b/Assets/ModuleData/DataSuture/DataSutureSide.cs deleted file mode 100644 index a139263..0000000 --- a/Assets/ModuleData/DataSuture/DataSutureSide.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 缝合边 -/// -public class DataSutureSide { - /// 关联的边 - public readonly DataPlateSide plateSide; - /// 关联的缝合数据 - public readonly DataSuture suture; - /// 缝合边 - public DataSutureSide(DataPlateSide side, DataSuture suture) { - this.plateSide = side; - this.suture = suture; - } - - #region 核心数据 - /// 是否反转 - public bool isReversal; - #endregion - - #region 次要数据 - /// 设计缓存数据 - public DataSutureSideDesign dataDesign = new DataSutureSideDesign(); - /// 烘焙缓存数据 - public DataSutureSideBaking dataBaking = new DataSutureSideBaking(); - #endregion - - #region 可视化数据 - /// 可视化对象 - public ModulePrefab design; - /// 可视化对象 - public ModulePrefab baking; - #endregion -} -/// 设计缓存数据 -public class DataSutureSideDesign { - /// 位置列表 - public Vector3[] positions; - /// A点位置 - public Vector3 PointA => positions[0]; - /// B点位置 - public Vector3 PointB => positions[positions.Length - 1]; -} -/// 烘焙缓存数据 -public class DataSutureSideBaking { - /// 位置列表 - public Vector3[] positions; - /// 全部顶点列表 - public DataSutureSideVertex[] allVertexs; - /// 关联的顶点列表 - public DataSutureSideVertex[] vertexs; - /// A点位置 - public Vector3 PointA => positions[0]; - /// B点位置 - public Vector3 PointB => positions[positions.Length - 1]; -} -public class DataSutureSideVertex { - /// 边起点到a点的距离 - public float origin; - /// a点 - public DataPlateVertex a; - /// a点的下一个点 - public DataPlateVertex b; - /// 缝合边顶点 - public DataSutureSideVertex(float origin, DataPlateVertex a, DataPlateVertex b) { - this.origin = origin; - this.a = a; - this.b = b; - } - /// 最大距离 origin + a - b - public float MaxDistance => origin + Distance; - /// 分段距离 a-b - public float Distance => Vector3.Distance(a.position, b.position); -} \ No newline at end of file diff --git a/Assets/ModuleData/DataSuture/DataSutureSide.cs.meta b/Assets/ModuleData/DataSuture/DataSutureSide.cs.meta deleted file mode 100644 index 5a51d19..0000000 --- a/Assets/ModuleData/DataSuture/DataSutureSide.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cd87f3680da7d114ca6d49384e0212a4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleData/DataTriangle.cs b/Assets/ModuleData/DataTriangle.cs deleted file mode 100644 index 59d0d42..0000000 --- a/Assets/ModuleData/DataTriangle.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public struct DataTriangle { - public Vector3 a; - public Vector3 b; - public Vector3 c; - - public override string ToString() { - return $"{a} , {b} , {c}"; - } -} diff --git a/Assets/ModuleData/DataTriangle.cs.meta b/Assets/ModuleData/DataTriangle.cs.meta deleted file mode 100644 index 7bb3f0d..0000000 --- a/Assets/ModuleData/DataTriangle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0119f0f1ae644424b8ed9bd212d86ec1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleFixed.meta b/Assets/ModuleFixed.meta index 05ad472..ff10e49 100644 --- a/Assets/ModuleFixed.meta +++ b/Assets/ModuleFixed.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c656e0d2f7e80eb4c9d4a345d1b71a2d +guid: b0dab98b9033323428c3db1f2c7946c0 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleFixed/FixedArrange.cs b/Assets/ModuleFixed/FixedArrange.cs deleted file mode 100644 index e6cb474..0000000 --- a/Assets/ModuleFixed/FixedArrange.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class FixedArrange : ModuleFixed { - public GameObject markPoints; - private void Awake() { - ModuleCore.OnBakingMobilePlate += ModuleCore_OnBakingMobilePlate; - } - private void OnDestroy() { - ModuleCore.OnBakingMobilePlate -= ModuleCore_OnBakingMobilePlate; - } - private void ModuleCore_OnBakingMobilePlate(DataPlate obj) { - markPoints.SetActive(obj != null); - } -} diff --git a/Assets/ModuleFixed/FixedArrange.cs.meta b/Assets/ModuleFixed/FixedArrange.cs.meta deleted file mode 100644 index 9329e4d..0000000 --- a/Assets/ModuleFixed/FixedArrange.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1114659c98eaef449fcb99cfb34b313 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleFixed/ModuleFixed.cs.meta b/Assets/ModuleFixed/ModuleFixed.cs.meta index 99f6505..9b7a292 100644 --- a/Assets/ModuleFixed/ModuleFixed.cs.meta +++ b/Assets/ModuleFixed/ModuleFixed.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: eec3b1cad3ba3554fa807026197bba57 +guid: 529fed83b6e5fff43b7bdf3eca7dbd0e MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModulePrefab.meta b/Assets/ModulePrefab.meta index dfb5e21..79655c9 100644 --- a/Assets/ModulePrefab.meta +++ b/Assets/ModulePrefab.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6e7511bbe5bc5ef488c36c5aa60d5406 +guid: b8989716a20d28b4180f6cceee0898f7 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModulePrefab/ModulePrefab.cs.meta b/Assets/ModulePrefab/ModulePrefab.cs.meta index 0f47307..7b1e8b7 100644 --- a/Assets/ModulePrefab/ModulePrefab.cs.meta +++ b/Assets/ModulePrefab/ModulePrefab.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f29e3f72f567ffc4f97bdc9129f2fe1b +guid: 84ffbf591cb4c0e4483f5c577ba37d68 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModulePrefab/PrefabConnector.cs b/Assets/ModulePrefab/PrefabConnector.cs deleted file mode 100644 index d134ca8..0000000 --- a/Assets/ModulePrefab/PrefabConnector.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabConnector : ModulePrefab { - - public Transform aPonit; - public Transform bPoint; - public LineRenderer lineRenderer; - private DataConnector connector; - - public override DataConnector Value => connector; - - public override void UpdateVisual(DataConnector connector) { - this.connector = connector; - aPonit.localPosition = connector.aPoint; - bPoint.localPosition = connector.bPoint; - lineRenderer.SetPosition(0, connector.aPoint); - lineRenderer.SetPosition(1, connector.bPoint); - } - -} diff --git a/Assets/ModulePrefab/PrefabConnector.cs.meta b/Assets/ModulePrefab/PrefabConnector.cs.meta deleted file mode 100644 index 8af5138..0000000 --- a/Assets/ModulePrefab/PrefabConnector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 139466628cb8f5d4882b2c4d84899b57 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModulePrefab/PrefabPlateBaking.cs b/Assets/ModulePrefab/PrefabPlateBaking.cs deleted file mode 100644 index 479d2ca..0000000 --- a/Assets/ModulePrefab/PrefabPlateBaking.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabPlateBaking : ModulePrefab { - - private DataPlate plate; - private MeshFilter meshFilter => GetComponent(); - private MeshCollider meshCollider => GetComponent(); - - public override DataPlate Value => plate; - - public override void UpdateVisual(DataPlate plate) { - this.plate = plate; - DataPlateBaking baking = plate.dataBaking; - //transform.localPosition = baking.position; - //transform.localEulerAngles = baking.eulerAngles; - meshFilter.mesh = baking.mesh; - meshCollider.sharedMesh = baking.mesh; - } -} diff --git a/Assets/ModulePrefab/PrefabPlateBaking.cs.meta b/Assets/ModulePrefab/PrefabPlateBaking.cs.meta deleted file mode 100644 index c9875b8..0000000 --- a/Assets/ModulePrefab/PrefabPlateBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 78d649ecc86d78140a6fc3668cfd51d1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModulePrefab/PrefabPlateDesign.cs b/Assets/ModulePrefab/PrefabPlateDesign.cs deleted file mode 100644 index be15782..0000000 --- a/Assets/ModulePrefab/PrefabPlateDesign.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabPlateDesign : ModulePrefab { - - private DataPlate plate; - private MeshFilter meshFilter => GetComponent(); - private MeshCollider meshCollider => GetComponent(); - - public override DataPlate Value => plate; - - public override void UpdateVisual(DataPlate plate) { - this.plate = plate; - DataPlateDesign design = plate.dataDesign; - transform.localPosition = design.position; - meshFilter.mesh = design.mesh; - meshCollider.sharedMesh = design.mesh; - } - -} diff --git a/Assets/ModulePrefab/PrefabPlateDesign.cs.meta b/Assets/ModulePrefab/PrefabPlateDesign.cs.meta deleted file mode 100644 index 21eb2c2..0000000 --- a/Assets/ModulePrefab/PrefabPlateDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 96e2853481aa5c647a532a352a3c33d8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModulePrefab/PrefabPoint.cs b/Assets/ModulePrefab/PrefabPoint.cs deleted file mode 100644 index 91df555..0000000 --- a/Assets/ModulePrefab/PrefabPoint.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabPoint : ModulePrefab { - private DataPlatePoint point; - - public override DataPlatePoint Value => point; - - public override void UpdateVisual(DataPlatePoint point) { - this.point = point; - transform.localPosition = point.position; - } -} diff --git a/Assets/ModulePrefab/PrefabPoint.cs.meta b/Assets/ModulePrefab/PrefabPoint.cs.meta deleted file mode 100644 index 5be7b1f..0000000 --- a/Assets/ModulePrefab/PrefabPoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4746c152c7202c84f974eeab499c1e8c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModulePrefab/PrefabSide.cs b/Assets/ModulePrefab/PrefabSide.cs deleted file mode 100644 index dbcec12..0000000 --- a/Assets/ModulePrefab/PrefabSide.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabSide : ModulePrefab { - public Transform aPoint; - public Transform bPoint; - public LineRenderer lineRenderer; - public LineRenderer aBezier; - public LineRenderer bBezier; - private DataPlateSide side; - - #region 引用模块 - /// 设计UI输入模块 - public ModuleUIInput UIInputDesign => ModuleCore.I.UIInputDesign; - #endregion - - public override DataPlateSide Value => side; - - private void Awake() { - UIInputDesign.OnChangeInput += UIInputDesign_OnChangeInput; - } - private void OnDestroy() { - if (UIInputDesign == null) { return; } - UIInputDesign.OnChangeInput -= UIInputDesign_OnChangeInput; - } - - private void UIInputDesign_OnChangeInput(UnitMouseInput obj) { - Type type = UIInputDesign.Current.GetType(); - if (type == typeof(DesignBezier)) { UpdateVisual(side); return; } - aPoint.gameObject.SetActive(false); - bPoint.gameObject.SetActive(false); - aBezier.gameObject.SetActive(false); - bBezier.gameObject.SetActive(false); - } - public override void UpdateVisual(DataPlateSide side) { - this.side = side; - - DataPlateSideDesign design = side.dataDesign; - lineRenderer.positionCount = design.positions.Length; - lineRenderer.SetPositions(design.positions); - - Type type = UIInputDesign.Current.GetType(); - if (type != typeof(DesignBezier)) { ActiveGameObject(false); return; } - if (side.bezier == Bezier.一阶) { ActiveGameObject(false); return; } - if (side.bezier == Bezier.二阶) { ActiveGameObject(true); } - if (side.bezier == Bezier.三阶) { ActiveGameObject(true); } - - aPoint.localPosition = side.aBezier; - bPoint.localPosition = side.bBezier; - aBezier.SetPosition(0, side.aPoint.position); - aBezier.SetPosition(1, side.aBezier); - bBezier.SetPosition(0, side.bPoint.position); - bBezier.SetPosition(1, side.bBezier); - } - private void ActiveGameObject(bool isActive) { - aPoint.gameObject.SetActive(isActive); - bPoint.gameObject.SetActive(isActive); - aBezier.gameObject.SetActive(isActive); - bBezier.gameObject.SetActive(isActive); - } - -} diff --git a/Assets/ModulePrefab/PrefabSide.cs.meta b/Assets/ModulePrefab/PrefabSide.cs.meta deleted file mode 100644 index ad0bbe2..0000000 --- a/Assets/ModulePrefab/PrefabSide.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b75d83af36741c649b1caa22b1bd103c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModulePrefab/PrefabSutureBaking.cs b/Assets/ModulePrefab/PrefabSutureBaking.cs deleted file mode 100644 index b027967..0000000 --- a/Assets/ModulePrefab/PrefabSutureBaking.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabSutureBaking : ModulePrefab { - - public LineRenderer aLineRenderer; - public LineRenderer bLineRenderer; - - private DataSuture suture; - - public override DataSuture Value => suture; - - public override void UpdateVisual(DataSuture suture) { - this.suture = suture; - - DataSutureSideBaking aBaking = suture.a.dataBaking; - DataSutureSideBaking bBaking = suture.b.dataBaking; - aLineRenderer.SetPosition(0, aBaking.PointA); - aLineRenderer.SetPosition(1, bBaking.PointA); - - bLineRenderer.SetPosition(0, aBaking.PointB); - bLineRenderer.SetPosition(1, bBaking.PointB); - } -} diff --git a/Assets/ModulePrefab/PrefabSutureBaking.cs.meta b/Assets/ModulePrefab/PrefabSutureBaking.cs.meta deleted file mode 100644 index f6c1d7e..0000000 --- a/Assets/ModulePrefab/PrefabSutureBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 75e541a37f3fd844bbf81bc250bd1a23 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModulePrefab/PrefabSutureDesign.cs b/Assets/ModulePrefab/PrefabSutureDesign.cs deleted file mode 100644 index 132af21..0000000 --- a/Assets/ModulePrefab/PrefabSutureDesign.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabSutureDesign : ModulePrefab { - - public LineRenderer aLineRenderer; - public LineRenderer bLineRenderer; - - private DataSuture suture; - - public override DataSuture Value => suture; - - public override void UpdateVisual(DataSuture suture) { - this.suture = suture; - - DataSutureSideDesign aDesign = suture.a.dataDesign; - DataSutureSideDesign bDesign = suture.b.dataDesign; - aLineRenderer.SetPosition(0, aDesign.PointA); - aLineRenderer.SetPosition(1, bDesign.PointA); - - bLineRenderer.SetPosition(0, aDesign.PointB); - bLineRenderer.SetPosition(1, bDesign.PointB); - } -} diff --git a/Assets/ModulePrefab/PrefabSutureDesign.cs.meta b/Assets/ModulePrefab/PrefabSutureDesign.cs.meta deleted file mode 100644 index 0e0191f..0000000 --- a/Assets/ModulePrefab/PrefabSutureDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1eb2df51fd021c64ba16fd7aea74de71 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModulePrefab/PrefabSutureSideBaking.cs b/Assets/ModulePrefab/PrefabSutureSideBaking.cs deleted file mode 100644 index 8504900..0000000 --- a/Assets/ModulePrefab/PrefabSutureSideBaking.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabSutureSideBaking : ModulePrefab { - - private DataSutureSide sutureSide; - - public override DataSutureSide Value => sutureSide; - public LineRenderer lineRenderer => GetComponent(); - - public override void UpdateVisual(DataSutureSide sutureSide) { - this.sutureSide = sutureSide; - - DataSutureSideBaking baking = sutureSide.dataBaking; - lineRenderer.positionCount = baking.positions.Length; - lineRenderer.SetPositions(baking.positions); - } -} diff --git a/Assets/ModulePrefab/PrefabSutureSideBaking.cs.meta b/Assets/ModulePrefab/PrefabSutureSideBaking.cs.meta deleted file mode 100644 index e25c1c6..0000000 --- a/Assets/ModulePrefab/PrefabSutureSideBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f3f822abebf5e5c4a9d564052bddb818 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModulePrefab/PrefabSutureSideDesign.cs b/Assets/ModulePrefab/PrefabSutureSideDesign.cs deleted file mode 100644 index ae5f52f..0000000 --- a/Assets/ModulePrefab/PrefabSutureSideDesign.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PrefabSutureSideDesign : ModulePrefab { - - private DataSutureSide sutureSide; - - public override DataSutureSide Value => sutureSide; - public LineRenderer lineRenderer => GetComponent(); - - public override void UpdateVisual(DataSutureSide sutureSide) { - this.sutureSide = sutureSide; - - DataSutureSideDesign design = sutureSide.dataDesign; - lineRenderer.positionCount = design.positions.Length; - lineRenderer.SetPositions(design.positions); - } -} diff --git a/Assets/ModulePrefab/PrefabSutureSideDesign.cs.meta b/Assets/ModulePrefab/PrefabSutureSideDesign.cs.meta deleted file mode 100644 index 60a6f4e..0000000 --- a/Assets/ModulePrefab/PrefabSutureSideDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4f5c45672bf96354da7017651e332f58 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleTools.meta b/Assets/ModuleTools.meta index b528a0e..fe8d336 100644 --- a/Assets/ModuleTools.meta +++ b/Assets/ModuleTools.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f681d7f25ba1c8543ba8d133e7bede99 +guid: 3161d7f50e461bf4896cdd13d8b508be folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleTools/DataSideTool.cs b/Assets/ModuleTools/DataSideTool.cs deleted file mode 100644 index 897a4aa..0000000 --- a/Assets/ModuleTools/DataSideTool.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public static class DataSideTool { - public static void SetBezierPositionA(this DataPlateSide side, Vector3 position) { - if (side.bezier == Bezier.一阶) { return; } - if (side.bezier == Bezier.二阶) { side.bBezier = position; } - side.aBezier = position; - } - public static void SetBezierPositionB(this DataPlateSide side, Vector3 position) { - if (side.bezier == Bezier.一阶) { return; } - if (side.bezier == Bezier.二阶) { side.aBezier = position; } - side.bBezier = position; - } - public static void OneRankBezier(this DataPlateSide side) { - side.bezier = Bezier.一阶; - } - public static void TwoRankBezier(this DataPlateSide side) { - side.bezier = Bezier.二阶; - DataPlatePoint a = side.aPoint; - DataPlatePoint b = side.bPoint; - side.aBezier = a.position + (b.position - a.position) * 0.5f; - side.bBezier = a.position + (b.position - a.position) * 0.5f; - } - public static void ThreeRankBezier(this DataPlateSide side) { - side.bezier = Bezier.三阶; - DataPlatePoint a = side.aPoint; - DataPlatePoint b = side.bPoint; - side.aBezier = a.position + (b.position - a.position) * 0.3f; - side.bBezier = a.position + (b.position - a.position) * 0.7f; - } -} diff --git a/Assets/ModuleTools/DataSideTool.cs.meta b/Assets/ModuleTools/DataSideTool.cs.meta deleted file mode 100644 index 0ab9b95..0000000 --- a/Assets/ModuleTools/DataSideTool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d2976a2951aeed54fab8d29f912822f4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleTools/DataSutureTool.cs b/Assets/ModuleTools/DataSutureTool.cs deleted file mode 100644 index 874573c..0000000 --- a/Assets/ModuleTools/DataSutureTool.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public static class DataSutureTool { - //public static float SutureLength(this DataSuture suture) { - // if (suture.a.MaxLength < suture.b.MaxLength) { - // return suture.a.MaxLength; - // } - // else { return suture.b.MaxLength; } - //} -} diff --git a/Assets/ModuleTools/DataSutureTool.cs.meta b/Assets/ModuleTools/DataSutureTool.cs.meta deleted file mode 100644 index ae4987e..0000000 --- a/Assets/ModuleTools/DataSutureTool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 37c96b1f560cfb14caa5c758ce900239 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleTools/GridTool.cs b/Assets/ModuleTools/GridTool.cs deleted file mode 100644 index 1967221..0000000 --- a/Assets/ModuleTools/GridTool.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class GridTool { - public Data[,] array; - public readonly int wide; - public readonly int high; - /// 初始化网格 - public GridTool(int wide, int high, Func generate) { - this.wide = wide; - this.high = high; - array = new Data[wide, high]; - Loop((x, y) => { array[x, y] = generate(x, y); }); - } - /// 循环网格获取x和y - public void Loop(Action action) { - for (int y = 0; y < high; y++) { - for (int x = 0; x < wide; x++) { action?.Invoke(x, y); } - } - } - /// 校验xy是否超限 - public bool TryXY(int x, int y) { - return x >= 0 && x < wide && y >= 0 && y < high; - } - /// 强制写入数据,超过边界时写在边界 - public Data Get(int x, int y) { - x = Mathf.Clamp(x, 0, wide - 1); - y = Mathf.Clamp(y, 0, high - 1); - return array[x, y]; - } - /// 强制读取数据,超过边界时读取边界 - public void Set(int x, int y, Data data) { - x = Mathf.Clamp(x, 0, wide - 1); - y = Mathf.Clamp(y, 0, high - 1); - array[x, y] = data; - } - /// 校验xy是否超限 读取正确范围内的数据 - public bool TryGet(int x, int y, out Data data) { - data = Get(x, y); return TryXY(x, y); - } - /// 校验xy是否超限 写入正确范围内的数据 - public bool TrySet(int x, int y, Data data) { - if (TryXY(x, y)) { array[x, y] = data; return true; } - else { return false; } - } -} diff --git a/Assets/ModuleTools/GridTool.cs.meta b/Assets/ModuleTools/GridTool.cs.meta deleted file mode 100644 index 7cb6e8d..0000000 --- a/Assets/ModuleTools/GridTool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0d586f3bf8d81b64da59700b2f31c48a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleTools/LayerMaskTool.cs b/Assets/ModuleTools/LayerMaskTool.cs deleted file mode 100644 index 2010551..0000000 --- a/Assets/ModuleTools/LayerMaskTool.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 图层遮罩工具 -/// -public static class LayerMaskTool { - /// 安排点图层遮罩 - public static readonly LayerMask Arrange = 1 << LayerMask.NameToLayer("Arrange"); -} diff --git a/Assets/ModuleTools/LayerMaskTool.cs.meta b/Assets/ModuleTools/LayerMaskTool.cs.meta deleted file mode 100644 index 2ffe0f2..0000000 --- a/Assets/ModuleTools/LayerMaskTool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f6c7eea6439008142b8aaeae1445a351 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleTools/LoopIndexTool.cs b/Assets/ModuleTools/LoopIndexTool.cs deleted file mode 100644 index e3e14f3..0000000 --- a/Assets/ModuleTools/LoopIndexTool.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public static class LoopIndexTool { - /// 头尾循环标准化索引 - public static Data LoopIndex(this List list, int index) { - return list[LoopIndex(index, list.Count)]; - } - /// 头尾循环标准化索引 - public static Data LoopIndex(this Data[] array, int index) { - return array[LoopIndex(index, array.Length)]; - } - /// 头尾循环标准化索引 - public static int LoopIndex(int index, int maxIndex) { - if (maxIndex == 0) { Debug.LogError("错误索引:maxIndex = 0"); return 0; } - if (index < 0) { return LoopIndex(index + maxIndex, maxIndex); } - if (index >= maxIndex) { return LoopIndex(index - maxIndex, maxIndex); } - return index; - } -} diff --git a/Assets/ModuleTools/LoopIndexTool.cs.meta b/Assets/ModuleTools/LoopIndexTool.cs.meta deleted file mode 100644 index 1bdb6eb..0000000 --- a/Assets/ModuleTools/LoopIndexTool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6c9df3d905e1531439a43a695934de29 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleTools/Module.cs b/Assets/ModuleTools/Module.cs new file mode 100644 index 0000000..9cf1683 --- /dev/null +++ b/Assets/ModuleTools/Module.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 模块基类 +/// +/// +public class Module where ModuleCore : Module, new() { + /// 模块单例 + public static ModuleCore I => Instantiate(); + + private static ModuleCore core; + private static ModuleCore Instantiate() => core == null ? core = new ModuleCore() : core; +} diff --git a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmEdge.cs.meta b/Assets/ModuleTools/Module.cs.meta similarity index 83% rename from Assets/ModuleCore/ModuleAlgorithm/AlgorithmEdge.cs.meta rename to Assets/ModuleTools/Module.cs.meta index 3a9d8d8..d72d566 100644 --- a/Assets/ModuleCore/ModuleAlgorithm/AlgorithmEdge.cs.meta +++ b/Assets/ModuleTools/Module.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d17cdf61cce7657489b657640646a786 +guid: 86acb6fd9f576cc458df7bcc1581c098 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleTools/VectorTool.cs b/Assets/ModuleTools/VectorTool.cs deleted file mode 100644 index 2f15959..0000000 --- a/Assets/ModuleTools/VectorTool.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public static class VectorTool { - /// 向量的xyz和 - public static float VectorSum(this Vector3 v) { - return v.x + v.y + v.z; - } -} diff --git a/Assets/ModuleTools/VectorTool.cs.meta b/Assets/ModuleTools/VectorTool.cs.meta deleted file mode 100644 index de19f39..0000000 --- a/Assets/ModuleTools/VectorTool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3909cc8b21b91e740b86bb3a8ffcda0e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit.meta b/Assets/ModuleUnit.meta index 3d833b4..3a7378e 100644 --- a/Assets/ModuleUnit.meta +++ b/Assets/ModuleUnit.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: abb7449466a8f3b4ea6cd8d497cdb279 +guid: eb08bfa039088344e9950d9325b67e71 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleUnit/UnitAlgorithm.meta b/Assets/ModuleUnit/UnitAlgorithm.meta deleted file mode 100644 index a4e1160..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e32e80c5be1d97347ba09f54d8962952 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithm.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithm.cs deleted file mode 100644 index b887db3..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithm.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 单个算法函数 -/// -/// -public interface UnitAlgorithm { - /// 执行算法 - public void Compute(Data data); -} \ No newline at end of file diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithm.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithm.cs.meta deleted file mode 100644 index 0da1df3..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithm.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 60c99317b7676b6408025f3f6fed9f1a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBakingVertex.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBakingVertex.cs deleted file mode 100644 index 3812020..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBakingVertex.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 烘焙顶点计算 -/// -public class UnitAlgorithmBakingVertex : UnitAlgorithm { - - /// 烘焙顶点计算 - public UnitAlgorithmBakingVertex() { } - - public void Compute(DataPlateBaking plateBaking) { - DataBorder border = plateBaking.border; - Vector3[] points = border.points; - - //计算内部顶点 - //plateBaking.grid = new GridTool(border.GridWide, border.GridHigh, (x, y) => { - // Vector3 position = border.MinPoint + new Vector3(x * border.smooth, y * border.smooth); - // DataPlateVertex vertex = new DataPlateVertex(); - // vertex.isValid = FindPlateInside(points, position); - // vertex.position = position; - // return vertex; - //}); - - //List plateSides = plateBaking.plate.plateSides; - //边缘所有的线段 - //for (int i = 0; i < plateSides.Count; i++) { - //Compute(plateSides[i], border.GridWide, border.GridHigh, border, border.smooth, plateBaking.grid); - //} - } - /// 向网格和边缘写入顶点数据 - private void Compute(DataPlateSide side, int wide, int high, DataBorder border, float smooth, GridTool grid) { - DataPlateLine[] lines = side.dataBaking.lines; - List sideVertices = new List(); - //计算水平线段顶点 - for (int x = 0; x < wide; x++) { - Vector3 a = new Vector3(border.minX + x * smooth, border.minY - 1); - Vector3 b = new Vector3(border.minX + x * smooth, border.maxY + 1); - for (int i = 0; i < lines.Length; i++) { - DataPlateVertex vertex = Compute(a, b, lines[i], smooth, border, grid); - if (vertex == null) { continue; } - float distance = Vector3.Distance(lines[i].a, vertex.position) + lines[i].origin; - SideVertex sideVertex = new SideVertex(); - sideVertex.distance = distance; - sideVertex.vertex = vertex; - sideVertices.Add(sideVertex); - } - } - //计算垂直线段顶点 - for (int y = 0; y < high; y++) { - Vector3 a = new Vector3(border.minX - 1, border.minY + y * smooth); - Vector3 b = new Vector3(border.maxX + 1, border.minY + y * smooth); - for (int i = 0; i < lines.Length; i++) { - DataPlateVertex vertex = Compute(a, b, lines[i], smooth, border, grid); - if (vertex == null) { continue; } - float distance = Vector3.Distance(lines[i].a, vertex.position) + lines[i].origin; - SideVertex sideVertex = new SideVertex(); - sideVertex.distance = distance; - sideVertex.vertex = vertex; - sideVertices.Add(sideVertex); - } - } - sideVertices.Sort(); - List vertices = new List(); - for (int i = 0; i < sideVertices.Count; i++) { - vertices.Add(sideVertices[i].vertex); - } - //side.vertices = vertices.ToArray(); - } - /// 向网格写入边缘顶点数据 - private DataPlateVertex Compute(Vector3 a, Vector3 b, DataPlateLine line, float smooth, DataBorder border, GridTool grid) { - //计算交点 - if (!TryGetIntersectPoint(a, b, line.a, line.b, out Vector3 IntersectPoint)) { return null; } - //计算顶点xy - Vector3 offset = new Vector3(smooth, smooth, 0) * 0.3f; - Vector3 position = IntersectPoint - border.MinPoint + offset; - int vertexX = Mathf.FloorToInt(position.x / smooth); - int vertexY = Mathf.FloorToInt(position.y / smooth); - //填充数据 - DataPlateVertex vertex = grid.Get(vertexX, vertexY); - vertex.isValid = true; - vertex.position = IntersectPoint; - return vertex; - } - - public class SideVertex : IComparable { - public float distance; - public DataPlateVertex vertex; - - public int CompareTo(SideVertex other) { - return other.distance >= distance ? 1 : -1; - } - } - - /// 转角法查询位置是否在板片内 - public static bool FindPlateInside(Vector3[] points, Vector3 position) { - double angles = 0; - for (int i = 0; i < points.Length; i++) { - Vector3 a = points.LoopIndex(i + 0) - position; - Vector3 b = points.LoopIndex(i + 1) - position; - float angle = Vector2.SignedAngle(a, b); - angles += angle; - } - int normal = (int)(angles * 1000); - return normal > 1000; - } - /// - /// 计算AB与CD两条线段的交点. - /// - /// A点 - /// B点 - /// C点 - /// D点 - /// AB与CD的交点 - /// 是否相交 true:相交 false:未相交 - private bool TryGetIntersectPoint(Vector3 a, Vector3 b, Vector3 c, Vector3 d, out Vector3 intersectPos) { - intersectPos = Vector3.zero; - - Vector3 ab = b - a; - Vector3 ca = a - c; - Vector3 cd = d - c; - - Vector3 v1 = Vector3.Cross(ca, cd); - // 不共面 - if (Mathf.Abs(Vector3.Dot(v1, ab)) > 1e-6) { return false; } - // 平行 - if (Vector3.Cross(ab, cd).sqrMagnitude <= 1e-6) { return false; } - - Vector3 ad = d - a; - Vector3 cb = b - c; - // 快速排斥 - if (Mathf.Min(a.x, b.x) > Mathf.Max(c.x, d.x) || Mathf.Max(a.x, b.x) < Mathf.Min(c.x, d.x) - || Mathf.Min(a.y, b.y) > Mathf.Max(c.y, d.y) || Mathf.Max(a.y, b.y) < Mathf.Min(c.y, d.y) - || Mathf.Min(a.z, b.z) > Mathf.Max(c.z, d.z) || Mathf.Max(a.z, b.z) < Mathf.Min(c.z, d.z)) { - return false; - } - - // 跨立试验 - if (Vector3.Dot(Vector3.Cross(-ca, ab), Vector3.Cross(ab, ad)) > 0 - && Vector3.Dot(Vector3.Cross(ca, cd), Vector3.Cross(cd, cb)) > 0) { - Vector3 v2 = Vector3.Cross(cd, ab); - float ratio = Vector3.Dot(v1, v2) / v2.sqrMagnitude; - intersectPos = a + ab * ratio; - return true; - } - - return false; - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBakingVertex.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBakingVertex.cs.meta deleted file mode 100644 index 41bfdc9..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBakingVertex.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e8b300a54238da848b5628cef749aeb2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBezier.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBezier.cs deleted file mode 100644 index 3721ceb..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBezier.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -/// -/// 贝塞尔算法 -/// -public class UnitAlgorithmBezier : UnitAlgorithm { - /// 贝塞尔算法 - public UnitAlgorithmBezier() { } - - public void Compute(DataPlate data) { - List points = new List(); - for (int i = 0; i < data.plateSides.Count; i++) { - Compute(data.plateSides[i]); - //points.AddRange(data.plateSides[i].positions); - } - //去除重复边缘点 - points = points.Distinct().ToList(); - //data.edgePoints = points; - } - public void Compute(DataPlateSide data) { - DataBezier dataBezier = new DataBezier(); - dataBezier.bezier = data.bezier; - //dataBezier.smooth = data.plate.smooth; - dataBezier.aPoint = data.aPoint.position; - dataBezier.bPoint = data.bPoint.position; - dataBezier.aBezier = data.aBezier; - dataBezier.bBezier = data.bBezier; - - dataBezier.Compute(); - - //data.length = dataBezier.length; - //data.positions = dataBezier.positions.ToArray(); - //data.lines = dataBezier.lines.ToArray(); - } - - public class DataBezier { - //输入 - public float smooth; - public Bezier bezier; - public Vector3 aPoint; - public Vector3 bPoint; - public Vector3 aBezier; - public Vector3 bBezier; - //输出 - public float length; - public List positions = new List(); - public List lines = new List(); - /// 计算曲线细分点 - public void Compute() { - //细分点 - if (bezier == Bezier.一阶) { positions = new List { aPoint, bPoint }; } - if (bezier == Bezier.二阶) { positions = Compute(aPoint, aBezier, bPoint); } - if (bezier == Bezier.三阶) { positions = Compute(aPoint, aBezier, bBezier, bPoint); } - //线段 - lines = new List(); - for (int i = 0; i < positions.Count - 1; i++) { - DataPlateLine line = new DataPlateLine(); - line.a = positions.LoopIndex(i + 0); - line.b = positions.LoopIndex(i + 1); - line.origin = length; - lines.Add(line); - length += line.Distance; - } - } - /// 二阶贝塞尔线段 - private List Compute(Vector3 a, Vector3 b, Vector3 c) { - List points = new List(); - //方向,距离 - float distance = Vector2.Distance(c, a); - //求余,得商数 - int quotient = Quotient(distance, smooth); - //贝塞尔曲线点 - for (int i = 0; i < quotient; i++) { - float t = i * (distance / quotient) / distance; - Vector2 position = ComputeBezier(a, b, c, t); - points.Add(position); - } - points.Add(c); - return points; - } - /// 三阶贝塞尔线段 - private List Compute(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { - List points = new List(); - //方向,距离 - Vector2 direction = (d - a).normalized; - float distance = Vector2.Distance(d, a); - //求余,得商数 - int quotient = Quotient(distance, smooth); - //贝塞尔曲线点 - for (int i = 0; i < quotient; i++) { - float t = i * (distance / quotient) / distance; - Vector2 position = ComputeBezier(a, b, c, d, t); - points.Add(position); - } - points.Add(d); - return points; - } - } - - /// 商数 - public static int Quotient(float distance, float smooth) { - int a = (int)(distance * 1000); - int b = (int)(smooth * 1000); - return Math.DivRem(a, b, out int remainder); - } - /// - /// 一阶贝塞尔算法 - /// - /// 起点 - /// 终点 - /// 进度 - /// - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, float t) { - return a + (b - a) * t; - } - /// - /// 二阶贝塞尔算法 - /// - /// 起点 - /// 贝塞尔点 - /// 终点 - /// 进度 - /// 当前进度的曲线点 - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, float t) { - Vector3 aa = a + (b - a) * t; - Vector3 bb = b + (c - b) * t; - return aa + (bb - aa) * t; - } - /// - /// 三阶贝塞尔算法 - /// - /// 起点 - /// 起点的贝塞尔点 - /// 终点的贝塞尔点 - /// 终点 - /// 进度 - /// 当前进度的曲线点 - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float t) { - Vector3 aa = a + (b - a) * t; - Vector3 bb = b + (c - b) * t; - Vector3 cc = c + (d - c) * t; - - Vector3 aaa = aa + (bb - aa) * t; - Vector3 bbb = bb + (cc - bb) * t; - return aaa + (bbb - aaa) * t; - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBezier.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBezier.cs.meta deleted file mode 100644 index 2fe4283..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBezier.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c59160eac8bcdec48a6b5584c7c91192 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBorder.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBorder.cs deleted file mode 100644 index 07b56a0..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBorder.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -/// -/// 散点边界算法 -/// -public class UnitAlgorithmBorder : UnitAlgorithm { - /// 散点边界算法 - public UnitAlgorithmBorder() { } - - public void Compute(DataPlateBaking plateBaking) { - //List plateSides = plateBaking.plate.plateSides; - - //List points = new List(); - //for (int i = 0; i < plateSides.Count; i++) { - // points.AddRange(plateSides[i].dataBaking.positions); - //} - - //plateBaking.border = Border(points.Distinct().ToArray()); - } - - public static DataBorder Border(Vector3[] points) { - float minX = 0; float minY = 0; - float maxX = 0; float maxY = 0; - for (int i = 0; i < points.Length; i++) { - if (points[i].x < minX) { minX = points[i].x; } - if (points[i].x > maxX) { maxX = points[i].x; } - if (points[i].y < minY) { minY = points[i].y; } - if (points[i].y > maxY) { maxY = points[i].y; } - } - return new DataBorder(minX, maxX, minY, maxY, points); - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBorder.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBorder.cs.meta deleted file mode 100644 index 97f17e2..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmBorder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 794f9553060acb04e88211793e35c810 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEarCutting.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEarCutting.cs deleted file mode 100644 index d3516fc..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEarCutting.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -/// -/// 多边形耳切法 -/// -public class UnitAlgorithmEarCutting : UnitAlgorithm { - /// 多边形耳切法 - public UnitAlgorithmEarCutting() { } - - public class Auriculare { - public int index; - public Vector3 aPoint;//+0 - public Vector3 bPoint;//-1 - public Vector3 cPoint;//+1 - } - - public void Compute(DataPlateDesign plateDesign) { - List points = new List(plateDesign.points); - //判断散列点排序方向 - Vector3[] allPoints = plateDesign.points; - bool isClockWise = IsClockWise(allPoints); - //耳切法生成三角形 - List triangles = new List(); - ComputeAuriculare(triangles, points, allPoints, isClockWise); - plateDesign.triangles = triangles; - } - - #region 函数 - /// 循环计算有效的耳点 - public static void ComputeAuriculare(List triangles, List edgePoints, Vector3[] allPoints, bool isClockWise) { - List temp = ComputeAuriculare(edgePoints, allPoints, isClockWise); - if (temp.Count == 0) { return; } - triangles.AddRange(temp); - ComputeAuriculare(triangles, edgePoints, allPoints, isClockWise); - } - /// 计算一个有效的耳点 - public static List ComputeAuriculare(List edgePoints, Vector3[] allPoints, bool isClockWise) { - Vector3[] array = edgePoints.ToArray(); - List polygons = new List(); - for (int i = 0; i < array.Length; i++) { - Auriculare auriculare = CreateAuriculare(i, array); - // 等于180,大于180,不可能为耳点 - if (!GetAngleType(auriculare, isClockWise)) { continue; } - // 包含其他点,不可能为耳点 - if (IsInsideTriangle(auriculare, allPoints)) { continue; } - // 包含其他耳点,不可能成为耳点 - if (!IsInsideAuriculare(auriculare, edgePoints)) { continue; } - edgePoints.Remove(auriculare.aPoint); - polygons.Add(CreateAuriculareToTriangle(auriculare)); - } - return polygons; - } - /// 创建耳点 - public static Auriculare CreateAuriculare(int index, Vector3[] array) { - Auriculare auriculare = new Auriculare(); - auriculare.index = index; - auriculare.bPoint = array.LoopIndex(index - 1); - auriculare.aPoint = array.LoopIndex(index); - auriculare.cPoint = array.LoopIndex(index + 1); - return auriculare; - } - /// 计算三角形内是否包含其他点 - public static bool IsInsideTriangle(Auriculare auriculare, Vector3[] array) { - for (int i = 0; i < array.Length; i++) { - if (array[i] == auriculare.aPoint) { continue; } - if (array[i] == auriculare.bPoint) { continue; } - if (array[i] == auriculare.cPoint) { continue; } - if (IsInsideTriangle(auriculare, array[i])) { return true; } - } - return false; - } - /// 计算三角形内是否包含其他点 - public static bool IsInsideAuriculare(Auriculare auriculare, List edgePoints) { - if (!edgePoints.Contains(auriculare.aPoint)) { return false; } - if (!edgePoints.Contains(auriculare.bPoint)) { return false; } - if (!edgePoints.Contains(auriculare.cPoint)) { return false; } - return true; - } - /// 从节点创建三角形 - public static DataTriangle CreateAuriculareToTriangle(Auriculare auriculare) { - DataTriangle triangle = new DataTriangle(); - triangle.a = auriculare.aPoint; - triangle.b = auriculare.bPoint; - triangle.c = auriculare.cPoint; - return triangle; - } - #endregion - - #region 算法 - /// 当前的点方向是否为顺时针 - public static bool IsClockWise(Vector3[] array) { - // 通过计算叉乘来确定方向 - float sum = 0f; - double count = array.Length; - Vector3 va, vb; - for (int i = 0; i < array.Length; i++) { - va = array[i]; - vb = (i == count - 1) ? array[0] : array[i + 1]; - sum += va.x * vb.y - va.y * vb.x; - } - return sum < 0; - } - /// 判断角的类型 - public static bool GetAngleType(Auriculare auriculare, bool isClockWise) { - // 角度是否小于180 - // oa & ob 之间的夹角,(右手法则) - // 逆时针顺序是相反的 - Vector2 a = auriculare.aPoint; - Vector2 b = auriculare.bPoint; - Vector2 c = auriculare.cPoint; - float f = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); - bool flag = isClockWise ? f > 0 : f < 0; - if (f == 0) { return false;/*平角*/ } - else if (flag) { return true;/*劣角*/ } - else { return false;/*优角*/ } - } - /// p点是否在点a,b,c组成的三角形内,或边上 - public static bool IsInsideTriangle(Auriculare auriculare, Vector2 p) { - // p点是否在abc三角形内 - Vector2 a = auriculare.aPoint; - Vector2 b = auriculare.bPoint; - Vector2 c = auriculare.cPoint; - float c1 = (b.x - a.x) * (p.y - b.y) - (b.y - a.y) * (p.x - b.x); - float c2 = (c.x - b.x) * (p.y - c.y) - (c.y - b.y) * (p.x - c.x); - float c3 = (a.x - c.x) * (p.y - a.y) - (a.y - c.y) * (p.x - a.x); - return (c1 > 0f && c2 >= 0f && c3 >= 0f) || (c1 < 0f && c2 <= 0f && c3 <= 0f); - } - #endregion - -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEarCutting.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEarCutting.cs.meta deleted file mode 100644 index 678cfac..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEarCutting.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4372bf8b5aa864f47bc02eec462942d7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEdgePoint.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEdgePoint.cs deleted file mode 100644 index 44d3862..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEdgePoint.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 贝塞尔曲线计算边缘点 -/// -public class UnitAlgorithmEdgePoint : UnitAlgorithm { - - /// 三阶贝塞尔曲线计算边缘点 - public UnitAlgorithmEdgePoint() { } - - public void Compute(DataPolygon data) { - //List points = new List(data.points); - //List edgePoints = new List(); - //for (int i = 0; i < points.Count; i++) { - // DataPoint aPoint = points.LoopIndex(i); - // DataPoint bPoint = points.LoopIndex(i + 1); - // if (!aPoint.isCurveAfter && !bPoint.isCurveFront) { - // edgePoints.Add(aPoint.position); - // } - // if (!aPoint.isCurveAfter && bPoint.isCurveFront) { - // edgePoints.AddRange(CreateLine(aPoint, bPoint, bPoint.frontBezier, data.edgeSmooth)); - // } - // if (aPoint.isCurveAfter && !bPoint.isCurveFront) { - // edgePoints.AddRange(CreateLine(aPoint, bPoint, aPoint.afterBezier, data.edgeSmooth)); - // } - // if (aPoint.isCurveAfter && bPoint.isCurveFront) { - // edgePoints.AddRange(CreateLine(aPoint, bPoint, data.edgeSmooth)); - // } - //} - //data.edgePoints = edgePoints; - } - - #region 函数 - /// 二阶贝塞尔线段 - public List CreateLine(DataPlatePoint aPoint, DataPlatePoint bPoint, Vector3 b, float smooth) { - List points = new List(); - //方向,距离 - Vector2 direction = (bPoint.position - aPoint.position).normalized; - float distance = Vector2.Distance(bPoint.position, aPoint.position); - //求余,得商数 - int quotient = Quotient(distance, smooth); - //贝塞尔曲线点 - Vector3 a = aPoint.position; - Vector3 c = bPoint.position; - for (int i = 0; i < quotient; i++) { - float t = i * (distance / quotient) / distance; - Vector2 position = ComputeBezier(a, b, c, t); - points.Add(position); - } - return points; - } - /// 三阶贝塞尔线段 - public List CreateLine(DataPlatePoint aPoint, DataPlatePoint bPoint, float smooth) { - List points = new List(); - //方向,距离 - Vector2 direction = (bPoint.position - aPoint.position).normalized; - float distance = Vector2.Distance(bPoint.position, aPoint.position); - //求余,得商数 - int quotient = Quotient(distance, smooth); - //贝塞尔曲线点 - //Vector3 a = aPoint.position; - //Vector3 b = aPoint.afterBezier; - //Vector3 c = bPoint.frontBezier; - //Vector3 d = bPoint.position; - //for (int i = 0; i < quotient; i++) { - // float t = i * (distance / quotient) / distance; - // Vector2 position = ComputeBezier(a, b, c, d, t); - // points.Add(position); - //} - return points; - } - #endregion - - #region 算法 - /// 商数 - public static int Quotient(float distance, float smooth) { - int a = (int)(distance * 1000); - int b = (int)(smooth * 1000); - return Math.DivRem(a, b, out int remainder); - } - /// - /// 一阶贝塞尔算法 - /// - /// 起点 - /// 终点 - /// 进度 - /// - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, float t) { - return a + (b - a) * t; - } - /// - /// 二阶贝塞尔算法 - /// - /// 起点 - /// 贝塞尔点 - /// 终点 - /// 进度 - /// 当前进度的曲线点 - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, float t) { - Vector3 aa = a + (b - a) * t; - Vector3 bb = b + (c - b) * t; - return aa + (bb - aa) * t; - } - /// - /// 三阶贝塞尔算法 - /// - /// 起点 - /// 起点的贝塞尔点 - /// 终点的贝塞尔点 - /// 终点 - /// 进度 - /// 当前进度的曲线点 - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float t) { - Vector3 aa = a + (b - a) * t; - Vector3 bb = b + (c - b) * t; - Vector3 cc = c + (d - c) * t; - - Vector3 aaa = aa + (bb - aa) * t; - Vector3 bbb = bb + (cc - bb) * t; - return aaa + (bbb - aaa) * t; - } - #endregion - -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEdgePoint.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEdgePoint.cs.meta deleted file mode 100644 index 91987b9..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmEdgePoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1c3f376c874a464db8a962d4a2f4730 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmJobsSideSubdivision.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmJobsSideSubdivision.cs deleted file mode 100644 index bef47bc..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmJobsSideSubdivision.cs +++ /dev/null @@ -1,239 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Unity.Burst; -using Unity.Collections; -using Unity.Jobs; -using UnityEngine; - -/// -/// 贝塞尔算法 边缘细分 Jobs -/// -public class UnitAlgorithmJobsSideSubdivision : UnitAlgorithm, UnitAlgorithm { - - /// 贝塞尔算法 边缘细分 Jobs - public UnitAlgorithmJobsSideSubdivision() { } - - public void Compute(DataPlateDesign plateDesign) { - int count = plateDesign.plate.plateSides.Count; - List plateSides = plateDesign.plate.plateSides; - NativeArray jobSubdivisions = new NativeArray(count, Allocator.TempJob); - NativeArray jobHandles = new NativeArray(count, Allocator.TempJob); - //创建作业任务 - for (int i = 0; i < count; i++) { - jobSubdivisions[i] = ToJob(plateSides[i]); - jobHandles[i] = jobSubdivisions[i].Schedule(); - } - //执行作业 - JobHandle.CompleteAll(jobHandles); - //作业结果转换 - List points = new List(); - for (int i = 0; i < count; i++) { - DataPlateSideDesign design = plateSides[i].dataDesign; - JobToDesign(design, jobSubdivisions[i]); - points.AddRange(design.positions); - } - plateDesign.points = points.Distinct().ToArray(); - //释放作业 - jobSubdivisions.Dispose(); - jobHandles.Dispose(); - } - public void Compute(DataPlateBaking plateBaking) { - //int count = plateBaking.plate.plateSides.Count; - //List plateSides = plateBaking.plate.plateSides; - //NativeArray jobSubdivisions = new NativeArray(count, Allocator.Temp); - //NativeArray jobHandles = new NativeArray(count, Allocator.Temp); - ////创建作业任务 - //for (int i = 0; i < count; i++) { - // jobSubdivisions[i] = ToJob(plateSides[i]); - // jobHandles[i] = jobSubdivisions[i].Schedule(); - //} - ////执行作业 - //JobHandle.CompleteAll(jobHandles); - ////作业结果转换 - ////List points = new List(); - //for (int i = 0; i < count; i++) { - // DataPlateSideBaking sideBaking = plateSides[i].dataBaking; - // JobToBaking(sideBaking, jobSubdivisions[i]); - // //points.AddRange(sideBaking.positions); - //} - ////plateBaking.points = points.Distinct().ToArray(); - } - - /// 转换作业系统数据 - public JobSubdivision ToJob(DataPlateSide side) { - JobSubdivision jobSubdivision = new JobSubdivision(); - jobSubdivision.bezier = side.bezier; - jobSubdivision.aPoint = side.aPoint.position; - jobSubdivision.bPoint = side.bPoint.position; - jobSubdivision.aBezier = side.aBezier; - jobSubdivision.bBezier = side.bBezier; - //距离 - float distance = Vector2.Distance(jobSubdivision.aPoint, jobSubdivision.bPoint); - jobSubdivision.distance = distance; - //求余,得商数 - jobSubdivision.quotient = side.bezier == Bezier.一阶 ? 2 : 10; - - jobSubdivision.length = new NativeArray(1, Allocator.TempJob); - jobSubdivision.positions = new NativeArray(jobSubdivision.quotient, Allocator.TempJob); - jobSubdivision.lines = new NativeArray(jobSubdivision.quotient - 1, Allocator.TempJob); - - return jobSubdivision; - } - /// 作业系统数据转换设计数据 - public void JobToDesign(DataPlateSideDesign design, JobSubdivision job) { - design.length = job.length[0]; - design.positions = job.positions.ToArray(); - DataPlateLine[] lines = new DataPlateLine[job.lines.Length]; - for (int i = 0; i < job.lines.Length; i++) { - lines[i] = ToData(job.lines[i]); - } - design.lines = lines; - job.length.Dispose(); - job.positions.Dispose(); - job.lines.Dispose(); - } - /// 作业系统数据转换烘焙数据 - public void JobToBaking(DataPlateSideBaking baking, JobSubdivision job) { - baking.length = job.length[0]; - baking.positions = job.positions.ToArray(); - DataPlateLine[] lines = new DataPlateLine[job.lines.Length]; - for (int i = 0; i < job.lines.Length; i++) { - lines[i] = ToData(job.lines[i]); - } - baking.lines = lines; - job.length.Dispose(); - job.positions.Dispose(); - job.lines.Dispose(); - } - /// 转换托管数据 - public DataPlateLine ToData(JobDataLine jobDataLine) { - DataPlateLine line = new DataPlateLine(); - line.a = jobDataLine.a; - line.b = jobDataLine.b; - line.origin = jobDataLine.origin; - return line; - } - - /// 作业系统数据 - public struct JobDataLine { - /// 线段起点a - public Vector3 a; - /// 线段终点b - public Vector3 b; - /// 原始距离 - public float origin; - } - [BurstCompile] - public struct JobSubdivision : IJob { - - #region 输入 - /// 贝塞尔类型 - public Bezier bezier; - /// a点 - public Vector3 aPoint; - /// b点 - public Vector3 bPoint; - /// a点贝塞尔点 - public Vector3 aBezier; - /// b点贝塞尔点 - public Vector3 bBezier; - /// a-b距离 - public float distance; - /// 细分数 - public int quotient; - #endregion - - #region 输出 - /// 总长度 - public NativeArray length; - /// - public NativeArray positions; - /// 线 - public NativeArray lines; - #endregion - - public void Execute() { - //细分点 - if (bezier == Bezier.一阶) { ComputeBezierA(); } - if (bezier == Bezier.二阶) { ComputeBezierB(); } - if (bezier == Bezier.三阶) { ComputeBezierC(); } - //线段 - for (int i = 0; i < quotient - 1; i++) { - JobDataLine line = new JobDataLine(); - line.a = positions[i]; - line.b = positions[i + 1]; - line.origin = length[0]; - lines[i] = line; - length[0] += Vector3.Distance(line.a, line.b); - } - } - public void ComputeBezierA() { - positions[0] = aPoint; - positions[1] = bPoint; - } - public void ComputeBezierB() { - for (int i = 0; i < quotient; i++) { - float t = i * (distance / quotient) / distance; - Vector2 position = ComputeBezier(aPoint, aBezier, bPoint, t); - positions[i] = position; - } - } - public void ComputeBezierC() { - for (int i = 0; i < quotient; i++) { - float t = i * (distance / quotient) / distance; - Vector2 position = ComputeBezier(aPoint, aBezier, bBezier, bPoint, t); - positions[i] = position; - } - } - } - - /// 商数 - public static int Quotient(float distance, float smooth) { - int a = (int)(distance * 1000); - int b = (int)(smooth * 1000); - return Math.DivRem(a, b, out int remainder); - } - /// - /// 一阶贝塞尔算法 - /// - /// 起点 - /// 终点 - /// 进度 - /// - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, float t) { - return a + (b - a) * t; - } - /// - /// 二阶贝塞尔算法 - /// - /// 起点 - /// 贝塞尔点 - /// 终点 - /// 进度 - /// 当前进度的曲线点 - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, float t) { - Vector3 aa = a + (b - a) * t; - Vector3 bb = b + (c - b) * t; - return aa + (bb - aa) * t; - } - /// - /// 三阶贝塞尔算法 - /// - /// 起点 - /// 起点的贝塞尔点 - /// 终点的贝塞尔点 - /// 终点 - /// 进度 - /// 当前进度的曲线点 - public static Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float t) { - Vector3 aa = a + (b - a) * t; - Vector3 bb = b + (c - b) * t; - Vector3 cc = c + (d - c) * t; - - Vector3 aaa = aa + (bb - aa) * t; - Vector3 bbb = bb + (cc - bb) * t; - return aaa + (bbb - aaa) * t; - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmJobsSideSubdivision.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmJobsSideSubdivision.cs.meta deleted file mode 100644 index a41d505..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmJobsSideSubdivision.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 39a35ef3408d163469eb7c66d1df96ac -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangle.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangle.cs deleted file mode 100644 index 910f6e0..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangle.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Unity.Burst; -using Unity.Collections; -using Unity.Jobs; -using UnityEngine; - -/// -/// 三角形合并网格 -/// -public class UnitAlgorithmMergeTriangle : UnitAlgorithm, UnitAlgorithm { - /// 三角形合并网格 - public UnitAlgorithmMergeTriangle() { } - - public void Compute(DataPlateDesign plateDesign) { - List polygons = plateDesign.triangles; - //三角形合并 - List vertices = vertices = MergeVertices(polygons); - List triangles = JobFindTriangleIndex(polygons, vertices); - //展开uv (顶点去掉z坐标就是未缩放的平面UV) - List uv = new List(); - for (int i = 0; i < vertices.Count; i++) { uv.Add(vertices[i]); } - //附加数据 - plateDesign.mesh = new Mesh(); - plateDesign.mesh.vertices = vertices.ToArray(); - plateDesign.mesh.uv = uv.ToArray(); - plateDesign.mesh.triangles = triangles.ToArray(); - plateDesign.mesh.RecalculateBounds(); - plateDesign.mesh.RecalculateNormals(); - } - public void Compute(DataPlateBaking plateBaking) { - //List polygons = plateBaking.triangles; - ////三角形合并 - //List vertices = vertices = MergeVertices(polygons); - //List triangles = JobFindTriangleIndex(polygons, vertices); - ////展开uv (顶点去掉z坐标就是未缩放的平面UV) - //List uv = new List(); - //for (int i = 0; i < vertices.Count; i++) { uv.Add(vertices[i]); } - ////附加数据 - //plateBaking.mesh = new Mesh(); - //plateBaking.mesh.vertices = vertices.ToArray(); - //plateBaking.mesh.uv = uv.ToArray(); - //plateBaking.mesh.triangles = triangles.ToArray(); - //plateBaking.mesh.RecalculateBounds(); - //plateBaking.mesh.RecalculateNormals(); - } - /// 合并顶点 - private List MergeVertices(List polygons) { - List vertices = new List(); - for (int i = 0; i < polygons.Count; i++) { - vertices.Add(polygons[i].a); - vertices.Add(polygons[i].b); - vertices.Add(polygons[i].c); - } - return vertices.Distinct().ToList(); - } - - #region Jobs - /// 三角形顶点索引查找作业 - private List JobFindTriangleIndex(List polygons, List vertices) { - NativeArray dataArray = new NativeArray(polygons.ToArray(), Allocator.TempJob); - NativeArray verticeArray = new NativeArray(vertices.ToArray(), Allocator.TempJob); - NativeArray trianglesArray = new NativeArray(polygons.Count, Allocator.TempJob); - - TriangleIndex triangleIndex = new TriangleIndex(); - triangleIndex.dataArray = dataArray; - triangleIndex.vertices = verticeArray; - triangleIndex.triangles = trianglesArray; - - JobHandle dependency = new JobHandle(); - JobHandle handle = triangleIndex.ScheduleParallel(polygons.Count, 32, dependency); - handle.Complete(); - - List triangles = new List(); - for (int i = 0; i < trianglesArray.Length; i++) { - triangles.Add(trianglesArray[i].a); - triangles.Add(trianglesArray[i].b); - triangles.Add(trianglesArray[i].c); - } - - dataArray.Dispose(); - verticeArray.Dispose(); - trianglesArray.Dispose(); - return triangles; - } - /// 三角形顶点索引查找作业 - [BurstCompile] - public struct TriangleIndex : IJobFor { - [ReadOnly] public NativeArray dataArray; - [ReadOnly] public NativeArray vertices; - public NativeArray triangles; - - public void Execute(int index) { - DataTriangle dataTriangle = dataArray[index]; - Triangle triangle = new Triangle(); - bool a = false, b = false, c = false; - for (int i = 0; i < vertices.Length; i++) { - Vector3 vector = vertices[i]; - if (dataTriangle.a == vector) { triangle.a = i; a = true; } - if (dataTriangle.b == vector) { triangle.b = i; b = true; } - if (dataTriangle.c == vector) { triangle.c = i; c = true; } - if (a && b && c) { break; } - } - triangles[index] = triangle; - } - } - /// 三角形顶点索引 - public struct Triangle { public int a, b, c; } - #endregion - - /// 是否启用计时器 - private readonly bool isEnableTimer = true; - /// 计时器 - private void Chronoscope(string content, Action action) { - if (!isEnableTimer) { action?.Invoke(); return; } - float time = Time.realtimeSinceStartup; - action?.Invoke(); - float consumed = Time.realtimeSinceStartup - time; - Debug.Log($"{content}{consumed * 1000}"); - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangle.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangle.cs.meta deleted file mode 100644 index e684692..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangle.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e4f1e7f586419604093e6609268f27b8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangles.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangles.cs deleted file mode 100644 index 8cc9eba..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangles.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 合并三角形 -/// -public class UnitAlgorithmMergeTriangles : UnitAlgorithm { - public void Compute(DataPolygon data) { - //List triangles = new List(data.triangles); - //index = 0; - //Merge(triangles); - //data.triangles = triangles; - //ModuleCore.I.VisualPolygon.UpdateVisual(data); - } - private int index; - private int maxIndex; - /// 取一个三角形出来 匹配剩下的三角形 符合条件则合并 - private void Merge(List triangles) { - if (index > triangles.Count) { return; } - - DataTriangle aT = triangles[0]; - triangles.Remove(aT); - - maxIndex = triangles.Count; - for (int i = 0; i < triangles.Count; i++) { - DataTriangle bT = triangles[i]; - //ab同边 - if (MergeConditions(bT.a, bT.b, bT, ref aT)) { triangles.Remove(bT); continue; } - //bc同边 - if (MergeConditions(bT.b, bT.c, bT, ref aT)) { triangles.Remove(bT); continue; } - //ca同边 - if (MergeConditions(bT.c, bT.a, bT, ref aT)) { triangles.Remove(bT); continue; } - } - index = maxIndex == triangles.Count ? index + 1 : 0; - Debug.Log($"{index} , {maxIndex} , {triangles.Count}"); - - triangles.Add(aT); - Merge(triangles); - } - /// 匹配三角形 符合条件则合并 无法合并则返回 true - private bool Merge(List triangles, DataTriangle aT) { - for (int i = 0; i < triangles.Count; i++) { - DataTriangle bT = triangles[i]; - //ab同边 - if (MergeConditions(bT.a, bT.b, bT, ref aT)) { triangles.Remove(bT); } - //bc同边 - if (MergeConditions(bT.b, bT.c, bT, ref aT)) { triangles.Remove(bT); } - //ca同边 - if (MergeConditions(bT.c, bT.a, bT, ref aT)) { triangles.Remove(bT); } - } - return true; - } - /// 计算三角形内是否包含其他点 - private bool IsInsideTriangle(DataTriangle triangle, Vector3 point) { - if (triangle.a == point) { return true; } - if (triangle.b == point) { return true; } - if (triangle.c == point) { return true; } - return false; - } - //检测合并条件是否满足 - private bool MergeConditions(Vector3 a, Vector3 b, DataTriangle bT, ref DataTriangle aT) { - if (!IsInsideTriangle(aT, a, b, out Vector3 o)) { return false; } - if (!IsInsideTriangle(bT, a, b, out Vector3 c)) { return false; } - if (IsInsideTriangle(aT, c)) { return true; } - Vector3 oa = (o - a).normalized; - Vector3 ob = (o - b).normalized; - Vector3 oc = (o - c).normalized; - if (oc == oa) { aT.a = o; aT.b = b; aT.c = c; return true; } - if (oc == ob) { aT.a = o; aT.b = a; aT.c = c; return true; } - return false; - } - /// 计算三角形内是否包含其他点 - private bool IsInsideTriangle(DataTriangle triangle, Vector3 a, Vector3 b, out Vector3 o) { - if (triangle.a == a && triangle.b == b) { o = triangle.c; return true; } - if (triangle.a == b && triangle.b == a) { o = triangle.c; return true; } - if (triangle.a == a && triangle.c == b) { o = triangle.b; return true; } - if (triangle.a == b && triangle.c == a) { o = triangle.b; return true; } - if (triangle.b == a && triangle.c == b) { o = triangle.a; return true; } - if (triangle.b == b && triangle.c == a) { o = triangle.a; return true; } - o = a; return false; - } - - /// p点是否在点a,b,c组成的三角形内,或边上 - public static bool IsInsideTriangle(DataTriangle auriculare, Vector2 p) { - // p点是否在abc三角形内 - Vector2 a = auriculare.a; - Vector2 b = auriculare.b; - Vector2 c = auriculare.c; - float c1 = (b.x - a.x) * (p.y - b.y) - (b.y - a.y) * (p.x - b.x); - float c2 = (c.x - b.x) * (p.y - c.y) - (c.y - b.y) * (p.x - c.x); - float c3 = (a.x - c.x) * (p.y - a.y) - (a.y - c.y) * (p.x - a.x); - return (c1 > 0f && c2 >= 0f && c3 >= 0f) || (c1 < 0f && c2 <= 0f && c3 <= 0f); - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangles.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangles.cs.meta deleted file mode 100644 index 7b68621..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMergeTriangles.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 45d3c753563f5be468680173acf8b1e8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMeshVertex.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMeshVertex.cs deleted file mode 100644 index 5ae9d83..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMeshVertex.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class UnitAlgorithmMeshVertex : UnitAlgorithm { - public class Line { - public Vector3 aPoint; - public Vector3 bPoint; - } - - public class VertexUnit { - public Vector3 position; - } - - public VertexUnit[,] unitArray; - - public void Compute(DataPolygon data) { - //List edgePoints = new List(data.edgePoints); - ////计算边界 - //float minX = 0; float minY = 0; - //float maxX = 0; float maxY = 0; - //for (int i = 0; i < edgePoints.Count; i++) { - // if (edgePoints[i].x < minX) { minX = edgePoints[i].x; } - // if (edgePoints[i].x > maxX) { maxX = edgePoints[i].x; } - // if (edgePoints[i].y < minY) { minY = edgePoints[i].y; } - // if (edgePoints[i].y > maxY) { maxY = edgePoints[i].y; } - //} - //float wide = maxX - minX; - //float high = maxY - minY; - ////求余,得商数 - //int wideQuotient = Quotient(wide, 0.01f) + 1; - //int highQuotient = Quotient(high, 0.01f) + 1; - ////平均间隔 - //float wideAverage = wide / wideQuotient; - //float highAverage = high / highQuotient; - ////计算内部网格点 - //List vertices = new List(); - //Vector3 origin = new Vector3(minX, minY); - //for (int i = 0; i < highQuotient; i++) { - // for (int j = 0; j < wideQuotient; j++) { - // Vector3 position = origin + new Vector3(j * wideAverage, i * highAverage); - // if (FindPlateInside(edgePoints, position)) { vertices.Add(position); } - // } - //} - ////创建边缘线段,区分方向 - //List horizontal = new List(); - //List vertical = new List(); - //for (int i = 0; i < edgePoints.Count; i++) { - // Line line = new Line(); - // line.aPoint = edgePoints.LoopIndex(i + 0); - // line.bPoint = edgePoints.LoopIndex(i + 1); - // Vector3 direction = (line.bPoint - line.aPoint).normalized; - // if (Mathf.Abs(direction.x) >= 0.9) { horizontal.Add(line); } - // else { vertical.Add(line); } - //} - ////计算水平线段顶点 - //for (int i = 0; i < wideQuotient; i++) { - // Vector3 a = new Vector3(minX + i * wideAverage, minY - 1); - // Vector3 b = new Vector3(minX + i * wideAverage, maxY + 1); - // //Debug.Log($"线段:{a} , {b}"); - // for (int j = 0; j < horizontal.Count; j++) { - // Line line = horizontal[j]; - // //Debug.Log($"线段:{a} , {b} , {line.aPoint} , {line.bPoint}"); - // if (!TryGetIntersectPoint(a, b, line.aPoint, line.bPoint, out Vector3 intersectPos)) { continue; } - // //Debug.Log($"交点:{intersectPos}"); - // vertices.Add(intersectPos); - // } - //} - ////计算垂直线段顶点 - //for (int i = 0; i < highQuotient; i++) { - // Vector3 a = new Vector3(minX - 1, minY + i * highAverage); - // Vector3 b = new Vector3(maxX + 1, minY + i * highAverage); - // //Debug.Log($"线段:{a} , {b}"); - // for (int j = 0; j < vertical.Count; j++) { - // Line line = vertical[j]; - // //Debug.Log($"线段:{a} , {b} , {line.aPoint} , {line.bPoint}"); - // if (!TryGetIntersectPoint(a, b, line.aPoint, line.bPoint, out Vector3 intersectPos)) { continue; } - // //Debug.Log($"交点:{intersectPos}"); - // vertices.Add(intersectPos); - // } - //} - //Debug.Log(vertices.Count); - //data.vertices = vertices; - } - - - /// 商数 - public static int Quotient(float distance, float smooth) { - int a = (int)(distance * 1000); - int b = (int)(smooth * 1000); - return Math.DivRem(a, b, out int remainder); - } - /// 转角法查询位置是否在板片内 - public static bool FindPlateInside(List points, Vector3 position) { - double angles = 0; - for (int i = 0; i < points.Count; i++) { - Vector3 a = points.LoopIndex(i + 0) - position; - Vector3 b = points.LoopIndex(i + 1) - position; - float angle = Vector2.SignedAngle(a, b); - angles += angle; - } - int normal = (int)(angles * 1000); - return normal > 1000; - } - /// - /// 计算AB与CD两条线段的交点. - /// - /// A点 - /// B点 - /// C点 - /// D点 - /// AB与CD的交点 - /// 是否相交 true:相交 false:未相交 - private bool TryGetIntersectPoint(Vector3 a, Vector3 b, Vector3 c, Vector3 d, out Vector3 intersectPos) { - intersectPos = Vector3.zero; - - Vector3 ab = b - a; - Vector3 ca = a - c; - Vector3 cd = d - c; - - Vector3 v1 = Vector3.Cross(ca, cd); - // 不共面 - if (Mathf.Abs(Vector3.Dot(v1, ab)) > 1e-6) { return false; } - // 平行 - if (Vector3.Cross(ab, cd).sqrMagnitude <= 1e-6) { return false; } - - Vector3 ad = d - a; - Vector3 cb = b - c; - // 快速排斥 - if (Mathf.Min(a.x, b.x) > Mathf.Max(c.x, d.x) || Mathf.Max(a.x, b.x) < Mathf.Min(c.x, d.x) - || Mathf.Min(a.y, b.y) > Mathf.Max(c.y, d.y) || Mathf.Max(a.y, b.y) < Mathf.Min(c.y, d.y) - || Mathf.Min(a.z, b.z) > Mathf.Max(c.z, d.z) || Mathf.Max(a.z, b.z) < Mathf.Min(c.z, d.z)) { - return false; - } - - // 跨立试验 - if (Vector3.Dot(Vector3.Cross(-ca, ab), Vector3.Cross(ab, ad)) > 0 - && Vector3.Dot(Vector3.Cross(ca, cd), Vector3.Cross(cd, cb)) > 0) { - Vector3 v2 = Vector3.Cross(cd, ab); - float ratio = Vector3.Dot(v1, v2) / v2.sqrMagnitude; - intersectPos = a + ab * ratio; - return true; - } - - return false; - } - -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMeshVertex.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMeshVertex.cs.meta deleted file mode 100644 index 4da7425..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmMeshVertex.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9b4b2ff6807f9704cb50f12b41e2a0a5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmRhombus.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmRhombus.cs deleted file mode 100644 index a031c79..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmRhombus.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 菱形绘制三角形算法 -/// -public class UnitAlgorithmRhombus : UnitAlgorithm { - - public void Compute(DataPlateBaking plateBaking) { - List triangles = new List(); - List vertexs = new List(); - //plateBaking.grid.Loop((x, y) => { - // DataPlateVertex vertex = plateBaking.grid.Get(x, y); - // if (!vertex.isValid) { return; } - - // TryGet(plateBaking.grid, x, y + 1, ref vertex.above); - // TryGet(plateBaking.grid, x, y - 1, ref vertex.below); - // TryGet(plateBaking.grid, x - 1, y, ref vertex.left); - // TryGet(plateBaking.grid, x + 1, y, ref vertex.right); - - // TryGet(plateBaking.grid, x - 1, y + 1, ref vertex.leftAbove); - // TryGet(plateBaking.grid, x - 1, y - 1, ref vertex.leftBelow); - // TryGet(plateBaking.grid, x + 1, y + 1, ref vertex.rightAbove); - // TryGet(plateBaking.grid, x + 1, y - 1, ref vertex.rightBelow); - // //默认绘制左上角 - // if (vertex.above != null && vertex.left != null) { - // triangles.Add(CreateDataTriangle(vertex, vertex.left, vertex.above)); - // } - // //默认绘制右下角 - // if (vertex.below != null && vertex.right != null) { - // triangles.Add(CreateDataTriangle(vertex, vertex.right, vertex.below)); - // } - // //如果右上角点不存在,则尝试绘制右上角 - // if (vertex.rightAbove == null && vertex.above != null && vertex.right != null) { - // triangles.Add(CreateDataTriangle(vertex, vertex.above, vertex.right)); - // } - // //如果左下角点不存在,则尝试绘制左下角 - // if (vertex.leftBelow == null && vertex.below != null && vertex.left != null) { - // triangles.Add(CreateDataTriangle(vertex, vertex.below, vertex.left)); - // } - // vertexs.Add(vertex); - //}); - //plateBaking.triangles = triangles; - //plateBaking.vertexs = vertexs.ToArray(); - } - - /// 校验性获取网格上的点 - private void TryGet(GridTool grid, int x, int y, ref DataPlateVertex vertex) { - vertex = null; - if (!grid.TryGet(x, y, out DataPlateVertex data)) { return; } - if (data.isValid) { vertex = data; } - } - /// 创建三角形 - private DataTriangle CreateDataTriangle(DataPlateVertex a, DataPlateVertex b, DataPlateVertex c) { - DataTriangle triangle = new DataTriangle(); - triangle.b = a.position; - triangle.c = b.position; - triangle.a = c.position; - return triangle; - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmRhombus.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmRhombus.cs.meta deleted file mode 100644 index 9664e66..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmRhombus.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e45b841993dc7c04584b87f7794cf2fb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSubdivision.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSubdivision.cs deleted file mode 100644 index 34d8724..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSubdivision.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class UnitAlgorithmSubdivision : UnitAlgorithm { - public void Compute(DataPolygon data) { - //List triangles = new List(data.triangles); - //List subdivision = new List(); - //for (int i = 0; i < triangles.Count; i++) { - // subdivision.AddRange(Compute(triangles[i])); - //} - //subdivision.AddRange(Subdivision(triangles[121], data.edgeSmooth)); - - //data.triangles = subdivision; - } - private List Compute(DataTriangle triangle) { - float ab = Vector3.Distance(triangle.a, triangle.b); - float bc = Vector3.Distance(triangle.b, triangle.c); - float ca = Vector3.Distance(triangle.c, triangle.a); - if (ab > bc && ab > ca && ab > 0.02f) { return Compute(triangle.c, triangle.a, triangle.b); } - if (bc > ab && bc > ca && bc > 0.02f) { return Compute(triangle.a, triangle.b, triangle.c); } - if (ca > bc && ca > ab && ca > 0.02f) { return Compute(triangle.b, triangle.c, triangle.a); } - - return new List { triangle }; - } - private List Compute(Vector3 a, Vector3 b, Vector3 c) { - Vector3 direction = b - c; - Vector3 d = c + direction * 0.5f; - - DataTriangle aT = new DataTriangle { a = a, b = d, c = c }; - DataTriangle bT = new DataTriangle { a = a, b = b, c = d }; - return new List { aT, bT, }; - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSubdivision.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSubdivision.cs.meta deleted file mode 100644 index e92ccd5..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSubdivision.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bb4aa74668cf2134eb322b3a40d74c29 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureBaking.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureBaking.cs deleted file mode 100644 index 9b18839..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureBaking.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 烘焙的缝合线 -/// -public class UnitAlgorithmSutureBaking : UnitAlgorithm { - /// 烘焙的缝合线 - public UnitAlgorithmSutureBaking() { } - - public void Compute(DataSutureSide sutureSide) { - AllVertexs(sutureSide); - //缝合范围内的顶点 - SetVertex(sutureSide); - //顶点转换位置 - SetPositions(sutureSide); - } - /// 顶点距离数据 - private List GetVertex(DataPlateVertex[] vertexsArray, bool isReversal) { - float length = 0; - List vertexs = new List(); - List sideVertexs = new List(vertexsArray); - if (isReversal) { sideVertexs.Reverse(); } - for (int i = 0; i < sideVertexs.Count - 1; i++) { - DataSutureSideVertex vertex = new DataSutureSideVertex(length, sideVertexs[i], sideVertexs[i + 1]); - vertexs.Add(vertex); length += vertex.Distance; - } - return vertexs; - } - /// 全部顶点 - private void AllVertexs(DataSutureSide sutureSide) { - DataPlateVertex[] vertexsArray = sutureSide.plateSide.dataBaking.vertexs; - List allVertexs = GetVertex(vertexsArray, false); - sutureSide.dataBaking.allVertexs = allVertexs.ToArray(); - } - /// 缝合范围内的顶点 - private void SetVertex(DataSutureSide sutureSide) { - //全部顶点 - List allVertexs = GetVertex(sutureSide.plateSide.dataBaking.vertexs, sutureSide.isReversal); - //缝合范围内的顶点 - float maxLength = sutureSide.suture.length; - List vertexs = new List(); - for (int i = 0; i < allVertexs.Count; i++) { - if (allVertexs[i].origin <= maxLength) { vertexs.Add(allVertexs[i]); } - } - sutureSide.dataBaking.vertexs = vertexs.ToArray(); - } - /// 顶点转换位置 - private void SetPositions(DataSutureSide sutureSide) { - Vector3 platePosition = sutureSide.plateSide.plate.dataBaking.position; - Vector3 plateEulerAngles = sutureSide.plateSide.plate.dataBaking.eulerAngles; - List positions = new List(); - DataSutureSideVertex[] vertexs = sutureSide.dataBaking.vertexs; - for (int i = 0; i < vertexs.Length; i++) { - Quaternion quaternion = Quaternion.Euler(plateEulerAngles); - Vector3 baking = quaternion * vertexs[i].a.position; - Vector3 position = baking + platePosition; - positions.Add(position); - } - sutureSide.dataBaking.positions = positions.ToArray(); - } -} - diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureBaking.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureBaking.cs.meta deleted file mode 100644 index 4ef1daa..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureBaking.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9735cc247f76e0b42b50f8b7956d3c8a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureDesign.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureDesign.cs deleted file mode 100644 index 7900e38..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureDesign.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 设计的缝合线 -/// -public class UnitAlgorithmSutureDesign : UnitAlgorithm { - /// 设计的缝合线 - public UnitAlgorithmSutureDesign() { } - - public class Line { - public float origin; - public Vector3 a; - public Vector3 b; - public Line(float origin, Vector3 a, Vector3 b) { - this.origin = origin; - this.a = a; - this.b = b; - } - public float Distance => Vector3.Distance(a, b); - } - - public void Compute(DataSutureSide sutureSide) { - float maxLength = sutureSide.suture.length; - Vector3 platePosition = sutureSide.plateSide.plate.dataDesign.position; - List sidePositions = new List(sutureSide.plateSide.dataDesign.positions); - - float length = 0; - List lines = new List(); - if (sutureSide.isReversal) { sidePositions.Reverse(); } - for (int i = 0; i < sidePositions.Count - 1; i++) { - Line line = new Line(length, sidePositions[i], sidePositions[i + 1]); - lines.Add(line); - length += line.Distance; - } - List positions = new List(); - for (int i = 0; i < lines.Count; i++) { - Line line = lines[i]; - if (line.origin < maxLength) { positions.Add(line.a + platePosition); } - float nextDistance = line.origin + line.Distance; - if (nextDistance < maxLength) { continue; } - if (nextDistance == maxLength) { positions.Add(line.b + platePosition); break; } - float distance = maxLength - line.origin; - Vector3 direction = (line.b - line.a).normalized; - Vector3 position = line.a + direction * distance; - positions.Add(position + platePosition); - break; - } - sutureSide.dataDesign.positions = positions.ToArray(); - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureDesign.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureDesign.cs.meta deleted file mode 100644 index d25174c..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmSutureDesign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b98adb17aebd36b4ab5dfe90020fb902 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmVertex.cs b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmVertex.cs deleted file mode 100644 index f5bf92b..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmVertex.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 顶点算法 -/// -public class UnitAlgorithmVertex : UnitAlgorithm { - - public class SideVertex : IComparable { - public float distance; - public Vector3 position; - - public int CompareTo(SideVertex other) { - if (other == null || this == null) { return 0; } - if (other == this) { return 0; } - if (other.distance > distance) { return -1; } - if (other.distance < distance) { return 1; } - return 0; - } - } - - public void Compute(DataPlateBaking plateBaking) { - DataBorder border = plateBaking.border; - Vector3[] points = border.points; - - //计算内部顶点 - //plateBaking.grid = new GridTool(border.GridWide, border.GridHigh, (x, y) => { - // Vector3 position = new Vector3(x, y) * border.smooth + border.MinPoint; - // DataPlateVertex vertex = new DataPlateVertex(); - // vertex.isValid = FindPlateInside(points, position); - // vertex.position = position; - // return vertex; - //}); - - //边缘所有的线段 - //List plateSides = plateBaking.plate.plateSides; - //for (int i = 0; i < plateSides.Count; i++) { - // SubdivideSideVertex(plateBaking, plateSides[i]); - //} - } - - private void SubdivideSideVertex(DataPlateBaking plateBaking, DataPlateSide plateSides) { - DataBorder border = plateBaking.border; - DataPlateLine[] lines = plateSides.dataBaking.lines; - //计算水平线段顶点 - List sideVertexs = new List(); - for (int x = 0; x < border.GridWide; x++) { - Vector3 a = new Vector3(border.minX + x * border.smooth, border.minY - 1); - Vector3 b = new Vector3(border.minX + x * border.smooth, border.maxY + 1); - for (int i = 0; i < lines.Length; i++) { - if (!TryGetIntersectPoint(a, b, lines[i].a, lines[i].b, out Vector3 IntersectPoint)) { continue; } - float distance = Vector3.Distance(lines[i].a, IntersectPoint) + lines[i].origin; - SideVertex sideVertex = new SideVertex(); - sideVertex.distance = distance; - sideVertex.position = IntersectPoint; - sideVertexs.Add(sideVertex); - } - } - //计算垂直线段顶点 - for (int y = 0; y < border.GridHigh; y++) { - Vector3 a = new Vector3(border.minX - 1, border.minY + y * border.smooth); - Vector3 b = new Vector3(border.maxX + 1, border.minY + y * border.smooth); - for (int i = 0; i < lines.Length; i++) { - if (!TryGetIntersectPoint(a, b, lines[i].a, lines[i].b, out Vector3 IntersectPoint)) { continue; } - float distance = Vector3.Distance(lines[i].a, IntersectPoint) + lines[i].origin; - SideVertex sideVertex = new SideVertex(); - sideVertex.distance = distance; - sideVertex.position = IntersectPoint; - sideVertexs.Add(sideVertex); - } - } - //排序 - sideVertexs.Sort(); - //写入网格,写入顶点 - Vector3 offset = border.MinPoint - new Vector3(border.smooth, border.smooth, 0) * 0.3f; - List vertexs = new List(); - for (int i = 0; i < sideVertexs.Count; i++) { - Vector3 position = sideVertexs[i].position; - Vector3 gridPosition = position - offset; - int vertexX = Mathf.FloorToInt(gridPosition.x / border.smooth); - int vertexY = Mathf.FloorToInt(gridPosition.y / border.smooth); - //填充数据 - //DataPlateVertex vertex = plateBaking.grid.Get(vertexX, vertexY); - //vertex.isValid = true; - //vertex.position = position; - ////写入顶点 - //vertexs.Add(vertex); - } - plateSides.dataBaking.vertexs = vertexs.ToArray(); - } - - /// 转角法查询位置是否在板片内 - public static bool FindPlateInside(Vector3[] points, Vector3 position) { - double angles = 0; - for (int i = 0; i < points.Length; i++) { - Vector3 a = points.LoopIndex(i + 0) - position; - Vector3 b = points.LoopIndex(i + 1) - position; - float angle = Vector2.SignedAngle(a, b); - angles += angle; - } - int normal = (int)(angles * 1000); - return normal > 1000; - } - /// - /// 计算AB与CD两条线段的交点. - /// - /// A点 - /// B点 - /// C点 - /// D点 - /// AB与CD的交点 - /// 是否相交 true:相交 false:未相交 - private bool TryGetIntersectPoint(Vector3 a, Vector3 b, Vector3 c, Vector3 d, out Vector3 intersectPos) { - intersectPos = Vector3.zero; - - Vector3 ab = b - a; - Vector3 ca = a - c; - Vector3 cd = d - c; - - Vector3 v1 = Vector3.Cross(ca, cd); - // 不共面 - if (Mathf.Abs(Vector3.Dot(v1, ab)) > 1e-6) { return false; } - // 平行 - if (Vector3.Cross(ab, cd).sqrMagnitude <= 1e-6) { return false; } - - Vector3 ad = d - a; - Vector3 cb = b - c; - // 快速排斥 - if (Mathf.Min(a.x, b.x) > Mathf.Max(c.x, d.x) || Mathf.Max(a.x, b.x) < Mathf.Min(c.x, d.x) - || Mathf.Min(a.y, b.y) > Mathf.Max(c.y, d.y) || Mathf.Max(a.y, b.y) < Mathf.Min(c.y, d.y) - || Mathf.Min(a.z, b.z) > Mathf.Max(c.z, d.z) || Mathf.Max(a.z, b.z) < Mathf.Min(c.z, d.z)) { - return false; - } - - // 跨立试验 - if (Vector3.Dot(Vector3.Cross(-ca, ab), Vector3.Cross(ab, ad)) > 0 - && Vector3.Dot(Vector3.Cross(ca, cd), Vector3.Cross(cd, cb)) > 0) { - Vector3 v2 = Vector3.Cross(cd, ab); - float ratio = Vector3.Dot(v1, v2) / v2.sqrMagnitude; - intersectPos = a + ab * ratio; - return true; - } - - return false; - } -} diff --git a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmVertex.cs.meta b/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmVertex.cs.meta deleted file mode 100644 index 6accb4b..0000000 --- a/Assets/ModuleUnit/UnitAlgorithm/UnitAlgorithmVertex.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4a24da15970a3654386664f8d6503d04 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitFind.meta b/Assets/ModuleUnit/UnitFind.meta deleted file mode 100644 index 83d32ee..0000000 --- a/Assets/ModuleUnit/UnitFind.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3105cf897e8dcb6408a9d5b207fa348e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitFind/FindSideIntersectPoint.cs b/Assets/ModuleUnit/UnitFind/FindSideIntersectPoint.cs deleted file mode 100644 index 2802840..0000000 --- a/Assets/ModuleUnit/UnitFind/FindSideIntersectPoint.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 查询边交点 -/// -public class FindSideIntersectPoint : UnitFind { - public readonly float FindRange = 0.01f; - /// 板片资产 - public ModuleAssets AssetsPlate => ModuleCore.I.AssetsPlate; - - /// 查询边交点 - public FindSideIntersectPoint() { } - - public bool Find(Vector3 position, out SideIntersectPoint sip) { - sip = new SideIntersectPoint(); - List plates = AssetsPlate.Datas; - for (int i = 0; i < plates.Count; i++) { - Vector3 localPosition = position - plates[i].dataDesign.position; - sip.side = Find(plates[i], localPosition, out sip.intersectPoint); - sip.intersectPoint += plates[i].dataDesign.position; - if (sip.side != null) { return true; } - } - return false; - } - /// 查询匹配的边 - private DataPlateSide Find(DataPlate plate, Vector3 localPosition, out Vector3 intersectPoint) { - intersectPoint = Vector3.zero; - for (int i = 0; i < plate.plateSides.Count; i++) { - DataPlateSide side = Find(plate.plateSides[i], localPosition, out intersectPoint); - if (side != null) { return side; } - } - return null; - } - /// 查询匹配的边 - private DataPlateSide Find(DataPlateSide side, Vector3 localPosition, out Vector3 intersectPoint) { - intersectPoint = Vector3.zero; - for (int i = 0; i < side.dataDesign.lines.Length; i++) { - Vector3 a = side.dataDesign.lines[i].a; - Vector3 b = side.dataDesign.lines[i].b; - float distance = ProjectDistance(a, b, localPosition, out intersectPoint); - if (distance < FindRange) { return side; } - } - return null; - } - - /// - /// 向量投影法 - /// 计算点c到线段ab最近的点 - /// - /// - /// - /// - /// 如果不在线段上返回 float.MaxValue - public static float ProjectDistance(Vector3 a, Vector3 b, Vector3 c, out Vector3 intersectPoint) { - Vector3 ab = b - a; - Vector3 ac = c - a; - Vector3 p = Vector3.Project(ac, ab); - intersectPoint = p + a; - if (ab.normalized != p.normalized) { return float.MaxValue; } - if (ab.magnitude < p.magnitude) { return float.MaxValue; } - return Vector3.Distance(c, p + a); - } -} -/// -/// 边交点 -/// -public class SideIntersectPoint { - /// 匹配的边 - public DataPlateSide side; - /// 交点 - public Vector3 intersectPoint; -} \ No newline at end of file diff --git a/Assets/ModuleUnit/UnitFind/FindSideIntersectPoint.cs.meta b/Assets/ModuleUnit/UnitFind/FindSideIntersectPoint.cs.meta deleted file mode 100644 index f0852bf..0000000 --- a/Assets/ModuleUnit/UnitFind/FindSideIntersectPoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 368e1bf20f25d424f8ed16d00323b8b8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitFind/UnitFind.cs b/Assets/ModuleUnit/UnitFind/UnitFind.cs deleted file mode 100644 index f0eea95..0000000 --- a/Assets/ModuleUnit/UnitFind/UnitFind.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public interface UnitFind { - /// 查询 - public bool Find(Vector3 position, out Data data); -} diff --git a/Assets/ModuleUnit/UnitFind/UnitFind.cs.meta b/Assets/ModuleUnit/UnitFind/UnitFind.cs.meta deleted file mode 100644 index b08f85f..0000000 --- a/Assets/ModuleUnit/UnitFind/UnitFind.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 77073523d35e8fb4bb758404278690c5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput.meta b/Assets/ModuleUnit/UnitMouseInput.meta index 88a2d70..a90b7da 100644 --- a/Assets/ModuleUnit/UnitMouseInput.meta +++ b/Assets/ModuleUnit/UnitMouseInput.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4ef3354979b38474ab3efdbe7d603f9c +guid: e6ffff57450000c409c511daef71ed5a folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleUnit/UnitMouseInput/BakingMobile.cs b/Assets/ModuleUnit/UnitMouseInput/BakingMobile.cs deleted file mode 100644 index 50f9e6a..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/BakingMobile.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class BakingMobile : UnitMouseInput { - /// 设计视图相机模块 - public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking; - - private Vector3 mousePosition; - private Vector3 originalPosition; - - public override void MouseDown(DataMouseInput data) { - mousePosition = data.ScreenPosition; - originalPosition = ViewCamera.Position; - } - public override void MouseDrag(DataMouseInput data) { - Vector3 original = ViewCamera.ScreenToWorldPosition(mousePosition); - Vector3 current = data.WorldPosition; - Vector3 offset = current - original; - Vector3 up = ViewCamera.Up * offset.y; - Vector3 right = ViewCamera.Right * offset.x; - ViewCamera.Position = originalPosition + up + right; - } -} diff --git a/Assets/ModuleUnit/UnitMouseInput/BakingMobile.cs.meta b/Assets/ModuleUnit/UnitMouseInput/BakingMobile.cs.meta deleted file mode 100644 index bf9da39..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/BakingMobile.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2e91048b6b41fcd488c55503ebfc3723 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/BakingMobilePlate.cs b/Assets/ModuleUnit/UnitMouseInput/BakingMobilePlate.cs deleted file mode 100644 index a4d911a..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/BakingMobilePlate.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class BakingMobilePlate : UnitMouseInput { - /// 安排点图层遮罩 - private readonly LayerMask Arrange = LayerMaskTool.Arrange; - /// 烘焙视图相机模块 - public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking; - - private Vector3 mousePosition; - private Vector3 originalPosition; - private FixedArrange arrange; - private ModulePrefab platePrefab; - - public override void MouseDown(DataMouseInput data) { - if (!ViewCamera.ScreenToWorldObject(data.ScreenPosition, out platePrefab)) { return; } - mousePosition = data.ScreenPosition; - originalPosition = platePrefab.transform.localPosition; - platePrefab.Value.dataBaking.position = originalPosition; - ModuleCore.BakingMobilePlate(platePrefab.Value); - } - public override void MouseDrag(DataMouseInput data) { - if (platePrefab == null) { return; } - if (ViewCamera.ScreenToWorldObjectParent(data.ScreenPosition, out arrange, Arrange)) { - platePrefab.Value.arrange = arrange; - platePrefab.Value.dataBaking.position = arrange.transform.localPosition; - platePrefab.Value.dataBaking.eulerAngles = arrange.transform.localEulerAngles; - } - else { Mobile(data.WorldPosition); } - platePrefab.Value.UpdateVisual(false); - } - public override void MouseRelease(DataMouseInput data) { - ModuleCore.BakingMobilePlate(null); - } - - private void Mobile(Vector3 worldPosition) { - platePrefab.Value.arrange = null; - Vector3 original = ViewCamera.ScreenToWorldPosition(mousePosition); - Vector3 current = worldPosition; - Vector3 offset = current - original; - Vector3 up = ViewCamera.Up * offset.y; - Vector3 right = ViewCamera.Right * offset.x; - platePrefab.Value.dataBaking.position = originalPosition - up - right; - } -} diff --git a/Assets/ModuleUnit/UnitMouseInput/BakingMobilePlate.cs.meta b/Assets/ModuleUnit/UnitMouseInput/BakingMobilePlate.cs.meta deleted file mode 100644 index 19debe1..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/BakingMobilePlate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 00b6b3cc18640204a8ad48985d53db48 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/BakingRotate.cs b/Assets/ModuleUnit/UnitMouseInput/BakingRotate.cs deleted file mode 100644 index 66e3a7d..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/BakingRotate.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class BakingRotate : UnitMouseInput { - /// 设计视图相机模块 - public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking; - - private Vector3 mousePosition; - private Vector3 originalEulerAngles; - - public override void MouseDown(DataMouseInput data) { - mousePosition = data.ViewPosition; - originalEulerAngles = ViewCamera.EulerAngles; - } - public override void MouseDrag(DataMouseInput data) { - float offsetX = data.ViewPosition.x - mousePosition.x; - float offsetY = data.ViewPosition.y - mousePosition.y; - ViewCamera.EulerAngles = originalEulerAngles + new Vector3(-offsetY, offsetX , 0) * 360; - } -} diff --git a/Assets/ModuleUnit/UnitMouseInput/BakingRotate.cs.meta b/Assets/ModuleUnit/UnitMouseInput/BakingRotate.cs.meta deleted file mode 100644 index 9d1e440..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/BakingRotate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 49bda1134b4639f4cb22ffd3bb0499ce -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/BakingSelect.cs b/Assets/ModuleUnit/UnitMouseInput/BakingSelect.cs deleted file mode 100644 index 3255378..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/BakingSelect.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class BakingSelect : UnitMouseInput { - -} diff --git a/Assets/ModuleUnit/UnitMouseInput/BakingSelect.cs.meta b/Assets/ModuleUnit/UnitMouseInput/BakingSelect.cs.meta deleted file mode 100644 index 90c9681..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/BakingSelect.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1b9618a80c54534ca23a5e71c9d9de0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignBezier.cs b/Assets/ModuleUnit/UnitMouseInput/DesignBezier.cs deleted file mode 100644 index c4a2027..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignBezier.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DesignBezier : UnitMouseInput { - /// 设计视图相机模块 - public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign; - /// 查询点算法模块 - public ModuleFind FindSide => ModuleCore.FindSide; - - public override void MouseDown(DataMouseInput data) { - if (!FindSide.Find(data.WorldPosition, out DataPlateSide side)) { return; } - if (side.bezier == Bezier.一阶) { side.TwoRankBezier(); side.plate.UpdateVisual(); return; } - if (side.bezier == Bezier.二阶) { side.ThreeRankBezier(); side.plate.UpdateVisual(); return; } - if (side.bezier == Bezier.三阶) { side.OneRankBezier(); side.plate.UpdateVisual(); return; } - } -} diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignBezier.cs.meta b/Assets/ModuleUnit/UnitMouseInput/DesignBezier.cs.meta deleted file mode 100644 index c4f9fea..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignBezier.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c4c272ae3cc78a54c819d6b6194a75a8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignInsert.cs b/Assets/ModuleUnit/UnitMouseInput/DesignInsert.cs deleted file mode 100644 index d580bdc..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignInsert.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DesignInsert : UnitMouseInput { - /// 查询边交点 - public UnitFind find = new FindSideIntersectPoint(); - - public override void MouseDown(DataMouseInput data) { - if (!find.Find(data.WorldPosition, out SideIntersectPoint sip)) { return; } - Insert(sip.side, sip.side.plate, sip.side.aPoint, sip.side.bPoint, sip.intersectPoint); - } - - private void Insert(DataPlateSide side, DataPlate plate, DataPlatePoint aPoint, DataPlatePoint bPoint, Vector3 position) { - //创建新的点 - DataPlatePoint newPoint = new DataPlatePoint(plate); - newPoint.position = position - plate.dataDesign.position; - //改变关联的边B点,重置贝塞尔曲线 - side.bPoint = newPoint; - side.OneRankBezier(); - //创建新的边 - DataPlateSide newSide = new DataPlateSide(plate); - newSide.aPoint = newPoint; - newSide.bPoint = bPoint; - newSide.OneRankBezier(); - //插入边 - int sideIndex = plate.plateSides.IndexOf(side); - plate.plateSides.Insert(sideIndex + 1, newSide); - //插入点 - int pointIndex = plate.platePoints.IndexOf(aPoint); - plate.platePoints.Insert(pointIndex + 1, newPoint); - //更新数据 - plate.UpdateVisual(); - } -} diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignInsert.cs.meta b/Assets/ModuleUnit/UnitMouseInput/DesignInsert.cs.meta deleted file mode 100644 index c2337a1..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignInsert.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6572c7ebab448a94d880fca85c728132 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignMobile.cs b/Assets/ModuleUnit/UnitMouseInput/DesignMobile.cs deleted file mode 100644 index c1055a2..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignMobile.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DesignMobile : UnitMouseInput { - /// 设计视图相机模块 - public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign; - /// 查询贝塞尔点算法模块 - public ModuleFind FindBezier => ModuleCore.FindBezier; - - private DataBezier bezier; - private Vector3 mousePosition; - private Vector3 originalPosition; - private ModulePrefab prefabPoint; - private ModulePrefab prefabPlate; - - public override void MouseDown(DataMouseInput data) { - //判断是否选中贝塞尔点 - if (FindBezier.Find(data.WorldPosition, out bezier)) { - RecordBezier(data.ScreenPosition); return; - } - //判断是否选中点 - if (ViewCamera.ScreenToWorldObjectParent(data.ScreenPosition, out prefabPoint)) { - RecordPoint(data.ScreenPosition); return; - } - //判断是否选中板片 - if (ViewCamera.ScreenToWorldObjectParent(data.ScreenPosition,out prefabPlate)) { - RecordPlate(data.ScreenPosition); return; - } - RecordCamera(data.ScreenPosition); - } - public override void MouseDrag(DataMouseInput data) { - Vector3 original = ViewCamera.ScreenToWorldPosition(mousePosition); - Vector3 current = data.WorldPosition; - Vector3 offset = current - original; - - if (bezier != null) { MobileBezier(offset); return; } - if (prefabPoint != null) { MobilePoint(offset); return; } - if (prefabPlate != null) { MobilePlate(offset); return; } - MobileCamera(offset); - } - - //贝塞尔 - private void RecordBezier(Vector3 screenPosition) { - mousePosition = screenPosition; - originalPosition = bezier.position; - } - private void MobileBezier(Vector3 offset) { - Vector3 position = originalPosition + offset; - bezier.SetBezierPosition(position); - } - //点 - private void RecordPoint(Vector3 screenPosition) { - mousePosition = screenPosition; - originalPosition = prefabPoint.Value.position; - } - private void MobilePoint(Vector3 offset) { - prefabPoint.Value.position = originalPosition + offset; - prefabPoint.Value.plate.UpdateVisual(); - } - //板片 - private void RecordPlate(Vector3 screenPosition) { - mousePosition = screenPosition; - originalPosition = prefabPlate.Value.dataDesign.position; - } - private void MobilePlate(Vector3 offset) { - prefabPlate.Value.dataDesign.position = originalPosition + offset; - prefabPlate.Value.UpdateVisual(false); - } - //相机 - private void RecordCamera(Vector3 screenPosition) { - mousePosition = screenPosition; - originalPosition = ViewCamera.Position; - } - private void MobileCamera(Vector3 offset) { - ViewCamera.Position = originalPosition - offset; - } -} diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignMobile.cs.meta b/Assets/ModuleUnit/UnitMouseInput/DesignMobile.cs.meta deleted file mode 100644 index 9b81089..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignMobile.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1d9fbc3106b97d147ac9164dc314865a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignSuture.cs b/Assets/ModuleUnit/UnitMouseInput/DesignSuture.cs deleted file mode 100644 index a3eac79..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignSuture.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DesignSuture : UnitMouseInput { - /// 查询边交点 - public UnitFind find = new FindSideIntersectPoint(); - /// 连接可视化内容生成模块 - public ModuleVisual VisualConnector => ModuleCore.VisualConnector; - - private DataPlateSide aSide; - private DataPlateSide bSide; - private DataConnector connector; - - public override void MouseDown(DataMouseInput data) { - connector = new DataConnector(); - connector.aPoint = data.WorldPosition; - if (!find.Find(data.WorldPosition, out SideIntersectPoint sip)) { return; } - connector.aPoint = sip.intersectPoint; - aSide = sip.side; - } - public override void MouseDrag(DataMouseInput data) { - if (connector == null) { return; } - connector.bPoint = data.WorldPosition; - if (find.Find(data.WorldPosition, out SideIntersectPoint sip)) { - connector.bPoint = sip.intersectPoint; - bSide = sip.side; - } - else { connector.bPoint = data.WorldPosition; } - VisualConnector.UpdateVisual(connector); - } - public override void MouseRelease(DataMouseInput data) { - if (connector == null) { return; } - VisualConnector.ReleaseVisual(connector); - connector = null; - - if (aSide == null || bSide == null || aSide == bSide) { return; } - if (aSide.suture != null || bSide.suture != null) { return; } - DataSuture suture = new DataSuture(aSide, bSide); - aSide.suture = suture; - bSide.suture = suture; - aSide.plate.UpdateVisual(); - } - - //private Vector3 GetPosition(DataMouseInput data) { - // if (!FindSide.Find(data.WorldPosition, out bSide)) { return data.WorldPosition; } - // if (aSide == bSide) { return data.WorldPosition; } - // if (Intersect(bSide, data.WorldPosition, out Vector3 intersectPoint)) { return intersectPoint; } - // else { return data.WorldPosition; } - //} - //private bool Intersect(DataSide side, Vector3 position, out Vector3 intersectPoint) { - //DataIntersect intersect = new DataIntersect(side, position); - //AlgorithmSidePoint.Compute(intersect); - //intersectPoint = intersect.intersectPoint; - //return intersect.isIntersect; - //} -} diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignSuture.cs.meta b/Assets/ModuleUnit/UnitMouseInput/DesignSuture.cs.meta deleted file mode 100644 index e42f305..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignSuture.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f4da355235e26524388688f6bd6d5f43 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignSutureReversal.cs b/Assets/ModuleUnit/UnitMouseInput/DesignSutureReversal.cs deleted file mode 100644 index d095227..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignSutureReversal.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DesignSutureReversal : UnitMouseInput { - /// 设计视图相机模块 - public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign; - /// 查询点算法模块 - public ModuleFind FindSide => ModuleCore.FindSide; - - public override void MouseDown(DataMouseInput data) { - if (!FindSide.Find(data.WorldPosition, out DataPlateSide side)) { return; } - if (side.suture.a.plateSide == side) { - side.suture.a.isReversal = !side.suture.a.isReversal; - } - if (side.suture.b.plateSide == side) { - side.suture.b.isReversal = !side.suture.b.isReversal; - } - side.plate.UpdateVisual(); - } -} diff --git a/Assets/ModuleUnit/UnitMouseInput/DesignSutureReversal.cs.meta b/Assets/ModuleUnit/UnitMouseInput/DesignSutureReversal.cs.meta deleted file mode 100644 index d5558b3..0000000 --- a/Assets/ModuleUnit/UnitMouseInput/DesignSutureReversal.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4360e81518739f24c842afc64b8e81b3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitMouseInput/UnitMouseInput.cs b/Assets/ModuleUnit/UnitMouseInput/UnitMouseInput.cs index 14bc1fc..6886c0d 100644 --- a/Assets/ModuleUnit/UnitMouseInput/UnitMouseInput.cs +++ b/Assets/ModuleUnit/UnitMouseInput/UnitMouseInput.cs @@ -2,9 +2,6 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -/// -/// 鼠标输入单元 -/// public abstract class UnitMouseInput { /// 核心模块 protected virtual ModuleCore ModuleCore => ModuleCore.I; @@ -17,4 +14,6 @@ public abstract class UnitMouseInput { public virtual void MouseMove(DataMouseInput data) { } /// 释放鼠标 public virtual void MouseRelease(DataMouseInput data) { } + /// 鼠标滚轮 + public virtual void MouseScroll(DataMouseInput data) { } } diff --git a/Assets/ModuleUnit/UnitMouseInput/UnitMouseInput.cs.meta b/Assets/ModuleUnit/UnitMouseInput/UnitMouseInput.cs.meta index 0e22f13..3476e19 100644 --- a/Assets/ModuleUnit/UnitMouseInput/UnitMouseInput.cs.meta +++ b/Assets/ModuleUnit/UnitMouseInput/UnitMouseInput.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e54a1981f15dce04b95e1b917c13cccd +guid: d6cbde8dad4ff3f44bd5cc80c96fc3b9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleUnit/UnitUIControl.meta b/Assets/ModuleUnit/UnitUIControl.meta deleted file mode 100644 index 733beaa..0000000 --- a/Assets/ModuleUnit/UnitUIControl.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 003c25d4c480b204eb86572109652c5d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleUnit/UnitUIControl/UIControlBaking.cs b/Assets/ModuleUnit/UnitUIControl/UIControlBaking.cs deleted file mode 100644 index 5ebc449..0000000 --- a/Assets/ModuleUnit/UnitUIControl/UIControlBaking.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UIElements; - -public class UIControlBaking : UnitUIControl { - - #region UI元素 - public override VisualElement Element => ModuleUIPage.Q("PlateBaking"); - public VisualElement Rendering => Element.Q("Rendering"); - public Button Button1 => Element.Q