Page 1 of 1

the macro "PixelAligned" has some mistake

Posted: Mon Oct 06, 2008 11:23
by flyue
After my test, the macro
"#define PixelAligned(x)( (float)(int)(( x ) + (( x ) > 0.0f ? 0.5f : -0.5f)) )"
is wrong. The right should be:
"#define PixelAligned(x)((float)((x) + ((x) >= 0.0f ? 0.5f : -0.5f)))" :roll:

Posted: Mon Oct 06, 2008 13:57
by CrazyEddie
I do not have time to check the results of switching the comparison operator, but having said this, removal of the integer cast part is definitely a mistake - without this the macro ceases to perform the intended operation. Since I believe that getting a "correct" result when using the >= over the > probably requires the integer cast to be removed, this whole 'fix' is completely worthless.

Perhaps you could post some relevant information - such as some values passed in, the results you're getting out, the results you think you should have received, and why you believe the ones you're getting are incorrect?

:roll:

CE

Posted: Tue Oct 07, 2008 10:23
by flyue
Thank you very much for the reply, although my English is not very good

now I am reading your CEGUI source code, I learned a lot of new techniques from it.

In China, there are many video games use CEGUI :D , so I'm learning it now.

Posted: Thu Oct 09, 2008 07:48
by CrazyEddie
flyue wrote:In China, there are many video games use CEGUI :D

It is good to hear that CEGUI is getting used for games in China. I hope you also have success in your learning and use of the library :)

CE.