BSD Server calculates different.
by Thomas Huehn · in Torque Game Engine · 05/07/2008 (5:03 am) · 2 replies
I have this problem with fxshapereplicator even if I use the "fixed" replicator (http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6947)
The problem is, that the transform on the client (windows) shape is different to the freebsd server shape. This makes the collisions very ugly.
A sample transform of the same shape generated on a win server and on a bsd server. I'll test the same later on linux:
As you can see while the position is nearly the same. The rotation is completly different. I made some tests to see if it's maybe the random generator but the values where the same in my tests with different seeds.
The code where the rotation is set :
Any ideas what may cause this - Maybe a compiler flag or something else ?
The problem is, that the transform on the client (windows) shape is different to the freebsd server shape. This makes the collisions very ugly.
A sample transform of the same shape generated on a win server and on a bsd server. I'll test the same later on linux:
Windows: 107.403 -103.663 98.0162 0.44062 0.0156898 0.897557 3.07769 BSD: 107.403 -103.663 98.0161 0.434253 0.17008 0.884589 2.47456
As you can see while the position is nearly the same. The rotation is completly different. I made some tests to see if it's maybe the random generator but the values where the same in my tests with different seeds.
The code where the rotation is set :
ShapeRotation.set( mDegToRad(RandomGen.randF(mFieldData.mShapeRotateMin.x, mFieldData.mShapeRotateMax.x)),
mDegToRad(RandomGen.randF(mFieldData.mShapeRotateMin.y, mFieldData.mShapeRotateMax.y)),
mDegToRad(RandomGen.randF(mFieldData.mShapeRotateMin.z, mFieldData.mShapeRotateMax.z)));Any ideas what may cause this - Maybe a compiler flag or something else ?
About the author
Contact: torque [AT] ohmtal [DOT] com
#2
While digging arround I made a hack to make the values equal :
Only the z axis on windows have a 0.0001 difference in this example.
The hack only works if the values are not to big and is:
I added a function floatPrec to MathUtils which rounds the float value:
then i rewrote the the rotation routine:
While this is fine for this special case, I must find to make the precisions equal ;)
05/07/2008 (7:41 am)
Yes it's the precision. I'am using VC++ 2003 Standart on Windows and cant change the optimation flags. I guess I've to use an express version ;) While digging arround I made a hack to make the values equal :
Linux (AthlonXP) : -264.01 179.217 81.756 0.845902 -0.279662 0.454136 3.43965 BSD (Pentium3) : -264.01 179.217 81.756 0.845902 -0.279662 0.454136 3.43965 Windows (Pentium4) : -264.01 179.217 81.7561 0.845902 -0.279662 0.454136 3.43965
Only the z axis on windows have a 0.0001 difference in this example.
The hack only works if the values are not to big and is:
I added a function floatPrec to MathUtils which rounds the float value:
F32 floatPrec(F32 value) {
return (mFloor(value*1000)/1000);
}then i rewrote the the rotation routine:
F32 tmpx= MathUtils::floatPrec(mDegToRad(MathUtils::floatPrec(RandomGen.randF(mFieldData.mShapeRotateMin.x, mFieldData.mShapeRotateMax.x)))); F32 tmpy= MathUtils::floatPrec(mDegToRad(MathUtils::floatPrec(RandomGen.randF(mFieldData.mShapeRotateMin.y, mFieldData.mShapeRotateMax.y)))); F32 tmpz= MathUtils::floatPrec(mDegToRad(MathUtils::floatPrec(RandomGen.randF(mFieldData.mShapeRotateMin.z, mFieldData.mShapeRotateMax.z)))); ShapeRotation.set( tmpx,tmpy,tmpz );
While this is fine for this special case, I must find to make the precisions equal ;)
Torque Owner Hadoken
some compilers let you choose which floating point model you want to use. In visual studio, for example, you have a choice between fast, precise and something in between (I don't remember what it's called). Compiler flags look something like "/fp". Just make sure you're using the same settings on all platforms.
And don't let the names fool you, for example "precise" is often faster than "fast". It depends on what you're doing.