shell mesh
[meshfrac] / src / geom.c
index 4e30628..67c3c31 100644 (file)
@@ -32,7 +32,7 @@ void poly_normal(const struct poly *poly, cgm_vec3 *n)
        va = poly->verts[1].pos;
        cgm_vsub(&va, &poly->verts[0].pos);
        vb = poly->verts[2].pos;
-       cgm_vsub(&vb, &poly->verts[2].pos);
+       cgm_vsub(&vb, &poly->verts[0].pos);
 
        cgm_vcross(n, &va, &vb);
        cgm_vnormalize(n);
@@ -138,6 +138,11 @@ int init_poly(struct poly *p)
        return p->verts ? 0 : -1;
 }
 
+void destroy_poly(struct poly *p)
+{
+       dynarr_free(p->verts);
+}
+
 /* returns:
  *  1 -> both inside
  *  0 -> straddling and clipped
@@ -203,7 +208,7 @@ int clip_poly(struct poly *pout, const struct poly *pin, const struct plane *pla
        int i, nextidx, res = 0, vnum;
        int edges_clipped = 0;
 
-       dynarr_clear(pout->verts);
+       DYNARR_CLEAR(pout->verts);
 
        vnum = dynarr_size(pin->verts);
        for(i=0; i<vnum; i++) {