Game Development Community

Back to the basics...

by Alex Scarborough · 04/15/2006 (2:32 pm) · 6 comments

So, DRL is out, again, and no major world ending issues have come up so far, so I'm due for another little side project. Rendering is all fine and dandy, but I'd like to get back to collisions and physics and such. For whatever reason, it's much more rewarding to work on things that people don't notice unless they don't work right. Of course, it's been six months since I've really looked at the collision stuff in Torque, so I picked up a quick project to reacquaint myself with the basics. Just something to do at 2AM in the morning.

Particle collisions

Took about twenty minutes from start to finish, though it's probably horrifically slow. It just runs a ray between the particles old and new position. Yay castRay. I didn't really want to look up the proper way to handle response, so I just grabbed the code from T2D and assumed it'd work for 3D. I have no idea how correct it is, but it seems to work fine.

What'd I'd like to do, instead of using castRay, is write my own quick collision detection routine and use buildPolyList to get a list of polies the particles might collide against. I have no idea if it'll be any faster than castRay, but that's not the point. I just want to try out new things and learn as I go.

All in all, not bad for 20 minutes of work and 10 lines of code.

#1
04/15/2006 (2:56 pm)
nice shots there! too bad i can't do anything like that.
#2
04/15/2006 (3:03 pm)
Wow that's great. I could use this greatly for my flamethrower particles. :D
#3
04/16/2006 (1:30 am)
Wheee, got elastic collisions working (ie restitution free go with the flow collisions). The particles don't bounce around a ton now.

Waterfall
On terrain

The only issue is that it has a tendency to miss collisions and fall through when we go between terrain squares.
#4
04/16/2006 (3:47 am)
Alex,

I remember doing something similar in '03. In-fact, I've still got an old movie I dug-up here (6.1mb). I did the exact same thing and doing a little profiling showed that it was actually very quick.

I may have done some other minor tweaks but I don't think it was anything extraordinary.

Particles with collisions are fun!

One question from above though; You mention the T2D particle-engine but how is that being used? Did you simply reference how that handled particle collisions?

- Melv.
#5
04/16/2006 (10:36 am)
@Melv: I took the code for the T2D particle response. Basically, I was too lazy to look up the actual math, and I assumed that the 2D response would at least be similar to the 3D response. It certainly seems to work fine, so...

Awesome video, by the way.

Edit: Stress test

That hurt framerate. A lot. Went from 40 FPS to 20 in the first shot, then to 7 for the second. Sure looks nice though.
#6
04/17/2006 (1:11 am)
Ah, understand now. Confused me that's all. For a minute there I thought you had somehow adapted some of the T2D particle engine to work in 3D. That certainly wouldn't be bad for 20 minutes work. ;)

Good luck,

- Melv.