Tuesday, October 28, 2008

One of those days...

The collision bug I mentioned last time turned out to go deeper than I'd realized. At the lowest levels of my swept ellipsoid tests, I transform the ellipsoid into a unit sphere and transform each triangle in each collision mesh into the same space as this sphere. It sort of normalizes and simplifies the math. So then I sweep this sphere against the plane of the triangle, and if there's an intersection, test that point for containment in the triangle. That was where I thought things were going wrong before, but it was actually because of bad results from the sphere-plane sweep. It took me several hours trying various permutations of potential fixes on a half page of code before I finally rewound, started fresh, and ended up with a fix that I swore was one of the first things I had tried.

That's the frustrating side of programming. Hard-to-debug problems without obvious causes, where there's nothing to do but keep hypothesizing about why it's broken, applying a patch based on that theory, and then hammering on it to see if it holds. Fortunately, days like that aren't as common as the good, fun days where everything just works. Sometimes, though, we just have to dig in and fix nasty bugs. That's what really separates a good program from a bad one, regardless of the programmer. It's still pretty satisfying when it's finally fixed; in this case, I can walk through the 3D world and trust that it's solid again. That's a nice feeling.

0 Comments:

Post a Comment

<< Home