Blender  V3.3
Classes | Macros | Typedefs | Enumerations | Functions | Variables
MOD_skin.c File Reference
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_array.h"
#include "BLI_bitmap.h"
#include "BLI_heap_simple.h"
#include "BLI_math.h"
#include "BLI_math_geom.h"
#include "BLI_stack.h"
#include "BLT_translation.h"
#include "DNA_defaults.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_lib_id.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "RNA_prototypes.h"
#include "WM_types.h"
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
#include "bmesh.h"

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
 

Typedefs

typedef struct Frame Frame
 
typedef enum eSkinErrorFlag eSkinErrorFlag
 

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

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 skin_frame_find_contained_faces (const Frame *frame, BMFace *fill_faces[2])
 
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, const MeshElemMap *emap, const MEdge *medge, 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 MVert *mvert, const MVertSkin *nodes, const MeshElemMap *emap, EMat *emat)
 
static int connection_node_mat (float mat[3][3], int v, const MeshElemMap *emap, EMat *emat)
 
static void connection_node_frames (int v, SkinNode *skin_nodes, const MVert *mvert, const MVertSkin *nodes, const MeshElemMap *emap, EMat *emat)
 
static SkinNodebuild_frames (const MVert *mvert, int verts_num, const MVertSkin *nodes, const MeshElemMap *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, const MeshElemMap *emap, const MEdge *medge, const MVertSkin *vs, const MVert *mvert)
 
static EMatbuild_edge_mats (const MVertSkin *vs, const MVert *mvert, const int verts_num, const MEdge *medge, const MeshElemMap *emap, const int edges_num, bool *has_valid_root)
 
static int calc_edge_subdivisions (const MVert *mvert, const MVertSkin *nodes, const MEdge *e, const 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, const MeshElemMap *emap, const MEdge *medge)
 
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 MEdge *medge, int edges_num)
 
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, const MeshElemMap *emap, const MEdge *medge)
 
