Beispiel #1
0
 static bool SegmentVisistor(Segment s0, Segment s1, ref Context context, UserData userData, out UserData o_userData)
 {
     o_userData = new UserData();
     if (s0 == null) // starting segment
     {
         Assert.IsNull(userData);
         int n0      = s1.Index * 2,
             n1      = n0 + 1;
         float width = (s1.Highway) ? context.highwayWidth : context.streetWidth;
         CreateStartSegmentPoints(
             s1.Start * context.scale,
             s1.End * context.scale,
             width,
             context.lengthStep,
             (s1.Highway) ? context.highwayU : 1,
             n0,
             n1,
             ref context.segmentPositions,
             ref context.crossingPositions,
             ref context.segmentUVs,
             ref context.segmentIndices,
             context.edgeToIndicesMap,
             out o_userData.i0,
             out o_userData.i1,
             out o_userData.v
             );
         o_userData.origin = s1.Start;
     }
     else if (s1 == null) // end segment
     {
         int n0      = s0.Index * 2,
             n1      = n0 + 1;
         float width = (s0.Highway) ? context.highwayWidth : context.streetWidth;
         CreateEndSegmentPoints(
             ((userData != null) ? userData.origin : s0.Start) * context.scale,
             s0.Start * context.scale,
             s0.End * context.scale,
             width,
             context.lengthStep,
             (s0.Highway) ? context.highwayU : 1,
             (userData != null) ? userData.v : 0,
             n0,
             n1,
             (userData != null) ? userData.i0 : -1,
             (userData != null) ? userData.i1 : -1,
             ref context.segmentPositions,
             ref context.crossingPositions,
             ref context.segmentUVs,
             ref context.segmentIndices,
             context.edgeToIndicesMap
             );
     }
     else // mid segment
     {
         Assert.IsNotNull(userData);
         Assert.AreEqual(s0.End, s1.Start);
         int n0      = s1.Index * 2,
             n1      = n0 + 1;
         float width = (s1.Highway) ? context.highwayWidth : context.streetWidth;
         CreateMidSegmentPoints(
             s0.Start * context.scale,
             s1.Start * context.scale,
             s1.End * context.scale,
             width,
             context.lengthStep,
             (s1.Highway) ? context.highwayU : 1,
             userData.v,
             n0,
             n1,
             userData.i0,
             userData.i1,
             ref context.segmentPositions,
             ref context.crossingPositions,
             ref context.segmentUVs,
             ref context.segmentIndices,
             context.edgeToIndicesMap,
             out o_userData.i0,
             out o_userData.i1,
             out o_userData.v
             );
         o_userData.origin = s1.Start;
     }
     return(true);
 }