cute_headers icon indicating copy to clipboard operation
cute_headers copied to clipboard

Fix contact points on c2AABBtoAABBManifold

Open lmbarros opened this issue 7 months ago • 1 comments

Another attempt at fixing a little issue I found in cute_c2. This is working fine in my test cases, though I believe there must be a smarter way of implementing this. :sweat_smile:


Previously, we would in some cases return contact points that were not within the intersection of the two AABBs. For example,

c2AABB a = {{-3.0, 2.0}, {1.001, 4.001}};
c2AABB b = {{1.0, 4.0}, {2.0, 6.0}};
c2Manifold m;
c2AABBtoAABBManifold(a, b, &m);
printf("p=(%f, %f)\n", m.contact_points[0].x, m.contact_points[0].y);

would print p=(-0.999500, 4.001000).

This commit offsets the "other" coordinate of the contact points so that it lies within the intersection of the two AABBs. With the example above, it now prints p=(1.001000, 4.001000).

lmbarros avatar Jul 11 '24 22:07 lmbarros