ewjordan
Ex Member
Re: Destructible Terrain (solution and discussion)
Reply #9 - Aug 21st , 2007, 3:05pm
>> Yes my demo breaks, but I already uploaded it >> and my internet connection is useless. Understood - during college I lived off campus and had nothing but dialup AOL, so I'm no stranger to the crappy connection. Even just to download a PDF file for a class could take up to an hour, which made things quite difficult...in any case, don't worry about it, proof of concept demos are entirely exempt from any expectation of debugging, in my opinion. >> Why the hell would you need springs? Why? Why? Why? Why? True, I never did explain this...you need springs if you want to physically model dirt as opposed to sand. A pile of sand is very well approximated (for the purposes of game physics, at least) by a whole bunch of spheres undergoing almost completely inelastic collisions (too much jitter if they are elastic). If you hit a pile of spheres with a big heavy sphere, it will basically just spray everywhere, with no clumping or anything like that, just like real sand does when you kick it. In contrast, if you play around with some actual dirt, it clumps together, and if you stick an M80 in a pile of it, you'll blow it up and get a lot of reasonably sized chunks flying through the air. That's why you'd need springs, if you wanted to capture that clumping aspect of a ground explosion. In reality, though, it's probably easier just to use a bunch of colliding spheres and attach clump-shaped graphics to them, since that will look almost as convincing. Re: collisions against thin pixel walls. My latest Verlet project was exclusively points and lines, so I've dealt a lot with "tunneling" issues, though not pixel based. Since you've already got Bresenham's algorithm running, couldn't you do a rasterization from the last position to the current position and pick out a collision point that way rather than simply testing the current position for penetration distance? This would require a Bresenham calc each time step rather than at each reported collision, which is slightly more computationally intensive than a single pixel check, but that's the price we pay for avoiding tunneling...anyhow, with today's computers you can do hundreds/thousands of lines with Bresenham without maxing out the processor, so it shouldn't be too much of an issue to do one for each particle (the mere drawing of the particle itself, if you're using circles, will outweigh the cost of the collision check). Generally speaking a collision detector provides at least two things: 1) a collision point, and 2) a collision normal. For the collision point, just run Bresenham from last->current and pick out the first occupied pixel. For the normal things get a bit more complex, because the normal direction is not really specified from a pixel map - more thought would be required there, probably something along the lines of checking the neighborhood of the collision point and massaging that data somehow to come up with a normal direction. It sounds like you're getting by without using normals anyhow, so you may not need to go there. BTW, once I finish up the engine for the game I'm working on I'll post the source, where I have a lot of useful (and painfully debugged) code for doing Verlet collision resolution. You might find some of it useful for your stuff. At the moment I'm still tinkering, though, so I want to get it right before I put it online. In any case, am I correct to assume that you've not tried to deal with bodies that have extent in this way? (as in full sprite-on-sprite collision) At some point I might take a swing at that, P3D and P2D have some nice, fast triangle rasterization routines that could be modded to do overlap queries without too much trouble. Even swept detection might not be too slow in such a scheme...would be interesting to try, at least.