| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -17,37 +17,55 @@ void map_chain_to_parameteric_plane(const baked_blobtree_t& | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        patch_of_subface[subface_index].emplace_back(patch_index); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const auto& subfaces = tree.subfaces; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const auto&                          subfaces = tree.subfaces; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    stl_vector_mp<uint32_t>              unique_chain_indices{}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    flat_hash_map_mp<uint32_t, uint32_t> old_chain_index_to_unique_index{}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    auto                                 unique_end_iter = unique_chain_indices.begin(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    for (const auto& [subface_index, patch_indices] : patch_of_subface) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        const auto& subface                   = *subfaces[subface_index].object_ptr; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto        mapping_func              = subface.fetch_param_mapping_evaluator(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto&       parameteric_plane         = parameteric_planes[subface_index]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto&       chain_vertices            = parameteric_plane.chain_vertices; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto&       chain_group_start_indices = parameteric_plane.chain_group_start_indices; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto&       chain_vertex_flags        = parameteric_plane.vertex_special_flags; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        chain_group_start_indices.reserve(patch_indices.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        chain_group_start_indices.emplace_back(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        const auto& subface             = subfaces[subface_index].object_ptr.get(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto        mapping_func        = subface.fetch_param_mapping_evaluator(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto&       parameteric_plane   = parameteric_planes[subface_index]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto&       chain_vertices      = parameteric_plane.chain_vertices; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto&       chain_group_indices = parameteric_plane.chain_group_indices; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto&       chain_vertex_flags  = parameteric_plane.vertex_special_flags; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        chain_group_indices.reserve(patch_indices.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        unique_chain_indices.clear(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        old_chain_index_to_unique_index.clear(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (const auto& patch_index : patch_indices) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            const auto& chain_indices = chain_of_patch.at(patch_index); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            chain_group_start_indices.emplace_back(chain_indices.size() + chain_group_start_indices.back()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            chain_vertices.reserve(chain_vertices.size() + chain_indices.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            chain_vertex_flags.reserve(chain_vertex_flags.size() + chain_indices.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for (const auto& chain_index : chain_indices) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                const auto& chain = chains[chain_index]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            unique_chain_indices.insert(unique_chain_indices.end(), chain_indices.begin(), chain_indices.end()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        std::sort(unique_chain_indices.begin(), unique_chain_indices.end()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        unique_end_iter = std::unique(unique_chain_indices.begin(), unique_chain_indices.end()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (auto iter = unique_chain_indices.begin(); iter != unique_end_iter; ++iter) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            old_chain_index_to_unique_index[*iter] = std::distance(unique_chain_indices.begin(), iter); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        chain_vertices.reserve(unique_chain_indices.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        chain_vertex_flags.reserve(unique_chain_indices.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (const auto& chain_index : unique_chain_indices) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            const auto& chain = chains[chain_index]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            auto& chain_vertices_ = chain_vertices.emplace_back(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            chain_vertices_.resize(chain.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            std::transform(chain.begin(), chain.end(), chain_vertices_.begin(), [&](uint32_t vertex_index) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                auto mapped_vertex_index = vertex_old_index_to_unique_index.at(vertex_index); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                return mapping_func(vertices[mapped_vertex_index]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                auto& chain_vertices_ = chain_vertices.emplace_back(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                chain_vertices_.resize(chain.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                std::transform(chain.begin(), chain.end(), chain_vertices_.begin(), [&](uint32_t vertex_index) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    auto mapped_vertex_index = vertex_old_index_to_unique_index.at(vertex_index); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    return mapping_func(vertices[mapped_vertex_index]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            auto& chain_vertex_flags_ = chain_vertex_flags.emplace_back(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            chain_vertex_flags_.resize(chain.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            chain_vertex_flags_[0]                = chain_end_vertex_signular_flag[2 * chain_index]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            chain_vertex_flags_[chain.size() - 1] = chain_end_vertex_signular_flag[2 * chain_index + 1]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                auto& chain_vertex_flags_ = chain_vertex_flags.emplace_back(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                chain_vertex_flags_.resize(chain.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                chain_vertex_flags_[0]                = chain_end_vertex_signular_flag[2 * chain_index]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                chain_vertex_flags_[chain.size() - 1] = chain_end_vertex_signular_flag[2 * chain_index + 1]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (const auto& patch_index : patch_indices) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            const auto& chain_indices = chain_of_patch.at(patch_index); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            auto&       chain_group   = chain_group_indices.emplace_back(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            std::transform(chain_indices.begin(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                           chain_indices.end(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                           std::back_inserter(chain_group), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                           [&](uint32_t chain_index) { return old_chain_index_to_unique_index[chain_index]; }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |