SoftGPU: Correct negative coord handling.

Fixes #5159 - we need this signed to handle negative values properly.
This commit is contained in:
Unknown W. Brackets committed 2017-04-15 19:52:17 -07:00
1 parent 627c280031
commit dfed20701a
4 files changed
+13 -14

No files matched your search

+4 -4
View File
@@ -128,10 +128,10 @@ static inline int CalcClipMask(const ClipCoords& v)
}
static void RotateUVThrough(const VertexData &tl, const VertexData &br, VertexData &tr, VertexData &bl) {
const fixed16 x1 = tl.screenpos.x;
const fixed16 x2 = br.screenpos.x;
const fixed16 y1 = tl.screenpos.y;
const fixed16 y2 = br.screenpos.y;
const int x1 = tl.screenpos.x;
const int x2 = br.screenpos.x;
const int y1 = tl.screenpos.y;
const int y2 = br.screenpos.y;
if ((x1 < x2 && y1 > y2) || (x1 > x2 && y1 < y2)) {
std::swap(bl.texturecoords, tr.texturecoords);
+2 -2
View File
@@ -509,14 +509,14 @@ static inline bool DepthTestPassed(int x, int y, u16 z)
}
}
static inline bool IsRightSideOrFlatBottomLine(const Vec2<fixed16>& vertex, const Vec2<fixed16>& line1, const Vec2<fixed16>& line2)
static inline bool IsRightSideOrFlatBottomLine(const Vec2<int>& vertex, const Vec2<int>& line1, const Vec2<int>& line2)
{
if (line1.y == line2.y) {
// just check if vertex is above us => bottom line parallel to x-axis
return vertex.y < line1.y;
} else {
// check if vertex is on our left => right side
return vertex.x < line1.x + ((int)line2.x - (int)line1.x) * ((int)vertex.y - (int)line1.y) / ((int)line2.y - (int)line1.y);
return vertex.x < line1.x + (line2.x - line1.x) * (vertex.y - line1.y) / (line2.y - line1.y);
}
}
+2 -2
View File
@@ -191,8 +191,8 @@ VertexData TransformUnit::ReadVertex(VertexReader& vreader)
Lighting::Process(vertex, vreader.hasColor0());
} else {
vertex.screenpos.x = (u32)pos[0] * 16 + gstate.getOffsetX16();
vertex.screenpos.y = (u32)pos[1] * 16 + gstate.getOffsetY16();
vertex.screenpos.x = (int)(pos[0] * 16) + gstate.getOffsetX16();
vertex.screenpos.y = (int)(pos[1] * 16) + gstate.getOffsetY16();
vertex.screenpos.z = pos[2];
vertex.clippos.w = 1.f;
vertex.fogdepth = 1.f;
+5 -6
View File
@@ -23,7 +23,6 @@
using namespace Math3D;
typedef u16 fixed16;
typedef u16 u10; // TODO: erm... :/
typedef Vec3<float> ModelCoords;
@@ -36,17 +35,17 @@ struct SplinePatch;
struct ScreenCoords
{
ScreenCoords() {}
ScreenCoords(fixed16 x, fixed16 y, u16 z) : x(x), y(y), z(z) {}
ScreenCoords(int x, int y, u16 z) : x(x), y(y), z(z) {}
fixed16 x;
fixed16 y;
int x;
int y;
u16 z;
Vec2<fixed16> xy() const { return Vec2<fixed16>(x, y); }
Vec2<int> xy() const { return Vec2<int>(x, y); }
ScreenCoords operator * (const float t) const
{
return ScreenCoords((fixed16)(x * t), (fixed16)(y * t), (u16)(z * t));
return ScreenCoords((int)(x * t), (int)(y * t), (u16)(z * t));
}
ScreenCoords operator / (const int t) const