Blender  V3.3
Classes | Typedefs | Functions
multires_reshape.h File Reference
#include "BLI_sys_types.h"
#include "BKE_multires.h"

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
 

Functions

struct Subdivmultires_reshape_create_subdiv (struct Depsgraph *depsgraph, struct Object *object, const struct MultiresModifierData *mmd)
 
bool multires_reshape_context_create_from_object (MultiresReshapeContext *reshape_context, struct Depsgraph *depsgraph, struct Object *object, struct MultiresModifierData *mmd)
 
bool multires_reshape_context_create_from_base_mesh (MultiresReshapeContext *reshape_context, struct Depsgraph *depsgraph, struct Object *object, struct MultiresModifierData *mmd)
 
bool multires_reshape_context_create_from_ccg (MultiresReshapeContext *reshape_context, struct SubdivCCG *subdiv_ccg, struct Mesh *base_mesh, int top_level)
 
bool multires_reshape_context_create_from_modifier (MultiresReshapeContext *reshape_context, struct Object *object, struct MultiresModifierData *mmd, int top_level)
 
bool multires_reshape_context_create_from_subdiv (MultiresReshapeContext *reshape_context, struct Object *object, struct MultiresModifierData *mmd, struct Subdiv *subdiv, int top_level)
 
void multires_reshape_free_original_grids (MultiresReshapeContext *reshape_context)
 
void multires_reshape_context_free (MultiresReshapeContext *reshape_context)
 
int multires_reshape_grid_to_face_index (const MultiresReshapeContext *reshape_context, int grid_index)
 
int multires_reshape_grid_to_corner (const MultiresReshapeContext *reshape_context, int grid_index)
 
bool multires_reshape_is_quad_face (const MultiresReshapeContext *reshape_context, int face_index)
 
int multires_reshape_grid_to_ptex_index (const MultiresReshapeContext *reshape_context, int grid_index)
 
PTexCoord multires_reshape_grid_coord_to_ptex (const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord)
 
GridCoord multires_reshape_ptex_coord_to_grid (const MultiresReshapeContext *reshape_context, const PTexCoord *ptex_coord)
 
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])
 
ReshapeGridElement multires_reshape_grid_element_for_grid_coord (const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord)
 
ReshapeGridElement multires_reshape_grid_element_for_ptex_coord (const MultiresReshapeContext *reshape_context, const PTexCoord *ptex_coord)
 
ReshapeConstGridElement multires_reshape_orig_grid_element_for_grid_coord (const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord)
 
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])
 
void multires_reshape_ensure_grids (struct Mesh *mesh, int level)
 
bool multires_reshape_assign_final_coords_from_vertcos (const MultiresReshapeContext *reshape_context, const float(*vert_coords)[3], int num_vert_coords)
 
bool multires_reshape_assign_final_coords_from_ccg (const MultiresReshapeContext *reshape_context, struct SubdivCCG *subdiv_ccg)
 
void multires_reshape_assign_final_coords_from_mdisps (const MultiresReshapeContext *reshape_context)
 
void multires_reshape_assign_final_elements_from_orig_mdisps (const MultiresReshapeContext *reshape_context)
 
void multires_reshape_smooth_object_grids_with_details (const MultiresReshapeContext *reshape_context)
 
void multires_reshape_smooth_object_grids (const MultiresReshapeContext *reshape_context, enum eMultiresSubdivideModeType mode)
 
void multires_reshape_store_original_grids (MultiresReshapeContext *reshape_context)
 
void multires_reshape_object_grids_to_tangent_displacement (const MultiresReshapeContext *reshape_context)
 
void multires_reshape_apply_base_update_mesh_coords (MultiresReshapeContext *reshape_context)
 
void multires_reshape_apply_base_refit_base_mesh (MultiresReshapeContext *reshape_context)
 
void multires_reshape_apply_base_refine_from_base (MultiresReshapeContext *reshape_context)
 
void multires_reshape_apply_base_refine_from_deform (MultiresReshapeContext *reshape_context)
 

Typedef Documentation

◆ GridCoord

typedef struct GridCoord GridCoord

Coordinate which identifies element of a grid. This is directly related on how CD_MDISPS stores displacement.

◆ MultiresReshapeContext

◆ PTexCoord

typedef struct PTexCoord PTexCoord

Coordinate within ptex, which is what OpenSubdiv API operates on.

◆ ReshapeConstGridElement

◆ ReshapeGridElement

Element of a grid data stored in the destination mesh. This is where reshaped coordinates and mask values will be written to.

Function Documentation

◆ multires_reshape_apply_base_refine_from_base()

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().

◆ multires_reshape_apply_base_refine_from_deform()

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).

Note
Will re-evaluate all leading modifiers, so it's not cheap.

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().

◆ multires_reshape_apply_base_refit_base_mesh()

void multires_reshape_apply_base_refit_base_mesh ( MultiresReshapeContext reshape_context)