static BMeshbuild_skin (SkinNode *skin_nodes, int verts_num, const MeshElemMap *emap, const MEdge *medge, int edges_num, 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 initData (ModifierData *md)
 
static MeshmodifyMesh (ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
 
static void requiredDataMask (Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
 
static void panel_draw (const bContext *UNUSED(C), Panel *panel)
 
static void panelRegister (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.c.

◆ NUM_SUBDIVISIONS_MAX

#define NUM_SUBDIVISIONS_MAX   128

◆ PRINT_HOLE_INFO

#define PRINT_HOLE_INFO   0

Definition at line 1113 of file MOD_skin.c.

Typedef Documentation

◆ eSkinErrorFlag

◆ Frame

typedef struct Frame Frame

Definition at line 261 of file frames.hpp.

Enumeration Type Documentation

◆ eSkinErrorFlag

Enumerator
SKIN_ERROR_NO_VALID_ROOT 
SKIN_ERROR_HULL 

Definition at line 1807 of file MOD_skin.c.

◆ SkinNodeFlag

Enumerator
CAP_START 
CAP_END 
SEAM_FRAME 
FLIP_NORMAL 

Definition at line 127 of file MOD_skin.c.

Function Documentation

◆ add_poly()

static void add_poly ( SkinOutput so,
BMVert v1,
BMVert v2,
BMVert v3,
BMVert v4 
)
static

◆ add_quad_from_tris()

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

Definition at line 1472 of file MOD_skin.c.

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

Referenced by hull_merge_triangles().

◆ base_skin()

static Mesh* base_skin ( Mesh origmesh,
SkinModifierData smd,
eSkinErrorFlag r_error 
)
static

◆ build_edge_mats()

static EMat* build_edge_mats ( const MVertSkin vs,
const MVert mvert,
const int  verts_num,
const MEdge medge,
const MeshElemMap emap,
const int  edges_num,
bool has_valid_root 
)
static

◆ build_emats_stack()

static void build_emats_stack ( BLI_Stack stack,
BLI_bitmap visited_e,
EMat emat,
const MeshElemMap emap,
const MEdge medge,
const MVertSkin vs,
const MVert mvert 
)
static

◆ build_frames()

static SkinNode* build_frames ( const MVert mvert,
int  verts_num,
const MVertSkin nodes,
const MeshElemMap emap,
EMat emat 
)
static

Definition at line 651 of file MOD_skin.c.

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

Referenced by base_skin().

◆ build_hull()

static bool build_hull ( SkinOutput so,
Frame **  frames,
int  totframe 
)
static

◆ build_skin()

static BMesh* build_skin ( SkinNode skin_nodes,
int  verts_num,
const MeshElemMap emap,
const MEdge medge,
int  edges_num,
const MDeformVert input_dvert,
SkinModifierData smd,
eSkinErrorFlag r_error 
)
static

◆ calc_edge_mat()

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

◆ calc_edge_subdivisions()

static int calc_edge_subdivisions ( const MVert mvert,
const MVertSkin nodes,
const MEdge e,
const int *  degree 
)
static

Definition at line 828 of file MOD_skin.c.

References MVert::co, e, half_v2(), len_v3v3(), MVERT_SKIN_LOOSE, and NUM_SUBDIVISIONS_MAX.

Referenced by subdivide_base().

◆ calc_frame_center()

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

Definition at line 1115 of file MOD_skin.c.

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

Referenced by skin_hole_target_face().

◆ collapse_face_corners()

static BMFace* collapse_face_corners ( BMesh bm,
BMFace f,
int  n,
BMVert **  orig_verts 
)
static

◆ collect_hull_frames()

static Frame** collect_hull_frames ( int  v,
SkinNode frames,
const MeshElemMap emap,
const MEdge medge,
int *  tothullframe 
)
static

◆ connect_frames()

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

◆ connection_node_frames()

static void connection_node_frames ( int  v,
SkinNode skin_nodes,
const MVert mvert,
const MVertSkin nodes,
const MeshElemMap emap,
EMat emat 
)
static

◆ connection_node_mat()

static int connection_node_mat ( float  mat[3][3],
int  v,
const MeshElemMap emap,
EMat emat 
)
static

◆ create_frame()

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

Definition at line 489 of file MOD_skin.c.

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

Referenced by connection_node_frames(), and end_node_frames().

◆ end_node_frames()

static void end_node_frames ( int  v,
SkinNode skin_nodes,
const MVert mvert,
const MVertSkin nodes,
const MeshElemMap emap,
EMat emat 
)
static

◆ final_skin()

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

◆ frame_len()

static float frame_len ( const Frame frame)
static

◆ half_v2()

static float half_v2 ( const float  v[2])
static

Definition at line 516 of file MOD_skin.c.

References v.

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

◆ hull_merge_triangles()

static void hull_merge_triangles ( SkinOutput so,
const SkinModifierData smd 
)
static

◆ initData()

static void initData ( ModifierData md)
static

◆ is_quad_symmetric()

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

◆ isect_ray_poly()

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

Definition at line 1125 of file MOD_skin.c.

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

Referenced by skin_hole_target_face().

◆ merge_frame_corners()

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

◆ modifyMesh()

static Mesh* modifyMesh ( ModifierData md,
const ModifierEvalContext ctx,
Mesh mesh 
)
static

◆ node_frames_init()

static void node_frames_init ( SkinNode nf,
int  totframe 
)
static

◆ output_frames()

static void output_frames ( BMesh bm,
SkinNode sn,
const MDeformVert input_dvert 
)
static

◆ panel_draw()

static void panel_draw ( const bContext UNUSEDC,
Panel panel 
)
static

◆ panelRegister()

static void panelRegister ( ARegionType region_type)
static

Definition at line 2066 of file MOD_skin.c.

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

◆ quad_crosses_symmetry_plane()

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

Definition at line 211 of file MOD_skin.c.

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

Referenced by hull_merge_triangles().

◆ quad_from_tris()

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

◆ requiredDataMask()

static void requiredDataMask ( Object UNUSEDob,
ModifierData UNUSEDmd,
CustomData_MeshMasks r_cddata_masks 
)
static

Definition at line 2007 of file MOD_skin.c.

References CD_MASK_MDEFORMVERT, CD_MASK_MVERT_SKIN, and CustomData_MeshMasks::vmask.

◆ skin_choose_quad_bridge_order()

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

◆ skin_fix_hole_no_good_verts()

static void skin_fix_hole_no_good_verts ( BMesh bm,
Frame frame,
BMFace split_face 
)
static

◆ skin_fix_hull_topology()

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

◆ skin_frame_find_contained_faces()

static bool skin_frame_find_contained_faces ( const Frame frame,
BMFace fill_faces[2] 
)
static

Definition at line 240 of file MOD_skin.c.

References BM_edge_exists(), BM_edge_face_pair(), and Frame::verts.

Referenced by build_hull().

◆ skin_hole_detach_partially_attached_frame()

static void skin_hole_detach_partially_attached_frame ( BMesh bm,
Frame frame 
)
static

Definition at line 1417 of file MOD_skin.c.

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

Referenced by skin_fix_hull_topology().

◆ skin_hole_target_face()

static BMFace* skin_hole_target_face ( BMesh bm,
Frame frame 
)
static

◆ skin_merge_close_frame_verts()

static void skin_merge_close_frame_verts ( SkinNode skin_nodes,
int  verts_num,
const MeshElemMap emap,
const MEdge medge 
)
static

Definition at line 1558 of file MOD_skin.c.

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

Referenced by build_skin().

◆ skin_output_branch_hulls()

static bool skin_output_branch_hulls ( SkinOutput so,
SkinNode skin_nodes,
int  verts_num,
const MeshElemMap emap,
const MEdge medge 
)
static

Definition at line 1778 of file MOD_skin.c.

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

Referenced by build_skin().

◆ skin_output_connections()

static void skin_output_connections ( SkinOutput so,
SkinNode skin_nodes,
const MEdge medge,
int  edges_num 
)
static

◆ skin_output_end_nodes()

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

◆ skin_set_orig_indices()

static void skin_set_orig_indices ( Mesh mesh)
static

◆ skin_smooth_hulls()

static void skin_smooth_hulls ( BMesh bm,
SkinNode skin_nodes,
int  verts_num,
const SkinModifierData smd 
)
static

◆ skin_update_merged_vertices()

static void skin_update_merged_vertices ( SkinNode skin_nodes,
int  verts_num 
)
static

◆ subdivide_base()

static Mesh* subdivide_base ( const Mesh orig)
static

◆ vert_array_face_normal_update()

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

Recalculate the normals of all faces connected to verts.

Definition at line 107 of file MOD_skin.c.

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

static void vert_face_normal_mark_set ( BMVert v)
static

Definition at line 84 of file MOD_skin.c.

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

Referenced by vert_array_face_normal_update().

◆ vert_face_normal_mark_update()

static void vert_face_normal_mark_update ( BMVert v)
static

Definition at line 93 of file MOD_skin.c.

References BM_face_normal_update(), BM_FACES_OF_VERT, BM_ITER_ELEM, BMFace::no, and v.

Referenced by vert_array_face_normal_update().

Variable Documentation

◆ modifierType_Skin

ModifierTypeInfo modifierType_Skin

Definition at line 2071 of file MOD_skin.c.