Blender
V3.3
|
Go to the source code of this file.
Classes | |
struct | MultiresReshapeContext |
struct | GridCoord |
struct | PTexCoord |
struct | ReshapeGridElement |
struct | ReshapeConstGridElement |
Typedefs | |
typedef struct MultiresReshapeContext | MultiresReshapeContext |
typedef struct GridCoord | GridCoord |
typedef struct PTexCoord | PTexCoord |
typedef struct ReshapeGridElement | ReshapeGridElement |
typedef struct ReshapeConstGridElement | ReshapeConstGridElement |
Coordinate which identifies element of a grid. This is directly related on how CD_MDISPS stores displacement.
typedef struct MultiresReshapeContext MultiresReshapeContext |
Coordinate within ptex, which is what OpenSubdiv API operates on.
typedef struct ReshapeConstGridElement ReshapeConstGridElement |
typedef struct ReshapeGridElement ReshapeGridElement |
Element of a grid data stored in the destination mesh. This is where reshaped coordinates and mask values will be written to.
void multires_reshape_apply_base_refine_from_base | ( | MultiresReshapeContext * | reshape_context | ) |
Refine subdivision surface to the new positions of the base mesh.
Definition at line 162 of file multires_reshape_apply_base.c.
References MultiresReshapeContext::base_mesh, BKE_subdiv_eval_refine_from_mesh(), NULL, and MultiresReshapeContext::subdiv.
Referenced by multiresModifier_base_apply().
void multires_reshape_apply_base_refine_from_deform | ( | MultiresReshapeContext * | reshape_context | ) |
Refine subdivision surface to the new positions of the deformed mesh (base mesh with all modifiers leading the multi-res applied).
Definition at line 167 of file multires_reshape_apply_base.c.
References MultiresReshapeContext::base_mesh, BKE_multires_create_deformed_base_mesh_vert_coords(), BKE_subdiv_eval_refine_from_mesh(), BLI_assert, MultiresReshapeContext::depsgraph, depsgraph, float(), MEM_freeN, MultiresReshapeContext::mmd, NULL, MultiresReshapeContext::object, and MultiresReshapeContext::subdiv.
Referenced by multiresModifier_base_apply().
void multires_reshape_apply_base_refit_base_mesh | ( | MultiresReshapeContext * | reshape_context | ) |
Perform better fitting of the base mesh so its subdivided version brings vertices to their desired locations.
Definition at line 66 of file multires_reshape_apply_base.c.
References add_v3_v3(), MultiresReshapeContext::base_mesh, BKE_mesh_calc_poly_normal_coords(), BKE_mesh_tag_coords_changed(), BKE_mesh_vert_poly_map_create(), center, MVert::co, copy_v3_v3(), MeshElemMap::count, count, float(), MeshElemMap::indices, MPoly::loopstart, MEM_calloc_arrayN, MEM_freeN, MEM_malloc_arrayN, Mesh::mloop, Mesh::mpoly, mul_v3_fl(), Mesh::mvert, normalize_v3(), Mesh::totloop, MPoly::totloop, Mesh::totpoly, Mesh::totvert, MLoop::v, and v3_dist_from_plane().
Referenced by multiresModifier_base_apply().
void multires_reshape_apply_base_update_mesh_coords | ( | MultiresReshapeContext * | reshape_context | ) |
Update mesh coordinates to the final positions of displacement in object space. This is effectively desired position of base mesh vertices after canceling out displacement.
Definition at line 30 of file multires_reshape_apply_base.c.
References add_v3_v3v3(), MultiresReshapeContext::base_mesh, MVert::co, D(), ReshapeConstGridElement::displacement, GridCoord::grid_index, Mesh::mloop, mul_v3_m3v3(), multires_reshape_evaluate_limit_at_grid(), multires_reshape_orig_grid_element_for_grid_coord(), Mesh::mvert, P(), Mesh::totloop, GridCoord::u, GridCoord::v, and MLoop::v.
Referenced by multiresModifier_base_apply().
bool multires_reshape_assign_final_coords_from_ccg | ( | const MultiresReshapeContext * | reshape_context, |
struct SubdivCCG * | subdiv_ccg | ||
) |
Store final object-space coordinates in the displacement grids. The reason why displacement grids are used for storage is based on memory footprint optimization.
Definition at line 17 of file multires_reshape_ccg.c.
References BKE_subdiv_ccg_key(), BLI_assert, CCG_grid_elem_co(), CCG_grid_elem_mask(), ReshapeGridElement::displacement, float(), GridCoord::grid_index, MultiresReshapeContext::grid_size, SubdivCCG::grids, CCGKey::has_mask, MultiresReshapeContext::level, ReshapeGridElement::mask, multires_reshape_grid_element_for_grid_coord(), NULL, SubdivCCG::num_grids, MultiresReshapeContext::reshape, GridCoord::u, GridCoord::v, v, x, and y.
Referenced by multiresModifier_reshapeFromCCG().
void multires_reshape_assign_final_coords_from_mdisps | ( | const MultiresReshapeContext * | reshape_context | ) |
Reads and writes to the current mesh CD_MDISPS.
Definition at line 744 of file multires_reshape_util.c.
References assign_final_coords_from_mdisps(), foreach_grid_coordinate(), MultiresReshapeContext::level, NULL, and MultiresReshapeContext::top.
Referenced by multires_do_versions_simple_to_catmull_clark(), multiresModifier_base_apply(), and multiresModifier_rebuild_subdiv().
bool multires_reshape_assign_final_coords_from_vertcos | ( | const MultiresReshapeContext * | reshape_context, |
const float(*) | vert_coords[3], | ||
int | num_vert_coords | ||
) |
Set displacement grids values at a reshape level to a object coordinates of the given source.
False will be returned if the number of vertex coordinates did not match required number of vertices at a reshape level.
Definition at line 170 of file multires_reshape_vertcos.c.
References MultiresReshapeContext::base_mesh, BKE_subdiv_foreach_subdiv_geometry(), MultiresReshapeContext::level, multires_reshape_vertcos_foreach_topology_info(), multires_reshape_vertcos_foreach_vertex_every_corner(), multires_reshape_vertcos_foreach_vertex_every_edge(), multires_reshape_vertcos_foreach_vertex_inner(), MultiresReshapeContext::reshape, MultiresReshapeAssignVertcosContext::reshape_context, SubdivToMeshSettings::resolution, MultiresReshapeContext::subdiv, SubdivForeachContext::topology_info, and SubdivToMeshSettings::use_optimal_display.
Referenced by multiresModifier_reshapeFromVertcos().
void multires_reshape_assign_final_elements_from_orig_mdisps | ( | const MultiresReshapeContext * | reshape_context | ) |
Reads from original #CD_MIDTSPS, writes to the current mesh CD_MDISPS.
Definition at line 774 of file multires_reshape_util.c.
References assign_final_elements_from_orig_mdisps(), foreach_grid_coordinate(), MultiresReshapeContext::level, NULL, and MultiresReshapeContext::top.
Referenced by multiresModifier_subdivide_to_level().
bool multires_reshape_context_create_from_base_mesh | ( | MultiresReshapeContext * | reshape_context, |
struct Depsgraph * | depsgraph, | ||
struct Object * | object, | ||
struct MultiresModifierData * | mmd | ||
) |
Definition at line 139 of file multires_reshape_util.c.
References MultiresReshapeContext::base_mesh, BKE_subdiv_grid_size_from_level(), context_init_commoon(), context_verify_or_free(), context_zero(), Object::data, DEG_get_evaluated_scene(), MultiresReshapeContext::depsgraph, depsgraph, MultiresReshapeContext::grid_size, MultiresReshapeContext::level, MultiresReshapeContext::mmd, multires_get_level(), multires_reshape_create_subdiv(), MultiresReshapeContext::need_free_subdiv, NULL, MultiresReshapeContext::object, MultiresReshapeContext::reshape, MultiresReshapeContext::subdiv, MultiresReshapeContext::top, and MultiresModifierData::totlvl.
Referenced by multiresModifier_rebuild_subdiv().
bool multires_reshape_context_create_from_ccg | ( | MultiresReshapeContext * | reshape_context, |
struct SubdivCCG * | subdiv_ccg, | ||
struct Mesh * | base_mesh, | ||
int | top_level | ||
) |
Definition at line 207 of file multires_reshape_util.c.
References MultiresReshapeContext::base_mesh, BKE_subdiv_grid_size_from_level(), context_init_commoon(), context_verify_or_free(), context_zero(), MultiresReshapeContext::grid_size, SubdivCCG::level, MultiresReshapeContext::level, MultiresReshapeContext::need_free_subdiv, MultiresReshapeContext::reshape, SubdivCCG::subdiv, MultiresReshapeContext::subdiv, and MultiresReshapeContext::top.
Referenced by multiresModifier_reshapeFromCCG().
bool multires_reshape_context_create_from_modifier | ( | MultiresReshapeContext * | reshape_context, |
struct Object * | object, | ||
struct MultiresModifierData * | mmd, | ||
int | top_level | ||
) |
Definition at line 231 of file multires_reshape_util.c.
References multires_reshape_context_create_from_subdiv(), multires_reshape_create_subdiv(), MultiresReshapeContext::need_free_subdiv, NULL, and result.
Referenced by multires_do_versions_simple_to_catmull_clark(), multires_subdivide_create_tangent_displacement_linear_grids(), and multiresModifier_subdivide_to_level().
bool multires_reshape_context_create_from_object | ( | MultiresReshapeContext * | reshape_context, |
struct Depsgraph * | depsgraph, | ||
struct Object * | object, | ||
struct MultiresModifierData * | mmd | ||
) |
Definition at line 172 of file multires_reshape_util.c.
References MultiresReshapeContext::base_mesh, BKE_subdiv_grid_size_from_level(), CD_CREASE, MultiresReshapeContext::cd_vertex_crease, context_init_commoon(), context_verify_or_free(), context_zero(), CustomData_get_layer(), Object::data, DEG_get_evaluated_scene(), MultiresReshapeContext::depsgraph, depsgraph, MultiresReshapeContext::grid_size, MultiresReshapeContext::level, MultiresReshapeContext::mmd, multires_get_level(), multires_reshape_create_subdiv(), MultiresReshapeContext::need_free_subdiv, MultiresReshapeContext::object, MultiresReshapeContext::reshape, MultiresReshapeContext::subdiv, MultiresReshapeContext::top, MultiresModifierData::totlvl, and Mesh::vdata.
Referenced by multiresModifier_base_apply(), multiresModifier_rebuild_subdiv(), and multiresModifier_reshapeFromVertcos().
bool multires_reshape_context_create_from_subdiv | ( | MultiresReshapeContext * | reshape_context, |
struct Object * | object, | ||
struct MultiresModifierData * | mmd, | ||
struct Subdiv * | subdiv, | ||
int | top_level | ||
) |
Definition at line 246 of file multires_reshape_util.c.
References MultiresReshapeContext::base_mesh, BKE_subdiv_grid_size_from_level(), context_init_commoon(), context_verify_or_free(), context_zero(), Object::data, MultiresReshapeContext::grid_size, MultiresReshapeContext::level, MultiresReshapeContext::mmd, MultiresReshapeContext::need_free_subdiv, MultiresReshapeContext::reshape, MultiresReshapeContext::subdiv, MultiresReshapeContext::top, and MultiresModifierData::totlvl.
Referenced by multires_do_versions_simple_to_catmull_clark(), and multires_reshape_context_create_from_modifier().
void multires_reshape_context_free | ( | MultiresReshapeContext * | reshape_context | ) |
Definition at line 302 of file multires_reshape_util.c.
References BKE_subdiv_free(), MultiresReshapeContext::face_start_grid_index, MultiresReshapeContext::grid_to_face_index, MEM_SAFE_FREE, multires_reshape_free_original_grids(), MultiresReshapeContext::need_free_subdiv, MultiresReshapeContext::ptex_start_grid_index, and MultiresReshapeContext::subdiv.
Referenced by context_verify_or_free(), multires_do_versions_simple_to_catmull_clark(), multires_subdivide_create_tangent_displacement_linear_grids(), multiresModifier_base_apply(), multiresModifier_rebuild_subdiv(), multiresModifier_reshapeFromCCG(), multiresModifier_reshapeFromVertcos(), and multiresModifier_subdivide_to_level().
struct Subdiv* multires_reshape_create_subdiv | ( | struct Depsgraph * | depsgraph, |
struct Object * | object, | ||
const struct MultiresModifierData * | mmd | ||
) |
Create subdivision surface descriptor which is configured for surface evaluation at a given multi-res modifier.
Make sure custom data is allocated for the given level.
Definition at line 572 of file multires_reshape_util.c.
References ensure_displacement_grids(), ensure_mask_grids(), and mesh.
Referenced by multires_subdivide_create_tangent_displacement_linear_grids(), multiresModifier_reshapeFromCCG(), multiresModifier_reshapeFromVertcos(), and multiresModifier_subdivide_to_level().
void multires_reshape_evaluate_limit_at_grid | ( | const MultiresReshapeContext * | reshape_context, |
const GridCoord * | grid_coord, | ||
float | r_P[3], | ||
float | r_tangent_matrix[3][3] | ||
) |
Evaluate limit surface created from base mesh. This is the limit surface which defines tangent space for MDisps.
Definition at line 494 of file multires_reshape_util.c.
References BKE_subdiv_eval_limit_point_and_derivatives(), GridCoord::grid_index, multires_reshape_grid_coord_to_ptex(), multires_reshape_grid_to_corner(), multires_reshape_grid_to_face_index(), multires_reshape_tangent_matrix_for_corner(), PTexCoord::ptex_face_index, MultiresReshapeContext::subdiv, PTexCoord::u, and PTexCoord::v.
Referenced by assign_final_coords_from_mdisps(), assign_final_elements_from_orig_mdisps(), evaluate_final_original_point(), multires_reshape_apply_base_update_mesh_coords(), object_grid_element_to_tangent_displacement(), and reshape_subdiv_refine_orig_P().
void multires_reshape_free_original_grids | ( | MultiresReshapeContext * | reshape_context | ) |
Definition at line 274 of file multires_reshape_util.c.
References GridPaintMask::data, MDisps::disps, MultiresReshapeContext::grid_paint_masks, MultiresReshapeContext::mdisps, MEM_SAFE_FREE, NULL, MultiresReshapeContext::num_grids, and MultiresReshapeContext::orig.
Referenced by multires_reshape_context_free(), and multiresModifier_subdivide_to_level().
PTexCoord multires_reshape_grid_coord_to_ptex | ( | const MultiresReshapeContext * | reshape_context, |
const GridCoord * | grid_coord | ||
) |
Convert normalized coordinate within a grid to a normalized coordinate within a PTEX face.
Definition at line 360 of file multires_reshape_util.c.
References BKE_subdiv_grid_uv_to_ptex_face_uv(), BKE_subdiv_ptex_face_uv_to_grid_uv(), BKE_subdiv_rotate_grid_to_quad(), GridCoord::grid_index, multires_reshape_grid_to_corner(), multires_reshape_grid_to_face_index(), multires_reshape_grid_to_ptex_index(), multires_reshape_is_quad_face(), PTexCoord::ptex_face_index, GridCoord::u, PTexCoord::u, GridCoord::v, and PTexCoord::v.
Referenced by multires_reshape_evaluate_limit_at_grid().
ReshapeGridElement multires_reshape_grid_element_for_grid_coord | ( | const MultiresReshapeContext * | reshape_context, |
const GridCoord * | grid_coord | ||
) |
Get grid elements which are to be reshaped at a given or PTEX coordinate. The data is coming from final custom mdata layers.
Definition at line 426 of file multires_reshape_util.c.
References GridPaintMask::data, ReshapeGridElement::displacement, MDisps::disps, GridCoord::grid_index, MultiresReshapeContext::grid_paint_masks, MultiresReshapeContext::grid_size, ReshapeGridElement::mask, MultiresReshapeContext::mdisps, NULL, MultiresReshapeContext::top, GridCoord::u, and GridCoord::v.
Referenced by assign_final_coords_from_mdisps(), assign_final_elements_from_orig_mdisps(), evaluate_higher_grid_positions_callback(), evaluate_higher_grid_positions_with_details_callback(), linear_grid_element_final_get(), multires_reshape_assign_final_coords_from_ccg(), multires_reshape_grid_element_for_ptex_coord(), multires_reshape_vertcos_foreach_single_vertex(), object_grid_element_to_tangent_displacement(), and reshape_subdiv_refine_final_P().
ReshapeGridElement multires_reshape_grid_element_for_ptex_coord | ( | const MultiresReshapeContext * | reshape_context, |
const PTexCoord * | ptex_coord | ||
) |
Definition at line 449 of file multires_reshape_util.c.
References multires_reshape_grid_element_for_grid_coord(), and multires_reshape_ptex_coord_to_grid().
int multires_reshape_grid_to_corner | ( | const MultiresReshapeContext * | reshape_context, |
int | grid_index | ||
) |
For the given grid index get corner of a face it was created for.
Definition at line 333 of file multires_reshape_util.c.
References BLI_assert, MultiresReshapeContext::face_start_grid_index, and multires_reshape_grid_to_face_index().
Referenced by multires_reshape_evaluate_limit_at_grid(), multires_reshape_grid_coord_to_ptex(), multires_reshape_grid_to_ptex_index(), and reshape_subdiv_evaluate_limit_at_grid().
int multires_reshape_grid_to_face_index | ( | const MultiresReshapeContext * | reshape_context, |
int | grid_index | ||
) |
For the given grid index get index of face it was created for.
Definition at line 321 of file multires_reshape_util.c.
References BLI_assert, and MultiresReshapeContext::grid_to_face_index.
Referenced by foreach_vertex(), multires_reshape_evaluate_limit_at_grid(), multires_reshape_grid_coord_to_ptex(), multires_reshape_grid_to_corner(), multires_reshape_grid_to_ptex_index(), multires_reshape_vertcos_foreach_vertex(), and reshape_subdiv_evaluate_limit_at_grid().
int multires_reshape_grid_to_ptex_index | ( | const MultiresReshapeContext * | reshape_context, |
int | grid_index | ||
) |
For the given grid index get index of corresponding PTEX face.
Definition at line 351 of file multires_reshape_util.c.
References MultiresReshapeContext::face_ptex_offset, multires_reshape_grid_to_corner(), multires_reshape_grid_to_face_index(), and multires_reshape_is_quad_face().
Referenced by multires_reshape_grid_coord_to_ptex().
bool multires_reshape_is_quad_face | ( | const MultiresReshapeContext * | reshape_context, |
int | face_index | ||
) |
Definition at line 345 of file multires_reshape_util.c.
References MultiresReshapeContext::base_mesh, Mesh::mpoly, and MPoly::totloop.
Referenced by multires_reshape_grid_coord_to_ptex(), multires_reshape_grid_to_ptex_index(), multires_reshape_ptex_coord_to_grid(), and multires_reshape_tangent_matrix_for_corner().
void multires_reshape_object_grids_to_tangent_displacement | ( | const MultiresReshapeContext * | reshape_context | ) |
Definition at line 710 of file multires_reshape_util.c.
References foreach_grid_coordinate(), MultiresReshapeContext::level, NULL, object_grid_element_to_tangent_displacement(), and MultiresReshapeContext::top.
Referenced by multires_do_versions_simple_to_catmull_clark(), multires_subdivide_create_tangent_displacement_linear_grids(), multiresModifier_base_apply(), multiresModifier_rebuild_subdiv(), multiresModifier_reshapeFromCCG(), multiresModifier_reshapeFromVertcos(), and multiresModifier_subdivide_to_level().
ReshapeConstGridElement multires_reshape_orig_grid_element_for_grid_coord | ( | const MultiresReshapeContext * | reshape_context, |
const GridCoord * | grid_coord | ||
) |
Get original grid element for the given coordinate.
Definition at line 456 of file multires_reshape_util.c.
References BKE_subdiv_grid_size_from_level(), copy_v3_v3(), GridPaintMask::data, ReshapeConstGridElement::displacement, MDisps::disps, GridCoord::grid_index, MultiresReshapeContext::grid_paint_masks, MDisps::level, GridPaintMask::level, ReshapeConstGridElement::mask, MultiresReshapeContext::mdisps, NULL, MultiresReshapeContext::orig, GridCoord::u, and GridCoord::v.
Referenced by assign_final_elements_from_orig_mdisps(), evaluate_final_original_point(), linear_grid_element_orig_get(), multires_reshape_apply_base_update_mesh_coords(), propagate_linear_data_delta(), and reshape_subdiv_refine_orig_P().
GridCoord multires_reshape_ptex_coord_to_grid | ( | const MultiresReshapeContext * | reshape_context, |
const PTexCoord * | ptex_coord | ||
) |
Convert a normalized coordinate within a PTEX face to a normalized coordinate within a grid.
Definition at line 387 of file multires_reshape_util.c.
References BKE_subdiv_ptex_face_uv_to_grid_uv(), BKE_subdiv_rotate_quad_to_corner(), GridCoord::grid_index, MultiresReshapeContext::grid_to_face_index, multires_reshape_is_quad_face(), PTexCoord::ptex_face_index, MultiresReshapeContext::ptex_start_grid_index, GridCoord::u, PTexCoord::u, GridCoord::v, and PTexCoord::v.
Referenced by foreach_vertex(), multires_reshape_grid_element_for_ptex_coord(), and multires_reshape_vertcos_foreach_vertex().
void multires_reshape_smooth_object_grids | ( | const MultiresReshapeContext * | reshape_context, |
enum eMultiresSubdivideModeType | mode | ||
) |
Operates on a displacement grids (CD_MDISPS) which contains object space-coordinates stored for the reshape level.
Makes it so surface on top level looks smooth. Details are not preserved
Definition at line 1512 of file multires_reshape_smooth.c.
References context_free(), context_init(), evaluate_higher_grid_positions(), evaluate_linear_delta_grids(), geometry_create(), MultiresReshapeContext::level, MultiresReshapeContext::reshape, reshape_subdiv_create(), reshape_subdiv_refine_final(), and MultiresReshapeContext::top.
Referenced by multiresModifier_subdivide_to_level().
void multires_reshape_smooth_object_grids_with_details | ( | const MultiresReshapeContext * | reshape_context | ) |
Operates on a displacement grids (CD_MDISPS) which contains object space coordinates stored for the reshape level.
The result is grids which are defining mesh with a smooth surface and details starting from reshape level up to top level added back from original displacement grids.
Definition at line 1480 of file multires_reshape_smooth.c.
References base_surface_grids_allocate(), context_free(), context_init(), evaluate_base_surface_grids(), evaluate_higher_grid_positions_with_details(), evaluate_linear_delta_grids(), geometry_create(), SubdivSettings::is_simple, MultiresReshapeContext::level, MULTIRES_SUBDIVIDE_CATMULL_CLARK, MULTIRES_SUBDIVIDE_SIMPLE, MultiresReshapeContext::reshape, reshape_subdiv_create(), reshape_subdiv_refine_final(), reshape_subdiv_refine_orig(), Subdiv::settings, MultiresReshapeContext::subdiv, and MultiresReshapeContext::top.
Referenced by multiresModifier_reshapeFromCCG(), multiresModifier_reshapeFromVertcos(), and multiresModifier_subdivide_to_level().
void multires_reshape_store_original_grids | ( | MultiresReshapeContext * | reshape_context | ) |
Store original grid data, so then it's possible to calculate delta from it and add high-frequency content on top of reshaped grids.
Definition at line 584 of file multires_reshape_util.c.
References GridPaintMask::data, MDisps::disps, MultiresReshapeContext::grid_paint_masks, MultiresReshapeContext::mdisps, MEM_dupallocN, NULL, MultiresReshapeContext::num_grids, and MultiresReshapeContext::orig.
Referenced by multires_do_versions_simple_to_catmull_clark(), multiresModifier_base_apply(), multiresModifier_rebuild_subdiv(), multiresModifier_reshapeFromCCG(), multiresModifier_reshapeFromVertcos(), and multiresModifier_subdivide_to_level().
void multires_reshape_tangent_matrix_for_corner | ( | const MultiresReshapeContext * | reshape_context, |
int | face_index, | ||
int | corner, | ||
const float | dPdu[3], | ||
const float | dPdv[3], | ||
float | r_tangent_matrix[3][3] | ||
) |
Calculate tangent matrix which converts displacement to a object vector. Is calculated for the given surface derivatives at a given base face corner.
Definition at line 412 of file multires_reshape_util.c.
References BKE_multires_construct_tangent_matrix(), and multires_reshape_is_quad_face().
Referenced by multires_reshape_evaluate_limit_at_grid(), and reshape_subdiv_evaluate_limit_at_grid().