Пример #1
0
        public Vector3 HalfVectorToB(LineData other)
        {
            var lineA = this;
            var lineB = other;

            if (other.points[1] == points[0])
            {
                lineA = other;
                lineB = this;
            }

            var a = lineA.points[0].LocalPos - lineA.points[1].LocalPos;
            var b = lineB.points[1].LocalPos - lineB.points[0].LocalPos;

            var fromVector2 = GridNavigator.Inst().InPlaneVector(a);
            var toVector2   = GridNavigator.Inst().InPlaneVector(b);

            var mid = (fromVector2.normalized + toVector2.normalized).normalized;

            var cross = Vector3.Cross(fromVector2, toVector2);

            if (cross.z > 0)
            {
                mid = -mid;
            }

            return(GridNavigator.Inst().PlaneToWorldVector(mid).normalized);
        }
Пример #2
0
        private void ProcessPointOnALine(Vertex a, Vertex b, Triangle t)
        {
            if (EditorInputManager.GetMouseButtonDown(1))
            {
                SelectedLine = new LineData(t, a, b);
                UpdateLocalSpaceMousePosition();
            }

            PointedLine = new LineData(t, new Vertex[] { a, b });
        }
Пример #3
0
        public LineData[] GetLinesFor(Vertex pnt)
        {
            var ld = new LineData[2];
            var no = NumberOf(pnt);

            ld[0] = new LineData(this, new Vertex[] { vertexes[no], vertexes[(no + 1) % 3] });
            ld[1] = new LineData(this, new Vertex[] { vertexes[(no + 2) % 3], vertexes[no] });

            return(ld);
        }
Пример #4
0
        public void NullPointedSelected()
        {
            pointedUv        = null;
            pointedLine      = null;
            pointedTriangle  = null;
            selectedUv       = null;
            selectedLine     = null;
            selectedTriangle = null;

            triVertices = 0;
        }
Пример #5
0
        public bool AllVerticesShared(LineData ld)
        {
            var changed = false;

            for (var i = 0; i < 2; i++)
            {
                changed |= SetAllUVsShared(ld[i]);
            }

            return(changed);
        }
Пример #6
0
        public Vertex GetNotOneIn(LineData l)
        {
            for (var i = 0; i < 3; i++)
            {
                if ((vertexes[i].meshPoint != l.points[0].meshPoint) && (vertexes[i].meshPoint != l.points[1].meshPoint))
                {
                    return(vertexes[i]);
                }
            }

            return(vertexes[0]);
        }
Пример #7
0
        public int GetIndexOfNoOneIn(LineData l)
        {
            for (var i = 0; i < 3; i++)
            {
                if ((vertexes[i].meshPoint != l.points[0].meshPoint) && (vertexes[i].meshPoint != l.points[1].meshPoint))
                {
                    return(i);
                }
            }

            return(0);
        }
Пример #8
0
        public void RemoveLine(LineData ld)
        {
            var a = ld.points[0];
            var b = ld.points[1];

            for (var i = 0; i < triangles.Count; i++)
            {
                if (triangles[i].Includes(a.meshPoint, b.meshPoint))
                {
                    triangles.Remove(triangles[i]);
                    i--;
                }
            }
        }
Пример #9
0
        public void GiveLineUniqueVerticesRefreshTriangleListing(LineData ld)
        {
            var trs = ld.GetAllTriangles();

            if (trs.Count != 2)
            {
                return;
            }

            ld.points[0].meshPoint.smoothNormal = true;
            ld.points[1].meshPoint.smoothNormal = true;

            trs[0].GiveUniqueVerticesAgainst(trs[1]);
            RefreshVertexTriangleList();
        }
Пример #10
0
 public void SetLastPointed(LineData l)
 {
     ClearLastPointed();
     lastFramePointedLine = l;
 }
Пример #11
0
 public void ClearLastPointed()
 {
     lastFramePointedUv       = null;
     lastFramePointedLine     = null;
     lastFramePointedTriangle = null;
 }
Пример #12
0
        public void DeleteLine(LineData ld)
        {
            NullPointedSelected();

            RemoveLine(ld);
        }
Пример #13
0
        public static void PutEdgeOnLine(LineData ld)
        {
            var vrtA = ld.points[0].meshPoint;
            var vrtB = ld.points[1].meshPoint;

            var tris = ld.GetAllTriangles();

            foreach (var t in tris)
            {
                t.edgeWeight[t.GetIndexOfNoOneIn(ld)] = ShiftInvertedValue;// true;
            }
            var edValA = ShiftInvertedValue;
            var edValB = ShiftInvertedValue;

            if (_editingFlexibleEdge)
            {
                foreach (var uv in vrtA.vertices)
                {
                    foreach (var t in uv.triangles)
                    {
                        var opposite = t.NumberOf(uv);
                        for (var i = 0; i < 3; i++)
                        {
                            if (opposite != i)
                            {
                                edValA = Mathf.Max(edValA, t.edgeWeight[i]);
                            }
                        }
                    }
                }

                foreach (var uv in vrtB.vertices)
                {
                    foreach (var t in uv.triangles)
                    {
                        var opposite = t.NumberOf(uv);
                        for (var i = 0; i < 3; i++)
                        {
                            if (opposite != i)
                            {
                                edValB = Mathf.Max(edValB, t.edgeWeight[i]);
                            }
                        }
                    }
                }
            }

            vrtA.edgeStrength = edValA;
            vrtB.edgeStrength = edValB;

            if (_alsoDoColor)
            {
                var col = GlobalBrush.Color;
                foreach (var uvi in vrtA.vertices)
                {
                    GlobalBrush.mask.SetValuesOn(ref uvi.color, col);
                }
                foreach (var uvi in vrtB.vertices)
                {
                    GlobalBrush.mask.SetValuesOn(ref uvi.color, col);
                }
            }

            EditedMesh.Dirty = true;
        }
Пример #14
0
 public static bool Contains(this List <MeshPoint> lst, LineData ld) => lst.Contains(ld.points[0].meshPoint) && lst.Contains(ld.points[1].meshPoint);
Пример #15
0
 public bool SameVertices(LineData other) => (((other.points[0].meshPoint == points[0].meshPoint) && (other.points[1].meshPoint == points[1].meshPoint)) ||
                                              ((other.points[0].meshPoint == points[1].meshPoint) && (other.points[1].meshPoint == points[0].meshPoint)));
Пример #16
0
 public bool Includes(LineData ld) => (Includes(ld.points[0].meshPoint) && (Includes(ld.points[1].meshPoint)));