Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / [Dark Dynamix] Group masks

Author
Message
Fallout
16
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 3rd Jul 2012 15:43 Edited at: 3rd Jul 2012 15:44
I just wonder exactly how you use 'Group Masks' with commands such as the raycast commands.

Quote: "bool dynRaycastClosestShape (int origVec3ID, int dirVec3ID, int flag, int groups)
groups - Groups mask to filter shapes. "


I am defining groups using standard integers 1,2,3,4,5,6 etc. So what is the format for the group mask bits?

I'm guessing 0 = no collision (I think I tested that), then each bit from then on represents one of the groups. So I guess this means we have a maximum of 16 groups? Also, -1 seems to cause collision with all objects. Is that a special code for all objects, or is that caused by some sort of datatype wrapping error, effectively setting all the bits?

A bit of clarity would be really handy, as I'm starting to use more and more groups and having control over which groups I target is important.

Matty H
10
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 3rd Jul 2012 16:30
Although groups are assigned with group ID's 1,2,3,4... they are stored away as bits and can be accessed using bits.

From the raycast example you can define what groups to be included in the raycast with:

int groupFlag = 1<<1 | 1<<2; // Groups 1 and 2

Fallout
16
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 3rd Jul 2012 17:37
Cool, thanks for the clarification. I'll use the bit shifts as you've described. Is it a 16 bit number we're dealing with btw?

Matty H
10
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 3rd Jul 2012 19:20
I think I may have implemented it as an 'int' rather than 'unsigned int', so you may need to keep to 16 bits for now. I will look at this again, I was not sure how DBPro handled unsigned int's when I implemented this so I stuck to int.

If it needs changing I will do so for the next update.

Fallout
16
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 3rd Jul 2012 19:33
Can't imagine I'll need more than 16 groups, so should be fine for now!

Olby
15
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 3rd Jul 2012 23:17
Quote: "640K ought to be enough for anybody."


Just had to say it although I don't think I would come close to that limit any time soon.


Intel Core2Duo 2.2GHZ, 2GB, GeForce 8600M GT 1280MB, Windows Vista Ultimate SP2, PureBasic 4.61 + DarkGDK 2.0
Fallout
16
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 3rd Jul 2012 23:26
True. I can easily see a scenario where you'd want more than 16 groups. I suppose if it gets to that stage, you could have a version of the command where you just pass it a group number. You'd then just have to run the command for every group you wanted to check again.

Just a thought!

Login to post a reply

Server time is: 2019-07-20 13:52:18
Your offset time is: 2019-07-20 13:52:18