Blender V5.3
mesh_bevel.cc File Reference
#include <algorithm>
#include <memory>
#include <optional>
#include <utility>
#include <fmt/format.h>
#include "BLI_array.hh"
#include "BLI_array_utils.hh"
#include "BLI_index_mask.hh"
#include "BLI_map.hh"
#include "BLI_math_base.hh"
#include "BLI_math_base_c.hh"
#include "BLI_math_geom.hh"
#include "BLI_math_matrix.hh"
#include "BLI_math_rotation.hh"
#include "BLI_math_vector.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_offset_indices.hh"
#include "BLI_ordered_edge.hh"
#include "BLI_span.hh"
#include "BLI_vector.hh"
#include "BKE_attribute.hh"
#include "BKE_attribute_filters.hh"
#include "BKE_attribute_math.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_mapping.hh"
#include "GEO_mesh_bevel.hh"
#include "GEO_mesh_selection.hh"

Go to the source code of this file.

Classes

struct  blender::geometry::ProfileSpacing
struct  blender::geometry::UVFace
struct  blender::geometry::NewVert
struct  blender::geometry::Profile
struct  blender::geometry::EdgeHalf
struct  blender::geometry::BoundVert
struct  blender::geometry::VMesh
struct  blender::geometry::BevVert
class  blender::geometry::ExtendableMesh
class  blender::geometry::uv::UVMapInfo
struct  blender::geometry::uv::UVMapInfo::UVLayer
struct  blender::geometry::BevelState
struct  blender::geometry::construct::NewCornerInterpData
struct  blender::geometry::construct::NewCornerInterpWeights

Namespaces

namespace  blender
 BMesh Iterators.
namespace  blender::geometry
namespace  blender::geometry::uv
namespace  blender::geometry::geom
namespace  blender::geometry::debug
namespace  blender::geometry::profile
namespace  blender::geometry::construct

Typedefs

using blender::geometry::UVVertBucket = Set<int>
using blender::geometry::UVVertMap = Map<int, Vector<UVVertBucket>>

Enumerations

enum class  blender::geometry::FKind { blender::geometry::Orig = 0 , blender::geometry::Edge = 1 , blender::geometry::Vert = 2 , blender::geometry::Profile = 3 }
enum class  blender::geometry::AngleKind { blender::geometry::Smaller = -1 , blender::geometry::Straight = 0 , blender::geometry::Larger = 1 }
enum class  blender::geometry::MeshKind {
  blender::geometry::None = 0 , blender::geometry::Poly , blender::geometry::Adj , blender::geometry::TriFan ,
  blender::geometry::Cutoff
}
enum class  blender::geometry::VMeshMethod { blender::geometry::Adj , blender::geometry::Cutoff }
enum class  blender::geometry::NewFaceKind : uint8_t { blender::geometry::Other = 0 , blender::geometry::VertexFace = 1 , blender::geometry::EdgeFace = 2 }
enum class  blender::geometry::NewEdgeKind : uint8_t { blender::geometry::Other = 0 , blender::geometry::OuterEdge = 1 , blender::geometry::MidEdge = 2 }
enum  blender::geometry::construct::AngleKind { blender::geometry::construct::ANGLE_SMALLER , blender::geometry::construct::ANGLE_STRAIGHT , blender::geometry::construct::ANGLE_LARGER }

Functions

