Game Development Community

Bug? Camera Distance in Shapebase.cpp

by Steve Acaster · in Torque 3D Professional · 11/11/2009 (8:17 pm) · 2 replies

Non-coder here.

Whilst confusing myself greatly with various camera/controlobject related things I noticed something which looked a bit odd.

Shapbase.cpp around line 86/7
hulkSequence( -1 ),
   cameraMaxDist( 0.0f ),
   cameraMinDist( 0.2f ),
   cameraDefaultFov( 90.0f ),
   cameraMinFov( 5.0f ),

cameraMinDist was larger than cameraMaxDist.

Later down at ShapeBaseDataProto, around line 147 it reads
...
      maxEnergy = 0;
      cameraMaxDist = 0;
      cameraMinDist = 0.2f;
      cameraDefaultFov = 90.f;
...

cameraMinDist being larger again and cameraMaxDist doesn't have an f at the end here.

For the sake of arguement I changed both settings to
cameraMaxDist = 0.0f;
      cameraMinDist = 0.0f;

and nothing bad happened --- I just thought it looked "funny".

#1
11/12/2009 (5:40 am)
Most probabily nothing happens, because in your player datablock you have a cameraMaxDist set with a value greater than cameraMinDist, so the value you found in the constructor isn't used, also, cameraMaxDist in no way can be zero, but at min it is the length of the bounding box, it is changed in the preload function.
The values in ShapeBaseDataProto should be always the same as the ShapeBaseData defaults, because ShapeBaseDataProto is used to reduce the badnwidth needed to send the datablock over the net, if the values are the same, the server, insteand of sending to the client, the data, it just send a flag, only one bit, because the client object has been already intialized with the same value as the server.

Edit:
Sorry, yes, it has more sense to have cameraMaxDist greater than cameraMinDist :)
#2
11/12/2009 (10:15 am)
If you don't override cameraMaxDist in your player datablock, cameraMaxDist will get set to half the player's bounding box width. This could potentially be a problem if you had a very small character who's bounding box was less than 0.4 wide, making cameraMaxDist less than cameraMinDist. Also, the "f" in "0.0f" just tells the compiler that it is a floating point value. Leaving it as "cameraMaxDist = 0;" is fine... the compiler will convert the zero from an integer to a float.