◆ multires_reshape_apply_base_update_mesh_coords()

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.

Note
Expects that mesh's CD_MDISPS has been set to object space positions.

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().

◆ multires_reshape_assign_final_coords_from_ccg()

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.

Note
Displacement grids to be at least at a reshape level.
Returns
truth if all coordinates have been updated.

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().

◆ multires_reshape_assign_final_coords_from_mdisps()

void multires_reshape_assign_final_coords_from_mdisps ( const MultiresReshapeContext reshape_context)

◆ multires_reshape_assign_final_coords_from_vertcos()

bool multires_reshape_assign_final_coords_from_vertcos ( const MultiresReshapeContext reshape_context,
const float(*)  vert_coords[3],
int  num_vert_coords 
)

◆ multires_reshape_assign_final_elements_from_orig_mdisps()

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().

◆ multires_reshape_context_create_from_base_mesh()

bool multires_reshape_context_create_from_base_mesh ( MultiresReshapeContext reshape_context,
struct Depsgraph depsgraph,
struct Object object,
struct MultiresModifierData mmd 
)

◆ multires_reshape_context_create_from_ccg()

bool multires_reshape_context_create_from_ccg ( MultiresReshapeContext reshape_context,
struct SubdivCCG subdiv_ccg,
struct Mesh base_mesh,
int  top_level 
)

◆ multires_reshape_context_create_from_modifier()

bool multires_reshape_context_create_from_modifier ( MultiresReshapeContext reshape_context,
struct Object object,
struct MultiresModifierData mmd,
int  top_level 
)

◆ multires_reshape_context_create_from_object()

bool multires_reshape_context_create_from_object ( MultiresReshapeContext reshape_context,
struct Depsgraph depsgraph,
struct Object object,
struct MultiresModifierData mmd 
)

◆ multires_reshape_context_create_from_subdiv()

bool multires_reshape_context_create_from_subdiv ( MultiresReshapeContext reshape_context,
struct Object object,
struct MultiresModifierData mmd,
struct Subdiv subdiv,
int  top_level 
)

◆ multires_reshape_context_free()

void multires_reshape_context_free ( MultiresReshapeContext reshape_context)

◆ multires_reshape_create_subdiv()

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.

◆ multires_reshape_ensure_grids()

void multires_reshape_ensure_grids ( struct Mesh mesh,
int  level 
)

◆ multires_reshape_evaluate_limit_at_grid()

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] 
)

◆ multires_reshape_free_original_grids()

void multires_reshape_free_original_grids ( MultiresReshapeContext reshape_context)

◆ multires_reshape_grid_coord_to_ptex()

PTexCoord multires_reshape_grid_coord_to_ptex ( const MultiresReshapeContext reshape_context,
const GridCoord grid_coord 
)

◆ multires_reshape_grid_element_for_grid_coord()

ReshapeGridElement multires_reshape_grid_element_for_grid_coord ( const MultiresReshapeContext reshape_context,
const GridCoord grid_coord 
)

◆ multires_reshape_grid_element_for_ptex_coord()

ReshapeGridElement multires_reshape_grid_element_for_ptex_coord ( const MultiresReshapeContext reshape_context,
const PTexCoord ptex_coord 
)

◆ multires_reshape_grid_to_corner()

int multires_reshape_grid_to_corner ( const MultiresReshapeContext reshape_context,
int  grid_index 
)

◆ multires_reshape_grid_to_face_index()

int multires_reshape_grid_to_face_index ( const MultiresReshapeContext reshape_context,
int  grid_index 
)

◆ multires_reshape_grid_to_ptex_index()

int multires_reshape_grid_to_ptex_index ( const MultiresReshapeContext reshape_context,
int  grid_index 
)

◆ multires_reshape_is_quad_face()

bool multires_reshape_is_quad_face ( const MultiresReshapeContext reshape_context,
int  face_index 
)

◆ multires_reshape_object_grids_to_tangent_displacement()

void multires_reshape_object_grids_to_tangent_displacement ( const MultiresReshapeContext reshape_context)

◆ multires_reshape_orig_grid_element_for_grid_coord()

ReshapeConstGridElement multires_reshape_orig_grid_element_for_grid_coord ( const MultiresReshapeContext reshape_context,
const GridCoord grid_coord 
)

◆ multires_reshape_ptex_coord_to_grid()

GridCoord multires_reshape_ptex_coord_to_grid ( const MultiresReshapeContext reshape_context,
const PTexCoord ptex_coord 
)

◆ multires_reshape_smooth_object_grids()

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().

◆ multires_reshape_smooth_object_grids_with_details()

void multires_reshape_smooth_object_grids_with_details ( const MultiresReshapeContext reshape_context)

◆ multires_reshape_store_original_grids()

void multires_reshape_store_original_grids ( MultiresReshapeContext reshape_context)

◆ multires_reshape_tangent_matrix_for_corner()

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().