static int blender::geometry::geom::edge_other_vert (const ExtendableMesh &emesh, int e, int v)
static float3 blender::geometry::geom::slide_dist (const ExtendableMesh &emesh, int e, int v, float d)
static bool blender::geometry::geom::is_outside_edge (const ExtendableMesh &emesh, EdgeHalf *eh, const float co[3], int *ret_closer_v)
static bool blender::geometry::geom::point_between_edges (const ExtendableMesh &emesh, const float co[3], int v, int f, EdgeHalf *e1, EdgeHalf *e2)
static float3 blender::geometry::geom::offset_meet (const ExtendableMesh &emesh, EdgeHalf *e1, EdgeHalf *e2, int v, int f, bool edges_between, const EdgeHalf *e_in_plane)
template<typename T>
static void blender::geometry::debug::print_span (Span< T > span, const char *label)
static void blender::geometry::debug::print_float3 (const float3 &v)
static void blender::geometry::debug::print_float3_span (Span< float3 > span, const char *label)
static void blender::geometry::debug::print_int2 (const int2 pair)
static void blender::geometry::debug::print_int2_span (Span< int2 > span, const char *label)
static void blender::geometry::debug::print_indexrange (const IndexRange &range)
static void blender::geometry::debug::print_groupedspan (const GroupedSpan< int > &groupedspan, const char *label)
static const char * blender::geometry::debug::mesh_kind_name (MeshKind kind)
static void blender::geometry::debug::dump_profile (const Profile &prof)
static void blender::geometry::debug::dump_edge_half (const EdgeHalf &eh, const int index)
static void blender::geometry::debug::dump_bound_vert (const BoundVert &bndv)
static void blender::geometry::debug::dump_vmesh (const VMesh &vm)
static void blender::geometry::debug::dump_bev_vert (const BevVert &bv)
static void blender::geometry::debug::dump_edge_polygons (const BevelState &state, const BevVert &bv)
static void blender::geometry::debug::dump_rebuilt_face (const BevelState &state, const int face_idx)
static void blender::geometry::debug::dump_new_face_examples (const BevelState &state)
static void blender::geometry::debug::dump_new_edge_examples (const BevelState &state)
static void blender::geometry::construct::adjust_miter_coords (const BevelState &state, BevVert *bv, EdgeHalf *emiter)
static void blender::geometry::construct::adjust_miter_inner_coords (const BevelState &state, BevVert *bv, EdgeHalf *emiter)
static bool blender::geometry::construct::edges_face_connected_at_vert (const ExtendableMesh &emesh, const int e1, const int e2)
static int blender::geometry::construct::bev_ccw_test (const ExtendableMesh &emesh, const int a, const int b, const int f)
static bool blender::geometry::construct::fast_bevel_edge_order (const ExtendableMesh &emesh, BevVert *bv, bool is_edge_bevel)
static int blender::geometry::construct::bevel_edge_order_extend (const ExtendableMesh &emesh, BevVert *bv, int i, bool is_edge_bevel)
static BoundVert * blender::geometry::construct::add_new_bound_vert (BevVert *bv, const float3 &co)
static void blender::geometry::construct::adjust_bound_vert (BoundVert *bndv, const float3 &co)
static void blender::geometry::construct::check_edge_data_seam_sharp_edges (const BevelState &state, BevVert *bv, bool check_seam, bool check_sharp)
static void blender::geometry::construct::set_bound_vert_seams (const BevelState &state, BevVert *bv, bool mark_seam, bool mark_sharp)
static float3 blender::geometry::construct::offset_in_plane (const ExtendableMesh &emesh, EdgeHalf *e, const float3 *plane_no, bool left)
static void blender::geometry::construct::build_boundary_vertex_only (const BevelState &state, BevVert *bv, bool construct)
static void blender::geometry::construct::build_boundary_terminal_edge (const BevelState &state, BevVert *bv, EdgeHalf *efirst, const bool construct)
static EdgeHalf * blender::geometry::construct::next_bev (BevVert *bv, EdgeHalf *from_e)
static bool blender::geometry::construct::nearly_parallel_normalized (const float3 &d1, const float3 &d2)
static AngleKind blender::geometry::construct::edges_angle_kind (const ExtendableMesh &emesh, EdgeHalf *e1, EdgeHalf *e2, int v)
static bool blender::geometry::construct::edge_has_miter (const BevelState &state, const EdgeHalf *e, int v)
static void blender::geometry::construct::build_boundary (const BevelState &state, BevVert *bv, bool construct)
static void blender::geometry::construct::find_bevel_edge_order (const ExtendableMesh &emesh, BevVert *bv, int first_e, bool is_edge_bevel)
static double blender::geometry::profile::superellipse_co (double x, float r, bool rbig)
static double blender::geometry::profile::find_superellipse_chord_endpoint (double x0, double dtarget, float r, bool rbig)
static void blender::geometry::profile::find_even_superellipse_chords_general (int seg, float r, MutableSpan< double > xvals, MutableSpan< double > yvals)
static void blender::geometry::profile::find_even_superellipse_chords (int n, float r, MutableSpan< double > xvals, MutableSpan< double > yvals)
static float blender::geometry::profile::find_profile_fullness (BevelState *bs)
static void blender::geometry::profile::set_profile_spacing (BevelState *bs, ProfileSpacing *pro_spacing, bool custom)
static void blender::geometry::construct::determine_uv_vert_connectivity (BevelState &state, const int v)
static void blender::geometry::construct::bevel_vert_construct (BevelState &state, int v)
std::optional< Mesh * > blender::geometry::mesh_bevel (const Mesh &src_mesh, const IndexMask &selection, const BevelParameters &params, const bke::AttributeFilter &attribute_filter)
VMesh grid helpers
static NewVert * blender::geometry::geom::mesh_vert (VMesh *vm, int i, int j, int k)
static NewVert * blender::geometry::geom::mesh_vert_canon (VMesh *vm, int i, int j, int k)
static bool blender::geometry::geom::is_canon (const VMesh *vm, int i, int j, int k)
static void blender::geometry::geom::vmesh_copy_equiv_verts (VMesh *vm)
static float3 blender::geometry::geom::vmesh_center (VMesh *vm)
static float3 blender::geometry::geom::avg4 (const NewVert *v0, const NewVert *v1, const NewVert *v2, const NewVert *v3)
Profile geometry helpers
static bool blender::geometry::geom::nearly_parallel (const float3 &d1, const float3 &d2)
static bool blender::geometry::geom::make_unit_square_map (const float3 &va, const float3 &vmid, const float3 &vb, float4x4 &r_mat)
static float blender::geometry::geom::sabin_gamma (int n)
Profile parameter setup and evaluation
static void blender::geometry::profile::set_profile_params (const BevelState &state, const BevVert *bv, BoundVert *bndv)
static void blender::geometry::profile::move_profile_plane (BoundVert *bndv, float3 bmvert_co)
static float3 blender::geometry::profile::project_to_edge (const ExtendableMesh &emesh, int e_idx, const float3 &co_a, const float3 &co_b)
static void blender::geometry::profile::move_weld_profile_planes (BoundVert *bndv1, BoundVert *bndv2, const float3 v_co)
static void blender::geometry::profile::calculate_profile_segments (const Profile &pro, const float4x4 &map, const bool use_map, const bool reversed, const int ns, const double *xvals, const double *yvals, MutableSpan< float3 > r_prof_co)
static void blender::geometry::profile::calculate_profile (BevelState &state, BoundVert *bndv, bool reversed, bool)
static float3 blender::geometry::profile::get_profile_point (const BevelState &state, const Profile *pro, int i, int nseg)
static void blender::geometry::profile::calculate_vm_profiles (BevelState &state, BevVert *bv, VMesh *vm)
Profile orientation helpers

