Skip to content

Assert failure in AddRightEdges() (similar to reported in #72?) #77

@wrmorris-google

Description

@wrmorris-google

I've found another failure similar to what I reported in #72. Here's a minimal input set that produces this error, which is an assert failure in sweep.c:AddRightEdges() (but this time it's an assert relating to the winding number)

assert( regPrev->windingNumber - e->winding == reg->windingNumber );

with call stack:
sweep.c:AddRightEdges
sweep.c:SweepEvent
sweep.c:ComputeInterior
tess.c:tessTesselate

The test case that produces this assertion failure:

  TESStesselator* libtess = tessNewTess(nullptr);
  const int kSize = 2;
  const int kStride = kSize * sizeof(float);
  float contour_1[] = {
      -1.0934316, 0.6718408,   //
      -1.0224961, 0.6719364,   //
      -0.8962616, 0.79851276,  //
      -0.9317774, 0.8339327,   //
  };
  tessSetOption(libtess, TESS_REVERSE_CONTOURS, 0);
  tessAddContour(libtess, kSize, contour_1, kStride,
                 sizeof(contour_1) / sizeof(float) / 2);

  float contour_2[] = {
      -1.0934275, 0.6718371,   //
      -1.1465579, 0.6185637,   //
      4.8087187,  -5.320729,   //
      4.8618493,  -5.2674556,  //
  };
  tessSetOption(libtess, TESS_REVERSE_CONTOURS, 1);
  tessAddContour(libtess, kSize, contour_2, kStride,
                 sizeof(contour_2) / sizeof(float) / 2);

  float contour_3[] = {
      -0.044983167, -0.3736277,   //
      -0.09811407,  -0.42690045,  //
      4.8087497,    -5.320695,    //
      4.861881,     -5.267422,    //
  };
  tessSetOption(libtess, TESS_REVERSE_CONTOURS, 1);
  tessAddContour(libtess, kSize, contour_3, kStride,
                 sizeof(contour_3) / sizeof(float) / 2);

  float contour_4[] = {
      -0.044942975, -0.37370682,  //
      -0.09807353,  -0.42697996,  //
      4.808758,     -5.3206916,   //
      4.8618884,    -5.2674184,   //
  };
  tessSetOption(libtess, TESS_REVERSE_CONTOURS, 1);
  tessAddContour(libtess, kSize, contour_4, kStride,
                 sizeof(contour_4) / sizeof(float) / 2);

  float contour_5[] = {
      -0.0449009,  -0.3737888,   //
      -0.09803118, -0.42706218,  //
      4.8087616,   -5.320684,    //
      4.8618917,   -5.2674108,   //
  };
  tessSetOption(libtess, TESS_REVERSE_CONTOURS, 1);
  tessAddContour(libtess, kSize, contour_5, kStride,
                 sizeof(contour_5) / sizeof(float) / 2);

  float contour_6[] = {
      -0.044857033, -0.37371138,  //
      -0.097987816, -0.42698428,  //
      4.8087854,    -5.32066,     //
      4.861916,     -5.267387,    //
  };
  tessSetOption(libtess, TESS_REVERSE_CONTOURS, 1);
  tessAddContour(libtess, kSize, contour_6, kStride,
                 sizeof(contour_6) / sizeof(float) / 2);

  float contour_7[] = {
      -0.044842396, -0.37368622,  //
      -0.097973324, -0.42695898,  //
      4.808791,     -5.320654,    //
      4.861922,     -5.267381,    //
  };
  tessSetOption(libtess, TESS_REVERSE_CONTOURS, 1);
  tessAddContour(libtess, kSize, contour_7, kStride,
                 sizeof(contour_7) / sizeof(float) / 2);

  float normal[] = {0.0f, 0.0f, 1.0f};
  tessTesselate(libtess, TESS_WINDING_POSITIVE, TESS_POLYGONS,
                /*polySize=*/3, /*vertexSize=*/2, normal);
  tessDeleteTess(libtess);

Sorry about the size of the input set - if any of these are removed, no failure occurs.

I've not looked into this further. Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions