Blender V5.0
subdiv_ccg.cc File Reference
#include "BKE_subdiv_ccg.hh"
#include "MEM_guardedalloc.h"
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_index_mask.hh"
#include "BLI_math_bits.h"
#include "BLI_math_geom.h"
#include "BLI_math_vector.h"
#include "BLI_set.hh"
#include "BLI_task.hh"
#include "BLI_vector_set.hh"
#include "BKE_ccg.hh"
#include "BKE_mesh.hh"
#include "BKE_subdiv.hh"
#include "BKE_subdiv_eval.hh"

Go to the source code of this file.

Classes

struct  GrainSize

Typedefs

using float3

Functions

Creation / evaluation
std::unique_ptr< SubdivCCGBKE_subdiv_to_ccg (Subdiv &subdiv, const SubdivToCCGSettings &settings, const Mesh &coarse_mesh, SubdivCCGMaskEvaluator *mask_evaluator)
MeshBKE_subdiv_to_ccg_mesh (Subdiv &subdiv, const SubdivToCCGSettings &settings, const Mesh &coarse_mesh)
CCGKey BKE_subdiv_ccg_key (const SubdivCCG &, int level)
CCGKey BKE_subdiv_ccg_key_top_level (const SubdivCCG &subdiv_ccg)
Normals
void BKE_subdiv_ccg_recalc_normals (SubdivCCG &subdiv_ccg)
void BKE_subdiv_ccg_update_normals (SubdivCCG &subdiv_ccg, const IndexMask &face_mask)
Boundary averaging/stitching
void BKE_subdiv_ccg_average_grids (SubdivCCG &subdiv_ccg)
void BKE_subdiv_ccg_average_stitch_faces (SubdivCCG &subdiv_ccg, const IndexMask &face_mask)
void BKE_subdiv_ccg_topology_counters (const SubdivCCG &subdiv_ccg, int &r_num_vertices, int &r_num_edges, int &r_num_faces, int &r_num_loops)
Neighbors
void BKE_subdiv_ccg_print_coord (const char *message, const SubdivCCGCoord &coord)
bool BKE_subdiv_ccg_check_coord_valid (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord)
BLI_INLINE void subdiv_ccg_neighbors_init (SubdivCCGNeighbors &neighbors, const int num_unique, const int num_duplicates)
BLI_INLINE bool is_corner_grid_coord (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord)
BLI_INLINE bool is_boundary_grid_coord (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord)
BLI_INLINE bool is_inner_edge_grid_coordinate (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord)
BLI_INLINE SubdivCCGCoord coord_at_prev_row (const SubdivCCG &, const SubdivCCGCoord &coord)
BLI_INLINE SubdivCCGCoord coord_at_next_row (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord)
BLI_INLINE SubdivCCGCoord coord_at_prev_col (const SubdivCCG &, const SubdivCCGCoord &coord)
BLI_INLINE SubdivCCGCoord coord_at_next_col (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord)
void BKE_subdiv_ccg_neighbor_coords_get (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, const bool include_duplicates, SubdivCCGNeighbors &r_neighbors)
static void adjacent_vertices_index_from_adjacent_edge (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, const blender::Span< int > corner_verts, const blender::OffsetIndices< int > faces, int &r_v1, int &r_v2)
SubdivCCGAdjacencyType BKE_subdiv_ccg_coarse_mesh_adjacency_info_get (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, const blender::Span< int > corner_verts, const blender::OffsetIndices< int > faces, int &r_v1, int &r_v2)
bool BKE_subdiv_ccg_coord_is_mesh_boundary (const OffsetIndices< int > faces, const Span< int > corner_verts, const blender::BitSpan boundary_verts, const SubdivCCG &subdiv_ccg, const SubdivCCGCoord coord)
blender::BitGroupVectorBKE_subdiv_ccg_grid_hidden_ensure (SubdivCCG &subdiv_ccg)
void BKE_subdiv_ccg_grid_hidden_free (SubdivCCG &subdiv_ccg)
static void subdiv_ccg_coord_to_ptex_coord (const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, int &r_ptex_face_index, float &r_u, float &r_v)
void BKE_subdiv_ccg_eval_limit_positions (const SubdivCCG &subdiv_ccg, const CCGKey &key, const int grid_index, const MutableSpan< float3 > r_limit_positions)

