~zjm/Moon3D

8f875a71c31491fc39a773d802afc2b60dfecb90 — Zack Michener a month ago aba8e66
fix up clip polygon test
1 files changed, 11 insertions(+), 31 deletions(-)

M test/clipping.test.c
M test/clipping.test.c => test/clipping.test.c +11 -31
@@ 61,16 61,6 @@ void TestClipPolygon(void)
  vertex = NewVertex(mesh.vertices);
  *vertex = V(1.33, 0.5, 0.67);

  /* polygonC */
  vertex = NewVertex(mesh.vertices);
  *vertex = V4D( -2.0750, +0.9184, +0.1827, +1.0000 );
  vertex = NewVertex(mesh.vertices);
  *vertex = V4D( +13.1148, -5.3145, -7.9813, +1.0000 );
  vertex = NewVertex(mesh.vertices);
  *vertex = V4D( +13.1148, +5.3145, -7.9813, +1.0000 );
  vertex = NewVertex(mesh.vertices);
  *vertex = V4D( -2.0750, -0.9184, +0.1827, +1.0000 );

  int *polygonA = NewPolygon(mesh.faces);
  AddPolygonValue(polygonA, mesh.faces, 0);
  AddPolygonValue(polygonA, mesh.faces, 1);


@@ 82,29 72,19 @@ void TestClipPolygon(void)
  AddPolygonValue(polygonB, mesh.faces, 5);
  AddPolygonValue(polygonB, mesh.faces, 6);

  int *polygonC = NewPolygon(mesh.faces);
  AddPolygonValue(polygonC, mesh.faces, 7);
  AddPolygonValue(polygonC, mesh.faces, 8);
  AddPolygonValue(polygonC, mesh.faces, 9);
  AddPolygonValue(polygonC, mesh.faces, 10);

  // verts_before = PoolTotal(mesh.vertices);
  // clipped_polygon = ClipPolygon(polygonA, &mesh, renderer);
  // AssertTrue(PoolTotal(mesh.vertices) == verts_before + 2);
  // AssertTrue(NumPolygonVertices(clipped_polygon) == 4);
  // AssertTrue(VectorEqual(*PolygonVertex(clipped_polygon, mesh.vertices, 0), V(0.5, 0.5, 0.5)));
  // AssertTrue(VectorEqual(*PolygonVertex(clipped_polygon, mesh.vertices, 1), V(-1, 0.5, 0.5)));
  // AssertTrue(VectorEqual(*PolygonVertex(clipped_polygon, mesh.vertices, 2), V(-1, 0.1666667, 0.1666667)));
  // AssertTrue(VectorEqual(*PolygonVertex(clipped_polygon, mesh.vertices, 3), V(0, 0, 0)));

  // verts_before = PoolTotal(mesh.vertices);
  // clipped_polygon = ClipPolygon(polygonB, &mesh, renderer);
  // AssertTrue(PoolTotal(mesh.vertices) == verts_before + 4);
  // AssertTrue(NumPolygonVertices(clipped_polygon) == 5);
  verts_before = PoolTotal(mesh.vertices);
  clipped_polygon = ClipPolygon(polygonA, &mesh, renderer);
  AssertTrue(PoolTotal(mesh.vertices) == verts_before + 2);
  AssertTrue(NumPolygonVertices(clipped_polygon) == 4);
  AssertTrue(VectorEqual(*PolygonVertex(clipped_polygon, mesh.vertices, 0), V(0.5, 0.5, 0.5)));
  AssertTrue(VectorEqual(*PolygonVertex(clipped_polygon, mesh.vertices, 1), V(-1, 0.5, 0.5)));
  AssertTrue(VectorEqual(*PolygonVertex(clipped_polygon, mesh.vertices, 2), V(-1, 0.1666667, 0.1666667)));
  AssertTrue(VectorEqual(*PolygonVertex(clipped_polygon, mesh.vertices, 3), V(0, 0, 0)));

  verts_before = PoolTotal(mesh.vertices);
  clipped_polygon = ClipPolygon(polygonC, &mesh, renderer);
  AssertTrue(NumPolygonVertices(clipped_polygon) == 0);
  clipped_polygon = ClipPolygon(polygonB, &mesh, renderer);
  AssertTrue(PoolTotal(mesh.vertices) == verts_before + 4);
  AssertTrue(NumPolygonVertices(clipped_polygon) == 5);
}

void TestVertexInside(void)