You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.7 KiB
C

#include <stdio.h>
#define CUTE_C2_IMPLEMENTATION
#include "cute_c2.h"
int main(int argc, char ** argv)
{
int face_index = -1;
#define V(xin, yin) (c2v){.x = xin, .y = yin}
#define VN(x, y) (c2Norm(V(x, y)))
#if 0
c2v vert = V(1.0, 2.0);
c2v vert_no_macro = (c2v){.x = 1.0, .y = 2.0};
#endif
#if 0
c2Poly A = (c2Poly){
.count = 1,
.verts = {V(-1.0, 26.0)},
.norms = {V(-1.0, 0.0)},
};
printf("%f\n", A.verts[0].y);
#endif
#if 1
c2Poly A = (c2Poly){
.count = 4,
.verts = {V(-1, 1), V(1, 1), V(1, -1), V(-1, -1)},
};
c2MakePoly(&A);
c2Poly B = (c2Poly){
.count = 4,
.verts = {V(-0.5, 1), V(1.5, 1), V(1.5, -1), V(-0.5, -1)},
};
c2MakePoly(&B);
c2v b_offset = V(0.0, 0.0);
for(int i = 0; i < B.count; i++) {
B.verts[i].x += b_offset.x;
B.verts[i].y += b_offset.y;
}
printf("A\n");
for(int i = 0; i < A.count; i++) {
printf("(%f,%f), ", A.verts[i].x, A.verts[i].y);
}
printf("\n");
printf("Normals: ");
for(int i = 0; i < A.count; i++) {
printf("(%f,%f), ", A.norms[i].x, A.norms[i].y);
}
printf("\n");
printf("\n");
printf("B\n");
for(int i = 0; i < B.count; i++) {
printf("(%f,%f), ", B.verts[i].x, B.verts[i].y);
}
printf("\n");
float output = c2CheckFaces(&A, c2xIdentity(), &B, c2xIdentity(), &face_index);
printf("Separation %f face_index %d\n", output, face_index);
c2Manifold m = {0};
c2PolytoPolyManifold(&A, NULL, &B, NULL, &m);
printf("Manifold normal (%f, %f) | depth 0 %f | depth 1 %f |\n", m.n.x, m.n.y, m.depths[0], m.depths[1]);
#endif
getchar(); // so terminal doesn't close immediately in remedybg
}