更新NvTriStrip
This commit is contained in:
parent
d6ebb6a65f
commit
73f282c689
@ -85,12 +85,10 @@ namespace NvTriStrip
|
|||||||
//Cleanup strips / faces, used by generatestrips
|
//Cleanup strips / faces, used by generatestrips
|
||||||
void Cleanup(NvStripInfoVec& tempStrips, NvFaceInfoVec& tempFaces)
|
void Cleanup(NvStripInfoVec& tempStrips, NvFaceInfoVec& tempFaces)
|
||||||
{
|
{
|
||||||
int i,j;
|
|
||||||
|
|
||||||
//delete strips
|
//delete strips
|
||||||
for(i = 0; i < tempStrips.size(); i++)
|
for(unsigned int i = 0; i < tempStrips.size(); i++)
|
||||||
{
|
{
|
||||||
for(j = 0; j < tempStrips[i]->m_faces.size(); j++)
|
for(unsigned int j = 0; j < tempStrips[i]->m_faces.size(); j++)
|
||||||
{
|
{
|
||||||
delete tempStrips[i]->m_faces[j];
|
delete tempStrips[i]->m_faces[j];
|
||||||
tempStrips[i]->m_faces[j] = nullptr;
|
tempStrips[i]->m_faces[j] = nullptr;
|
||||||
@ -101,7 +99,7 @@ namespace NvTriStrip
|
|||||||
}
|
}
|
||||||
|
|
||||||
//delete faces
|
//delete faces
|
||||||
for(i = 0; i < tempFaces.size(); i++)
|
for(unsigned int i = 0; i < tempFaces.size(); i++)
|
||||||
{
|
{
|
||||||
delete tempFaces[i];
|
delete tempFaces[i];
|
||||||
tempFaces[i] = nullptr;
|
tempFaces[i] = nullptr;
|
||||||
@ -154,7 +152,7 @@ namespace NvTriStrip
|
|||||||
//hash this triangle
|
//hash this triangle
|
||||||
bool isLegit = false;
|
bool isLegit = false;
|
||||||
int ctr = v0 % NUMBINS;
|
int ctr = v0 % NUMBINS;
|
||||||
for (int k = 0; k < in_bins[ctr].size(); ++k)
|
for (unsigned int k = 0; k < in_bins[ctr].size(); ++k)
|
||||||
{
|
{
|
||||||
//check triangles in this bin
|
//check triangles in this bin
|
||||||
if (SameTriangle(in_bins[ctr][k].m_v0, in_bins[ctr][k].m_v1, in_bins[ctr][k].m_v2,
|
if (SameTriangle(in_bins[ctr][k].m_v0, in_bins[ctr][k].m_v1, in_bins[ctr][k].m_v2,
|
||||||
@ -167,7 +165,7 @@ namespace NvTriStrip
|
|||||||
if (!isLegit)
|
if (!isLegit)
|
||||||
{
|
{
|
||||||
ctr = v1 % NUMBINS;
|
ctr = v1 % NUMBINS;
|
||||||
for (int k = 0; k < in_bins[ctr].size(); ++k)
|
for (unsigned int k = 0; k < in_bins[ctr].size(); ++k)
|
||||||
{
|
{
|
||||||
//check triangles in this bin
|
//check triangles in this bin
|
||||||
if (SameTriangle(in_bins[ctr][k].m_v0, in_bins[ctr][k].m_v1, in_bins[ctr][k].m_v2,
|
if (SameTriangle(in_bins[ctr][k].m_v0, in_bins[ctr][k].m_v1, in_bins[ctr][k].m_v2,
|
||||||
@ -181,7 +179,7 @@ namespace NvTriStrip
|
|||||||
if (!isLegit)
|
if (!isLegit)
|
||||||
{
|
{
|
||||||
ctr = v2 % NUMBINS;
|
ctr = v2 % NUMBINS;
|
||||||
for (int k = 0; k < in_bins[ctr].size(); ++k)
|
for (unsigned int k = 0; k < in_bins[ctr].size(); ++k)
|
||||||
{
|
{
|
||||||
//check triangles in this bin
|
//check triangles in this bin
|
||||||
if (SameTriangle(in_bins[ctr][k].m_v0, in_bins[ctr][k].m_v1, in_bins[ctr][k].m_v2,
|
if (SameTriangle(in_bins[ctr][k].m_v0, in_bins[ctr][k].m_v1, in_bins[ctr][k].m_v2,
|
||||||
@ -217,7 +215,7 @@ namespace NvTriStrip
|
|||||||
tempIndices.resize(in_numIndices);
|
tempIndices.resize(in_numIndices);
|
||||||
unsigned short maxIndex = 0;
|
unsigned short maxIndex = 0;
|
||||||
unsigned short minIndex = 0xFFFF;
|
unsigned short minIndex = 0xFFFF;
|
||||||
for(int i = 0; i < in_numIndices; i++)
|
for(unsigned int i = 0; i < in_numIndices; i++)
|
||||||
{
|
{
|
||||||
tempIndices[i] = in_indices[i];
|
tempIndices[i] = in_indices[i];
|
||||||
if (in_indices[i] > maxIndex)
|
if (in_indices[i] > maxIndex)
|
||||||
@ -246,7 +244,7 @@ namespace NvTriStrip
|
|||||||
|
|
||||||
//count the total number of indices
|
//count the total number of indices
|
||||||
unsigned int numIndices = 0;
|
unsigned int numIndices = 0;
|
||||||
for(int i = 0; i < tempStrips.size(); i++)
|
for(unsigned int i = 0; i < tempStrips.size(); i++)
|
||||||
{
|
{
|
||||||
numIndices += tempStrips[i]->m_faces.size() * 3;
|
numIndices += tempStrips[i]->m_faces.size() * 3;
|
||||||
}
|
}
|
||||||
@ -260,9 +258,9 @@ namespace NvTriStrip
|
|||||||
|
|
||||||
//do strips
|
//do strips
|
||||||
unsigned int indexCtr = 0;
|
unsigned int indexCtr = 0;
|
||||||
for(int i = 0; i < tempStrips.size(); i++)
|
for(unsigned int i = 0; i < tempStrips.size(); i++)
|
||||||
{
|
{
|
||||||
for(int j = 0; j < tempStrips[i]->m_faces.size(); j++)
|
for(unsigned int j = 0; j < tempStrips[i]->m_faces.size(); j++)
|
||||||
{
|
{
|
||||||
//degenerates are of no use with lists
|
//degenerates are of no use with lists
|
||||||
if(!NvStripifier::IsDegenerate(tempStrips[i]->m_faces[j]))
|
if(!NvStripifier::IsDegenerate(tempStrips[i]->m_faces[j]))
|
||||||
@ -280,7 +278,7 @@ namespace NvTriStrip
|
|||||||
}
|
}
|
||||||
|
|
||||||
//do lists
|
//do lists
|
||||||
for(int i = 0; i < tempFaces.size(); i++)
|
for(unsigned int i = 0; i < tempFaces.size(); i++)
|
||||||
{
|
{
|
||||||
primGroupArray[0].indices[indexCtr++] = tempFaces[i]->m_v0;
|
primGroupArray[0].indices[indexCtr++] = tempFaces[i]->m_v0;
|
||||||
primGroupArray[0].indices[indexCtr++] = tempFaces[i]->m_v1;
|
primGroupArray[0].indices[indexCtr++] = tempFaces[i]->m_v1;
|
||||||
@ -304,14 +302,14 @@ namespace NvTriStrip
|
|||||||
|
|
||||||
//first, the strips
|
//first, the strips
|
||||||
int startingLoc = 0;
|
int startingLoc = 0;
|
||||||
for(int stripCtr = 0; stripCtr < numSeparateStrips; stripCtr++)
|
for(unsigned int stripCtr = 0; stripCtr < numSeparateStrips; stripCtr++)
|
||||||
{
|
{
|
||||||
int stripLength = 0;
|
int stripLength = 0;
|
||||||
|
|
||||||
if(!bStitchStrips)
|
if(!bStitchStrips)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
//if we've got multiple strips, we need to figure out the correct length
|
//if we've got multiple strips, we need to figure out the correct length
|
||||||
|
unsigned int i;
|
||||||
for(i = startingLoc; i < stripIndices.size(); i++)
|
for(i = startingLoc; i < stripIndices.size(); i++)
|
||||||
{
|
{
|
||||||
if(stripIndices[i] == -1)
|
if(stripIndices[i] == -1)
|
||||||
@ -344,7 +342,7 @@ namespace NvTriStrip
|
|||||||
primGroupArray[faceGroupLoc].indices = new unsigned short[tempFaces.size() * 3];
|
primGroupArray[faceGroupLoc].indices = new unsigned short[tempFaces.size() * 3];
|
||||||
primGroupArray[faceGroupLoc].numIndices = tempFaces.size() * 3;
|
primGroupArray[faceGroupLoc].numIndices = tempFaces.size() * 3;
|
||||||
int indexCtr = 0;
|
int indexCtr = 0;
|
||||||
for(int i = 0; i < tempFaces.size(); i++)
|
for(unsigned int i = 0; i < tempFaces.size(); i++)
|
||||||
{
|
{
|
||||||
primGroupArray[faceGroupLoc].indices[indexCtr++] = tempFaces[i]->m_v0;
|
primGroupArray[faceGroupLoc].indices[indexCtr++] = tempFaces[i]->m_v0;
|
||||||
primGroupArray[faceGroupLoc].indices[indexCtr++] = tempFaces[i]->m_v1;
|
primGroupArray[faceGroupLoc].indices[indexCtr++] = tempFaces[i]->m_v1;
|
||||||
@ -361,7 +359,7 @@ namespace NvTriStrip
|
|||||||
std::vector<NvFaceInfo> in_bins[NUMBINS];
|
std::vector<NvFaceInfo> in_bins[NUMBINS];
|
||||||
|
|
||||||
//hash input indices on first index
|
//hash input indices on first index
|
||||||
for (int i = 0; i < in_numIndices; i += 3)
|
for (unsigned int i = 0; i < in_numIndices; i += 3)
|
||||||
{
|
{
|
||||||
NvFaceInfo faceInfo(in_indices[i], in_indices[i + 1], in_indices[i + 2]);
|
NvFaceInfo faceInfo(in_indices[i], in_indices[i + 1], in_indices[i + 2]);
|
||||||
in_bins[in_indices[i] % NUMBINS].push_back(faceInfo);
|
in_bins[in_indices[i] % NUMBINS].push_back(faceInfo);
|
||||||
@ -373,7 +371,7 @@ namespace NvTriStrip
|
|||||||
{
|
{
|
||||||
case PT_LIST:
|
case PT_LIST:
|
||||||
{
|
{
|
||||||
for (int j = 0; j < (*primGroups)[i].numIndices; j += 3)
|
for (unsigned int j = 0; j < (*primGroups)[i].numIndices; j += 3)
|
||||||
{
|
{
|
||||||
unsigned short v0 = (*primGroups)[i].indices[j];
|
unsigned short v0 = (*primGroups)[i].indices[j];
|
||||||
unsigned short v1 = (*primGroups)[i].indices[j + 1];
|
unsigned short v1 = (*primGroups)[i].indices[j + 1];
|
||||||
@ -396,7 +394,7 @@ namespace NvTriStrip
|
|||||||
{
|
{
|
||||||
int brokenCtr = 0;
|
int brokenCtr = 0;
|
||||||
bool flip = false;
|
bool flip = false;
|
||||||
for (int j = 2; j < (*primGroups)[i].numIndices; ++j)
|
for (unsigned int j = 2; j < (*primGroups)[i].numIndices; ++j)
|
||||||
{
|
{
|
||||||
unsigned short v0 = (*primGroups)[i].indices[j - 2];
|
unsigned short v0 = (*primGroups)[i].indices[j - 2];
|
||||||
unsigned short v1 = (*primGroups)[i].indices[j - 1];
|
unsigned short v1 = (*primGroups)[i].indices[j - 1];
|
||||||
@ -478,7 +476,7 @@ namespace NvTriStrip
|
|||||||
(*remappedGroups)[i].numIndices = numIndices;
|
(*remappedGroups)[i].numIndices = numIndices;
|
||||||
(*remappedGroups)[i].indices = new unsigned short[numIndices];
|
(*remappedGroups)[i].indices = new unsigned short[numIndices];
|
||||||
|
|
||||||
for(int j = 0; j < numIndices; j++)
|
for(unsigned int j = 0; j < numIndices; j++)
|
||||||
{
|
{
|
||||||
int cachedIndex = indexCache[in_primGroups[i].indices[j]];
|
int cachedIndex = indexCache[in_primGroups[i].indices[j]];
|
||||||
if(cachedIndex == -1) //we haven't seen this index before
|
if(cachedIndex == -1) //we haven't seen this index before
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#pragma warning( disable : 4786 )
|
#pragma warning( disable : 4786 )
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <algorithm>
|
||||||
#include "NvTriStripObjects.h"
|
#include "NvTriStripObjects.h"
|
||||||
#include "VertexCache.h"
|
#include "VertexCache.h"
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ namespace NvTriStrip
|
|||||||
|
|
||||||
bool NvStripifier::AlreadyExists(NvFaceInfo* faceInfo, NvFaceInfoVec& faceInfos)
|
bool NvStripifier::AlreadyExists(NvFaceInfo* faceInfo, NvFaceInfoVec& faceInfos)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < faceInfos.size(); ++i)
|
for(unsigned int i = 0; i < faceInfos.size(); ++i)
|
||||||
{
|
{
|
||||||
if( (faceInfos[i]->m_v0 == faceInfo->m_v0) &&
|
if( (faceInfos[i]->m_v0 == faceInfo->m_v0) &&
|
||||||
(faceInfos[i]->m_v1 == faceInfo->m_v1) &&
|
(faceInfos[i]->m_v1 == faceInfo->m_v1) &&
|
||||||
@ -138,7 +140,7 @@ namespace NvTriStrip
|
|||||||
{
|
{
|
||||||
if (edgeInfo01->m_face1 != nullptr)
|
if (edgeInfo01->m_face1 != nullptr)
|
||||||
{
|
{
|
||||||
printf("BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences\n");
|
fprintf(stderr, "BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -169,7 +171,7 @@ namespace NvTriStrip
|
|||||||
{
|
{
|
||||||
if (edgeInfo12->m_face1 != nullptr)
|
if (edgeInfo12->m_face1 != nullptr)
|
||||||
{
|
{
|
||||||
printf("BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences\n");
|
fprintf(stderr, "BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -200,7 +202,7 @@ namespace NvTriStrip
|
|||||||
{
|
{
|
||||||
if (edgeInfo20->m_face1 != nullptr)
|
if (edgeInfo20->m_face1 != nullptr)
|
||||||
{
|
{
|
||||||
printf("BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences\n");
|
fprintf(stderr, "BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -245,7 +247,7 @@ namespace NvTriStrip
|
|||||||
int bestCtr = -1;
|
int bestCtr = -1;
|
||||||
int bestIndex = -1;
|
int bestIndex = -1;
|
||||||
|
|
||||||
for(int i = 0; i < faceInfos.size(); i++)
|
for(unsigned int i = 0; i < faceInfos.size(); i++)
|
||||||
{
|
{
|
||||||
int ctr = 0;
|
int ctr = 0;
|
||||||
|
|
||||||
@ -436,22 +438,22 @@ namespace NvTriStrip
|
|||||||
|
|
||||||
if (fv0 != v0 && fv0 != v1){
|
if (fv0 != v0 && fv0 != v1){
|
||||||
if ((fv1 != v0 && fv1 != v1) || (fv2 != v0 && fv2 != v1)){
|
if ((fv1 != v0 && fv1 != v1) || (fv2 != v0 && fv2 != v1)){
|
||||||
printf("GetNextIndex: Triangle doesn't have all of its vertices\n");
|
fprintf(stderr, "GetNextIndex: Triangle doesn't have all of its vertices\n");
|
||||||
printf("GetNextIndex: Duplicate triangle probably got us derailed\n");
|
fprintf(stderr, "GetNextIndex: Duplicate triangle probably got us derailed\n");
|
||||||
}
|
}
|
||||||
return fv0;
|
return fv0;
|
||||||
}
|
}
|
||||||
if (fv1 != v0 && fv1 != v1){
|
if (fv1 != v0 && fv1 != v1){
|
||||||
if ((fv0 != v0 && fv0 != v1) || (fv2 != v0 && fv2 != v1)){
|
if ((fv0 != v0 && fv0 != v1) || (fv2 != v0 && fv2 != v1)){
|
||||||
printf("GetNextIndex: Triangle doesn't have all of its vertices\n");
|
fprintf(stderr, "GetNextIndex: Triangle doesn't have all of its vertices\n");
|
||||||
printf("GetNextIndex: Duplicate triangle probably got us derailed\n");
|
fprintf(stderr, "GetNextIndex: Duplicate triangle probably got us derailed\n");
|
||||||
}
|
}
|
||||||
return fv1;
|
return fv1;
|
||||||
}
|
}
|
||||||
if (fv2 != v0 && fv2 != v1){
|
if (fv2 != v0 && fv2 != v1){
|
||||||
if ((fv0 != v0 && fv0 != v1) || (fv1 != v0 && fv1 != v1)){
|
if ((fv0 != v0 && fv0 != v1) || (fv1 != v0 && fv1 != v1)){
|
||||||
printf("GetNextIndex: Triangle doesn't have all of its vertices\n");
|
fprintf(stderr, "GetNextIndex: Triangle doesn't have all of its vertices\n");
|
||||||
printf("GetNextIndex: Duplicate triangle probably got us derailed\n");
|
fprintf(stderr, "GetNextIndex: Duplicate triangle probably got us derailed\n");
|
||||||
}
|
}
|
||||||
return fv2;
|
return fv2;
|
||||||
}
|
}
|
||||||
@ -504,7 +506,7 @@ namespace NvTriStrip
|
|||||||
bool bv0, bv1, bv2; //bools to indicate whether a vertex is in the faceVec or not
|
bool bv0, bv1, bv2; //bools to indicate whether a vertex is in the faceVec or not
|
||||||
bv0 = bv1 = bv2 = false;
|
bv0 = bv1 = bv2 = false;
|
||||||
|
|
||||||
for(int i = 0; i < faceVec.size(); i++)
|
for(unsigned int i = 0; i < faceVec.size(); i++)
|
||||||
{
|
{
|
||||||
if(!bv0)
|
if(!bv0)
|
||||||
{
|
{
|
||||||
@ -625,7 +627,7 @@ namespace NvTriStrip
|
|||||||
// tempAllFaces is going to be forwardFaces + backwardFaces
|
// tempAllFaces is going to be forwardFaces + backwardFaces
|
||||||
// it's used for Unique()
|
// it's used for Unique()
|
||||||
NvFaceInfoVec tempAllFaces;
|
NvFaceInfoVec tempAllFaces;
|
||||||
for(int i = 0; i < forwardFaces.size(); i++)
|
for(unsigned int i = 0; i < forwardFaces.size(); i++)
|
||||||
tempAllFaces.push_back(forwardFaces[i]);
|
tempAllFaces.push_back(forwardFaces[i]);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -703,15 +705,14 @@ namespace NvTriStrip
|
|||||||
//
|
//
|
||||||
void NvStripInfo::Combine(const NvFaceInfoVec &forward, const NvFaceInfoVec &backward){
|
void NvStripInfo::Combine(const NvFaceInfoVec &forward, const NvFaceInfoVec &backward){
|
||||||
|
|
||||||
int i;
|
|
||||||
// add backward faces
|
// add backward faces
|
||||||
int numFaces = backward.size();
|
int numFaces = backward.size();
|
||||||
for (i = numFaces - 1; i >= 0; i--)
|
for (int i = numFaces - 1; i >= 0; i--)
|
||||||
m_faces.push_back(backward[i]);
|
m_faces.push_back(backward[i]);
|
||||||
|
|
||||||
// add forward faces
|
// add forward faces
|
||||||
numFaces = forward.size();
|
numFaces = forward.size();
|
||||||
for (i = 0; i < numFaces; i++)
|
for (int i = 0; i < numFaces; i++)
|
||||||
m_faces.push_back(forward[i]);
|
m_faces.push_back(forward[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,12 +837,12 @@ namespace NvTriStrip
|
|||||||
allBigStrips.clear(); //make sure these are empty
|
allBigStrips.clear(); //make sure these are empty
|
||||||
NvFaceInfoVec tempFaceList;
|
NvFaceInfoVec tempFaceList;
|
||||||
|
|
||||||
for(int i = 0; i < allStrips.size(); i++)
|
for(unsigned int i = 0; i < allStrips.size(); i++)
|
||||||
{
|
{
|
||||||
if(allStrips[i]->m_faces.size() < minStripLength)
|
if(allStrips[i]->m_faces.size() < minStripLength)
|
||||||
{
|
{
|
||||||
//strip is too small, add faces to faceList
|
//strip is too small, add faces to faceList
|
||||||
for(int j = 0; j < allStrips[i]->m_faces.size(); j++)
|
for(unsigned int j = 0; j < allStrips[i]->m_faces.size(); j++)
|
||||||
tempFaceList.push_back(allStrips[i]->m_faces[j]);
|
tempFaceList.push_back(allStrips[i]->m_faces[j]);
|
||||||
|
|
||||||
//and free memory
|
//and free memory
|
||||||
@ -869,7 +870,7 @@ namespace NvTriStrip
|
|||||||
bestNumHits = -1;
|
bestNumHits = -1;
|
||||||
|
|
||||||
//find best face to add next, given the current cache
|
//find best face to add next, given the current cache
|
||||||
for(int i = 0; i < tempFaceList.size(); i++)
|
for(unsigned int i = 0; i < tempFaceList.size(); i++)
|
||||||
{
|
{
|
||||||
if(bVisitedList[i])
|
if(bVisitedList[i])
|
||||||
continue;
|
continue;
|
||||||
@ -1106,7 +1107,7 @@ namespace NvTriStrip
|
|||||||
int numSamples = 10;
|
int numSamples = 10;
|
||||||
|
|
||||||
//the cache size, clamped to one
|
//the cache size, clamped to one
|
||||||
cacheSize = max(1, in_cacheSize - CACHE_INEFFICIENCY);
|
cacheSize = std::max(1, in_cacheSize - CACHE_INEFFICIENCY);
|
||||||
|
|
||||||
minStripLength = in_minStripLength; //this is the strip size threshold below which we dump the strip into a list
|
minStripLength = in_minStripLength; //this is the strip size threshold below which we dump the strip into a list
|
||||||
|
|
||||||
@ -1126,14 +1127,13 @@ namespace NvTriStrip
|
|||||||
//split up the strips into cache friendly pieces, optimize them, then dump these into outStrips
|
//split up the strips into cache friendly pieces, optimize them, then dump these into outStrips
|
||||||
SplitUpStripsAndOptimize(allStrips, outStrips, allEdgeInfos, outFaceList);
|
SplitUpStripsAndOptimize(allStrips, outStrips, allEdgeInfos, outFaceList);
|
||||||
|
|
||||||
int i;
|
|
||||||
//clean up
|
//clean up
|
||||||
for(i = 0; i < allStrips.size(); i++)
|
for(unsigned int i = 0; i < allStrips.size(); i++)
|
||||||
{
|
{
|
||||||
delete allStrips[i];
|
delete allStrips[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < allEdgeInfos.size(); i++)
|
for (unsigned int i = 0; i < allEdgeInfos.size(); i++)
|
||||||
{
|
{
|
||||||
NvEdgeInfo *info = allEdgeInfos[i];
|
NvEdgeInfo *info = allEdgeInfos[i];
|
||||||
while (info != nullptr)
|
while (info != nullptr)
|
||||||
@ -1143,10 +1143,8 @@ namespace NvTriStrip
|
|||||||
info = next;
|
info = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NvStripifier::IsDegenerate(const NvFaceInfo* face)
|
bool NvStripifier::IsDegenerate(const NvFaceInfo* face)
|
||||||
{
|
{
|
||||||
if(face->m_v0 == face->m_v1)
|
if(face->m_v0 == face->m_v1)
|
||||||
@ -1185,13 +1183,13 @@ namespace NvTriStrip
|
|||||||
NvStripInfoVec tempStrips;
|
NvStripInfoVec tempStrips;
|
||||||
|
|
||||||
//split up strips into threshold-sized pieces
|
//split up strips into threshold-sized pieces
|
||||||
for(int i = 0; i < allStrips.size(); i++)
|
for(unsigned int i = 0; i < allStrips.size(); i++)
|
||||||
{
|
{
|
||||||
NvStripInfo* currentStrip;
|
NvStripInfo* currentStrip;
|
||||||
NvStripStartInfo startInfo(nullptr, nullptr, false);
|
NvStripStartInfo startInfo(nullptr, nullptr, false);
|
||||||
|
|
||||||
int actualStripSize = 0;
|
int actualStripSize = 0;
|
||||||
for(int j = 0; j < allStrips[i]->m_faces.size(); ++j)
|
for(unsigned int j = 0; j < allStrips[i]->m_faces.size(); ++j)
|
||||||
{
|
{
|
||||||
if( !IsDegenerate(allStrips[i]->m_faces[j]) )
|
if( !IsDegenerate(allStrips[i]->m_faces[j]) )
|
||||||
actualStripSize++;
|
actualStripSize++;
|
||||||
@ -1204,7 +1202,7 @@ namespace NvTriStrip
|
|||||||
int numLeftover = actualStripSize /*allStrips[i]->m_faces.size()*/ % threshold;
|
int numLeftover = actualStripSize /*allStrips[i]->m_faces.size()*/ % threshold;
|
||||||
|
|
||||||
int degenerateCount = 0;
|
int degenerateCount = 0;
|
||||||
int j;
|
int j = 0;
|
||||||
for(j = 0; j < numTimes; j++)
|
for(j = 0; j < numTimes; j++)
|
||||||
{
|
{
|
||||||
currentStrip = new NvStripInfo(startInfo, 0, -1);
|
currentStrip = new NvStripInfo(startInfo, 0, -1);
|
||||||
@ -1308,7 +1306,7 @@ namespace NvTriStrip
|
|||||||
// this way we can delete allBigStrips later to free the memory
|
// this way we can delete allBigStrips later to free the memory
|
||||||
currentStrip = new NvStripInfo(startInfo, 0, -1);
|
currentStrip = new NvStripInfo(startInfo, 0, -1);
|
||||||
|
|
||||||
for(int j = 0; j < allStrips[i]->m_faces.size(); j++)
|
for(unsigned int j = 0; j < allStrips[i]->m_faces.size(); j++)
|
||||||
currentStrip->m_faces.push_back(allStrips[i]->m_faces[j]);
|
currentStrip->m_faces.push_back(allStrips[i]->m_faces[j]);
|
||||||
|
|
||||||
tempStrips.push_back(currentStrip);
|
tempStrips.push_back(currentStrip);
|
||||||
@ -1337,12 +1335,12 @@ namespace NvTriStrip
|
|||||||
int firstIndex = 0;
|
int firstIndex = 0;
|
||||||
float minCost = 10000.0f;
|
float minCost = 10000.0f;
|
||||||
|
|
||||||
for(int i = 0; i < tempStrips2.size(); i++)
|
for(unsigned int i = 0; i < tempStrips2.size(); i++)
|
||||||
{
|
{
|
||||||
int numNeighbors = 0;
|
int numNeighbors = 0;
|
||||||
|
|
||||||
//find strip with least number of neighbors per face
|
//find strip with least number of neighbors per face
|
||||||
for(int j = 0; j < tempStrips2[i]->m_faces.size(); j++)
|
for(unsigned int j = 0; j < tempStrips2[i]->m_faces.size(); j++)
|
||||||
{
|
{
|
||||||
numNeighbors += NumNeighbors(tempStrips2[i]->m_faces[j], edgeInfos);
|
numNeighbors += NumNeighbors(tempStrips2[i]->m_faces[j], edgeInfos);
|
||||||
}
|
}
|
||||||
@ -1369,7 +1367,7 @@ namespace NvTriStrip
|
|||||||
bestNumHits = -1.0f;
|
bestNumHits = -1.0f;
|
||||||
|
|
||||||
//find best strip to add next, given the current cache
|
//find best strip to add next, given the current cache
|
||||||
for(int i = 0; i < tempStrips2.size(); i++)
|
for(unsigned int i = 0; i < tempStrips2.size(); i++)
|
||||||
{
|
{
|
||||||
if(tempStrips2[i]->visited)
|
if(tempStrips2[i]->visited)
|
||||||
continue;
|
continue;
|
||||||
@ -1444,7 +1442,7 @@ namespace NvTriStrip
|
|||||||
//
|
//
|
||||||
void NvStripifier::UpdateCacheStrip(VertexCache* vcache, NvStripInfo* strip)
|
void NvStripifier::UpdateCacheStrip(VertexCache* vcache, NvStripInfo* strip)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < strip->m_faces.size(); ++i)
|
for(unsigned int i = 0; i < strip->m_faces.size(); ++i)
|
||||||
{
|
{
|
||||||
if(!vcache->InCache(strip->m_faces[i]->m_v0))
|
if(!vcache->InCache(strip->m_faces[i]->m_v0))
|
||||||
vcache->AddEntry(strip->m_faces[i]->m_v0);
|
vcache->AddEntry(strip->m_faces[i]->m_v0);
|
||||||
@ -1485,7 +1483,7 @@ namespace NvTriStrip
|
|||||||
int numHits = 0;
|
int numHits = 0;
|
||||||
int numFaces = 0;
|
int numFaces = 0;
|
||||||
|
|
||||||
for(int i = 0; i < strip->m_faces.size(); i++)
|
for(unsigned int i = 0; i < strip->m_faces.size(); i++)
|
||||||
{
|
{
|
||||||
if(vcache->InCache(strip->m_faces[i]->m_v0))
|
if(vcache->InCache(strip->m_faces[i]->m_v0))
|
||||||
++numHits;
|
++numHits;
|
||||||
@ -1721,7 +1719,7 @@ namespace NvTriStrip
|
|||||||
{
|
{
|
||||||
NvStripInfo* currStrip = experiments[i][j];
|
NvStripInfo* currStrip = experiments[i][j];
|
||||||
//delete all bogus faces in the experiments
|
//delete all bogus faces in the experiments
|
||||||
for (int k = 0; k < currStrip->m_faces.size(); ++k)
|
for (unsigned int k = 0; k < currStrip->m_faces.size(); ++k)
|
||||||
{
|
{
|
||||||
if(currStrip->m_faces[k]->m_bIsFake)
|
if(currStrip->m_faces[k]->m_bIsFake)
|
||||||
{
|
{
|
||||||
|
@ -2,13 +2,15 @@
|
|||||||
#define NV_TRISTRIP_OBJECTS_H
|
#define NV_TRISTRIP_OBJECTS_H
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <windows.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "VertexCache.h"
|
#include "VertexCache.h"
|
||||||
|
|
||||||
namespace NvTriStrip
|
namespace NvTriStrip
|
||||||
{
|
{
|
||||||
|
typedef unsigned int UINT;
|
||||||
|
typedef long WORD;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Types defined for stripification
|
// Types defined for stripification
|
||||||
@ -27,6 +29,7 @@ namespace NvTriStrip
|
|||||||
float nx, ny, nz;
|
float nx, ny, nz;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class NvFaceInfo {
|
class NvFaceInfo {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -192,7 +195,7 @@ namespace NvTriStrip
|
|||||||
|
|
||||||
WordVec indices;
|
WordVec indices;
|
||||||
int cacheSize;
|
int cacheSize;
|
||||||
int minStripLength;
|
unsigned int minStripLength;
|
||||||
float meshJump;
|
float meshJump;
|
||||||
bool bFirstTimeResetPoint;
|
bool bFirstTimeResetPoint;
|
||||||
|
|
||||||
@ -237,7 +240,7 @@ namespace NvTriStrip
|
|||||||
|
|
||||||
// let our strip info classes and the other classes get
|
// let our strip info classes and the other classes get
|
||||||
// to these protected stripificaton methods if they want
|
// to these protected stripificaton methods if they want
|
||||||
friend NvStripInfo;
|
friend class NvStripInfo;
|
||||||
};
|
};
|
||||||
}//namespace NvTriStrip
|
}//namespace NvTriStrip
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef VERTEX_CACHE_H
|
#ifndef VERTEX_CACHE_H
|
||||||
#define VERTEX_CACHE_H
|
#define VERTEX_CACHE_H
|
||||||
|
|
||||||
#include<string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace NvTriStrip
|
namespace NvTriStrip
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ namespace NvTriStrip
|
|||||||
}
|
}
|
||||||
|
|
||||||
VertexCache() { VertexCache(16); }
|
VertexCache() { VertexCache(16); }
|
||||||
~VertexCache() { delete[] entries; entries = nullptr; }
|
~VertexCache() { delete[] entries; entries = 0; }
|
||||||
|
|
||||||
bool InCache(int entry)
|
bool InCache(int entry)
|
||||||
{
|
{
|
||||||
@ -74,6 +74,7 @@ namespace NvTriStrip
|
|||||||
|
|
||||||
int *entries;
|
int *entries;
|
||||||
int numEntries;
|
int numEntries;
|
||||||
|
|
||||||
};
|
};
|
||||||
}//namespace NvTriStrip
|
}//namespace NvTriStrip
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user