From 0a19925e99ac32366a9193dbad6ddc5d6e2a3bd1 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 24 Aug 2020 14:26:17 +0200 Subject: finished sprites --- src/render/Sprite.cpp | 6 +++--- src/render/Sprite2d.cpp | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index f26f8e63..401eebd0 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -148,10 +148,10 @@ CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, fl // Fade out when too near // why not in buffered version? - if(z < 3.0f){ - if(z < 1.5f) + if(z < 2.3f){ + if(z < 1.3f) return; - int f = (z - 1.5f)/1.5f * 255; + int f = (z - 1.3f)/(2.3f-1.3f) * 255; r = f*r >> 8; g = f*g >> 8; b = f*b >> 8; diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index 7dcedb26..0cd0e8bb 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -120,6 +120,8 @@ CSprite2d::Draw(float x1, float y1, float x2, float y2, float x3, float y3, floa void CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { + float offset = 1.0f/1024.0f; + // This is what we draw: // 0---1 // | / | @@ -130,8 +132,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwIm2DVertexSetCameraZ(&maVertices[0], NearCamZ); RwIm2DVertexSetRecipCameraZ(&maVertices[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&maVertices[0], 0.0f, RecipNearClip); - RwIm2DVertexSetV(&maVertices[0], 0.0f, RecipNearClip); + RwIm2DVertexSetU(&maVertices[0], 0.0f+offset, RecipNearClip); + RwIm2DVertexSetV(&maVertices[0], 0.0f+offset, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[1], r.right); RwIm2DVertexSetScreenY(&maVertices[1], r.top); @@ -139,8 +141,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwIm2DVertexSetCameraZ(&maVertices[1], NearCamZ); RwIm2DVertexSetRecipCameraZ(&maVertices[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&maVertices[1], 1.0f, RecipNearClip); - RwIm2DVertexSetV(&maVertices[1], 0.0f, RecipNearClip); + RwIm2DVertexSetU(&maVertices[1], 1.0f+offset, RecipNearClip); + RwIm2DVertexSetV(&maVertices[1], 0.0f+offset, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[2], r.right); RwIm2DVertexSetScreenY(&maVertices[2], r.bottom); @@ -148,8 +150,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwIm2DVertexSetCameraZ(&maVertices[2], NearCamZ); RwIm2DVertexSetRecipCameraZ(&maVertices[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&maVertices[2], 1.0f, RecipNearClip); - RwIm2DVertexSetV(&maVertices[2], 1.0f, RecipNearClip); + RwIm2DVertexSetU(&maVertices[2], 1.0f+offset, RecipNearClip); + RwIm2DVertexSetV(&maVertices[2], 1.0f+offset, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[3], r.left); RwIm2DVertexSetScreenY(&maVertices[3], r.bottom); @@ -157,8 +159,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwIm2DVertexSetCameraZ(&maVertices[3], NearCamZ); RwIm2DVertexSetRecipCameraZ(&maVertices[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&maVertices[3], 0.0f, RecipNearClip); - RwIm2DVertexSetV(&maVertices[3], 1.0f, RecipNearClip); + RwIm2DVertexSetU(&maVertices[3], 0.0f+offset, RecipNearClip); + RwIm2DVertexSetV(&maVertices[3], 1.0f+offset, RecipNearClip); } void -- cgit v1.2.3