diff options
author | aap <aap@papnet.eu> | 2020-08-13 18:47:39 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-08-13 18:47:39 +0200 |
commit | cdebea71f39377418355efdc86e2d6501cbf292f (patch) | |
tree | af8a5779be178c6b0358c5e07cda660d22fea8a7 /src/render | |
parent | fix render poly bug (diff) | |
download | re3-cdebea71f39377418355efdc86e2d6501cbf292f.tar re3-cdebea71f39377418355efdc86e2d6501cbf292f.tar.gz re3-cdebea71f39377418355efdc86e2d6501cbf292f.tar.bz2 re3-cdebea71f39377418355efdc86e2d6501cbf292f.tar.lz re3-cdebea71f39377418355efdc86e2d6501cbf292f.tar.xz re3-cdebea71f39377418355efdc86e2d6501cbf292f.tar.zst re3-cdebea71f39377418355efdc86e2d6501cbf292f.zip |
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/Hud.cpp | 62 | ||||
-rw-r--r-- | src/render/Sprite2d.cpp | 234 | ||||
-rw-r--r-- | src/render/Sprite2d.h | 3 |
3 files changed, 136 insertions, 163 deletions
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 10408355..cbf3c7f2 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -205,7 +205,8 @@ void CHud::Draw() rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.6f); rect.bottom = f3rdY + SCREEN_SCALE_Y(32.0f * 0.6f); - Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } else { rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.4f); @@ -213,7 +214,8 @@ void CHud::Draw() rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.4f); rect.bottom = f3rdY + SCREEN_SCALE_Y(32.0f * 0.4f); - Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } } else { if (Mode == CCam::MODE_M16_1STPERSON || @@ -223,7 +225,8 @@ void CHud::Draw() rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(32.0f); rect.right = (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(32.0f); rect.bottom = (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(32.0f); - Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } else if (Mode == CCam::MODE_1STPERSON_RUNABOUT) { rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(32.0f * 0.7f); @@ -231,7 +234,8 @@ void CHud::Draw() rect.right = (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(32.0f * 0.7f); rect.bottom = (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(32.0f * 0.7f); - Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } else if (Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT) { RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE); @@ -248,29 +252,33 @@ void CHud::Draw() // TODO(Miami) // Sniper - rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(210.0f); - rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(210.0f); - rect.right = SCREEN_WIDTH / 2; - rect.bottom = SCREEN_HEIGHT / 2; - Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); - - rect.right = (SCREEN_WIDTH / 2); - rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(210.0f); - rect.left = SCREEN_SCALE_X(210.0f) + (SCREEN_WIDTH / 2); - rect.bottom = SCREEN_HEIGHT / 2; - Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); - - rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(210.0f); - rect.bottom = (SCREEN_HEIGHT / 2); - rect.right = (SCREEN_WIDTH / 2); - rect.top = SCREEN_SCALE_Y(210.0f) + (SCREEN_HEIGHT / 2); - Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); - - rect.right = (SCREEN_WIDTH / 2); - rect.bottom = (SCREEN_HEIGHT / 2); - rect.left = SCREEN_SCALE_X(210.0f) + (SCREEN_WIDTH / 2); - rect.top = SCREEN_SCALE_Y(210.0f) + (SCREEN_HEIGHT / 2); - Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + rect.left = SCREEN_WIDTH/2 - SCREEN_SCALE_X(210.0f); + rect.top = SCREEN_HEIGHT/2 - SCREEN_SCALE_Y(210.0f); + rect.right = SCREEN_WIDTH/2; + rect.bottom = SCREEN_HEIGHT/2; + Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.01f, 0.01f, 1.0f, 0.0f, 0.01f, 1.0f, 1.0f, 1.0f); + + rect.left = SCREEN_WIDTH/2; + rect.top = SCREEN_HEIGHT/2 - SCREEN_SCALE_Y(210.0f); + rect.right = SCREEN_WIDTH/2 + SCREEN_SCALE_X(210.0f); + rect.bottom = SCREEN_HEIGHT/2; + Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.99f, 0.0f, 0.01f, 0.01f, 0.99f, 1.0f, 0.01f, 1.0f); + + rect.left = SCREEN_WIDTH/2 - SCREEN_SCALE_X(210.0f); + rect.top = SCREEN_HEIGHT/2; + rect.right = SCREEN_WIDTH/2; + rect.bottom = SCREEN_HEIGHT/2 + SCREEN_SCALE_Y(210.0f); + Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.01f, 0.99f, 1.0f, 0.99f, 0.01f, 0.01f, 1.0f, 0.01f); + + rect.left = SCREEN_WIDTH/2; + rect.top = SCREEN_HEIGHT/2; + rect.right = SCREEN_WIDTH/2 + SCREEN_SCALE_X(210.0f); + rect.bottom = SCREEN_HEIGHT/2 + SCREEN_SCALE_Y(210.0f); + Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.99f, 0.99f, 0.01f, 0.99f, 0.99f, 0.01f, 0.1f, 0.01f); } } RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA); diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index cba64e7a..7dcedb26 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -9,6 +9,7 @@ float CSprite2d::RecipNearClip; float CSprite2d::NearScreenZ; +float CSprite2d::NearCamZ; int CSprite2d::nextBufferVertex; int CSprite2d::nextBufferIndex; RwIm2DVertex CSprite2d::maVertices[8]; @@ -26,6 +27,9 @@ CSprite2d::InitPerFrame(void) nextBufferIndex = 0; RecipNearClip = 1.0f / RwCameraGetNearClipPlane(Scene.camera); NearScreenZ = RwIm2DGetNearScreenZ(); + // not original but you're supposed to set camera z too + // wrapping all this in FIX_BUGS is too ugly + NearCamZ = RwCameraGetNearClipPlane(Scene.camera); } void CSprite2d::Delete(void) @@ -71,7 +75,7 @@ CSprite2d::SetRenderState(void) void CSprite2d::Draw(float x, float y, float w, float h, const CRGBA &col) { - SetVertices(CRect(x, y, x + w, y + h), col, col, col, col, 0); + SetVertices(CRect(x, y, x + w, y + h), col, col, col, col); SetRenderState(); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); } @@ -79,7 +83,7 @@ CSprite2d::Draw(float x, float y, float w, float h, const CRGBA &col) void CSprite2d::Draw(const CRect &rect, const CRGBA &col) { - SetVertices(rect, col, col, col, col, 0); + SetVertices(rect, col, col, col, col); SetRenderState(); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); } @@ -96,7 +100,7 @@ CSprite2d::Draw(const CRect &rect, const CRGBA &col, void CSprite2d::Draw(const CRect &rect, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - SetVertices(rect, c0, c1, c2, c3, 0); + SetVertices(rect, c0, c1, c2, c3); SetRenderState(); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); } @@ -114,178 +118,149 @@ CSprite2d::Draw(float x1, float y1, float x2, float y2, float x3, float y3, floa // | | // 0---1 void -CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, uint32 far) +CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - float screenz, z, recipz; - - if(far){ - screenz = RwIm2DGetFarScreenZ(); - z = RwCameraGetFarClipPlane(Scene.camera); - }else{ - screenz = NearScreenZ; - z = 1.0f/RecipNearClip; - } - recipz = 1.0f/z; - // This is what we draw: // 0---1 // | / | // 3---2 RwIm2DVertexSetScreenX(&maVertices[0], r.left); RwIm2DVertexSetScreenY(&maVertices[0], r.top); - RwIm2DVertexSetScreenZ(&maVertices[0], screenz); - RwIm2DVertexSetCameraZ(&maVertices[0], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[0], recipz); + RwIm2DVertexSetScreenZ(&maVertices[0], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[0], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&maVertices[0], 0.0f, recipz); - RwIm2DVertexSetV(&maVertices[0], 0.0f, recipz); + RwIm2DVertexSetU(&maVertices[0], 0.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[0], 0.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[1], r.right); RwIm2DVertexSetScreenY(&maVertices[1], r.top); - RwIm2DVertexSetScreenZ(&maVertices[1], screenz); - RwIm2DVertexSetCameraZ(&maVertices[1], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[1], recipz); + RwIm2DVertexSetScreenZ(&maVertices[1], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[1], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&maVertices[1], 1.0f, recipz); - RwIm2DVertexSetV(&maVertices[1], 0.0f, recipz); + RwIm2DVertexSetU(&maVertices[1], 1.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[1], 0.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[2], r.right); RwIm2DVertexSetScreenY(&maVertices[2], r.bottom); - RwIm2DVertexSetScreenZ(&maVertices[2], screenz); - RwIm2DVertexSetCameraZ(&maVertices[2], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[2], recipz); + RwIm2DVertexSetScreenZ(&maVertices[2], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[2], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&maVertices[2], 1.0f, recipz); - RwIm2DVertexSetV(&maVertices[2], 1.0f, recipz); + RwIm2DVertexSetU(&maVertices[2], 1.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[2], 1.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[3], r.left); RwIm2DVertexSetScreenY(&maVertices[3], r.bottom); - RwIm2DVertexSetScreenZ(&maVertices[3], screenz); - RwIm2DVertexSetCameraZ(&maVertices[3], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[3], recipz); + RwIm2DVertexSetScreenZ(&maVertices[3], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[3], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&maVertices[3], 0.0f, recipz); - RwIm2DVertexSetV(&maVertices[3], 1.0f, recipz); + RwIm2DVertexSetU(&maVertices[3], 0.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[3], 1.0f, RecipNearClip); } void CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2) { - float screenz, z, recipz; - - screenz = NearScreenZ; - z = 1.0f/RecipNearClip; - recipz = 1.0f/z; - // This is what we draw: // 0---1 // | / | // 3---2 RwIm2DVertexSetScreenX(&maVertices[0], r.left); RwIm2DVertexSetScreenY(&maVertices[0], r.top); - RwIm2DVertexSetScreenZ(&maVertices[0], screenz); - RwIm2DVertexSetCameraZ(&maVertices[0], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[0], recipz); + RwIm2DVertexSetScreenZ(&maVertices[0], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[0], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&maVertices[0], u0, recipz); - RwIm2DVertexSetV(&maVertices[0], v0, recipz); + RwIm2DVertexSetU(&maVertices[0], u0, RecipNearClip); + RwIm2DVertexSetV(&maVertices[0], v0, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[1], r.right); RwIm2DVertexSetScreenY(&maVertices[1], r.top); - RwIm2DVertexSetScreenZ(&maVertices[1], screenz); - RwIm2DVertexSetCameraZ(&maVertices[1], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[1], recipz); + RwIm2DVertexSetScreenZ(&maVertices[1], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[1], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&maVertices[1], u1, recipz); - RwIm2DVertexSetV(&maVertices[1], v1, recipz); + RwIm2DVertexSetU(&maVertices[1], u1, RecipNearClip); + RwIm2DVertexSetV(&maVertices[1], v1, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[2], r.right); RwIm2DVertexSetScreenY(&maVertices[2], r.bottom); - RwIm2DVertexSetScreenZ(&maVertices[2], screenz); - RwIm2DVertexSetCameraZ(&maVertices[2], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[2], recipz); + RwIm2DVertexSetScreenZ(&maVertices[2], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[2], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&maVertices[2], u2, recipz); - RwIm2DVertexSetV(&maVertices[2], v2, recipz); + RwIm2DVertexSetU(&maVertices[2], u2, RecipNearClip); + RwIm2DVertexSetV(&maVertices[2], v2, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[3], r.left); RwIm2DVertexSetScreenY(&maVertices[3], r.bottom); - RwIm2DVertexSetScreenZ(&maVertices[3], screenz); - RwIm2DVertexSetCameraZ(&maVertices[3], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[3], recipz); + RwIm2DVertexSetScreenZ(&maVertices[3], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[3], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&maVertices[3], u3, recipz); - RwIm2DVertexSetV(&maVertices[3], v3, recipz); + RwIm2DVertexSetU(&maVertices[3], u3, RecipNearClip); + RwIm2DVertexSetV(&maVertices[3], v3, RecipNearClip); } void CSprite2d::SetVertices(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - float screenz, recipz; - float z = RwCameraGetNearClipPlane(Scene.camera); // not done by game - - screenz = NearScreenZ; - recipz = RecipNearClip; - RwIm2DVertexSetScreenX(&maVertices[0], x3); RwIm2DVertexSetScreenY(&maVertices[0], y3); - RwIm2DVertexSetScreenZ(&maVertices[0], screenz); - RwIm2DVertexSetCameraZ(&maVertices[0], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[0], recipz); + RwIm2DVertexSetScreenZ(&maVertices[0], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[0], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&maVertices[0], 0.0f, recipz); - RwIm2DVertexSetV(&maVertices[0], 0.0f, recipz); + RwIm2DVertexSetU(&maVertices[0], 0.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[0], 0.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[1], x4); RwIm2DVertexSetScreenY(&maVertices[1], y4); - RwIm2DVertexSetScreenZ(&maVertices[1], screenz); - RwIm2DVertexSetCameraZ(&maVertices[1], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[1], recipz); + RwIm2DVertexSetScreenZ(&maVertices[1], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[1], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&maVertices[1], 1.0f, recipz); - RwIm2DVertexSetV(&maVertices[1], 0.0f, recipz); + RwIm2DVertexSetU(&maVertices[1], 1.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[1], 0.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[2], x2); RwIm2DVertexSetScreenY(&maVertices[2], y2); - RwIm2DVertexSetScreenZ(&maVertices[2], screenz); - RwIm2DVertexSetCameraZ(&maVertices[2], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[2], recipz); + RwIm2DVertexSetScreenZ(&maVertices[2], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[2], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&maVertices[2], 1.0f, recipz); - RwIm2DVertexSetV(&maVertices[2], 1.0f, recipz); + RwIm2DVertexSetU(&maVertices[2], 1.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[2], 1.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[3], x1); RwIm2DVertexSetScreenY(&maVertices[3], y1); - RwIm2DVertexSetScreenZ(&maVertices[3], screenz); - RwIm2DVertexSetCameraZ(&maVertices[3], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[3], recipz); + RwIm2DVertexSetScreenZ(&maVertices[3], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[3], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&maVertices[3], 0.0f, recipz); - RwIm2DVertexSetV(&maVertices[3], 1.0f, recipz); + RwIm2DVertexSetU(&maVertices[3], 0.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[3], 1.0f, RecipNearClip); } void CSprite2d::SetVertices(int n, float *positions, float *uvs, const CRGBA &col) { int i; - float screenz, recipz, z; - - screenz = NearScreenZ; - recipz = RecipNearClip; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game - for(i = 0; i < n; i++){ RwIm2DVertexSetScreenX(&maVertices[i], positions[i*2 + 0]); RwIm2DVertexSetScreenY(&maVertices[i], positions[i*2 + 1]); - RwIm2DVertexSetScreenZ(&maVertices[i], screenz + 0.0001f); - RwIm2DVertexSetCameraZ(&maVertices[i], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[i], recipz); + RwIm2DVertexSetScreenZ(&maVertices[i], NearScreenZ + 0.0001f); + RwIm2DVertexSetCameraZ(&maVertices[i], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[i], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[i], col.r, col.g, col.b, col.a); - RwIm2DVertexSetU(&maVertices[i], uvs[i*2 + 0], recipz); - RwIm2DVertexSetV(&maVertices[i], uvs[i*2 + 1], recipz); + RwIm2DVertexSetU(&maVertices[i], uvs[i*2 + 0], RecipNearClip); + RwIm2DVertexSetV(&maVertices[i], uvs[i*2 + 1], RecipNearClip); } } @@ -293,18 +268,13 @@ void CSprite2d::SetMaskVertices(int n, float *positions) { int i; - float screenz, recipz, z; - - screenz = NearScreenZ; - recipz = RecipNearClip; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game for(i = 0; i < n; i++){ RwIm2DVertexSetScreenX(&maVertices[i], positions[i*2 + 0]); RwIm2DVertexSetScreenY(&maVertices[i], positions[i*2 + 1]); - RwIm2DVertexSetScreenZ(&maVertices[i], screenz); - RwIm2DVertexSetCameraZ(&maVertices[i], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[i], recipz); + RwIm2DVertexSetScreenZ(&maVertices[i], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[i], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[i], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[i], 255, 255, 255, 255); // 0, 0, 0, 0 on PC } } @@ -313,53 +283,47 @@ void CSprite2d::SetVertices(RwIm2DVertex *verts, const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2) { - float screenz, recipz, z; - - screenz = NearScreenZ; - recipz = RecipNearClip; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game - RwIm2DVertexSetScreenX(&verts[0], r.left); RwIm2DVertexSetScreenY(&verts[0], r.top); - RwIm2DVertexSetScreenZ(&verts[0], screenz); - RwIm2DVertexSetCameraZ(&verts[0], z); - RwIm2DVertexSetRecipCameraZ(&verts[0], recipz); + RwIm2DVertexSetScreenZ(&verts[0], NearScreenZ); + RwIm2DVertexSetCameraZ(&verts[0], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&verts[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&verts[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&verts[0], u0, recipz); - RwIm2DVertexSetV(&verts[0], v0, recipz); + RwIm2DVertexSetU(&verts[0], u0, RecipNearClip); + RwIm2DVertexSetV(&verts[0], v0, RecipNearClip); RwIm2DVertexSetScreenX(&verts[1], r.right); RwIm2DVertexSetScreenY(&verts[1], r.top); - RwIm2DVertexSetScreenZ(&verts[1], screenz); - RwIm2DVertexSetCameraZ(&verts[1], z); - RwIm2DVertexSetRecipCameraZ(&verts[1], recipz); + RwIm2DVertexSetScreenZ(&verts[1], NearScreenZ); + RwIm2DVertexSetCameraZ(&verts[1], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&verts[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&verts[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&verts[1], u1, recipz); - RwIm2DVertexSetV(&verts[1], v1, recipz); + RwIm2DVertexSetU(&verts[1], u1, RecipNearClip); + RwIm2DVertexSetV(&verts[1], v1, RecipNearClip); RwIm2DVertexSetScreenX(&verts[2], r.right); RwIm2DVertexSetScreenY(&verts[2], r.bottom); - RwIm2DVertexSetScreenZ(&verts[2], screenz); - RwIm2DVertexSetCameraZ(&verts[2], z); - RwIm2DVertexSetRecipCameraZ(&verts[2], recipz); + RwIm2DVertexSetScreenZ(&verts[2], NearScreenZ); + RwIm2DVertexSetCameraZ(&verts[2], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&verts[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&verts[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&verts[2], u2, recipz); - RwIm2DVertexSetV(&verts[2], v2, recipz); + RwIm2DVertexSetU(&verts[2], u2, RecipNearClip); + RwIm2DVertexSetV(&verts[2], v2, RecipNearClip); RwIm2DVertexSetScreenX(&verts[3], r.left); RwIm2DVertexSetScreenY(&verts[3], r.bottom); - RwIm2DVertexSetScreenZ(&verts[3], screenz); - RwIm2DVertexSetCameraZ(&verts[3], z); - RwIm2DVertexSetRecipCameraZ(&verts[3], recipz); + RwIm2DVertexSetScreenZ(&verts[3], NearScreenZ); + RwIm2DVertexSetCameraZ(&verts[3], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&verts[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&verts[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&verts[3], u3, recipz); - RwIm2DVertexSetV(&verts[3], v3, recipz); + RwIm2DVertexSetU(&verts[3], u3, RecipNearClip); + RwIm2DVertexSetV(&verts[3], v3, RecipNearClip); } void CSprite2d::DrawRect(const CRect &r, const CRGBA &col) { - SetVertices(r, col, col, col, col, false); + SetVertices(r, col, col, col, col); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); @@ -374,7 +338,7 @@ CSprite2d::DrawRect(const CRect &r, const CRGBA &col) void CSprite2d::DrawRect(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - SetVertices(r, c0, c1, c2, c3, false); + SetVertices(r, c0, c1, c2, c3); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); @@ -387,7 +351,7 @@ CSprite2d::DrawRect(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGB void CSprite2d::DrawRectXLU(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - SetVertices(r, c0, c1, c2, c3, false); + SetVertices(r, c0, c1, c2, c3); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); diff --git a/src/render/Sprite2d.h b/src/render/Sprite2d.h index 1adb5d49..5abd8d71 100644 --- a/src/render/Sprite2d.h +++ b/src/render/Sprite2d.h @@ -4,6 +4,7 @@ class CSprite2d { static float RecipNearClip; static float NearScreenZ; + static float NearCamZ; // not original static int nextBufferVertex; static int nextBufferIndex; static RwIm2DVertex maVertices[8]; @@ -27,7 +28,7 @@ public: void Draw(const CRect &rect, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3); void Draw(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &col); - static void SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, uint32 far); + static void SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3); static void SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2); static void SetVertices(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, |