Game Development Community

Using collisionMasks to group collisionobjects

by Wombah · in Torque Game Engine · 06/02/2004 (4:49 am) · 3 replies

I'm entirey new to torque, so maybe this should be posted in 'Getting Started', but here goes. Also, if this is alreday covered by some old post that I couldn't find, my apologies, and please provide a link.

I'm trying to figure out how to group objects together, and then make collisiontests only between objects in the same group. I've found the 'collisonMask' in vehicle.cc/.h, but it is only stored there, and used on some other level in the engine. I can't for the life of me figure out where though, so thats my first question. How and where are collisionMasks used?

Second, and more generally, could/should this be done, and how much work will/could it mean, taking into consideration I know C/++ fairly well, but I'm new to torque?

I realize this could be done in script (in onCollision e.g.), but then I'll end up doing a lot of collision-handling only to discard it when I find out that the two colliding objects really shouldn't be tested for collision between themselves since they're not in the same 'collisionGroup'. That's why I would like to add the option of grouping objects into the engine source itself, instead of scripting it.

Not sure I'm making any sense, but I'm grateful for any thoughts on the matter.

Thanks in advance
/Royne Borrud - 'Doggbert'

EDIT: Spelling, grammar, removed some (all?) stupidity

#2
06/02/2004 (5:57 am)
Thanks a bunch! Will look through it as soon as I find the time.
#3
06/14/2004 (4:09 am)
Ok. I've read up on this a bit, and got a way to do it. I still have a problem though.

The way I've done this is to add a mask to all vehicles, and a new objectType::groupedCollision to objectTypes.h. In convex::updateWorkingList() I first check if the objects are to be grouped and then I check for matching masks. If the mask doesn't match, you don't do collisiontesting. It seems like that would work, but...

For some reason, the car lags or skips a bit or something when it first comes into contact with another car of a different collision group, and then passes straight through it as if changing it's mind. It seems I've missed some preliminary test for collision, that has it's effect before updateWorkingList, but that shouldn't be, should it?

If it's needed or of interest, I can post the specifics of the codechanges I've done.