Game Development Community

Is there a Limit to add new Mask into ShapeBaseMasks

by vincent kway · in Torque Game Engine Advanced · 02/09/2011 (6:12 pm) · 4 replies

Hi guys,

I'm trying to add new mask into ShapeBaseMasks. Everything works fine until I add one more masking that reaches 13

...
showNameMask = Parent::NextFreeMask << 10, //vince mod: add control show name
InvincibleMask = Parent::NextFreeMask << 11,
SkinMask = Parent::NextFreeMask << 12,
SoundMaskN = Parent::NextFreeMask << 13, ///< Extends + MaxSoundThreads bits
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
...


then it starts to affect my game. Some of the items/objects inside my 3D world is not rendered.
if i remove the newly added mask and the bitwise is 12 then everything back to normal again.

...
//showNameMask = Parent::NextFreeMask << 10, //vince mod: add control show name
InvincibleMask = Parent::NextFreeMask << 10,
SkinMask = Parent::NextFreeMask << 11,
SoundMaskN = Parent::NextFreeMask << 12, ///< Extends + MaxSoundThreads bits
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
...

Anyone of you have any idea about the maxixmum number of masking can be added to ShapeBaseMasks?
I'm not familiar with the network packet send between client and server. I think maybe because I used over the limit of the packet send/receive in server.


#1
02/09/2011 (6:46 pm)
Will there be any problem is I change the code to become like this ?

...
showHealthMask = maxHealthMask + 1, //vince mod: add control show health
showNameMask = showHealthMask + 1, //vince mod: add control show name
InvincibleMask = showNameMask << 1,
SkinMask = InvincibleMask << 1,
SoundMaskN = SkinMask << 1, ///< Extends + MaxSoundThreads bits
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
...

In stead of bit shifting, I add 1 to the new mask. Will it affect any other place ? It seems to work this way but I'm afraid it will affect other part in the engine.

Please advise.
#2
02/09/2011 (7:11 pm)
Masks are 32bits so you have a total of 32 mask flags. Modifying ShapeBase masks is tricky as the class is that high up in the hierarchy and you affect a lot of other masks. Some subclass will probably bust the limit.
#3
02/10/2011 (10:27 pm)
I think it already bust the limit when i add another one to it. But in stead of bit shifting, I'm actually adding a value to it. I saw a place pathCamera using the same way to do the masking. When I try the same method, it works and now the problem solved.

So far I haven't seen anything error yet. I will revert back to the original code if it affects other place. Thanks for the reply.
#4
02/14/2011 (8:12 pm)
The method I use above will cause problem to the engine.

I've fixed the problem by grouping all the extra variable that I need to use together by using only 1 mask.

This is not the best way to do it, because the shapebase class is higher than other classes and it will affect a lot of other masks.

I will put the mask to the child class later coz it is not needed by other child class to use.