summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2013-04-08 17:22:16 +0200
committerdegasus <wickmarkus@web.de>2013-04-08 17:22:16 +0200
commit80b56ddd170b12db30e636c0d5014afe20ebb784 (patch)
tree45e355466258edebc7314e7ec19a5f1acb26c5a2 /Source/Core/VideoCommon
parentcf98ef8cf3331709396e0d1e3a25ba59c4823e8c (diff)
convert triangle_fan to triangle_strip
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/IndexGenerator.cpp71
1 files changed, 59 insertions, 12 deletions
diff --git a/Source/Core/VideoCommon/Src/IndexGenerator.cpp b/Source/Core/VideoCommon/Src/IndexGenerator.cpp
index 05097b7c9a..edc6e90309 100644
--- a/Source/Core/VideoCommon/Src/IndexGenerator.cpp
+++ b/Source/Core/VideoCommon/Src/IndexGenerator.cpp
@@ -21,15 +21,6 @@
#include "VideoConfig.h"
#include "IndexGenerator.h"
-/*
-*
-QUAD simulator
-
-0 1 4 5
-3 2 7 6
-012023 147172 ...
-*/
-
//Init
u16 *IndexGenerator::Tptr;
u16 *IndexGenerator::BASETptr;
@@ -130,24 +121,80 @@ void IndexGenerator::AddStrip(u32 const numVerts)
}
}
+/**
+ * FAN simulator:
+ *
+ * 2---3
+ * / \ / \
+ * 1---0---4
+ *
+ * would generate this triangles:
+ * 012, 023, 034
+ *
+ * rotated (for better striping):
+ * 120, 302, 034
+ *
+ * as odd ones have to winded, following strip is fine:
+ * 12034
+ *
+ * so we use 6 indices for 3 triangles
+ */
+
void IndexGenerator::AddFan(u32 numVerts)
{
- for (u32 i = 2; i < numVerts; ++i)
+ ERROR_LOG(VIDEO, "addfan: %d vertices", numVerts);
+ u32 i = 2;
+
+ if(g_Config.backend_info.bSupportsPrimitiveRestart) {
+ for(; i<=numVerts-3; i+=3) {
+ *Tptr++ = index + i - 1;
+ *Tptr++ = index + i + 0;
+ *Tptr++ = index;
+ *Tptr++ = index + i + 1;
+ *Tptr++ = index + i + 2;
+ *Tptr++ = 65535;
+ numT += 3;
+ }
+
+ for(; i<=numVerts-2; i+=2) {
+ *Tptr++ = index + i - 1;
+ *Tptr++ = index + i + 0;
+ *Tptr++ = index;
+ *Tptr++ = index + i + 1;
+ *Tptr++ = 65535;
+ numT += 2;
+ }
+ }
+
+ for (; i < numVerts; ++i)
{
WriteTriangle(index, index + i - 1, index + i);
}
}
+/*
+ * QUAD simulator
+ *
+ * 0---1 4---5
+ * |\ | |\ |
+ * | \ | | \ |
+ * | \| | \|
+ * 3---2 7---6
+ *
+ * 012,023, 456,467 ...
+ * or 120,302, 564,746
+ * or as strip: 1203, 5647
+ */
void IndexGenerator::AddQuads(u32 numVerts)
{
auto const numQuads = numVerts / 4;
for (u32 i = 0; i != numQuads; ++i)
{
if(g_Config.backend_info.bSupportsPrimitiveRestart) {
- *Tptr++ = index + i * 4 + 0;
*Tptr++ = index + i * 4 + 1;
- *Tptr++ = index + i * 4 + 3;
*Tptr++ = index + i * 4 + 2;
+ *Tptr++ = index + i * 4 + 0;
+ *Tptr++ = index + i * 4 + 3;
*Tptr++ = 65535;
numT += 2;
} else {