Game Development Community

T3D 1.1 Beta 3 - Source Code normalization for Datablock ID

by elvince · in Torque 3D Professional · 02/09/2011 (11:49 pm) · 4 replies

Hi,

I looked at the way to send datablock via netevent and in the code I found 3 different method to that.
I think it could be great to normalize this by choosing 1 method and stick to it.
This will help reading the code.

stream->writeInt(image.dataBlock->getId() - DataBlockObjectIdFirst,DataBlockObjectIdBitSize);
stream->writeRangedU32( projectile->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
stream->writeRangedS32( mProject->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast );

I think this one the best:
stream->writeRangedU32( projectile->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
I choose U32 because the ID is a U32.

what do you think?

#1
02/10/2011 (1:56 am)
writeRangedU32() is actually ranged writeInt(),where the transmission bits are log2(range).
For example if you send 500 using writeRangedU32(),but specify a range(0,1000),you transmit 10 bits.
If you send 500 using writeInt(),you must specify 9 bits.
If you send 500 using writeRangedU32(),but specify a range(400,600),you transmit 8 bits.
#2
02/10/2011 (3:38 am)
Thanks for the explanation.

My remarks was more that when we are transfering datablock id, which are always ranged id, we should always use the same fonction/code. Otherwise when you are reading the code, you can ask yourself why it s a special case.
#3
02/10/2011 (4:05 am)
Quote:writeRangedU32() is actually ranged writeInt(),where the transmission bits are log2(range).
So if we used writeInt, it would save us a log each time? Since this is obviously a critical performance bottleneck ;P
#4
03/15/2011 (12:40 pm)
Greetings!

Logged as THREED-1444 for someone to look into. On the surface, being consistent with datablock ID transmissions sounds like a good idea.

- Dave