This class is supposed to make it easier, to restore the exact value of floating- point-based types, like vector, mat4, float etc.
for debugging. printf cuts values and rounds it. Also denormalized values might be printed as "0.0". Its particulary useful, if a certain set of input-parameters lets a function crash. Just call printHex for floating-point-based params so they are being printed to stdout with its exact bit-pattern. That dump can be passed to restoreHex and you can debug that function with that particular input-set.
Printing a vec4 to stdout works like this:
vec4 v(1.0f, 2.0f, 3.0f, 4.0f);
DebugFloat::printHex(v, "v");
The output in stdout is this:
v: 0x3F800000, 0x40000000, 0x40400000, 0x40800000
To restore the values, just pass the output to restoreHex
vec4 v = DebugFloat::restoreHex(0x3F800000, 0x40000000, 0x40400000, 0x40800000);
Now v has the exact same value(bit pattern) as it had when being printed with printHex
There is also a normal "print" for each type. Quite useful is the quaternion-version, since it gives a more human-readable output than just the normal debugger.
- Copyright
- (C) 2009 Radon Labs GmbH (C) 2013-2020 Individual contributors, see AUTHORS file
|
static void | printHex (float val, const char *msg=NULL) |
| print float's bit pattern as hex to stdout
|
|
static void | printHex (const Math::vec4 &v, const char *msg=NULL) |
| print vec4's bit pattern as hex to stdout
|
|
static void | printHex (const Math::mat4 &m, const char *msg=NULL) |
| print matrix's bit pattern as hex to stdout
|
|
static void | printHex (const Math::quat &q, const char *msg=NULL) |
| print quaternion's bit pattern as hex to stdout
|
|
static void | printHex (const Math::plane &p, const char *msg=NULL) |
| print plane's bit pattern as hex to stdout
|
|
static void | restoreHex (float &v, int val) |
|
static void | restoreHex (Math::vec4 &v, int x, int y, int z, int w) |
|
static void | restoreHex (Math::mat4 &m, int m0, int m1, int m2, int m3, int m4, int m5, int m6, int m7, int m8, int m9, int m10, int m11, int m12, int m13, int m14, int m15) |
|
static void | restoreHex (Math::quat &q, int x, int y, int z, int w) |
|
static void | restoreHex (Math::plane &p, int x, int y, int z, int w) |
|
static void | print (const float &v, const char *msg=NULL) |
| print float's values plain to stdout
|
|
static void | print (const Math::vec4 &v, const char *msg=NULL) |
| print vec4's values plain to stdout
|
|
static void | print (const Math::mat4 &m, const char *msg=NULL) |
| print matrix's values plain to stdout
|
|
static void | print (const Math::quat &q, const char *msg=NULL) |
| print quaternion's values plain to stdout
|
|
static void | print (const Math::plane &p, const char *msg=NULL) |
| print plane's values plain to stdout
|
|