From 629ceaf2b115ffe6b7d315a78d1f4eeb4dede1ef Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Sat, 6 Sep 2014 01:24:03 -0500 Subject: Split some parts of UpdateBoundingBox into multiple lines. Also, fix issues causing failure on Lint. --- Source/Core/VideoCommon/VertexLoader.cpp | 117 +++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 12 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoader.cpp') diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index 6ca9a04da1..a227b6da52 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -374,10 +374,41 @@ static void LOADERDECL UpdateBoundingBox() { m = (p1.x - p0.x) ? ((p1.y - p0.y) / (p1.x - p0.x)) : highNum; c = p0.y - (m * p0.x); - if (i0 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); } - if (i0 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); } - if (i0 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); } - if (i0 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); } + if (i0 & 1) + { + s = (s32)(c + roundUp); + if (s >= 0 && s <= 479) + left = 0; + top = std::min(s, top); + bottom = std::max(s, bottom); + } + + if (i0 & 2) + { + s = (s32)((-c / m) + roundUp); + if (s >= 0 && s <= 607) + top = 0; + left = std::min(s, left); + right = std::max(s, right); + } + + if (i0 & 4) + { + s = (s32)((m * 607) + c + roundUp); + if (s >= 0 && s <= 479) + right = 607; + top = std::min(s, top); + bottom = std::max(s, bottom); + } + + if (i0 & 8) + { + s = (s32)(((479 - c) / m) + roundUp); + if (s >= 0 && s <= 607) + bottom = 479; + left = std::min(s, left); + right = std::max(s, right); + } } // Only check other lines if we are dealing with a triangle @@ -388,10 +419,41 @@ static void LOADERDECL UpdateBoundingBox() { m = (p2.x - p1.x) ? ((p2.y - p1.y) / (p2.x - p1.x)) : highNum; c = p1.y - (m * p1.x); - if (i1 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); } - if (i1 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); } - if (i1 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); } - if (i1 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); } + if (i1 & 1) + { + s = (s32)(c + roundUp); + if (s >= 0 && s <= 479) + left = 0; + top = std::min(s, top); + bottom = std::max(s, bottom); + } + + if (i1 & 2) + { + s = (s32)((-c / m) + roundUp); + if (s >= 0 && s <= 607) + top = 0; + left = std::min(s, left); + right = std::max(s, right); + } + + if (i1 & 4) + { + s = (s32)((m * 607) + c + roundUp); + if (s >= 0 && s <= 479) + right = 607; + top = std::min(s, top); + bottom = std::max(s, bottom); + } + + if (i1 & 8) + { + s = (s32)(((479 - c) / m) + roundUp); + if (s >= 0 && s <= 607) + bottom = 479; + left = std::min(s, left); + right = std::max(s, right); + } } // Third line intersects @@ -399,10 +461,41 @@ static void LOADERDECL UpdateBoundingBox() { m = (p2.x - p0.x) ? ((p2.y - p0.y) / (p2.x - p0.x)) : highNum; c = p0.y - (m * p0.x); - if (i2 & 1) { s = (s32)(c + roundUp); if (s >= 0 && s <= 479) left = 0; top = std::min(s, top); bottom = std::max(s, bottom); } - if (i2 & 2) { s = (s32)((-c / m) + roundUp); if (s >= 0 && s <= 607) top = 0; left = std::min(s, left); right = std::max(s, right); } - if (i2 & 4) { s = (s32)((m * 607) + c + roundUp); if (s >= 0 && s <= 479) right = 607; top = std::min(s, top); bottom = std::max(s, bottom); } - if (i2 & 8) { s = (s32)(((479 - c) / m) + roundUp); if (s >= 0 && s <= 607) bottom = 479; left = std::min(s, left); right = std::max(s, right); } + if (i2 & 1) + { + s = (s32)(c + roundUp); + if (s >= 0 && s <= 479) + left = 0; + top = std::min(s, top); + bottom = std::max(s, bottom); + } + + if (i2 & 2) + { + s = (s32)((-c / m) + roundUp); + if (s >= 0 && s <= 607) + top = 0; + left = std::min(s, left); + right = std::max(s, right); + } + + if (i2 & 4) + { + s = (s32)((m * 607) + c + roundUp); + if (s >= 0 && s <= 479) + right = 607; + top = std::min(s, top); + bottom = std::max(s, bottom); + } + + if (i2 & 8) + { + s = (s32)(((479 - c) / m) + roundUp); + if (s >= 0 && s <= 607) + bottom = 479; + left = std::min(s, left); + right = std::max(s, right); + } } } -- cgit v1.2.3