Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UP2 (squared)
#5
ohhhh it was a bug...small one but important, and probably not mine, though my activation of it was due to some sloppy code, it seems that this function in the binary reader

glm::vec3 BinaryReader::ReadCompressedVec3()
{
glm::vec3 vec;
vec.x = ReadByte();
vec.y = ReadByte();
vec.z = ReadByte();
return vec;
}

Behaves quite differently on intel chips, the byte that is read is sign extended (any value over 128 is considered negative in 2's compliment binary) creating a negative float (thats actually correct behaviour), rather than a value from 0-255 (which is the inncorrect behavoir of the ARM cast)
Its probably a bug in GLM rather than being a specific issue, someone coded the intel code to sign extend when loading a char into a float.

The fix is simple, make sure you only send the char part to the float, don't allow it to be sign extended

glm::vec3 BinaryReader::ReadCompressedVec3()
{
glm::vec3 vec;
vec.x = ReadByte() & 255;
vec.y = ReadByte() & 255;
vec.z = ReadByte() & 255;
return vec;
}

Or.. a more elegant fix is for ReadByte to return an unsigned char which is better, and what I should have done in the first place.

Quite a complex bug tbh, it took a lot of tracking down, and head scratching determining where the data was faulty, what data was faulty, where it was set up and finally where it was loaded...not an easy route..

But its all working fine now.  Big Grin the demo's will be updated accordingly for anyone using an intel based board, the fix does no harm to the ARM version.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply


Messages In This Thread
UP2 (squared) - by Brian Beuken - 06-07-2018, 11:47 AM
RE: UP2 (squared) - by Brian Beuken - 02-03-2019, 08:21 AM
RE: UP2 (squared) - by Brian Beuken - 02-03-2019, 11:28 AM
RE: UP2 (squared) - by Brian Beuken - 02-03-2019, 04:41 PM
RE: UP2 (squared) - by Brian Beuken - 02-03-2019, 09:11 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)