These functions find the chain or cycle of beveled edges connected to a given edge, and set consistent profile orientations along the chain.

static EdgeHalf * blender::geometry::construct::find_edge_half_for_edge (BevVert *bv, int edge_index)
static EdgeHalf * blender::geometry::construct::find_other_end_edge_half (const BevelState &state, EdgeHalf *e, BevVert **r_bvother)
static EdgeHalf * blender::geometry::construct::next_edgehalf_bev (const BevelState &state, EdgeHalf *start_edge, bool toward_bv, BevVert **r_bv)
static void blender::geometry::construct::regularize_profile_orientation (const BevelState &state, int edge_index)
ADJ vmesh subdivision helpers
static VMesh blender::geometry::construct::adj_vmesh (BevelState &state, BevVert *bv)
static VMesh blender::geometry::construct::new_adj_vmesh (int count, int seg, BoundVert *bounds)
static void blender::geometry::construct::fill_vmesh_fracs (VMesh *vm, MutableSpan< float > frac, int i)
static void blender::geometry::construct::fill_profile_fracs (const BevelState &state, const BoundVert *bndv, MutableSpan< float > frac, const int ns)
static int blender::geometry::construct::interp_range (const Span< float > frac, const int n, const float f, float *r_rest)
static VMesh blender::geometry::construct::interp_vmesh (const BevelState &state, VMesh &vm_in, int nseg)
static VMesh blender::geometry::construct::cubic_subdiv (const BevelState &state, VMesh &vm_in)
static void blender::geometry::construct::snap_to_superellipsoid (float3 &co, const float super_r, const bool midline)
static float4x4 blender::geometry::construct::make_unit_cube_map (const float3 &va, const float3 &vb, const float3 &vc, const float3 &vd)
static VMesh blender::geometry::construct::make_cube_corner_square (const int nseg)
static VMesh blender::geometry::construct::make_cube_corner_square_in (const int nseg)
static VMesh blender::geometry::construct::make_cube_corner_adj_vmesh (BevelState &state)
static float3 blender::geometry::construct::closer_v3_v3v3v3 (const float3 &a, const float3 &b, const float3 &v)
static float3 blender::geometry::construct::snap_to_pipe_profile (const BevelState &state, BevVert *bv, BoundVert *vpipe, bool midline, const float3 &co)
static int blender::geometry::construct::tri_corner_test (const BevelState &state, const BevVert *bv)
static VMesh blender::geometry::construct::tri_corner_adj_vmesh (BevelState &state, BevVert *bv)
Representative face / edge selection

