Inheritance: Terra.Geometry.Triangle
Esempio n. 1
0
        protected override Triangle AllocFace(Edge edge)
        {
            var tri = new TrackedTriangle(edge);

            heap.Insert(tri, -1.0f);
            return(tri);
        }
Esempio n. 2
0
        public void ScanTriangle(TrackedTriangle tri)
        {
            var zPlane = new Plane();

            ComputePlane(zPlane, tri, HeightMap);

            var vecArray = new[] { tri.Point1, tri.Point2, tri.Point3 };

            Array.Sort(vecArray, new Vector2TriangleComparer());

            var x1        = vecArray[0].X;
            var x2        = vecArray[0].X;
            var dx1       = (vecArray[1].X - vecArray[0].X) / (vecArray[1].Y - vecArray[0].Y);
            var dx2       = (vecArray[2].X - vecArray[0].X) / (vecArray[2].Y - vecArray[0].Y);
            var startY    = (int)vecArray[0].Y;
            var endY      = (int)vecArray[1].Y;
            var candidate = new Candidate();

            for (var y = startY; y < endY; y++)
            {
                ScanTriangleLine(zPlane, y, x1, x2, candidate);
                x1 += dx1;
                x2 += dx2;
            }

            dx1    = (vecArray[2].X - vecArray[1].X) / (vecArray[2].Y - vecArray[1].Y);
            x1     = vecArray[1].X;
            startY = (int)vecArray[1].Y;
            endY   = (int)vecArray[2].Y;

            for (var y = startY; y < endY; y++)
            {
                ScanTriangleLine(zPlane, y, x1, x2, candidate);
                x1 += dx1;
                x2 += dx2;
            }


            if (candidate.Importance < 1e-4f)
            {
                if (tri.Token != Heap.NOT_IN_HEAP)
                {
                    heap.Kill(tri.Token);
                }
                tri.SetCandidate(-69, -69, 0.0f);
                return;
            }

            Debug.Assert(PointStates[candidate.X, candidate.Y] == PointState.Unused);
            tri.SetCandidate(candidate.X, candidate.Y, candidate.Importance);
            if (tri.Token == Heap.NOT_IN_HEAP)
            {
                heap.Insert(tri, candidate.Importance);
            }
            else
            {
                heap.Update(tri, candidate.Importance);
            }
        }
Esempio n. 3
0
 protected override LinkedListTriangle AllocFace(Edge edge)
 {
     var tri = new TrackedTriangle(edge);
     heap.Insert(tri, -1.0f);
     return tri;
 }
Esempio n. 4
0
        public void ScanTriangle(TrackedTriangle tri)
        {
            var zPlane = new Plane();
            ComputePlane(zPlane, tri, HeightMap);

            var vecArray = new[] {tri.Point1, tri.Point2, tri.Point3};
            Array.Sort(vecArray, new Vector2TriangleComparer());

            var x1 = vecArray[0].X;
            var x2 = vecArray[0].X;
            var dx1 = (vecArray[1].X - vecArray[0].X)/(vecArray[1].Y - vecArray[0].Y);
            var dx2 = (vecArray[2].X - vecArray[0].X)/(vecArray[2].Y - vecArray[0].Y);
            var startY = (int) vecArray[0].Y;
            var endY = (int) vecArray[1].Y;
            var candidate = new Candidate();

            for(var y = startY; y < endY; y++)
            {
                ScanTriangleLine(zPlane, y, x1, x2, candidate);
                x1 += dx1;
                x2 += dx2;
            }

            dx1 = (vecArray[2].X - vecArray[1].X)/(vecArray[2].Y - vecArray[1].Y);
            x1 = vecArray[1].X;
            startY = (int) vecArray[1].Y;
            endY = (int) vecArray[2].Y;

            for (var y = startY; y < endY; y++)
            {
                ScanTriangleLine(zPlane, y, x1, x2, candidate);
                x1 += dx1;
                x2 += dx2;
            }

            if (candidate.Importance < 1e-4f)
            {
                if (tri.Token != Heap.NOT_IN_HEAP)
                {
                    heap.Kill(tri.Token);
                }
                tri.SetCandidate(-69, -69, 0.0f);
                return;
            }

            Debug.Assert(PointStates[candidate.X, candidate.Y] == PointState.Unused);
            tri.SetCandidate(candidate.X, candidate.Y, candidate.Importance);
            if (tri.Token == Heap.NOT_IN_HEAP)
            {
                heap.Insert(tri, candidate.Importance);
            }
            else
            {
                heap.Update(tri, candidate.Importance);
            }
        }