diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 9c2c989c0493..98b5adc0799c 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -786,33 +786,17 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, float vertical = transVtx2.y - transVtx1.y; Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized(); - // bottom right - trans[0] = transVtx2; - trans[0].x += addWidth.x * dx; - trans[0].y += addWidth.y * dy; - trans[0].u += addWidth.x * du; - trans[0].v += addWidth.y * dv; + float xoff = addWidth.x * dx; + float yoff = addWidth.y * dy; + // bottom right + trans[0].CopyFromWithOffset(transVtx2, xoff, yoff); // top right - trans[1] = transVtx1; - trans[1].x += addWidth.x * dx; - trans[1].y += addWidth.y * dy; - trans[1].u += addWidth.x * du; - trans[1].v += addWidth.y * dv; - + trans[1].CopyFromWithOffset(transVtx1, xoff, yoff); // top left - trans[2] = transVtx1; - trans[2].x -= addWidth.x * dx; - trans[2].y -= addWidth.y * dy; - trans[2].u -= addWidth.x * du; - trans[2].v -= addWidth.y * dv; - + trans[2].CopyFromWithOffset(transVtx1, -xoff, -yoff); // bottom left - trans[3] = transVtx2; - trans[3].x -= addWidth.x * dx; - trans[3].y -= addWidth.y * dy; - trans[3].u -= addWidth.x * du; - trans[3].v -= addWidth.y * dv; + trans[3].CopyFromWithOffset(transVtx2, -xoff, -yoff); // Triangle: BR-TR-TL indsOut[0] = i * 2 + 0; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 880aceab2573..623842853c88 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -57,6 +57,13 @@ struct TransformedVertex { u8 color1[4]; // prelit u32 color1_32; }; + + + void CopyFromWithOffset(const TransformedVertex &other, float xoff, float yoff) { + this->x = other.x + xoff; + this->y = other.y + yoff; + memcpy(&this->z, &other.z, sizeof(*this) - sizeof(float) * 2); + } }; class GPUCommon : public GPUInterface, public GPUDebugInterface {