Mirrors the BMesh choose_rep_face, boundvert_rep_face, and frep_for_center_poly functions used to select which original face should be the "example" for new bevel faces. The same 6-criterion lexicographic tie-breaking rule is used.

static bool blender::geometry::construct::face_point_inside_test (const ExtendableMesh &emesh, const int f, const float3 co)
static void blender::geometry::construct::get_incident_edges (const ExtendableMesh &emesh, const int f, const int v_idx, int *r_e1, int *r_e2)
static int blender::geometry::construct::find_face_internal_boundverts (const ExtendableMesh &emesh, const BevVert *bv, const int f, BoundVert *(r_internal[3]))
static float blender::geometry::construct::projected_boundary_area (const BevelState &state, BevVert *bv, const int f)
static bool blender::geometry::construct::is_bad_uv_poly (const BevelState &state, BevVert *bv, const int frep)
static int blender::geometry::construct::choose_rep_face (const BevelState &state, const Span< int > faces)
static int blender::geometry::construct::boundvert_rep_face (const BoundVert *v, int *r_fother)
static int blender::geometry::construct::find_closer_edge (const ExtendableMesh &emesh, const float3 &co, const int e1, const int e2)
static int blender::geometry::construct::snap_edge_for_center_vmesh_vert (const int i, const int n_bndv, const int eprev, const int enext, const Span< int > bndv_rep_faces, const int center_frep, const Span< bool > frep_beats_next)
static void blender::geometry::construct::snap_edges_for_vmesh_vert (const int i, const int j, const int k, const int ns, const int ns2, const int n_bndv, const int eprev, const int enext, const int enextnext, const Span< int > bndv_rep_faces, const int center_frep, const Span< bool > frep_beats_next, int r_snap_edges[4])
static int blender::geometry::construct::frep_for_center_poly (const BevelState &state, const BevVert *bv)
VMesh face builders
static int blender::geometry::construct::bevel_build_poly (BevelState &state, BevVert *bv)
static void blender::geometry::construct::bevel_build_trifan (BevelState &state, BevVert *bv)
static void blender::geometry::construct::bevel_vert_two_edges (BevelState &state, BevVert *bv)
static void blender::geometry::construct::bevel_build_rings (BevelState &state, BevVert *bv)
Face rebuild
static int blender::geometry::construct::count_ccw_edges_between (const EdgeHalf *e1, const EdgeHalf *e2)
static int blender::geometry::construct::bev_rebuild_polygon (BevelState &state, const int f_idx)
static void blender::geometry::construct::bevel_rebuild_existing_polygons (BevelState &state, Vector< int > &r_rebuilt_orig_faces, int &r_rebuilt_face_0)
Edge polygon construction
static bool blender::geometry::construct::bevvert_is_weld_cross (const BevVert *bv)
static void blender::geometry::construct::bevel_build_edge_polygons (BevelState &state, const int edge_index)
VMesh building
static BoundVert * blender::geometry::construct::pipe_test (const BevelState &state, BevVert *bv)
static VMesh blender::geometry::construct::pipe_adj_vmesh (BevelState &state, BevVert *bv, BoundVert *vpipe)
static VMesh blender::geometry::construct::square_out_adj_vmesh (BevelState &state, BevVert *bv)
static void blender::geometry::construct::build_vmesh (BevelState &state, BevVert *bv)
Output mesh assembly
static std::optional< NewCornerInterpData > blender::geometry::construct::resolve_new_corner_interp_data (const ExtendableMesh &emesh, const int nc, const int new_face_fallback)
static void blender::geometry::construct::compute_face_interp_weights (const ExtendableMesh &emesh, const int f_src, const float3 &co, MutableSpan< float > weights)
static NewCornerInterpWeights blender::geometry::construct::compute_new_corner_interp_weights (const ExtendableMesh &emesh)
static void blender::geometry::construct::interpolate_new_corner_attribute_from_faces (const NewCornerInterpWeights &interp_weights, const GSpan src, GMutableSpan dst)
static void blender::geometry::construct::fill_new_corner_uvs (BevelState &state, const NewCornerInterpWeights &interp_weights)
static void blender::geometry::construct::merge_uvs (BevelState &state)
static void blender::geometry::construct::bevel_extend_edge_data (BevelState &state)
static bool blender::geometry::construct::try_propagate_single_value (const bke::AttributeIter &iter, const GVArray &src, const IndexMask &edges_new_no_src, bke::MutableAttributeAccessor &dst_attrs)
static std::optional< Mesh * > blender::geometry::construct::build_output_mesh (const BevelState &state, const NewCornerInterpWeights &interp_weights, const bke::AttributeFilter &attribute_filter)

Variables

constexpr float blender::geometry::geom::BEVEL_EPSILON_D = 1e-6f
constexpr float blender::geometry::geom::BEVEL_EPSILON_SQ = 1e-12f
constexpr float blender::geometry::geom::BEVEL_EPSILON_BIG = 1e-4f
constexpr float blender::geometry::geom::BEVEL_EPSILON_ANG = DEG2RADF(2.0f)
constexpr float blender::geometry::geom::BEVEL_SMALL_ANG = DEG2RADF(10.0f)
const float blender::geometry::geom::BEVEL_SMALL_ANG_DOT = (1.0f - std::cos(BEVEL_SMALL_ANG))
const float blender::geometry::geom::BEVEL_EPSILON_ANG_DOT = (1.0f - std::cos(BEVEL_EPSILON_ANG))
constexpr float blender::geometry::profile::PRO_SQUARE_R = 1e4f
constexpr float blender::geometry::profile::PRO_CIRCLE_R = 2.0f
constexpr float blender::geometry::profile::PRO_LINE_R = 1.0f
constexpr float blender::geometry::profile::PRO_SQUARE_IN_R = 0.0f