Remove logic from IndexGenerator which does not seem to match that of Video Software.
This commit is contained in:
parent
368c78dd5c
commit
f16dcfe6f6
|
@ -29,16 +29,16 @@ QUAD simulator
|
|||
*/
|
||||
|
||||
//Init
|
||||
u16 *IndexGenerator::Tptr = 0;
|
||||
u16 *IndexGenerator::BASETptr = 0;
|
||||
u16 *IndexGenerator::Lptr = 0;
|
||||
u16 *IndexGenerator::BASELptr = 0;
|
||||
u16 *IndexGenerator::Pptr = 0;
|
||||
u16 *IndexGenerator::BASEPptr = 0;
|
||||
u32 IndexGenerator::numT = 0;
|
||||
u32 IndexGenerator::numL = 0;
|
||||
u32 IndexGenerator::numP = 0;
|
||||
u32 IndexGenerator::index = 0;
|
||||
u16 *IndexGenerator::Tptr;
|
||||
u16 *IndexGenerator::BASETptr;
|
||||
u16 *IndexGenerator::Lptr;
|
||||
u16 *IndexGenerator::BASELptr;
|
||||
u16 *IndexGenerator::Pptr;
|
||||
u16 *IndexGenerator::BASEPptr;
|
||||
u32 IndexGenerator::numT;
|
||||
u32 IndexGenerator::numL;
|
||||
u32 IndexGenerator::numP;
|
||||
u32 IndexGenerator::index;
|
||||
|
||||
void IndexGenerator::Start(u16* Triangleptr, u16* Lineptr, u16* Pointptr)
|
||||
{
|
||||
|
@ -58,13 +58,13 @@ void IndexGenerator::AddIndices(int primitive, u32 numVerts)
|
|||
{
|
||||
//switch (primitive)
|
||||
//{
|
||||
//case GX_DRAW_QUADS: IndexGenerator::AddQuads(numVertices); break;
|
||||
//case GX_DRAW_TRIANGLES: IndexGenerator::AddList(numVertices); break;
|
||||
//case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(numVertices); break;
|
||||
//case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(numVertices); break;
|
||||
//case GX_DRAW_LINES: IndexGenerator::AddLineList(numVertices); break;
|
||||
//case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(numVertices); break;
|
||||
//case GX_DRAW_POINTS: IndexGenerator::AddPoints(numVertices); break;
|
||||
//case GX_DRAW_QUADS: IndexGenerator::AddQuads(numVerts); break;
|
||||
//case GX_DRAW_TRIANGLES: IndexGenerator::AddList(numVerts); break;
|
||||
//case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(numVerts); break;
|
||||
//case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(numVerts); break;
|
||||
//case GX_DRAW_LINES: IndexGenerator::AddLineList(numVerts); break;
|
||||
//case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(numVerts); break;
|
||||
//case GX_DRAW_POINTS: IndexGenerator::AddPoints(numVerts); break;
|
||||
//}
|
||||
|
||||
static void (*const primitive_table[])(u32) =
|
||||
|
@ -96,58 +96,13 @@ void IndexGenerator::WriteTriangle(u32 index1, u32 index2, u32 index3)
|
|||
void IndexGenerator::AddList(u32 const numVerts)
|
||||
{
|
||||
auto const numTris = numVerts / 3;
|
||||
if (!numTris)
|
||||
{
|
||||
if (2 == numVerts)
|
||||
{
|
||||
// We have two verts. Render a degenerated triangle.
|
||||
WriteTriangle(index, index + 1, index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i = 0; i != numTris; ++i)
|
||||
{
|
||||
WriteTriangle(index + i * 3, index + i * 3 + 1, index + i * 3 + 2);
|
||||
}
|
||||
|
||||
auto const base_remaining_verts = numTris * 3;
|
||||
switch (numVerts % 3)
|
||||
{
|
||||
case 2:
|
||||
// We have 2 remaining verts. Use strip method
|
||||
WriteTriangle(
|
||||
index + base_remaining_verts - 1,
|
||||
index + base_remaining_verts,
|
||||
index + base_remaining_verts + 1);
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// We have 1 remaining vert. Use strip method this is only a conjeture
|
||||
WriteTriangle(
|
||||
index + base_remaining_verts - 2,
|
||||
index + base_remaining_verts - 1,
|
||||
index + base_remaining_verts);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void IndexGenerator::AddStrip(u32 const numVerts)
|
||||
{
|
||||
if (numVerts < 3)
|
||||
{
|
||||
if (2 == numVerts)
|
||||
{
|
||||
// We have two verts. Render a degenerated triangle.
|
||||
WriteTriangle(index, index + 1, index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool wind = false;
|
||||
for (u32 i = 2; i < numVerts; ++i)
|
||||
|
@ -160,82 +115,23 @@ void IndexGenerator::AddStrip(u32 const numVerts)
|
|||
wind ^= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IndexGenerator::AddFan(u32 numVerts)
|
||||
{
|
||||
if (numVerts < 3)
|
||||
{
|
||||
if (2 == numVerts)
|
||||
{
|
||||
// We have two verts. Render a degenerated triangle.
|
||||
WriteTriangle(index, index + 1, index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i = 2; i < numVerts; ++i)
|
||||
{
|
||||
WriteTriangle(index, index + i - 1, index + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IndexGenerator::AddQuads(u32 numVerts)
|
||||
{
|
||||
auto const numQuads = numVerts / 4;
|
||||
if (!numQuads)
|
||||
{
|
||||
if (2 == numVerts)
|
||||
{
|
||||
// We have two verts. Render a degenerated triangle.
|
||||
WriteTriangle(index, index + 1, index);
|
||||
}
|
||||
else if (3 == numVerts);
|
||||
{
|
||||
// We have 3 verts. Render a full triangle.
|
||||
WriteTriangle(index, index + 1, index + 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i = 0; i != numQuads; ++i)
|
||||
{
|
||||
WriteTriangle(index + i * 4, index + i * 4 + 1, index + i * 4 + 2);
|
||||
WriteTriangle(index + i * 4, index + i * 4 + 2, index + i * 4 + 3);
|
||||
}
|
||||
|
||||
auto const base_remaining_verts = numQuads * 4;
|
||||
switch (numVerts % 4)
|
||||
{
|
||||
case 3:
|
||||
// We have 3 remaining verts. Use strip method.
|
||||
WriteTriangle(
|
||||
index + base_remaining_verts,
|
||||
index + base_remaining_verts + 1,
|
||||
index + base_remaining_verts + 2);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// We have 3 remaining verts. Use strip method.
|
||||
WriteTriangle(
|
||||
index + base_remaining_verts - 1,
|
||||
index + base_remaining_verts,
|
||||
index + base_remaining_verts + 1);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// We have 1 remaining verts use strip method. This is only a conjeture.
|
||||
WriteTriangle(
|
||||
base_remaining_verts - 2,
|
||||
index + base_remaining_verts - 1,
|
||||
index + base_remaining_verts);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Lines
|
||||
|
|
|
@ -57,8 +57,6 @@ private:
|
|||
static void AddFan(u32 numVerts);
|
||||
static void AddQuads(u32 numVerts);
|
||||
|
||||
static void WriteTriangle(u32 index1, u32 index2, u32 index3);
|
||||
|
||||
// Lines
|
||||
static void AddLineList(u32 numVerts);
|
||||
static void AddLineStrip(u32 numVerts);
|
||||
|
@ -66,6 +64,8 @@ private:
|
|||
// Points
|
||||
static void AddPoints(u32 numVerts);
|
||||
|
||||
static void WriteTriangle(u32 index1, u32 index2, u32 index3);
|
||||
|
||||
static u16 *Tptr;
|
||||
static u16 *BASETptr;
|
||||
static u16 *Lptr;
|
||||
|
|
Loading…
Reference in New Issue