Typedef Documentation

◆ float3

Definition at line 619 of file BLI_math_vector_types.hh.

Function Documentation

◆ adjacent_vertices_index_from_adjacent_edge()

void adjacent_vertices_index_from_adjacent_edge ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord,
const blender::Span< int > corner_verts,
const blender::OffsetIndices< int > faces,
int & r_v1,
int & r_v2 )
static

◆ BKE_subdiv_ccg_average_grids()

◆ BKE_subdiv_ccg_average_stitch_faces()

◆ BKE_subdiv_ccg_check_coord_valid()

bool BKE_subdiv_ccg_check_coord_valid ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord )

◆ BKE_subdiv_ccg_coarse_mesh_adjacency_info_get()

SubdivCCGAdjacencyType BKE_subdiv_ccg_coarse_mesh_adjacency_info_get ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord,
blender::Span< int > corner_verts,
blender::OffsetIndices< int > faces,
int & r_v1,
int & r_v2 )

Returns if a grid coordinates is adjacent to a coarse mesh edge, vertex or nothing. If it is adjacent to an edge, r_v1 and r_v2 will be set to the two vertices of that edge. If it is adjacent to a vertex, r_v1 and r_v2 will be the index of that vertex.

Definition at line 1473 of file subdiv_ccg.cc.

References adjacent_vertices_index_from_adjacent_edge(), Edge, faces, SubdivCCGCoord::grid_index, SubdivCCG::grid_size, is_boundary_grid_coord(), is_corner_grid_coord(), is_inner_edge_grid_coordinate(), None, Vertex, SubdivCCGCoord::x, and SubdivCCGCoord::y.

Referenced by BKE_subdiv_ccg_coord_is_mesh_boundary(), blender::ed::sculpt_paint::face_set::vert_has_unique_face_set(), and blender::ed::sculpt_paint::boundary::vert_is_boundary().

◆ BKE_subdiv_ccg_coord_is_mesh_boundary()

bool BKE_subdiv_ccg_coord_is_mesh_boundary ( const OffsetIndices< int > faces,
const Span< int > corner_verts,
const blender::BitSpan boundary_verts,
const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord coord )

◆ BKE_subdiv_ccg_eval_limit_positions()

void BKE_subdiv_ccg_eval_limit_positions ( const SubdivCCG & subdiv_ccg,
const CCGKey & key,
const int grid_index,
const MutableSpan< float3 > r_limit_positions )

◆ BKE_subdiv_ccg_grid_hidden_ensure()

◆ BKE_subdiv_ccg_grid_hidden_free()

◆ BKE_subdiv_ccg_key()

◆ BKE_subdiv_ccg_key_top_level()

CCGKey BKE_subdiv_ccg_key_top_level ( const SubdivCCG & subdiv_ccg)

Definition at line 475 of file subdiv_ccg.cc.

References BKE_subdiv_ccg_key(), and SubdivCCG::level.

