Blender V5.0
MOD_skin.cc File Reference
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_array_utils.hh"
#include "BLI_bitmap.h"
#include "BLI_heap_simple.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_stack.h"
#include "BLI_vector.hh"
#include "BLT_translation.hh"
#include "DNA_defaults.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_screen_types.h"
#include "BKE_deform.hh"
#include "BKE_lib_id.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_mapping.hh"
#include "BKE_modifier.hh"
#include "UI_interface_layout.hh"
#include "UI_resources.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "WM_types.hh"
#include "MOD_ui_common.hh"
#include "bmesh.hh"

Go to the source code of this file.

Classes

struct  EMat
struct  Frame
struct  SkinNode
struct  SkinOutput
struct  EdgeStackElem

Macros

#define MAX_SKIN_NODE_FRAMES   2
#define NUM_SUBDIVISIONS_MAX   128
#define PRINT_HOLE_INFO   0

Enumerations

enum  SkinNodeFlag { CAP_START = 1 , CAP_END = 2 , SEAM_FRAME = 4 , FLIP_NORMAL = 8 }
enum  eSkinErrorFlag { SKIN_ERROR_NO_VALID_ROOT = (1 << 0) , SKIN_ERROR_HULL = (1 << 1) }

Functions

 ENUM_OPERATORS (SkinNodeFlag, FLIP_NORMAL)
static void add_poly (SkinOutput *so, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4)
static bool is_quad_symmetric (BMVert *quad[4], const SkinModifierData *smd)
static bool quad_crosses_symmetry_plane (BMVert *quad[4], const SkinModifierData *smd)
static bool build_hull (SkinOutput *so, Frame **frames, int totframe)
static float frame_len (const Frame *frame)
static void merge_frame_corners (Frame **frames, int totframe)
static Frame ** collect_hull_frames (int v, SkinNode *frames, blender::GroupedSpan< int > emap, const blender::Span< blender::int2 > edges, int *tothullframe)
static void node_frames_init (SkinNode *nf, int totframe)
static void create_frame (Frame *frame, const float co[3], const float radius[2], const float mat[3][3], float offset)
static float half_v2 (const float v[2])
static void end_node_frames (int v, SkinNode *skin_nodes, const blender::Span< blender::float3 > vert_positions, const MVertSkin *nodes, blender::GroupedSpan< int > emap, EMat *emat)
static int connection_node_mat (float mat[3][3], int v, blender::GroupedSpan< int > emap, EMat *emat)
static void connection_node_frames (int v, SkinNode *skin_nodes, const blender::Span< blender::float3 > vert_positions, const MVertSkin *nodes, blender::GroupedSpan< int > emap, EMat *emat)
static SkinNodebuild_frames (const blender::Span< blender::float3 > vert_positions, int verts_num, const MVertSkin *nodes, blender::GroupedSpan< int > emap, EMat *emat)
static void calc_edge_mat (float mat[3][3], const float a[3], const float b[3])
static void build_emats_stack (BLI_Stack *stack, BLI_bitmap *visited_e, EMat *emat, blender::GroupedSpan< int > emap, const blender::Span< blender::int2 > edges, const MVertSkin *vs, const blender::Span< blender::float3 > vert_positions)
static EMatbuild_edge_mats (const MVertSkin *vs, const blender::Span< blender::float3 > vert_positions, const int verts_num, const blender::Span< blender::int2 > edges, blender::GroupedSpan< int > emap, bool *has_valid_root)
static int calc_edge_subdivisions (const blender::Span< blender::float3 > vert_positions, const MVertSkin *nodes, const blender::int2 &edge, const blender::Span< int > degree)
static Meshsubdivide_base (const Mesh *orig)
static void connect_frames (SkinOutput *so, BMVert *frame1[4], BMVert *frame2[4])
static void output_frames (BMesh *bm, SkinNode *sn, const MDeformVert *input_dvert)
static void calc_frame_center (float center[3], const Frame *frame)
static int isect_ray_poly (const float ray_start[3], const float ray_dir[3], BMFace *f, float *r_lambda)
static BMFacecollapse_face_corners (BMesh *bm, BMFace *f, int n, BMVert **orig_verts)
static BMFaceskin_hole_target_face (BMesh *bm, Frame *frame)
static void skin_choose_quad_bridge_order (BMVert *a[4], BMVert *b[4], int best_order[4])
static void skin_fix_hole_no_good_verts (BMesh *bm, Frame *frame, BMFace *split_face)
static void skin_hole_detach_partially_attached_frame (BMesh *bm, Frame *frame)
static void quad_from_tris (BMEdge *e, BMFace *adj[2], BMVert *ndx[4])
static void add_quad_from_tris (SkinOutput *so, BMEdge *e, BMFace *adj[2])
static void hull_merge_triangles (SkinOutput *so, const SkinModifierData *smd)
static void skin_merge_close_frame_verts (SkinNode *skin_nodes, int verts_num, blender::GroupedSpan< int > emap, const blender::Span< blender::int2 > edges)
static void skin_update_merged_vertices (SkinNode *skin_nodes, int verts_num)
static void skin_fix_hull_topology (BMesh *bm, SkinNode *skin_nodes, int verts_num)
static void skin_output_end_nodes (SkinOutput *so, SkinNode *skin_nodes, int verts_num)
static void skin_output_connections (SkinOutput *so, SkinNode *skin_nodes, const blender::Span< blender::int2 > edges)
static void skin_smooth_hulls (BMesh *bm, SkinNode *skin_nodes, int verts_num, const SkinModifierData *smd)
static bool skin_output_branch_hulls (SkinOutput *so, SkinNode *skin_nodes, int verts_num, blender::GroupedSpan< int > emap, const blender::Span< blender::int2 > edges)
 ENUM_OPERATORS (eSkinErrorFlag, SKIN_ERROR_HULL)
