Code: Select all
if (current->isVisible() &&
(bits==0 || (bits != 0 && (current->getID() & bits))))
Code: Select all
if (current->isVisible() &&
(bits==0 || (bits != 0 && ((current->getID() & bits) == bits))))
Code: Select all
if (current->isVisible() &&
(bits==0 || (bits != 0 && (current->getID() & bits))))
Code: Select all
if (current->isVisible() &&
(bits==0 || (bits != 0 && ((current->getID() & bits) == bits))))
Code: Select all
(current->getID() & bits) == bits
0x0011 0x0010 0x0010
HEALTH idBitMask idBitMask
Code: Select all
if (current->isVisible() &&
(bits==0 || (bits != 0 && ( current->getID() == bits )))
Code: Select all
NT_PLAYER -> id=1 (0x000001)
NT_WEAPON -> id=2 (0x000010)
NT_HEALTH -> id=4 (0x000100)
NT_AND -> id=8 (0x001000)
NT_SO -> id=16 (0x010000)
NT_ON -> id=32 (0x100000)
Code: Select all
(NT_PLAYER|NT_WEAPON)
Code: Select all
enum NODE_TYPES {
NT_PLAYER =1
NT_WEAPON =2
NT_HEALTH =4
NT_AND =8
NT_SO =16
NT_ON =32
};
Yes there is one reason, that I also pointed out in my post: you can combine types. That is what I do myself and I wouldn't wanna miss that feature! I have different node types that need to get picked at the same time, but also need to be differentiable via the id. So I used the bit mask as it was supposed to be and it did exactly what I expected.Tyn wrote:I thought that myself actually, however there is no reason why it should be a mask instead of an exact match.
Maybe because it makes sense? Maybe because it's common style? And actually why should they NOT?? Theres even more complicated things you have to bother with if you get into c++/irrlicht/game programming stuff...Tyn wrote:Why should people be constricted to the power of two counting system caused by this?
It works just perfect for me. And I just made a test with your values and I can NOT confirm your experience.Tyn wrote:It doesn't work as far as I've seen anyway. I had a wall as id=16 and a character as id=1 and the mask set to 16. Which should mean:
character = 0001
wall = 1000
And so the character should be ignored but the collision is still detected on both.
Code: Select all
if (current->isVisible() &&
(bits==0 || (bits != 0 && ( current->getID() == bits )))
I see it the other way round.Tyn wrote:There is little reason not to simplify it and many reasons not to just leave it alone.
I see it this way: "Just because one doesn't know how to count in binary doesn't mean one shouldn't."Tyn wrote:Just because I know how to count in binary doesn't mean I should.
Isn't this topic an example?Tyn wrote:If you could give me an example where I would need to know how to count in binary or hex to program in C++ then I'm all ears
Code: Select all
enum E_BIT_MASK_MODE {
EBMM_BINARY,
EBMM_EXACT_MATCH
}
CSceneCollisionManager::setBitMaskMode(E_BIT_MASK_MODE mode);
Code: Select all
8-bit example
Jox's system Niko's system (2 bits for node)
00000001 00000011
00000010 00000101
00000100 00001001
00001000 00010001
00010000 00100001
00100000 01000001
01000000 10000001
10000000 00000110
00001010
00010010
00100010
01000010
10000010
00001100
00010100
00100100
01000100
10000100
... and 10 more
Code: Select all
We create ids:
NORMAL_DOOR = 0x00000001
LOCKED_DOOR = 0x00000010
LOCKED_CHEST = 0x00000100
CHAIR = 0x00001000
And then create following mask to be able to select...
openable items -> (NORMAL_DOOR | LOCKED_DOOR | LOCKED_CHEST)
locked items -> (LOCKED_DOOR | MOVABLE_LOCKED_CHEST)
movable items -> (LOCKED_CHEST | CHAIR)
movable locked items -> LOCKED_CHEST
Code: Select all
First we create mask for object types:
OPENABLE = 0x00000001
LOCKED = 0x00000010
MOVABLE = 0x00000100
then ids:
NORMAL_DOOR = OPENABLE
LOCKED_DOOR = (DOOR|LOCKED|OPENABLE)
MOVABLE_LOCKED_CHEST = (MOVABLE|LOCKED|OPENABLE)
CHAIR = MOVABLE
and now masks for selecting....
openable items -> OPENABLE
locked items -> LOCKED
movable items -> MOVABLE
movable locked items -> (MOVABLE | LOCKED)
Sorry for being dumb but I don't see anywhere in your post that shows that your two bit match system is right and the current one is wrong. I understand your system and it's uses but the inefficiency of using the current system is really small in terms of memory today. You are talking about possibly using one word instead of two. That really isn't going to crunch any memory away in the days of 1GB's of memory.Have you looked into documentation ? It's said there that:
"idBitMask: Only scene nodes with an id with bits set like in this mask will be tested. If the BitMask is 0, this feature is disabled."
> "standard bit mask system"warui wrote:"idBitMask: Only scene nodes with an id with bits set like in this mask will be tested. If the BitMask is 0, this feature is disabled."
So, using you example none of nodes should be picked because NT_PLAYER|NT_WEAPON = 0x000011 and there's no node that has first two bits set.
Code: Select all
enum E_BIT_MASK_MODE {
EBMM_ONE_OF_MATCH, // at least one of the bits set in id must match one of bit set in mask
EBMM_EXACT_MATCH // all bits set in id must match bits set in mask
}
It's not that way. Using what Jox presented we are restricted to only 32 diffrent types of node. 1GB of ram won't change anything. Problem lays in a size od s32 data type not size of whole ram.Tyn wrote: I understand your system and it's uses but the inefficiency of using the current system is really small in terms of memory today. You are talking about possibly using one word instead of two. That really isn't going to crunch any memory away in the days of 1GB's of memory.