[Plib-devel] How many triangles in a leaf?
Brought to you by:
sjbaker
From: Paolo L. <p.l...@ci...> - 2007-06-19 08:31:47
|
Dear Plib friends, I'd faced again (see my post on the list "Large geometry objects and crash in ssgLOS" on 2005-11-24) with the unclear limit on the number of primitives the IndexArray can index. Even if we accept filling the VertexArray with no more than sizeof(short) vertices, the problem is that we can't index more than sizeof(short)/3 triangles per ssgVtxTable (and derived leaf types), and it only arises when doing LOS or other queries on the geometry. Look at the code in ssgVtxArray.cxx: void ssgVtxArray::getTriangle ( int n, short *v1, short *v2, short *v3 ) { short vv1, vv2, vv3 ; ssgVtxTable::getTriangle ( n, &vv1, &vv2, &vv3 ) ; *v1 = *( indices -> get ( vv1 ) ) ; *v2 = *( indices -> get ( vv2 ) ) ; *v3 = *( indices -> get ( vv3 ) ) ; } ssgIndexArray::get would take unsigned int argument type, but it is fed with the results from ssgVtxTable::getTriangle, which does return short indices. Thus, by summarizing: max number of triangles in LOS-compatible ssgVtxTable and ssgVtxArray: 10922. For overcoming the limit we could either - leave such limitaion for ssgVtxTable, yet making ssgVtxArray::getTriangle independent of the ssgVtxTable::getTriangle call; Or - change the return type for ssgVtxTable::getTriangle indices to unsigned int; Or even - introduce a private method ssgVtxTable::getTriangle( int n, unsigned int *v1, unsigned int *v2, unsigned int *v3 ), and call this from both the official ssgVtxTable::getTriangle ( int n, short *v1, short *v2, short *v3 ) and from the ssgVtxArray::getTriangle above. Waiting for reactions - Paolo |