Cleanup quad creation: add i2fx to reduce confusion

This commit is contained in:
BeaR 2014-02-10 10:46:45 +01:00
parent 19912be97a
commit 2bfb848414
2 changed files with 21 additions and 25 deletions

View file

@ -39,6 +39,9 @@ inline float frandom() { return rand()/(float)(RAND_MAX); }
inline int f2fx(float v) { return (int)(v*(float)(1<<10)); }
inline float fx2f(int v) { return v*(1.0f/(1<<10)); }
// int to fixed
inline int i2fx(int v) { return v<<10; }
inline int gcd(int a, int b)
{
while(b != 0)

View file

@ -45,36 +45,29 @@ CQuad *CLayerQuads::NewQuad()
q->m_PosEnvOffset = 0;
q->m_ColorEnvOffset = 0;
int x = 0, y = 0;
q->m_aPoints[0].x = x;
q->m_aPoints[0].y = y;
q->m_aPoints[1].x = x+64;
q->m_aPoints[1].y = y;
q->m_aPoints[2].x = x;
q->m_aPoints[2].y = y+64;
q->m_aPoints[3].x = x+64;
q->m_aPoints[3].y = y+64;
q->m_aPoints[0].x = i2fx(x);
q->m_aPoints[0].y = i2fx(y);
q->m_aPoints[1].x = i2fx(x+64);
q->m_aPoints[1].y = i2fx(y);
q->m_aPoints[2].x = i2fx(x);
q->m_aPoints[2].y = i2fx(y+64);
q->m_aPoints[3].x = i2fx(x+64);
q->m_aPoints[3].y = i2fx(y+64);
q->m_aPoints[4].x = x+32; // pivot
q->m_aPoints[4].y = y+32;
q->m_aPoints[4].x = i2fx(x+32); // pivot
q->m_aPoints[4].y = i2fx(y+32);
for(int i = 0; i < 5; i++)
{
q->m_aPoints[i].x <<= 10;
q->m_aPoints[i].y <<= 10;
}
q->m_aTexcoords[0].x = i2fx(0);
q->m_aTexcoords[0].y = i2fx(0);
q->m_aTexcoords[1].x = i2fx(1);
q->m_aTexcoords[1].y = i2fx(0);
q->m_aTexcoords[0].x = 0;
q->m_aTexcoords[0].y = 0;
q->m_aTexcoords[2].x = i2fx(0);
q->m_aTexcoords[2].y = i2fx(1);
q->m_aTexcoords[1].x = 1<<10;
q->m_aTexcoords[1].y = 0;
q->m_aTexcoords[2].x = 0;
q->m_aTexcoords[2].y = 1<<10;
q->m_aTexcoords[3].x = 1<<10;
q->m_aTexcoords[3].y = 1<<10;
q->m_aTexcoords[3].x = i2fx(1);
q->m_aTexcoords[3].y = i2fx(1);
q->m_aColors[0].r = 255; q->m_aColors[0].g = 255; q->m_aColors[0].b = 255; q->m_aColors[0].a = 255;
q->m_aColors[1].r = 255; q->m_aColors[1].g = 255; q->m_aColors[1].b = 255; q->m_aColors[1].a = 255;