static BMeshbuild_skin (SkinNode *skin_nodes, int verts_num, blender::GroupedSpan< int > emap, const blender::Span< blender::int2 > edges, const MDeformVert *input_dvert, SkinModifierData *smd, eSkinErrorFlag *r_error)
static void skin_set_orig_indices (Mesh *mesh)
static Meshbase_skin (Mesh *origmesh, SkinModifierData *smd, eSkinErrorFlag *r_error)
static Meshfinal_skin (SkinModifierData *smd, Mesh *mesh, eSkinErrorFlag *r_error)
static void init_data (ModifierData *md)
static Meshmodify_mesh (ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
static void required_data_mask (ModifierData *, CustomData_MeshMasks *r_cddata_masks)
static void panel_draw (const bContext *, Panel *panel)
static void panel_register (ARegionType *region_type)
Generic BMesh Utilities
static void vert_face_normal_mark_set (BMVert *v)
static void vert_face_normal_mark_update (BMVert *v)
static void vert_array_face_normal_update (BMVert **verts, int verts_len)

Variables

ModifierTypeInfo modifierType_Skin

Macro Definition Documentation

◆ MAX_SKIN_NODE_FRAMES

#define MAX_SKIN_NODE_FRAMES   2

Definition at line 156 of file MOD_skin.cc.

◆ NUM_SUBDIVISIONS_MAX

#define NUM_SUBDIVISIONS_MAX   128

Referenced by calc_edge_subdivisions().

◆ PRINT_HOLE_INFO

#define PRINT_HOLE_INFO   0

Definition at line 1125 of file MOD_skin.cc.

Enumeration Type Documentation

◆ eSkinErrorFlag

Enumerator
SKIN_ERROR_NO_VALID_ROOT 
SKIN_ERROR_HULL 

Definition at line 1815 of file MOD_skin.cc.

◆ SkinNodeFlag

Enumerator
CAP_START 
CAP_END 
SEAM_FRAME 
FLIP_NORMAL 

Definition at line 126 of file MOD_skin.cc.

Function Documentation

◆ add_poly()

◆ add_quad_from_tris()

void add_quad_from_tris ( SkinOutput * so,
BMEdge * e,
BMFace * adj[2] )
static

Definition at line 1478 of file MOD_skin.cc.

References add_poly(), e, quad, and quad_from_tris().

Referenced by hull_merge_triangles().

◆ base_skin()

◆ build_edge_mats()

◆ build_emats_stack()

◆ build_frames()

SkinNode * build_frames ( const blender::Span< blender::float3 > vert_positions,
int verts_num,
const MVertSkin * nodes,
blender::GroupedSpan< int > emap,
EMat * emat )
static

Definition at line 658 of file MOD_skin.cc.

References connection_node_frames(), end_node_frames(), MEM_calloc_arrayN(), size(), and v.

Referenced by base_skin().

◆ build_hull()

◆ build_skin()

◆ calc_edge_mat()

void calc_edge_mat ( float mat[3][3],
const float a[3],
const float b[3] )
static

Definition at line 685 of file MOD_skin.cc.

References b, cross_v3_v3v3(), dot(), dot_v3v3(), normalize_v3(), and sub_v3_v3v3().

Referenced by build_edge_mats(), and build_emats_stack().

◆ calc_edge_subdivisions()

int calc_edge_subdivisions ( const blender::Span< blender::float3 > vert_positions,
const MVertSkin * nodes,
const blender::int2 & edge,
const blender::Span< int > degree )
static

Definition at line 838 of file MOD_skin.cc.

References flag, half_v2(), len_v3v3(), MVERT_SKIN_LOOSE, and NUM_SUBDIVISIONS_MAX.

Referenced by subdivide_base().

◆ calc_frame_center()

void calc_frame_center ( float center[3],
const Frame * frame )
static

Definition at line 1127 of file MOD_skin.cc.

References add_v3_v3(), add_v3_v3v3(), BMVert::co, mul_v3_fl(), and Frame::verts.

Referenced by skin_hole_target_face().

◆ collapse_face_corners()

◆ collect_hull_frames()

Frame ** collect_hull_frames ( int v,
SkinNode * frames,
blender::GroupedSpan< int > emap,
const blender::Span< blender::int2 > edges,
int * tothullframe )
static

◆ connect_frames()

void connect_frames ( SkinOutput * so,
BMVert * frame1[4],
BMVert * frame2[4] )
static

◆ connection_node_frames()

void connection_node_frames ( int v,
SkinNode * skin_nodes,
const blender::Span< blender::float3 > vert_positions,
const MVertSkin * nodes,
blender::GroupedSpan< int > emap,
EMat * emat )
static

◆ connection_node_mat()

int connection_node_mat ( float mat[3][3],
int v,
blender::GroupedSpan< int > emap,
EMat * emat )
static

◆ create_frame()

void create_frame ( Frame * frame,
const float co[3],
const float radius[2],
const float mat[3][3],
float offset )
static

Definition at line 496 of file MOD_skin.cc.

References add_v3_v3v3(), Frame::co, i, mul_v3_v3fl(), and sub_v3_v3v3().

Referenced by connection_node_frames(), and end_node_frames().

◆ end_node_frames()

void end_node_frames ( int v,
SkinNode * skin_nodes,
const blender::Span< blender::float3 > vert_positions,
const MVertSkin * nodes,
blender::GroupedSpan< int > emap,
EMat * emat )
static

◆ ENUM_OPERATORS() [1/2]

ENUM_OPERATORS ( eSkinErrorFlag ,
SKIN_ERROR_HULL  )

References SKIN_ERROR_HULL.

◆ ENUM_OPERATORS() [2/2]

ENUM_OPERATORS ( SkinNodeFlag ,
FLIP_NORMAL  )

References FLIP_NORMAL.

◆ final_skin()

Mesh * final_skin ( SkinModifierData * smd,
Mesh * mesh,
eSkinErrorFlag * r_error )
static

◆ frame_len()

float frame_len ( const Frame * frame)
static

Definition at line 384 of file MOD_skin.cc.

References Frame::co, and len_v3v3().

Referenced by BKE_cachefile_filepath_get(), merge_frame_corners(), and ptcache_frame_from_filename().

◆ half_v2()

float half_v2 ( const float v[2])
static

Definition at line 523 of file MOD_skin.cc.

References v.

Referenced by calc_edge_subdivisions(), connection_node_frames(), end_node_frames(), and subdivide_base().

◆ hull_merge_triangles()

◆ init_data()

◆ is_quad_symmetric()

bool is_quad_symmetric ( BMVert * quad[4],
const SkinModifierData * smd )
static

Definition at line 177 of file MOD_skin.cc.

References copy_v3_v3(), len_squared_v3v3(), quad, and SkinModifierData::symmetry_axes.

Referenced by hull_merge_triangles().

◆ isect_ray_poly()

int isect_ray_poly ( const float ray_start[3],
const float ray_dir[3],
BMFace * f,
float * r_lambda )
static

Definition at line 1137 of file MOD_skin.cc.

References BM_ITER_ELEM, BM_VERTS_OF_FACE, BMVert::co, FLT_MAX, isect_ray_tri_v3(), and v.

Referenced by skin_hole_target_face().

◆ merge_frame_corners()

void merge_frame_corners ( Frame ** frames,
int totframe )
static

◆ modify_mesh()

◆ node_frames_init()

void node_frames_init ( SkinNode * nf,
int totframe )
static

◆ output_frames()

◆ panel_draw()

◆ panel_register()

void panel_register ( ARegionType * region_type)
static

Definition at line 2057 of file MOD_skin.cc.

References eModifierType_Skin, modifier_panel_register(), and panel_draw().

◆ quad_crosses_symmetry_plane()

bool quad_crosses_symmetry_plane ( BMVert * quad[4],
const SkinModifierData * smd )
static

Definition at line 211 of file MOD_skin.cc.

References i, left, quad, and SkinModifierData::symmetry_axes.

Referenced by hull_merge_triangles().

◆ quad_from_tris()

void quad_from_tris ( BMEdge * e,
BMFace * adj[2],
BMVert * ndx[4] )
static

◆ required_data_mask()

void required_data_mask ( ModifierData * ,
CustomData_MeshMasks * r_cddata_masks )
static

◆ skin_choose_quad_bridge_order()

void skin_choose_quad_bridge_order ( BMVert * a[4],
BMVert * b[4],
int best_order[4] )
static

◆ skin_fix_hole_no_good_verts()

◆ skin_fix_hull_topology()

void skin_fix_hull_topology ( BMesh * bm,
SkinNode * skin_nodes,
int verts_num )
static

◆ skin_hole_detach_partially_attached_frame()

void skin_hole_detach_partially_attached_frame ( BMesh * bm,
Frame * frame )
static

Definition at line 1422 of file MOD_skin.cc.

References bm, BM_CREATE_NOP, BM_vert_create(), i, Frame::inside_hull, and Frame::verts.

Referenced by skin_fix_hull_topology().

◆ skin_hole_target_face()

◆ skin_merge_close_frame_verts()

void skin_merge_close_frame_verts ( SkinNode * skin_nodes,
int verts_num,
blender::GroupedSpan< int > emap,
const blender::Span< blender::int2 > edges )
static

Definition at line 1565 of file MOD_skin.cc.

References collect_hull_frames(), MEM_freeN(), merge_frame_corners(), and v.

Referenced by build_skin().

◆ skin_output_branch_hulls()

bool skin_output_branch_hulls ( SkinOutput * so,
SkinNode * skin_nodes,
int verts_num,
blender::GroupedSpan< int > emap,
const blender::Span< blender::int2 > edges )
static

Definition at line 1786 of file MOD_skin.cc.

References build_hull(), collect_hull_frames(), MEM_freeN(), result, SkinNode::totframe, and v.

Referenced by build_skin().

◆ skin_output_connections()

void skin_output_connections ( SkinOutput * so,
SkinNode * skin_nodes,
const blender::Span< blender::int2 > edges )
static

◆ skin_output_end_nodes()

void skin_output_end_nodes ( SkinOutput * so,
SkinNode * skin_nodes,
int verts_num )
static

◆ skin_set_orig_indices()

void skin_set_orig_indices ( Mesh * mesh)
static

◆ skin_smooth_hulls()

◆ skin_update_merged_vertices()

void skin_update_merged_vertices ( SkinNode * skin_nodes,
int verts_num )
static

◆ subdivide_base()

◆ vert_array_face_normal_update()

void vert_array_face_normal_update ( BMVert ** verts,
int verts_len )
static

Recalculate the normals of all faces connected to verts.

Definition at line 106 of file MOD_skin.cc.

References i, vert_face_normal_mark_set(), vert_face_normal_mark_update(), and verts.

Referenced by skin_fix_hole_no_good_verts().

◆ vert_face_normal_mark_set()

void vert_face_normal_mark_set ( BMVert * v)
static

Definition at line 83 of file MOD_skin.cc.

References BM_FACES_OF_VERT, BM_ITER_ELEM, FLT_MAX, BMFace::no, and v.

Referenced by vert_array_face_normal_update().

◆ vert_face_normal_mark_update()

void vert_face_normal_mark_update ( BMVert * v)
static

Variable Documentation

◆ modifierType_Skin

ModifierTypeInfo modifierType_Skin

Definition at line 2062 of file MOD_skin.cc.