mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Let's try rodolfo's fix of 4322
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4343 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -145,3 +145,152 @@ void IndexGenerator::AddPoints(int numVerts)
|
||||
numPrims += numVerts;
|
||||
adds++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Init
|
||||
void IndexGenerator2::Start(unsigned short *Triangleptr,unsigned short *Lineptr,unsigned short *Pointptr)
|
||||
{
|
||||
Tptr = Triangleptr;
|
||||
Lptr = Lineptr;
|
||||
Pptr = Pointptr;
|
||||
index = 0;
|
||||
numT = 0;
|
||||
numL = 0;
|
||||
numP = 0;
|
||||
Tadds = 0;
|
||||
Ladds = 0;
|
||||
Padds = 0;
|
||||
TindexLen = 0;
|
||||
LindexLen = 0;
|
||||
PindexLen = 0;
|
||||
LastTPrimitive = None;
|
||||
LastLPrimitive = None;
|
||||
}
|
||||
// Triangles
|
||||
void IndexGenerator2::AddList(int numVerts)
|
||||
{
|
||||
int numTris = numVerts / 3;
|
||||
if (numTris <= 0) return;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*Tptr++ = index+i*3;
|
||||
*Tptr++ = index+i*3+1;
|
||||
*Tptr++ = index+i*3+2;
|
||||
}
|
||||
TindexLen += numVerts;
|
||||
index += numVerts;
|
||||
numT += numTris;
|
||||
Tadds++;
|
||||
LastTPrimitive = List;
|
||||
}
|
||||
|
||||
void IndexGenerator2::AddStrip(int numVerts)
|
||||
{
|
||||
int numTris = numVerts - 2;
|
||||
if (numTris <= 0) return;
|
||||
bool wind = false;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*Tptr++ = index+i;
|
||||
*Tptr++ = index+i+(wind?2:1);
|
||||
*Tptr++ = index+i+(wind?1:2);
|
||||
wind = !wind;
|
||||
}
|
||||
TindexLen += numTris * 3;
|
||||
index += numVerts;
|
||||
numT += numTris;
|
||||
Tadds++;
|
||||
LastTPrimitive = Strip;
|
||||
}
|
||||
void IndexGenerator2::AddFan(int numVerts)
|
||||
{
|
||||
int numTris = numVerts - 2;
|
||||
if (numTris <= 0) return;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*Tptr++ = index;
|
||||
*Tptr++ = index+i+1;
|
||||
*Tptr++ = index+i+2;
|
||||
}
|
||||
TindexLen += numTris * 3;
|
||||
index += numVerts;
|
||||
numT += numTris;
|
||||
Tadds++;
|
||||
LastTPrimitive = Fan;
|
||||
}
|
||||
|
||||
void IndexGenerator2::AddQuads(int numVerts)
|
||||
{
|
||||
int numTris = (numVerts/4)*2;
|
||||
if (numTris <= 0) return;
|
||||
for (int i = 0; i < numTris / 2; i++)
|
||||
{
|
||||
*Tptr++ = index+i*4;
|
||||
*Tptr++ = index+i*4+1;
|
||||
*Tptr++ = index+i*4+3;
|
||||
*Tptr++ = index+i*4+1;
|
||||
*Tptr++ = index+i*4+2;
|
||||
*Tptr++ = index+i*4+3;
|
||||
}
|
||||
TindexLen += numTris * 3;
|
||||
index += numVerts;
|
||||
numT += numTris;
|
||||
Tadds++;
|
||||
LastTPrimitive = List;
|
||||
}
|
||||
|
||||
|
||||
//Lines
|
||||
void IndexGenerator2::AddLineList(int numVerts)
|
||||
{
|
||||
int numLines= numVerts / 2;
|
||||
if (numLines <= 0) return;
|
||||
for (int i = 0; i < numLines; i++)
|
||||
{
|
||||
*Lptr++ = index+i*2;
|
||||
*Lptr++ = index+i*2+1;
|
||||
}
|
||||
LindexLen += numVerts;
|
||||
index += numVerts;
|
||||
numL += numLines;
|
||||
Ladds++;
|
||||
LastLPrimitive = List;
|
||||
}
|
||||
|
||||
void IndexGenerator2::AddLineStrip(int numVerts)
|
||||
{
|
||||
int numLines = numVerts - 1;
|
||||
if (numLines <= 0) return;
|
||||
for (int i = 0; i < numLines; i++)
|
||||
{
|
||||
*Lptr++ = index+i;
|
||||
*Lptr++ = index+i+1;
|
||||
}
|
||||
LindexLen += numLines * 2;
|
||||
index += numVerts;
|
||||
numL += numLines;
|
||||
Ladds++;
|
||||
LastLPrimitive = Strip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Points
|
||||
void IndexGenerator2::AddPoints(int numVerts)
|
||||
{
|
||||
for (int i = 0; i < numVerts; i++)
|
||||
{
|
||||
*Pptr++ = index+i;
|
||||
}
|
||||
index += numVerts;
|
||||
numP += numVerts;
|
||||
PindexLen+=numVerts;
|
||||
Padds++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#ifndef _INDEXGENERATOR_H
|
||||
#define _INDEXGENERATOR_H
|
||||
|
||||
|
||||
|
||||
class IndexGenerator
|
||||
{
|
||||
public:
|
||||
@ -46,4 +48,55 @@ private:
|
||||
bool onlyLists;
|
||||
};
|
||||
|
||||
class IndexGenerator2
|
||||
{
|
||||
public:
|
||||
//Init
|
||||
void Start(unsigned short *Triangleptr,unsigned short *Lineptr,unsigned short *Pointptr);
|
||||
//Triangles
|
||||
void AddList(int numVerts);
|
||||
void AddStrip(int numVerts);
|
||||
void AddFan(int numVerts);
|
||||
void AddQuads(int numVerts);
|
||||
//Lines
|
||||
void AddLineList(int numVerts);
|
||||
void AddLineStrip(int numVerts);
|
||||
//Points
|
||||
void AddPoints(int numVerts);
|
||||
//Interface
|
||||
int GetNumTriangles() {return numT;}
|
||||
int GetNumLines() {return numL;}
|
||||
int GetNumPoints() {return numP;}
|
||||
int GetNumVerts() {return index;} //returns numprimitives
|
||||
int GetNumAdds() {return Tadds + Ladds + Padds;}
|
||||
int GetTriangleindexLen() {return TindexLen;}
|
||||
int GetLineindexLen() {return LindexLen;}
|
||||
int GetPointindexLen() {return PindexLen;}
|
||||
public:
|
||||
enum IndexPrimitiveType
|
||||
{
|
||||
None,
|
||||
List,
|
||||
Strip,
|
||||
Fan
|
||||
};
|
||||
private:
|
||||
unsigned short *Tptr;
|
||||
unsigned short *Lptr;
|
||||
unsigned short *Pptr;
|
||||
int numT;
|
||||
int numL;
|
||||
int numP;
|
||||
int index;
|
||||
int Tadds;
|
||||
int Ladds;
|
||||
int Padds;
|
||||
int TindexLen;
|
||||
int LindexLen;
|
||||
int PindexLen;
|
||||
IndexPrimitiveType LastTPrimitive;
|
||||
IndexPrimitiveType LastLPrimitive;
|
||||
|
||||
};
|
||||
|
||||
#endif // _INDEXGENERATOR_H
|
Reference in New Issue
Block a user