Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collision category bits #344

Closed
ghost opened this issue Jul 6, 2023 · 6 comments
Closed

Collision category bits #344

ghost opened this issue Jul 6, 2023 · 6 comments

Comments

@ghost
Copy link

ghost commented Jul 6, 2023

Here's the docs:

enum Category {
CATEGORY1 = 0x0001,
CATEGORY2 = 0x0002,
CATEGORY3 = 0x0004
};

When I start extending this, such as:

enum Category {
CATEGORY1 = 0x0001,
CATEGORY2 = 0x0002,
CATEGORY3 = 0x0004
CATEGORY4 = 0x0008
CATEGORY5 = 0x0016
CATEGORY6 = 0x0032
CATEGORY7 = 0x0064
};

I find that say CATEGORY4 | CATEGORY7 also tests true with CATEGORY2 - what am I doing wrong?

@ghost
Copy link
Author

ghost commented Jul 6, 2023

found it,

@DanielChappuis
Copy link
Owner

found it,

What did you find exactly? Did you find an issue in your code or in the library?

@ghost
Copy link
Author

ghost commented Jul 10, 2023

Well, I think it was an issue with trying to use higher 0x00 numbers. Enum (I believe) defaults to an Unsigned 32 bit number, and I see that RP3D expects Unsigned short, although I thought that the cast would work. Anyway, I just declare my collision categories like this and it worked:

static const U16 TEAM_0_ACTOR_COLLISION_CATEGORY = 256;
static const U16 TEAM_1_ACTOR_COLLISION_CATEGORY = 512;
static const U16 TEAM_2_ACTOR_COLLISION_CATEGORY = 1024;
static const U16 TEAM_3_ACTOR_COLLISION_CATEGORY = 2048;
static const U16 TEAM_4_ACTOR_COLLISION_CATEGORY = 4096;
static const U16 TEAM_5_ACTOR_COLLISION_CATEGORY = 8192;

@MintPaw
Copy link

MintPaw commented Aug 17, 2023

I'm guessing this feature isn't well tested because it's not often used. But this collision filtering seems totally broken in my application. I can't prevent collisions between spheres/boxes and triangle meshes, even if I set collider->setCollideWithMaskBits(0); every frame.

It does work if you set the bits to 0 on the first frame, but if you wait and set it later, it doesn't work. Is this the intended behavior?

@ScottFreeCode
Copy link

The issue with 0x0016, 0x0032 and 0x0064 is that 0x#… is a hexadecimal number. Removing the 0x and leading zeroes would make "16", "32" and "64" correct. Or, you could write 16 as 0x0010, 32 as 0x0020, 64 as 0x0040, 128 as 0x0080, 256 as 0x0100 and so on and so forth.

@DanielChappuis
Copy link
Owner

Thanks @ScottFreeCode for the explanation. I think I can now close this issue.

Do not hesitate to reopen it if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants