| | 460 | void group_split_context::greedy_split( size_t max_verts, |
|---|
| | 461 | size_t max_prims, size_t max_influences ) |
|---|
| | 462 | { |
|---|
| | 463 | for( size_t i_prim = 0; i_prim < prim_count; i_prim++ ) |
|---|
| | 464 | { |
|---|
| | 465 | //find the best group to add this triangle to |
|---|
| | 466 | |
|---|
| | 467 | group_split_target_ptr target; |
|---|
| | 468 | size_t target_vert_cost, target_inf_cost; |
|---|
| | 469 | |
|---|
| | 470 | for( size_t j = 0; j < target_groups.size(); j++ ) |
|---|
| | 471 | { |
|---|
| | 472 | group_split_target_ptr candidate = target_groups[j]; |
|---|
| | 473 | |
|---|
| | 474 | //see if this candidate even has room for the insert |
|---|
| | 475 | if( candidate->prim_count + 1 > max_prims ) |
|---|
| | 476 | continue; |
|---|
| | 477 | |
|---|
| | 478 | size_t vert_cost, inf_cost; |
|---|
| | 479 | candidate->compute_append_prim_cost( i_prim, vert_cost, inf_cost ); |
|---|
| | 480 | |
|---|
| | 481 | if( candidate->vertex_count() + vert_cost > max_verts ) |
|---|
| | 482 | continue; |
|---|
| | 483 | if( candidate->influences.size() + inf_cost > max_influences ) |
|---|
| | 484 | continue; |
|---|
| | 485 | |
|---|
| | 486 | //it's OK to add to this group, see if it's the best one |
|---|
| | 487 | if( !target || inf_cost < target_inf_cost || |
|---|
| | 488 | (inf_cost == target_inf_cost && vert_cost < target_vert_cost ) ) |
|---|
| | 489 | { |
|---|
| | 490 | target = candidate; |
|---|
| | 491 | target_vert_cost = vert_cost; |
|---|
| | 492 | target_inf_cost = inf_cost; |
|---|
| | 493 | } |
|---|
| | 494 | } |
|---|
| | 495 | |
|---|
| | 496 | if( !target ) |
|---|
| | 497 | target = create_target(); |
|---|
| | 498 | |
|---|
| | 499 | target->append_prim( i_prim ); |
|---|
| | 500 | } |
|---|
| | 501 | } |
|---|
| | 502 | |
|---|
| | 503 | void group_split_context::topological_split( size_t max_verts, |
|---|
| | 504 | size_t max_prims, size_t max_influences ) |
|---|
| | 505 | { |
|---|
| | 506 | if( elems_per_prim != 3 ) |
|---|
| | 507 | throw error( "Topological split only works on triangles." ); |
|---|
| | 508 | |
|---|
| | 509 | |
|---|
| | 510 | } |
|---|
| | 511 | |
|---|