Referenced by blender::ed::sculpt_paint::cloth::apply_filter_forces_grids(), blender::ed::sculpt_paint::mask::apply_mask_from_settings(), blender::ed::sculpt_paint::mask::apply_mask_grids(), blender::ed::sculpt_paint::mask::apply_new_mask_grids(), blender::ed::sculpt_paint::apply_translations(), blender::ed::sculpt_paint::smooth::average_data_grids(), BKE_pbvh_get_grid_num_faces(), BKE_pbvh_get_grid_num_verts(), BKE_pbvh_sync_visibility_from_verts(), BKE_subdiv_ccg_average_grids(), BKE_subdiv_ccg_average_stitch_faces(), BKE_subdiv_ccg_update_normals(), blender::ed::sculpt_paint::smooth::blur_geometry_data_array(), blender::ed::sculpt_paint::expand::boundary_from_enabled(), blender::ed::sculpt_paint::calc_area_normal_and_center_node_grids(), blender::ed::sculpt_paint::pose::calc_average_face_set_center(), blender::ed::sculpt_paint::boundary::calc_bend_grids(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_grids(), blender::ed::sculpt_paint::auto_mask::Cache::calc_cavity_factor(), blender::ed::sculpt_paint::cloth::calc_constraint_factors(), blender::ed::sculpt_paint::cloth::calc_forces_grids(), blender::ed::sculpt_paint::calc_front_face(), blender::ed::sculpt_paint::boundary::calc_grab_grids(), blender::ed::sculpt_paint::auto_mask::calc_grids_factors(), blender::ed::sculpt_paint::boundary::calc_inflate_grids(), blender::ed::sculpt_paint::filter::calc_limit_surface_positions(), blender::ed::sculpt_paint::pose::calc_pose_origin_and_factor_grids(), blender::ed::sculpt_paint::smooth::calc_relaxed_translations_grids(), blender::ed::sculpt_paint::filter::calc_sharpen_filter(), blender::ed::sculpt_paint::boundary::calc_slide_grids(), blender::ed::sculpt_paint::boundary::calc_smooth_grids(), blender::ed::sculpt_paint::expand::calc_topology_falloff_from_verts(), blender::ed::sculpt_paint::islands::calc_topology_islands_grids(), blender::ed::sculpt_paint::boundary::calc_twist_grids(), blender::ed::sculpt_paint::cloth::calc_vert_neighbor_indices_grids(), blender::ed::sculpt_paint::calc_vert_neighbors(), blender::ed::sculpt_paint::calc_vert_neighbors_interior(), blender::ed::sculpt_paint::mask::copy_old_hidden_mask_grids(), blender::ed::sculpt_paint::boundary::data_init(), blender::ed::sculpt_paint::boundary::data_init_grids(), blender::ed::sculpt_paint::mask::decrease_contrast_mask_grids(), blender::ed::sculpt_paint::brushes::do_displacement_smear_brush(), blender::ed::sculpt_paint::brushes::do_mask_brush(), blender::ed::sculpt_paint::cloth::do_simulation_step(), blender::ed::sculpt_paint::boundary::edit_data_init_grids(), blender::ed::sculpt_paint::expand::enabled_state_to_bitmap(), blender::ed::sculpt_paint::cloth::ensure_nodes_constraints(), blender::ed::sculpt_paint::flood_fill::FillDataGrids::execute(), blender::ed::sculpt_paint::fake_neighbor_search(), blender::draw::pbvh::fill_face_sets_grids(), blender::ed::sculpt_paint::fill_factor_from_hide(), blender::ed::sculpt_paint::fill_factor_from_hide_and_mask(), blender::ed::sculpt_paint::mask::fill_mask_grids(), blender::draw::pbvh::fill_masks_grids(), blender::draw::pbvh::fill_normals_grids(), blender::draw::pbvh::fill_positions_grids(), blender::ed::sculpt_paint::auto_mask::fill_topology_automasking_factors_grids(), blender::ed::sculpt_paint::face_set::filter_verts_with_unique_face_sets_grids(), blender::ed::sculpt_paint::find_symm_verts_grids(), blender::bke::pbvh::Tree::from_grids(), blender::ed::sculpt_paint::gather_data_grids(), blender::ed::sculpt_paint::gather_data_grids(), blender::ed::sculpt_paint::gather_grids_positions(), blender::ed::sculpt_paint::mask::gesture_apply_for_symmetry_pass(), blender::ed::sculpt_paint::boundary::get_closest_boundary_vert_grids(), blender::ed::sculpt_paint::pose::grow_factors_grids(), blender::ed::sculpt_paint::mask::grow_mask_grids(), blender::ed::sculpt_paint::hide::grow_shrink_visibility_grid(), blender::ed::sculpt_paint::pose::ik_chain_init_face_sets_fk_grids(), blender::ed::sculpt_paint::pose::ik_chain_init_face_sets_grids(), blender::ed::sculpt_paint::pose::ik_chain_init_topology(), blender::ed::sculpt_paint::mask::increase_contrast_mask_grids(), blender::ed::sculpt_paint::boundary::indices_init_grids(), blender::ed::sculpt_paint::boundary::init_boundary_grids(), blender::ed::sculpt_paint::auto_mask::init_boundary_masking_grids(), blender::ed::sculpt_paint::boundary::init_falloff_grids(), blender::ed::sculpt_paint::expand::init_from_face_set_boundary(), blender::ed::sculpt_paint::mask::init_mask_grids(), blender::ed::sculpt_paint::mask::invert_mask_grids(), blender::ed::sculpt_paint::expand::is_face_in_active_component(), blender::ed::sculpt_paint::boundary::is_vert_in_editable_boundary_grids(), blender::ed::sculpt_paint::filter::mesh_filter_sharpen_init(), blender::ed::sculpt_paint::nearest_vert_calc_grids(), blender::ed::sculpt_paint::smooth::neighbor_position_average_interior_grids_impl(), blender::bke::pbvh::node_raycast_grids(), blender::ed::sculpt_paint::expand::normals_falloff_create(), blender::ed::sculpt_paint::hide::partialvis_gesture_update_grids(), blender::ed::sculpt_paint::hide::partialvis_masked_update_grids(), blender::bke::pbvh::pbvh_grids_node_nearest_to_ray(), blender::ed::sculpt_paint::boundary::preview_data_init(), blender::ed::sculpt_paint::undo::restore_list(), blender::ed::sculpt_paint::undo::restore_mask_from_undo_step(), blender::ed::sculpt_paint::undo::restore_mask_grids(), blender::ed::sculpt_paint::undo::restore_position_from_undo_step(), blender::ed::sculpt_paint::scatter_data_grids(), blender::ed::sculpt_paint::expand::sculpt_expand_invoke(), blender::ed::sculpt_paint::mask::sculpt_mask_filter_exec(), blender::ed::sculpt_paint::mask::sculpt_mask_init_exec(), blender::ed::sculpt_paint::sculpt_raycast_cb(), blender::ed::sculpt_paint::mask::sharpen_mask_grids(), blender::ed::sculpt_paint::mask::shrink_mask_grids(), blender::ed::sculpt_paint::mask::smooth_mask_grids(), blender::ed::sculpt_paint::transform_node_grids(), blender::bke::pbvh::update_mask_grids(), blender::ed::sculpt_paint::expand::update_mask_grids(), and blender::ed::sculpt_paint::expand::vert_to_face_falloff_grids().

◆ BKE_subdiv_ccg_neighbor_coords_get()

void BKE_subdiv_ccg_neighbor_coords_get ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord,
bool include_duplicates,
SubdivCCGNeighbors & r_neighbors )

