Class NvStripifier
java.lang.Object
com.ardor3d.extension.model.util.nvtristrip.NvStripifier
Ported from NVIDIA's NvTriStrip Library
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected boolean
protected float
protected int
static int
private static final Logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) boolean
alreadyExists
(NvFaceInfo toFind, List<NvFaceInfo> faceInfos) (package private) float
avgStripSize
(List<NvStripInfo> strips) (package private) void
buildStripifyInfo
(List<NvFaceInfo> faceInfos, List<NvEdgeInfo> edgeInfos, int maxIndex) Builds the list of all face and edge infos(package private) int
calcNumHitsFace
(VertexCache vcache, NvFaceInfo face) (package private) float
calcNumHitsStrip
(VertexCache vcache, NvStripInfo strip) (package private) void
commitStrips
(List<NvStripInfo> allStrips, List<NvStripInfo> strips) "Commits" the input strips by setting their m_experimentId to -1 and adding to the allStrips vector(package private) int
createStrips
(List<NvStripInfo> allStrips, List<Integer> stripIndices, boolean bStitchStrips, boolean bRestart, int restartVal) Generates actual strips from the list-in-strip-order.(package private) void
findAllStrips
(List<NvStripInfo> allStrips, List<NvFaceInfo> allFaceInfos, List<NvEdgeInfo> allEdgeInfos, int numSamples) Does the stripification, puts output strips into vector allStrips Works by setting running a number of experiments in different areas of the mesh, and accepting the one which results in the longest strips.(package private) static NvEdgeInfo
findEdgeInfo
(List<NvEdgeInfo> edgeInfos, int v0, int v1) find the edge info for these two indices(package private) NvFaceInfo
findGoodResetPoint
(List<NvFaceInfo> faceInfos, List<NvEdgeInfo> edgeInfos) A good reset point is one near other committed areas so that we know that when we've made the longest strips its because we're stripifying in the same general orientation.(package private) static NvFaceInfo
findOtherFace
(List<NvEdgeInfo> edgeInfos, int v0, int v1, NvFaceInfo faceInfo) find the other face sharing these vertices(package private) int
findStartPoint
(List<NvFaceInfo> faceInfos, List<NvEdgeInfo> edgeInfos) Finds a good starting point, namely one which has only one neighbor(package private) boolean
findTraversal
(List<NvFaceInfo> faceInfos, List<NvEdgeInfo> edgeInfos, NvStripInfo strip, NvStripStartInfo startInfo) Finds the next face to start the next strip on.(package private) static int
getNextIndex
(List<Integer> indices, NvFaceInfo face) (package private) static int[]
getSharedVertices
(NvFaceInfo faceA, NvFaceInfo faceB) (package private) static int
getUniqueVertexInB
(NvFaceInfo faceA, NvFaceInfo faceB) (package private) static boolean
isCW
(NvFaceInfo faceInfo, int v0, int v1) (package private) static boolean
isDegenerate
(int v0, int v1, int v2) (package private) static boolean
isDegenerate
(NvFaceInfo face) (package private) static boolean
nextIsCW
(int numIndices) (package private) int
numNeighbors
(NvFaceInfo face, List<NvEdgeInfo> edgeInfoVec) (package private) void
removeSmallStrips
(List<NvStripInfo> allStrips, List<NvStripInfo> allBigStrips, List<NvFaceInfo> faceList) (package private) void
splitUpStripsAndOptimize
(List<NvStripInfo> allStrips, List<NvStripInfo> outStrips, List<NvEdgeInfo> edgeInfos, List<NvFaceInfo> outFaceList) Splits the input vector of strips (allBigStrips) into smaller, cache friendly pieces, then reorders these pieces to maximize cache hits.(package private) void
stripify
(List<Integer> in_indices, int in_cacheSize, int in_minStripLength, int maxIndex, List<NvStripInfo> outStrips, List<NvFaceInfo> outFaceList) (package private) void
updateCacheFace
(VertexCache vcache, NvFaceInfo face) Updates the input vertex cache with this face's vertices(package private) void
updateCacheStrip
(VertexCache vcache, NvStripInfo strip) Updates the input vertex cache with this strip's vertices
-
Field Details
-
logger
-
CACHE_INEFFICIENCY
-
_indices
-
_cacheSize
-
_minStripLength
-
_meshJump
-
_firstTimeResetPoint
-
-
Constructor Details
-
NvStripifier
-
-
Method Details
-
stripify
void stripify(List<Integer> in_indices, int in_cacheSize, int in_minStripLength, int maxIndex, List<NvStripInfo> outStrips, List<NvFaceInfo> outFaceList) - Parameters:
in_indices
- the input indices of the mesh to stripifyin_cacheSize
- the target cache sizein_minStripLength
- the minimum strip lengthmaxIndex
- the maximum indexoutStrips
- the stripsoutFaceList
- the face list
-
createStrips
int createStrips(List<NvStripInfo> allStrips, List<Integer> stripIndices, boolean bStitchStrips, boolean bRestart, int restartVal) Generates actual strips from the list-in-strip-order.- Parameters:
allStrips
- all stripsstripIndices
- the strip indicesbStitchStrips
-true
if the strips are stitchedbRestart
-true
if it restartsrestartVal
- restart value- Returns:
- the number of separate strips
-
getUniqueVertexInB
- Parameters:
faceA
- the face AfaceB
- the face B- Returns:
- the first vertex unique to faceB
-
isDegenerate
-
isDegenerate
-
isCW
- Parameters:
faceInfo
- the face infov0
- the vertex 0v1
- the vertex 1- Returns:
true
if the face is ordered in CW fashion
-
nextIsCW
- Parameters:
numIndices
- the number of indices- Returns:
true
if the next face should be ordered in CW fashion
-
getNextIndex
- Parameters:
indices
- the indicesface
- the face- Returns:
- vertex of the input face which is "next" in the input index list
-
findEdgeInfo
find the edge info for these two indices- Parameters:
edgeInfos
- the edge infosv0
- the vertex 0v1
- the vertex 1- Returns:
- the edge info
-
findOtherFace
find the other face sharing these vertices- Parameters:
edgeInfos
- the edge infosv0
- the vertex 0v1
- the vertex 1faceInfo
- the face info- Returns:
- the other face sharing these vertices
-
findGoodResetPoint
A good reset point is one near other committed areas so that we know that when we've made the longest strips its because we're stripifying in the same general orientation.- Parameters:
faceInfos
- the face infosedgeInfos
- the edge infos- Returns:
- the good reset point
-
findAllStrips
void findAllStrips(List<NvStripInfo> allStrips, List<NvFaceInfo> allFaceInfos, List<NvEdgeInfo> allEdgeInfos, int numSamples) Does the stripification, puts output strips into vector allStrips Works by setting running a number of experiments in different areas of the mesh, and accepting the one which results in the longest strips. It then accepts this, and moves on to a different area of the mesh. We try to jump around the mesh some, to ensure that large open spans of strips get generated.- Parameters:
allStrips
- all stripsallFaceInfos
- all face infosallEdgeInfos
- all edge infosnumSamples
- the number of samples
-
splitUpStripsAndOptimize
void splitUpStripsAndOptimize(List<NvStripInfo> allStrips, List<NvStripInfo> outStrips, List<NvEdgeInfo> edgeInfos, List<NvFaceInfo> outFaceList) Splits the input vector of strips (allBigStrips) into smaller, cache friendly pieces, then reorders these pieces to maximize cache hits. The final strips are stored in outStrips- Parameters:
allStrips
- all stripsoutStrips
- the resulting stripsedgeInfos
- the edge infosoutFaceList
- the resulting face list
-
removeSmallStrips
void removeSmallStrips(List<NvStripInfo> allStrips, List<NvStripInfo> allBigStrips, List<NvFaceInfo> faceList) - Parameters:
allStrips
- the whole strip vector...all small strips will be deleted from this list, to avoid leaking memallBigStrips
- an out parameter which will contain all strips above minStripLengthfaceList
- an out parameter which will contain all faces which were removed from the striplist
-
findTraversal
boolean findTraversal(List<NvFaceInfo> faceInfos, List<NvEdgeInfo> edgeInfos, NvStripInfo strip, NvStripStartInfo startInfo) Finds the next face to start the next strip on.- Parameters:
faceInfos
- the face infosedgeInfos
- the edge infosstrip
- the stripstartInfo
- the start info- Returns:
true
if the next face to start the next strip on is found
-
commitStrips
"Commits" the input strips by setting their m_experimentId to -1 and adding to the allStrips vector- Parameters:
allStrips
- all stripsstrips
- the strips
-
avgStripSize
- Parameters:
strips
- the strips- Returns:
- the average strip size of the input vector of strips
-
findStartPoint
Finds a good starting point, namely one which has only one neighbor- Parameters:
faceInfos
- the face infosedgeInfos
- the edge infos- Returns:
- the good starting point or -1
-
updateCacheStrip
Updates the input vertex cache with this strip's vertices- Parameters:
vcache
- the vertex cachestrip
- the strip
-
updateCacheFace
Updates the input vertex cache with this face's vertices- Parameters:
vcache
- the vertex cacheface
- the face
-
calcNumHitsStrip
- Parameters:
vcache
- the vertex cachestrip
- the strip- Returns:
- the number of cache hits per face in the strip
-
calcNumHitsFace
- Parameters:
vcache
- the vertex cacheface
- the face- Returns:
- the number of cache hits in the face
-
numNeighbors
- Parameters:
face
- the faceedgeInfoVec
- the edge info list- Returns:
- the number of neighbors that this face has
-
buildStripifyInfo
Builds the list of all face and edge infos- Parameters:
faceInfos
- the face infosedgeInfos
- the edge infosmaxIndex
- the maximum index
-
alreadyExists
-