[Scummvm-git-logs] scummvm master -> 30fe3ef07ad73c9959f31a0202c7c946f4c87dbf

mgerhardy martin.gerhardy at gmail.com
Mon Sep 6 18:02:15 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
30fe3ef07a TWINE: cleanup renderPolygonsGouraud


Commit: 30fe3ef07ad73c9959f31a0202c7c946f4c87dbf
    https://github.com/scummvm/scummvm/commit/30fe3ef07ad73c9959f31a0202c7c946f4c87dbf
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T20:00:26+02:00

Commit Message:
TWINE: cleanup renderPolygonsGouraud

Changed paths:
    engines/twine/renderer/renderer.cpp


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index d76a7d8c0f..84c70c17df 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -787,83 +787,68 @@ void Renderer::renderPolygonsGouraud(int vtop, int32 vsize) const {
 	}
 	for (int32 currentLine = 0; currentLine < renderLoop; ++currentLine) {
 		uint16 startColor = ptr2[0];
-		uint16 stopColor = ptr2[screenHeight];
+		const uint16 stopColor = ptr2[screenHeight];
 
-		int16 colorSize = stopColor - startColor;
+		int16 colorDiff = stopColor - startColor;
 
-		int16 stop = ptr1[screenHeight];
-		int16 start = ptr1[0];
+		const int16 stop = ptr1[screenHeight];
+		const int16 start = ptr1[0];
 
 		ptr1++;
 		uint8 *out2 = start + out;
 		int32 hsize = stop - start;
 
-		//varf2 = ptr2[screenHeight];
-		//varf3 = ptr2[0];
-
 		ptr2++;
 
-		//varf4 = (float)((int32)varf2 - (int32)varf3);
-
 		if (hsize == 0) {
 			if (start >= 0 && start < screenWidth) {
 				*out2 = ((startColor + stopColor) / 2) / 256; // average of the 2 colors
 			}
-		} else if (hsize > 0) {
-			if (hsize == 1) {
-				if (start >= -1 && start < screenWidth - 1) {
-					*(out2 + 1) = stopColor / 256;
-				}
+		} else if (hsize == 1) {
+			if (start >= -1 && start < screenWidth - 1) {
+				*(out2 + 1) = stopColor / 256;
+			}
 
-				if (start >= 0 && start < screenWidth) {
-					*out2 = startColor / 256;
-				}
-			} else if (hsize == 2) {
-				if (start >= -2 && start < screenWidth - 2) {
-					*(out2 + 2) = stopColor / 256;
-				}
+			if (start >= 0 && start < screenWidth) {
+				*out2 = startColor / 256;
+			}
+		} else if (hsize == 2) {
+			if (start >= -2 && start < screenWidth - 2) {
+				*(out2 + 2) = stopColor / 256;
+			}
 
-				if (start >= -1 && start < screenWidth - 1) {
-					*(out2 + 1) = ((startColor + stopColor) / 2) / 256;
-				}
+			if (start >= -1 && start < screenWidth - 1) {
+				*(out2 + 1) = ((startColor + stopColor) / 2) / 256; // average of the 2 colors
+			}
 
-				if (start >= 0 && start < screenWidth) {
+			if (start >= 0 && start < screenWidth) {
+				*out2 = startColor / 256;
+			}
+		} else if (hsize > 0) {
+			int32 currentXPos = start;
+			colorDiff /= hsize;
+			hsize++;
+
+			if (hsize % 2) {
+				if (currentXPos >= 0 && currentXPos < screenWidth) {
 					*out2 = startColor / 256;
 				}
-			} else {
-				int32 currentXPos = start;
-				colorSize /= hsize;
-				hsize++;
+				++out2;
+				++currentXPos;
+				startColor += colorDiff;
+			}
+			hsize /= 2;
 
-				if (hsize % 2) {
-					hsize /= 2;
+			do {
+				for (int i = 0; i < 2; ++i) {
 					if (currentXPos >= 0 && currentXPos < screenWidth) {
-						*out2 = startColor >> 8;
+						*out2 = startColor / 256;
 					}
-					out2++;
-					currentXPos++;
-					startColor += colorSize;
-				} else {
-					hsize /= 2;
+					++out2;
+					++currentXPos;
+					startColor += colorDiff;
 				}
-
-				do {
-					if (currentXPos >= 0 && currentXPos < screenWidth) {
-						*out2 = startColor >> 8;
-					}
-
-					currentXPos++;
-					startColor += colorSize;
-
-					if (currentXPos >= 0 && currentXPos < screenWidth) {
-						*(out2 + 1) = startColor >> 8;
-					}
-
-					currentXPos++;
-					out2 += 2;
-					startColor += colorSize;
-				} while (--hsize);
-			}
+			} while (--hsize);
 		}
 		out += screenWidth;
 	}




More information about the Scummvm-git-logs mailing list