+
+int poly_poly(const struct poly *p1, const struct poly *p2)
+{
+ int i, vnum1, vnum2;
+ float t;
+ cgm_ray ray;
+
+ vnum1 = dynarr_size(p1->verts);
+ vnum2 = dynarr_size(p2->verts);
+
+ for(i=0; i<vnum1; i++) {
+ ray.origin = p1->verts[i].pos;
+ ray.dir = p1->verts[(i + 1) & vnum1].pos;
+ cgm_vsub(&ray.dir, &ray.origin);
+
+ if((t = ray_poly(&ray, p2)) >= 0.0f && t <= 1.0f) {
+ return 1;
+ }
+ }
+
+ for(i=0; i<vnum2; i++) {
+ ray.origin = p2->verts[i].pos;
+ ray.dir = p2->verts[(i + 1) & vnum2].pos;
+ cgm_vsub(&ray.dir, &ray.origin);
+
+ if((t = ray_poly(&ray, p1)) >= 0.0f && t <= 1.0f) {
+ return 1;
+ }
+ }
+
+ return 0;
+}