Blender V5.3
bmesh_bevel.cc File Reference
#include <algorithm>
#include "MEM_guardedalloc.h"
#include "DNA_curveprofile_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "BLI_alloca.hh"
#include "BLI_map.hh"
#include "BLI_math_base_c.hh"
#include "BLI_math_base_safe.hh"
#include "BLI_math_geom_c.hh"
#include "BLI_math_matrix_c.hh"
#include "BLI_math_rotation_c.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_memarena.hh"
#include "BLI_set.hh"
#include "BLI_utildefines.hh"
#include "BLI_vector.hh"
#include "BKE_curveprofile.h"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_mapping.hh"
#include "eigen_capi.h"
#include "bmesh.hh"
#include "bmesh_bevel.hh"
#include "./intern/bmesh_private.hh"

Go to the source code of this file.

Classes

struct  blender::NewVert
struct  blender::EdgeHalf
struct  blender::Profile
struct  blender::ProfileSpacing
struct  blender::MathLayerInfo
struct  blender::UVFace
struct  blender::BoundVert
struct  blender::VMesh
struct  blender::BevVert
struct  blender::BevelParams

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define BEVEL_EPSILON_D   1e-6
#define BEVEL_EPSILON   1e-6f
#define BEVEL_EPSILON_SQ   1e-12f
#define BEVEL_EPSILON_BIG   1e-4f
#define BEVEL_EPSILON_BIG_SQ   1e-8f
#define BEVEL_EPSILON_ANG   DEG2RADF(2.0f)
#define BEVEL_SMALL_ANG   DEG2RADF(10.0f)
#define BEVEL_SMALL_ANG_DOT   (1.0f - cosf(BEVEL_SMALL_ANG))
#define BEVEL_EPSILON_ANG_DOT   (1.0f - cosf(BEVEL_EPSILON_ANG))
#define BEVEL_MAX_ADJUST_PCT   10.0f
#define BEVEL_MAX_AUTO_ADJUST_PCT   300.0f
#define BEVEL_MATCH_SPEC_WEIGHT   0.2
#define PRO_SQUARE_R   1e4f
#define PRO_CIRCLE_R   2.0f
#define PRO_LINE_R   1.0f
#define PRO_SQUARE_IN_R   0.0f
#define BM_ELEM_LONG_TAG   (1 << 6)
#define EDGE_OUT   4
#define VERT_OUT   8
#define VEC_VALUE_LEN   6
#define BEVEL_GOOD_ANGLE   0.1f
#define BEV_EXTEND_EDGE_DATA_CHECK(eh, flag)
#define HASNOT_SEAMSHARP(eh, flag)
#define BM_BEVEL_EDGE_TAG_ENABLE(bme)
#define BM_BEVEL_EDGE_TAG_DISABLE(bme)
#define BM_BEVEL_EDGE_TAG_TEST(bme)
#define CIRCLE_FULLNESS_SEGS   11

Typedefs

using blender::UVVertBucket = Set<BMLoop *>
using blender::UVVertMap = Map<BMVert *, Vector<UVVertBucket>>

Enumerations

enum  blender::MeshKind {
  blender::M_NONE , blender::M_POLY , blender::M_ADJ , blender::M_TRI_FAN ,
  blender::M_CUTOFF
}
enum  blender::FKind {
  blender::F_NONE , blender::F_ORIG , blender::F_VERT , blender::F_EDGE ,
  blender::F_RECON
}
enum  blender::AngleKind { blender::ANGLE_SMALLER = -1 , blender::ANGLE_STRAIGHT = 0 , blender::ANGLE_LARGER = 1 }

Functions

