Changeset 523

Show
Ignore:
Timestamp:
02/25/08 15:52:26 (11 months ago)
Author:
phill
Message:

o Getting up to speed on the splitting algorithms. Whee!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/morph-targets/libx42make/include/x42make-modelbuilder.h

    r522 r523  
    6161        void intrusive_ptr_release( const ref_obj *r ); 
    6262 
     63        class group_split_target; 
     64        class group_split_context; 
     65 
    6366        class model_data_builder; 
    6467}; 
     
    442445        void remap_vertices( const std::vector< index > &remap ); 
    443446 
     447        std::vector< index > get_point_list_indices() const; 
     448        std::vector< index > get_line_list_indices() const; 
    444449        std::vector< index > get_triangle_list_indices() const; 
     450 
     451        std::vector< index > get_list_indices() const; 
    445452 
    446453        X42_DECLARE_ENUM( optimize_type ) 
     
    454461        size_t vertex_count() const { return base_shape.size(); } 
    455462        size_t index_count() const { return indices.size(); } 
     463        size_t element_count() const { return indices.size() ? indices.size() : vertex_count(); } 
     464        size_t primitive_count() const { return prim_type.elems_to_prims( (uint)element_count() ); } 
    456465 
    457466        size_t count_max_influences_per_vert() const; 
     
    467476 
    468477        friend class model_builder; 
     478 
     479        friend class _impl::group_split_target; 
     480        friend class _impl::group_split_context; 
    469481}; 
    470482 
     
    482494 
    483495        friend class lod; 
     496 
     497        friend class _impl::group_split_target; 
     498        friend class _impl::group_split_context; 
    484499}; 
    485500 
  • branches/morph-targets/libx42make/libx42make.vcproj

    r521 r523  
    661661                </File> 
    662662                <File 
     663                        RelativePath=".\modelbuilder-batch.cpp" 
     664                        > 
     665                </File> 
     666                <File 
    663667                        RelativePath=".\modelbuilder-cull.cpp" 
    664668                        > 
  • branches/morph-targets/libx42make/modelbuilder-geometry.cpp

    r521 r523  
    239239} 
    240240 
     241std::vector< index > geometry::get_point_list_indices() const 
     242{ 
     243        if( prim_type != primitive_type::point_list ) 
     244                throw error( "Can't get point indices for non-point geometry." ); 
     245 
     246        std::vector< index > ret; 
     247 
     248        if( indices.size() ) 
     249        { 
     250                ret.insert( ret.end(), indices.begin(), indices.end() ); 
     251        } 
     252        else 
     253        { 
     254                ret.resize( vertex_count() ); 
     255                for( size_t i = 0; i < ret.size(); i++ ) 
     256                        ret[i] = (index)i; 
     257        } 
     258 
     259        return ret; 
     260} 
     261 
     262std::vector< index > geometry::get_line_list_indices() const 
     263{ 
     264        switch( prim_type ) 
     265        { 
     266        case primitive_type::line_list: 
     267        case primitive_type::line_strip: 
     268                break; 
     269 
     270        default: 
     271                throw error( "Can't get triangle indices for non-triangle geometry." ); 
     272        } 
     273 
     274        size_t elem_count = index_count() ? index_count() : vertex_count(); 
     275        size_t prim_count = (size_t)primitive_type::elems_to_prims( prim_type, (uint)elem_count ); 
     276 
     277        std::vector< index > ret( prim_count * 2 ); 
     278 
     279        if( prim_type == primitive_type::line_list && index_count() ) 
     280        { 
     281                if( indices.size() != ret.size() ) 
     282                        throw error( "Odd index count." ); 
     283 
     284                std::copy( indices.begin(), indices.end(), ret.begin() ); 
     285        } 
     286        else 
     287        { 
     288                size_t i = 0; 
     289 
     290                primitive_iterator< index > iter( prim_type, &indices[0], (uint)indices.size() ); 
     291                while( iter.next() ) 
     292                { 
     293                        ret[i + 0] = iter.current( 0 ); 
     294                        ret[i + 1] = iter.current( 1 ); 
     295 
     296                        i += 2; 
     297                } 
     298        } 
     299 
     300        return ret; 
     301} 
     302 
    241303std::vector< index > geometry::get_triangle_list_indices() const 
    242304{ 
     
    280342 
    281343        return ret; 
     344} 
     345 
     346std::vector< index > geometry::get_list_indices() const 
     347{ 
     348        switch( prim_type ) 
     349        { 
     350        case primitive_type::point_list: 
     351                return get_point_list_indices(); 
     352 
     353        case primitive_type::line_list: 
     354        case primitive_type::line_strip: 
     355                return get_line_list_indices(); 
     356 
     357        case primitive_type::triangle_list: 
     358        case primitive_type::triangle_strip: 
     359        case primitive_type::triangle_fan: 
     360                return get_triangle_list_indices(); 
     361 
     362        default: 
     363                throw error( "Invalid primitive type." ); 
     364        } 
    282365} 
    283366