Package pyffi :: Package utils :: Module vertex_cache
[hide private]
[frames] | no frames]

Module vertex_cache

source code

Algorithms to reorder triangle list order and vertex order aiming to minimize vertex cache misses.

This is effectively an implementation of 'Linear-Speed Vertex Cache Optimisation' by Tom Forsyth, 28th September 2006 http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html

Classes [hide private]
  VertexScore
Vertex score calculation.
  VertexInfo
Stores information about a vertex.
  TriangleInfo
  Mesh
Simple mesh implementation which keeps track of which triangles are used by which vertex, and vertex cache positions.
Functions [hide private]
 
get_cache_optimized_triangles(triangles)
Calculate cache optimized triangles, and return the result as a reordered set of triangles or strip of stitched triangles.
source code
 
get_unique_triangles(triangles)
Yield unique triangles.
source code
 
stable_stripify(triangles, stitchstrips=False)
Stitch all triangles together into a strip without changing the triangle ordering (for example because their ordering is already optimized).
source code
 
stripify(triangles, stitchstrips=False)
Stripify triangles, optimizing for the vertex cache.
source code
 
get_cache_optimized_vertex_map(strips)
Map vertices so triangles/strips have consequetive indices.
source code
 
average_transform_to_vertex_ratio(strips, cache_size=16)
Calculate number of transforms per vertex for a given cache size and triangles/strips.
source code
Variables [hide private]
  __package__ = 'pyffi.utils'
Function Details [hide private]

get_cache_optimized_triangles(triangles)

source code 
Calculate cache optimized triangles, and return the result as a reordered set of triangles or strip of stitched triangles.
Parameters:
  • triangles - The triangles (triples of vertex indices).
Returns:
A list of reordered triangles.

stable_stripify(triangles, stitchstrips=False)

source code 

Stitch all triangles together into a strip without changing the triangle ordering (for example because their ordering is already optimized).

>>> stable_stripify([(0, 1, 2), (2, 1, 4)])
[[0, 1, 2, 4]]
>>> stable_stripify([(0, 1, 2), (2, 3, 4)])
[[0, 1, 2], [2, 3, 4]]
>>> stable_stripify([(0, 1, 2), (2, 1, 3), (2, 3, 4), (1, 4, 5), (5, 4, 6)])
[[0, 1, 2, 3, 4], [1, 4, 5, 6]]
>>> stable_stripify([(0, 1, 2), (0, 3, 1), (0, 4, 3), (3, 5, 1), (6, 3, 4)])
[[2, 0, 1, 3], [0, 4, 3], [3, 5, 1], [6, 3, 4]]
Parameters:
  • triangles - The triangles (triples of vertex indices).
Returns:
A list of strips (list of vertex indices).

average_transform_to_vertex_ratio(strips, cache_size=16)

source code 
Calculate number of transforms per vertex for a given cache size and triangles/strips. See http://castano.ludicon.com/blog/2009/01/29/acmr/