static void blender::flag_out_edge (BMesh *bm, BMEdge *bme)
static void blender::flag_out_vert (BMesh *bm, BMVert *bmv)
static void blender::disable_flag_out_edge (BMesh *bm, BMEdge *bme)
static void blender::record_face_kind (BevelParams *bp, BMFace *f, FKind fkind)
static FKind blender::get_face_kind (BevelParams *bp, BMFace *f)
static bool blender::nearly_parallel (const float d1[3], const float d2[3])
static bool blender::nearly_parallel_normalized (const float d1[3], const float d2[3])
static BoundVert * blender::add_new_bound_vert (MemArena *mem_arena, VMesh *vm, const float co[3])
BLI_INLINE void blender::adjust_bound_vert (BoundVert *bv, const float co[3])
static NewVert * blender::mesh_vert (VMesh *vm, int i, int j, int k)
static void blender::create_mesh_bmvert (BMesh *bm, VMesh *vm, int i, int j, int k, BMVert *eg)
static void blender::copy_mesh_vert (VMesh *vm, int ito, int jto, int kto, int ifrom, int jfrom, int kfrom)
static EdgeHalf * blender::find_edge_half (BevVert *bv, BMEdge *bme)
static BevVert * blender::find_bevvert (BevelParams *bp, BMVert *bmv)
static UVFace * blender::find_uv_face (BevelParams *bp, BMFace *bmf)
static EdgeHalf * blender::find_other_end_edge_half (BevelParams *bp, EdgeHalf *e, BevVert **r_bvother)
static EdgeHalf * blender::next_bev (BevVert *bv, EdgeHalf *from_e)
static int blender::count_ccw_edges_between (EdgeHalf *e1, EdgeHalf *e2)
static bool blender::edges_face_connected_at_vert (BMEdge *bme1, BMEdge *bme2)
static UVFace * blender::register_uv_face (BevelParams *bp, BMFace *fnew, BMFace *frep, BMFace **frep_arr)
static void blender::update_uv_vert_map (BevelParams *bp, UVFace *uv_face, BMVert *bv, Map< BMVert *, BMVert * > *nv_bv_map)
static void blender::determine_uv_vert_connectivity (BevelParams *bp, BMesh *bm, BMVert *v)
static void blender::bevel_merge_uvs (BevelParams *bp, BMesh *bm)
static BMFace * blender::boundvert_rep_face (BoundVert *v, BMFace **r_fother)
static BMFace * blender::bev_create_ngon (BevelParams *bp, BMesh *bm, BMVert **vert_arr, const int totv, BMFace **face_arr, BMFace *facerep, BMEdge **snap_edge_arr, BMVert *bv, Map< BMVert *, BMVert * > *nv_bv_map, int mat_nr, bool do_interp)
static bool blender::contig_ldata_across_loops (BMesh *bm, BMLoop *l1, BMLoop *l2, int layer_index)
static bool blender::contig_ldata_across_edge (BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f2)
static bool blender::contig_ldata_around_vert (BMesh *bm, BMVert *v)
static void blender::swap_face_components (int *face_component, int totface, int c1, int c2)
static void blender::uv_vert_map_init (BevelParams *bp, BMesh *bm)
static void blender::uv_vert_map_pop (BevelParams *bp, BMVert *v)
static void blender::math_layer_info_init (BevelParams *bp, BMesh *bm)
static BMFace * blender::choose_rep_face (BevelParams *bp, BMFace **face, int nfaces)
static void blender::slide_dist (EdgeHalf *e, BMVert *v, float d, float r_slideco[3])
static bool blender::is_outside_edge (EdgeHalf *e, const float co[3], BMVert **ret_closer_v)
static AngleKind blender::edges_angle_kind (EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
static bool blender::point_between_edges (const float co[3], BMVert *v, BMFace *f, EdgeHalf *e1, EdgeHalf *e2)
static bool blender::edge_edge_angle_less_than_180 (const BMEdge *e1, const BMEdge *e2, const BMFace *f)
static void blender::offset_meet_lines_percent_or_absolute (BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float r_l1a[3], float r_l1b[3], float r_l2a[3], float r_l2b[3])
static void blender::offset_meet (BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool edges_between, float meetco[3], const EdgeHalf *e_in_plane)
static bool blender::offset_meet_edge (EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetco[3], float *r_angle)
static bool blender::good_offset_on_edge_between (EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v)
static bool blender::offset_on_edge_between (BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v, float meetco[3], float *r_sinratio)
static void blender::offset_in_plane (EdgeHalf *e, const float plane_no[3], bool left, float r_co[3])
static void blender::project_to_edge (const BMEdge *e, const float co_a[3], const float co_b[3], float projco[3])
static void blender::set_profile_params (BevelParams *bp, BevVert *bv, BoundVert *bndv)
static void blender::move_profile_plane (BoundVert *bndv, BMVert *bmvert)
static void blender::move_weld_profile_planes (BevVert *bv, BoundVert *bndv1, BoundVert *bndv2)
static int blender::bev_ccw_test (BMEdge *a, BMEdge *b, BMFace *f)
static bool blender::make_unit_square_map (const float va[3], const float vmid[3], const float vb[3], float r_mat[4][4])
static void blender::make_unit_cube_map (const float va[3], const float vb[3], const float vc[3], const float vd[3], float r_mat[4][4])
static double blender::superellipse_co (double x, float r, bool rbig)
static void blender::get_profile_point (BevelParams *bp, const Profile *pro, int i, int nseg, float r_co[3])
static void blender::calculate_profile_segments (const Profile *profile, const float map[4][4], const bool use_map, const bool reversed, const int ns, const double *xvals, const double *yvals, float *r_prof_co)
static void blender::calculate_profile (BevelParams *bp, BoundVert *bndv, bool reversed, bool miter)
static void blender::snap_to_superellipsoid (float co[3], const float super_r, bool midline)
static void blender::check_edge_data_seam_sharp_edges (BevVert *bv, int flag)
static void blender::bevel_extend_edge_data_ex (BevVert *bv, int flag)
static void blender::bevel_extend_edge_data (BevVert *bv)
static void blender::bevel_edges_sharp_boundary (BMesh *bm, BevelParams *bp)
static void blender::bevel_harden_normals (BevelParams *bp, BMesh *bm)
 Harden normals for bevel.
static void blender::bevel_set_weighted_normal_face_strength (BMesh *bm, BevelParams *bp)
static void blender::set_bound_vert_seams (BevVert *bv, bool mark_seam, bool mark_sharp)
static bool blender::eh_on_plane (EdgeHalf *e)
static void blender::calculate_vm_profiles (BevelParams *bp, BevVert *bv, VMesh *vm)
static void blender::build_boundary_vertex_only (BevelParams *bp, BevVert *bv, bool construct)
static void blender::build_boundary_terminal_edge (BevelParams *bp, BevVert *bv, EdgeHalf *efirst, const bool construct)
static void blender::adjust_miter_coords (BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
static void blender::adjust_miter_inner_coords (BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
static void blender::build_boundary (BevelParams *bp, BevVert *bv, bool construct)
static EdgeHalf * blender::next_edgehalf_bev (BevelParams *bp, EdgeHalf *start_edge, bool toward_bv, BevVert **r_bv)
static void blender::regularize_profile_orientation (BevelParams *bp, BMEdge *bme)
static void blender::adjust_the_cycle_or_chain (BoundVert *vstart, bool iscycle)
static void blender::adjust_offsets (BevelParams *bp, BMesh *bm)
static BoundVert * blender::pipe_test (BevVert *bv)
static VMesh * blender::new_adj_vmesh (MemArena *mem_arena, int count, int seg, BoundVert *bounds)
static NewVert * blender::mesh_vert_canon (VMesh *vm, int i, int j, int k)
static bool blender::is_canon (VMesh *vm, int i, int j, int k)
static void blender::vmesh_copy_equiv_verts (VMesh *vm)
static void blender::vmesh_center (VMesh *vm, float r_cent[3])
static void blender::avg4 (float co[3], const NewVert *v0, const NewVert *v1, const NewVert *v2, const NewVert *v3)
static float blender::sabin_gamma (int n)
static void blender::fill_vmesh_fracs (VMesh *vm, float *frac, int i)
static void blender::fill_profile_fracs (BevelParams *bp, BoundVert *bndv, float *frac, int ns)
static int blender::interp_range (const float *frac, int n, const float f, float *r_rest)
static VMesh * blender::interp_vmesh (BevelParams *bp, VMesh *vm_in, int nseg)
static VMesh * blender::cubic_subdiv (BevelParams *bp, VMesh *vm_in)
static VMesh * blender::make_cube_corner_square (MemArena *mem_arena, int nseg)
static VMesh * blender::make_cube_corner_square_in (MemArena *mem_arena, int nseg)
static VMesh * blender::make_cube_corner_adj_vmesh (BevelParams *bp)
static int blender::tri_corner_test (BevelParams *bp, BevVert *bv)
static VMesh * blender::tri_corner_adj_vmesh (BevelParams *bp, BevVert *bv)
static VMesh * blender::adj_vmesh (BevelParams *bp, BevVert *bv)
static void blender::snap_to_pipe_profile (BoundVert *vpipe, bool midline, float co[3])
static VMesh * blender::pipe_adj_vmesh (BevelParams *bp, BevVert *bv, BoundVert *vpipe)
static void blender::get_incident_edges (BMFace *f, BMVert *v, BMEdge **r_e1, BMEdge **r_e2)
static BMEdge * blender::find_closer_edge (float *co, BMEdge *e1, BMEdge *e2)
static int blender::find_face_internal_boundverts (const BevVert *bv, const BMFace *f, BoundVert *(r_internal[3]))
static float blender::projected_boundary_area (BevVert *bv, BMFace *f)
static bool blender::is_bad_uv_poly (BevVert *bv, BMFace *frep)
static BMFace * blender::frep_for_center_poly (BevelParams *bp, BevVert *bv)
static void blender::build_center_ngon (BevelParams *bp, BMesh *bm, BevVert *bv, int mat_nr)
static void blender::build_square_in_vmesh (BevelParams *bp, BMesh *bm, BevVert *bv, VMesh *vm1)
static void blender::closer_v3_v3v3v3 (float r[3], const float a[3], const float b[3], const float v[3])
static VMesh * blender::square_out_adj_vmesh (BevelParams *bp, BevVert *bv)
static BMEdge * blender::snap_edge_for_center_vmesh_vert (int i, int n_bndv, BMEdge *eprev, BMEdge *enext, BMFace **bndv_rep_faces, BMFace *center_frep, const bool *frep_beats_next)
static void blender::snap_edges_for_vmesh_vert (int i, int j, int k, int ns, int ns2, int n_bndv, BMEdge *eprev, BMEdge *enext, BMEdge *enextnext, BMFace **bndv_rep_faces, BMFace *center_frep, const bool *frep_beats_next, BMEdge *r_snap_edges[4])
static void blender::bevel_build_rings (BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert *vpipe)
static void blender::bevel_build_cutoff (BevelParams *bp, BMesh *bm, BevVert *bv)
static BMFace * blender::bevel_build_poly (BevelParams *bp, BMesh *bm, BevVert *bv)
static void blender::bevel_build_trifan (BevelParams *bp, BMesh *bm, BevVert *bv)
static void blender::bevel_vert_two_edges (BevelParams *bp, BMesh *bm, BevVert *bv)
static void blender::build_vmesh (BevelParams *bp, BMesh *bm, BevVert *bv)
static float blender::edge_face_angle (EdgeHalf *e)
static int blender::bevel_edge_order_extend (BMesh *bm, BevVert *bv, int i)
static bool blender::fast_bevel_edge_order (BevVert *bv)
static void blender::find_bevel_edge_order (BMesh *bm, BevVert *bv, BMEdge *first_bme)
static BevVert * blender::bevel_vert_construct (BMesh *bm, BevelParams *bp, BMVert *v)
static bool blender::bev_rebuild_polygon (BMesh *bm, BevelParams *bp, BMFace *f, BMFace **r_new_face=nullptr)
static void blender::bevel_rebuild_existing_polygons (BMesh *bm, BevelParams *bp, BMVert *v, Set< BMFace * > &rebuilt_orig_faces, BMFace **r_rebuilt_face_0=nullptr)
static void blender::bevel_reattach_wires (BMesh *bm, BevelParams *bp, BMVert *v)
static bool blender::bevvert_is_weld_cross (BevVert *bv)
static void blender::weld_cross_attrs_copy (BMesh *bm, BevVert *bv, VMesh *vm, int vmindex, EdgeHalf *e)
static void blender::bevel_build_edge_polygons (BMesh *bm, BevelParams *bp, BMEdge *bme)
static double blender::find_superellipse_chord_endpoint (double x0, double dtarget, float r, bool rbig)
static void blender::find_even_superellipse_chords_general (int seg, float r, double *xvals, double *yvals)
static void blender::find_even_superellipse_chords (int n, float r, double *xvals, double *yvals)
static float blender::find_profile_fullness (BevelParams *bp)
static void blender::set_profile_spacing (BevelParams *bp, ProfileSpacing *pro_spacing, bool custom)
static float blender::geometry_collide_offset (BevelParams *bp, EdgeHalf *eb)
static float blender::vertex_collide_offset (BevelParams *bp, EdgeHalf *ea)
static void blender::bevel_limit_offset (BevelParams *bp, BMesh *bm)
void blender::BM_mesh_bevel (BMesh *bm, const float offset, const int offset_type, const int profile_type, const int segments, const float profile, const bool affect_type, const bool use_weights, const bool limit_offset, const MDeformVert *dvert, const int vertex_group, const int mat, const bool loop_slide, const bool mark_seam, const bool mark_sharp, const bool harden_normals, const int face_strength_mode, const int miter_outer, const int miter_inner, const float spread, const CurveProfile *custom_profile, const int vmesh_method, const int bweight_offset_vert, const int bweight_offset_edge)

Detailed Description

Main functions for beveling a BMesh (used by the tool and modifier)

Definition in file bmesh_bevel.cc.

Macro Definition Documentation

◆ BEV_EXTEND_EDGE_DATA_CHECK

#define BEV_EXTEND_EDGE_DATA_CHECK ( eh,
flag )
Value:
BM_elem_flag_test(eh->e, flag)
#define BM_elem_flag_test(ele, hflag)

Definition at line 2832 of file bmesh_bevel.cc.

◆ BEVEL_EPSILON

◆ BEVEL_EPSILON_ANG

◆ BEVEL_EPSILON_ANG_DOT

#define BEVEL_EPSILON_ANG_DOT   (1.0f - cosf(BEVEL_EPSILON_ANG))

Difference in dot products that corresponds to 2.0 degree difference between vectors.

Definition at line 62 of file bmesh_bevel.cc.

Referenced by blender::nearly_parallel_normalized().

◆ BEVEL_EPSILON_BIG

◆ BEVEL_EPSILON_BIG_SQ

#define BEVEL_EPSILON_BIG_SQ   1e-8f

Definition at line 56 of file bmesh_bevel.cc.

◆ BEVEL_EPSILON_D

#define BEVEL_EPSILON_D   1e-6

Definition at line 52 of file bmesh_bevel.cc.

Referenced by blender::slide_dist(), and blender::snap_to_pipe_profile().

◆ BEVEL_EPSILON_SQ

#define BEVEL_EPSILON_SQ   1e-12f

Definition at line 54 of file bmesh_bevel.cc.

Referenced by blender::adj_vmesh().

◆ BEVEL_GOOD_ANGLE

#define BEVEL_GOOD_ANGLE   0.1f

Definition at line 2073 of file bmesh_bevel.cc.

Referenced by blender::offset_meet_edge().

◆ BEVEL_MATCH_SPEC_WEIGHT

#define BEVEL_MATCH_SPEC_WEIGHT   0.2

Definition at line 65 of file bmesh_bevel.cc.

Referenced by blender::adjust_the_cycle_or_chain().

◆ BEVEL_MAX_ADJUST_PCT

#define BEVEL_MAX_ADJUST_PCT   10.0f

Definition at line 63 of file bmesh_bevel.cc.

◆ BEVEL_MAX_AUTO_ADJUST_PCT

#define BEVEL_MAX_AUTO_ADJUST_PCT   300.0f

Definition at line 64 of file bmesh_bevel.cc.

◆ BEVEL_SMALL_ANG

#define BEVEL_SMALL_ANG   DEG2RADF(10.0f)

Definition at line 58 of file bmesh_bevel.cc.

Referenced by blender::offset_meet(), and blender::square_out_adj_vmesh().

◆ BEVEL_SMALL_ANG_DOT

#define BEVEL_SMALL_ANG_DOT   (1.0f - cosf(BEVEL_SMALL_ANG))

Difference in dot products that corresponds to 10 degree difference between vectors.

Definition at line 60 of file bmesh_bevel.cc.

Referenced by blender::next_edgehalf_bev().

◆ BM_BEVEL_EDGE_TAG_DISABLE

#define BM_BEVEL_EDGE_TAG_DISABLE ( bme)
Value:
BM_ELEM_API_FLAG_DISABLE((bme), _FLAG_OVERLAP)
#define BM_ELEM_API_FLAG_DISABLE(element, f)

Definition at line 6596 of file bmesh_bevel.cc.

Referenced by blender::bevel_edge_order_extend(), blender::bevel_vert_construct(), and blender::fast_bevel_edge_order().

◆ BM_BEVEL_EDGE_TAG_ENABLE

#define BM_BEVEL_EDGE_TAG_ENABLE ( bme)

◆ BM_BEVEL_EDGE_TAG_TEST

#define BM_BEVEL_EDGE_TAG_TEST ( bme)
Value:
BM_ELEM_API_FLAG_TEST((bme), _FLAG_OVERLAP)
#define BM_ELEM_API_FLAG_TEST(element, f)

Definition at line 6597 of file bmesh_bevel.cc.

Referenced by blender::bevel_edge_order_extend(), blender::fast_bevel_edge_order(), and blender::find_bevel_edge_order().

◆ BM_ELEM_LONG_TAG

#define BM_ELEM_LONG_TAG   (1 << 6)

◆ CIRCLE_FULLNESS_SEGS

#define CIRCLE_FULLNESS_SEGS   11

◆ EDGE_OUT

#define EDGE_OUT   4

Definition at line 754 of file bmesh_bevel.cc.

◆ HASNOT_SEAMSHARP

#define HASNOT_SEAMSHARP ( eh,
flag )
Value:
((flag == BM_ELEM_SEAM && !BM_elem_flag_test(eh->e, BM_ELEM_SEAM)) || \
(flag == BM_ELEM_SMOOTH && BM_elem_flag_test(eh->e, BM_ELEM_SMOOTH)))

Definition at line 2848 of file bmesh_bevel.cc.

Referenced by blender::check_edge_data_seam_sharp_edges().

◆ PRO_CIRCLE_R

◆ PRO_LINE_R

◆ PRO_SQUARE_IN_R

◆ PRO_SQUARE_R

◆ VEC_VALUE_LEN

#define VEC_VALUE_LEN   6

◆ VERT_OUT

#define VERT_OUT   8

Definition at line 755 of file bmesh_bevel.cc.