Get actual neighbors of the given coordinate.

If include_duplicates is true, vertices in other grids that match the current vertex are added at the end of the coords array.

Definition at line 1417 of file subdiv_ccg.cc.

References BKE_subdiv_ccg_check_coord_valid(), BLI_assert, SubdivCCGNeighbors::coords, SubdivCCGCoord::grid_index, SubdivCCG::grid_size, SubdivCCG::grids_num, i, blender::Vector< T, InlineBufferCapacity, Allocator >::index_range(), is_boundary_grid_coord(), is_corner_grid_coord(), UNUSED_VARS, SubdivCCGCoord::x, and SubdivCCGCoord::y.

Referenced by blender::ed::sculpt_paint::smooth::average_data_grids(), blender::ed::sculpt_paint::expand::boundary_from_enabled(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_grids(), blender::ed::sculpt_paint::smooth::calc_relaxed_translations_grids(), blender::ed::sculpt_paint::filter::calc_sharpen_filter(), blender::ed::sculpt_paint::cloth::calc_vert_neighbor_indices_grids(), blender::ed::sculpt_paint::calc_vert_neighbors(), blender::ed::sculpt_paint::calc_vert_neighbors_interior(), blender::ed::sculpt_paint::boundary::edit_data_init_grids(), blender::ed::sculpt_paint::flood_fill::FillDataGrids::execute(), blender::ed::sculpt_paint::pose::grow_factors_grids(), blender::ed::sculpt_paint::mask::grow_mask_grids(), blender::ed::sculpt_paint::hide::grow_shrink_visibility_grid(), blender::ed::sculpt_paint::pose::ik_chain_init_face_sets_grids(), blender::ed::sculpt_paint::auto_mask::init_boundary_masking_grids(), blender::ed::sculpt_paint::boundary::is_vert_in_editable_boundary_grids(), blender::ed::sculpt_paint::smooth::neighbor_position_average_interior_grids_impl(), and blender::ed::sculpt_paint::mask::shrink_mask_grids().

◆ BKE_subdiv_ccg_print_coord()

void BKE_subdiv_ccg_print_coord ( const char * message,
const SubdivCCGCoord & coord )

◆ BKE_subdiv_ccg_recalc_normals()

void BKE_subdiv_ccg_recalc_normals ( SubdivCCG & subdiv_ccg)

Recalculate all normals based on grid element coordinates.

Definition at line 579 of file subdiv_ccg.cc.

References BKE_subdiv_ccg_average_grids(), SubdivCCG::faces, SubdivCCG::normals, and UNUSED_VARS.

◆ BKE_subdiv_ccg_topology_counters()

void BKE_subdiv_ccg_topology_counters ( const SubdivCCG & subdiv_ccg,
int & r_num_vertices,
int & r_num_edges,
int & r_num_faces,
int & r_num_loops )

Get geometry counters at the current subdivision level.

Definition at line 885 of file subdiv_ccg.cc.

References SubdivCCG::grid_size, and SubdivCCG::grids_num.

Referenced by stats_mesheval().

◆ BKE_subdiv_ccg_update_normals()

void BKE_subdiv_ccg_update_normals ( SubdivCCG & subdiv_ccg,
const IndexMask & face_mask )

◆ BKE_subdiv_to_ccg()

std::unique_ptr< SubdivCCG > BKE_subdiv_to_ccg ( blender::bke::subdiv::Subdiv & subdiv,
const SubdivToCCGSettings & settings,
const Mesh & coarse_mesh,
SubdivCCGMaskEvaluator * mask_evaluator = nullptr )

Create CCG representation of subdivision surface.

Note
CCG stores dense vertices in a grid-like storage. There is no edges or faces information's for the high-poly surface.
Subdiv is expected to be refined and ready for evaluation.
CCG becomes an owner of subdiv.

TODO(sergey): Allow some user-counter or more explicit control over who owns the Subdiv. The goal should be to allow viewport GL Mesh and CCG to share same Subsurf without conflicts.

Definition at line 385 of file subdiv_ccg.cc.

References bitscan_forward_i(), BLI_assert, Mesh::corners_num, blender::bke::subdiv::grid_size_from_level(), SubdivToCCGSettings::resolution, blender::bke::subdiv::stats_begin(), blender::bke::subdiv::stats_end(), blender::bke::subdiv::SUBDIV_STATS_SUBDIV_TO_CCG, and UNUSED_VARS.

Referenced by BKE_subdiv_to_ccg_mesh().

◆ BKE_subdiv_to_ccg_mesh()

◆ coord_at_next_col()

BLI_INLINE SubdivCCGCoord coord_at_next_col ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord )

