Question about number of mask bits left...
by David Dougher · in Torque Game Engine · 03/06/2003 (4:21 pm) · 7 replies
Looking at this enum...
enum ShapeBaseMasks {
NameMask = Parent::NextFreeMask,
DamageMask = Parent::NextFreeMask << 1,
NoWarpMask = Parent::NextFreeMask << 2,
MountedMask = Parent::NextFreeMask << 3,
CloakMask = Parent::NextFreeMask << 4,
ShieldMask = Parent::NextFreeMask << 5,
InvincibleMask = Parent::NextFreeMask << 6,
SkinMask = Parent::NextFreeMask << 7,
SoundMaskN = Parent::NextFreeMask << 8, // Extends + MaxSoundThreads bits
ThreadMaskN = SoundMaskN << MaxSoundThreads, // Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, // Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
};
I count 8 bits up to SoundMaskN. MaxSoundThreads is defined as 4, MaxScriptThreads as 4, and MaxMountedImages as 8. This totals to exactly 24 bits. The mask is listed as a U32 so can I assume there are still 8 bits left or is there some overhead in the mask that I have not found? I recently implemented some changes that led me to believe that there may be far fewer mask bits left...
enum ShapeBaseMasks {
NameMask = Parent::NextFreeMask,
DamageMask = Parent::NextFreeMask << 1,
NoWarpMask = Parent::NextFreeMask << 2,
MountedMask = Parent::NextFreeMask << 3,
CloakMask = Parent::NextFreeMask << 4,
ShieldMask = Parent::NextFreeMask << 5,
InvincibleMask = Parent::NextFreeMask << 6,
SkinMask = Parent::NextFreeMask << 7,
SoundMaskN = Parent::NextFreeMask << 8, // Extends + MaxSoundThreads bits
ThreadMaskN = SoundMaskN << MaxSoundThreads, // Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, // Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
};
I count 8 bits up to SoundMaskN. MaxSoundThreads is defined as 4, MaxScriptThreads as 4, and MaxMountedImages as 8. This totals to exactly 24 bits. The mask is listed as a U32 so can I assume there are still 8 bits left or is there some overhead in the mask that I have not found? I recently implemented some changes that led me to believe that there may be far fewer mask bits left...
About the author
Owner - Pariah Games, Adjunct Professor - Bristol Community College, Mentor - Game Design - Met School Newport, Mentor - Game Design - Met School Providence
#2
While this is useful information (and I may try your idea...) It still doesn't answer the original question. Are there still 8 maskbits left to be used or have I missed some?
03/07/2003 (6:22 am)
Thanks Jared!While this is useful information (and I may try your idea...) It still doesn't answer the original question. Are there still 8 maskbits left to be used or have I missed some?
#3
08/15/2003 (6:58 pm)
Jared: I was wondering, where do you store those separate bools and when do you reset them? For correct processing, wouldn't they have to be copied to each GhostInfo/GhostRef in the same way that each GhostRef carries an individual copy of the updateMask for each individual client update?
#4
When a mounted image changes I set the master bit in the general update mask and then the individual bit in the separate mask which is then used to determine what images to update during packUpdate.
Problem is, I don't know when it would be a good time to reset the separate MountedImageMask (knowing that all ghosts have received their proper update) since the GhostInfo/GhostRefs will only hold on to the master bit from the general update mask, not the individual mask bits per image.
08/15/2003 (7:00 pm)
While trying to increase the number of mounted shape images, I took the old 8 ImageMask bits out of the general update mask to save mask space and now store a bit for each mounted image in a separate MountedImageMask (allowing for up to 32 mounted images) with only a single master bit used for all mounted images in the general update mask.When a mounted image changes I set the master bit in the general update mask and then the individual bit in the separate mask which is then used to determine what images to update during packUpdate.
Problem is, I don't know when it would be a good time to reset the separate MountedImageMask (knowing that all ghosts have received their proper update) since the GhostInfo/GhostRefs will only hold on to the master bit from the general update mask, not the individual mask bits per image.
#5
this is not an issue.
either preload or onAdd is the place for this.
you can depend on the usage inside the un/packUpdate for the remainder of the required usage.
David:
I'm sure you've missed the inheritance of the ShapeBase class
that it is effecting the Parent::NextFreeMask
to count the remainder of the bits you must simply go thru the class inheritance, counting each addition to NextFreeMask
Edit:
spelling.
08/15/2003 (7:22 pm)
Matthes:this is not an issue.
either preload or onAdd is the place for this.
you can depend on the usage inside the un/packUpdate for the remainder of the required usage.
David:
I'm sure you've missed the inheritance of the ShapeBase class
that it is effecting the Parent::NextFreeMask
to count the remainder of the bits you must simply go thru the class inheritance, counting each addition to NextFreeMask
Edit:
spelling.
#6
08/17/2003 (4:55 pm)
David: If you have VC6 you can fire up the debugger and highlight a mask name to take a look at its value. This should answer your question. Not sure if you can do this in other debuggers. I think I only added about 3 masks to Vehicle (which adds to Shapebase which adds to gamebase) and I was already at 30 bits or so... so check it out that way if you can.
#7
08/17/2003 (9:46 pm)
You also have to check the parent classes. I'm sure GameBase has a few that it needs.
Torque Owner Jared Schnelle
I ran into the problem of too many masks with my player.cc and I had to make some changes.
You can either 1) group up certian things to use the same bitmask.
Instead of health/power/stamina bitmasks, you could have a playerStatus bitmask, which when set will send all 3.
I chose a different method. I'm using a new notation bMask_CurrentHealth bMask_MaximumHealth where the bMask_* are bools.
Instead of doing a bitmask check in the packUpdate, I just have it check the bool for true/false.
Hope that helps