@ -33,17 +33,17 @@ namespace Implementation {
class CombineIndexedArrays {
public :
template < class . . . T > std : : vector < unsigned in t> operator ( ) ( const std : : tuple < const std : : vector < unsigned in t> & , std : : vector < T > & > & . . . indexedArrays ) {
template < class . . . T > std : : vector < std : : uint32_ t> operator ( ) ( const std : : tuple < const std : : vector < std : : uint32_ t> & , std : : vector < T > & > & . . . indexedArrays ) {
/* Compute index count */
std : : size_t _indexCount = indexCount ( std : : get < 0 > ( indexedArrays ) . . . ) ;
/* Resulting index array */
std : : vector < unsigned in t> result ;
std : : vector < std : : uint32_ t> result ;
result . resize ( _indexCount ) ;
std : : iota ( result . begin ( ) , result . end ( ) , 0 ) ;
/* All index combinations */
std : : vector < Math : : Vector < sizeof . . . ( indexedArrays ) , unsigned in t> > indexCombinations ( _indexCount ) ;
std : : vector < Math : : Vector < sizeof . . . ( indexedArrays ) , std : : uint32_ t> > indexCombinations ( _indexCount ) ;
writeCombinedIndices ( indexCombinations , std : : get < 0 > ( indexedArrays ) . . . ) ;
/* Make the combinations unique */
@ -56,13 +56,13 @@ class CombineIndexedArrays {
}
private :
template < class . . . T > inline static std : : size_t indexCount ( const std : : vector < unsigned in t> & first , const std : : vector < T > & . . . next ) {
template < class . . . T > inline static std : : size_t indexCount ( const std : : vector < std : : uint32_ t> & first , const std : : vector < T > & . . . next ) {
CORRADE_ASSERT ( sizeof . . . ( next ) = = 0 | | indexCount ( next . . . ) = = first . size ( ) , " MeshTools::combineIndexedArrays(): index arrays don't have the same length, nothing done. " , 0 ) ;
return first . size ( ) ;
}
template < std : : size_t size , class . . . T > static void writeCombinedIndices ( std : : vector < Math : : Vector < size , unsigned in t> > & output , const std : : vector < unsigned in t> & first , const std : : vector < T > & . . . next ) {
template < std : : size_t size , class . . . T > static void writeCombinedIndices ( std : : vector < Math : : Vector < size , std : : uint32_ t> > & output , const std : : vector < std : : uint32_ t> & first , const std : : vector < T > & . . . next ) {
/* Copy the data to output */
for ( std : : size_t i = 0 ; i ! = output . size ( ) ; + + i )
output [ i ] [ size - sizeof . . . ( next ) - 1 ] = first [ i ] ;
@ -70,7 +70,7 @@ class CombineIndexedArrays {
writeCombinedIndices ( output , next . . . ) ;
}
template < std : : size_t size , class T , class . . . U > static void writeCombinedArrays ( const std : : vector < Math : : Vector < size , unsigned in t> > & combinedIndices , std : : vector < T > & first , std : : vector < U > & . . . next ) {
template < std : : size_t size , class T , class . . . U > static void writeCombinedArrays ( const std : : vector < Math : : Vector < size , std : : uint32_ t> > & combinedIndices , std : : vector < T > & first , std : : vector < U > & . . . next ) {
/* Rewrite output array */
std : : vector < T > output ;
for ( std : : size_t i = 0 ; i ! = combinedIndices . size ( ) ; + + i )
@ -82,8 +82,8 @@ class CombineIndexedArrays {
/* Terminator functions for recursive calls */
inline static std : : size_t indexCount ( ) { return 0 ; }
template < std : : size_t size > inline static void writeCombinedIndices ( std : : vector < Math : : Vector < size , unsigned in t> > & ) { }
template < std : : size_t size > inline static void writeCombinedArrays ( const std : : vector < Math : : Vector < size , unsigned in t> > & ) { }
template < std : : size_t size > inline static void writeCombinedIndices ( std : : vector < Math : : Vector < size , std : : uint32_ t> > & ) { }
template < std : : size_t size > inline static void writeCombinedArrays ( const std : : vector < Math : : Vector < size , std : : uint32_ t> > & ) { }
} ;
}
@ -105,13 +105,13 @@ avoid explicit verbose specification of tuple type, you can write it with help
of some STL functions like shown below . Also if one index array is shader by
more than one attribute array , just pass the index array more times . Example :
@ code
std : : vector < unsigned in t> vertexIndices ;
std : : vector < std : : uint32_ t> vertexIndices ;
std : : vector < Point3D > positions ;
std : : vector < unsigned in t> normalTextureIndices ;
std : : vector < std : : uint32_ t> normalTextureIndices ;
std : : vector < Vector3 > normals ;
std : : vector < Vector2 > textureCoordinates ;
std : : vector < unsigned in t> indices = MeshTools : : combineIndexedArrays (
std : : vector < std : : uint32_ t> indices = MeshTools : : combineIndexedArrays (
std : : make_tuple ( std : : cref ( vertexIndices ) , std : : ref ( positions ) ) ,
std : : make_tuple ( std : : cref ( normalTextureIndices ) , std : : ref ( normals ) ) ,
std : : make_tuple ( std : : cref ( normalTextureIndices ) , std : : ref ( textureCoordinates ) )
@ -127,7 +127,7 @@ attributes indexed with `indices`.
which parameter is index array and which is attribute array , mainly when
both are of the same type .
*/
template < class . . . T > std : : vector < unsigned in t> combineIndexedArrays ( const std : : tuple < const std : : vector < unsigned in t> & , std : : vector < T > & > & . . . indexedArrays ) {
template < class . . . T > std : : vector < std : : uint32_ t> combineIndexedArrays ( const std : : tuple < const std : : vector < std : : uint32_ t> & , std : : vector < T > & > & . . . indexedArrays ) {
return Implementation : : CombineIndexedArrays ( ) ( indexedArrays . . . ) ;
}