◆ coord_at_next_row()

BLI_INLINE SubdivCCGCoord coord_at_next_row ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord )

◆ coord_at_prev_col()

BLI_INLINE SubdivCCGCoord coord_at_prev_col ( const SubdivCCG & ,
const SubdivCCGCoord & coord )

Definition at line 984 of file subdiv_ccg.cc.

References BLI_assert, BLI_INLINE, result, and SubdivCCGCoord::x.

◆ coord_at_prev_row()

BLI_INLINE SubdivCCGCoord coord_at_prev_row ( const SubdivCCG & ,
const SubdivCCGCoord & coord )

Definition at line 966 of file subdiv_ccg.cc.

References BLI_assert, BLI_INLINE, result, and SubdivCCGCoord::y.

◆ is_boundary_grid_coord()

BLI_INLINE bool is_boundary_grid_coord ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord )

◆ is_corner_grid_coord()

BLI_INLINE bool is_corner_grid_coord ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord )

◆ is_inner_edge_grid_coordinate()

BLI_INLINE bool is_inner_edge_grid_coordinate ( const SubdivCCG & subdiv_ccg,
const SubdivCCGCoord & coord )

◆ subdiv_ccg_coord_to_ptex_coord()

◆ subdiv_ccg_neighbors_init()

BLI_INLINE void subdiv_ccg_neighbors_init ( SubdivCCGNeighbors & neighbors,
const int num_unique,
const int num_duplicates )