Blender V5.3
mesh_normals.cc File Reference
#include <climits>
#include "BLI_math_geom_c.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_array_utils.hh"
#include "BLI_bit_vector.hh"
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_linklist.hh"
#include "BLI_math_base.hh"
#include "BLI_math_vector.hh"
#include "BLI_memarena.hh"
#include "BLI_span.hh"
#include "BLI_task.hh"
#include "BLI_utildefines.hh"
#include "BKE_attribute.hh"
#include "BKE_global.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_mapping.hh"

Go to the source code of this file.

Classes

struct  blender::bke::mesh::VertCornerInfo
struct  blender::bke::mesh::EdgeOneCorner
struct  blender::bke::mesh::EdgeTwoCorners
struct  blender::bke::mesh::EdgeSharp
struct  blender::bke::mesh::CornerSpaceGroup

Namespaces

namespace  blender
 BMesh Iterators.
namespace  blender::bke
namespace  blender::bke::mesh

Macros

#define INDEX_UNSET   INT_MIN
#define INDEX_INVALID   -1
#define IS_EDGE_SHARP(_e2l)

Typedefs

using blender::bke::mesh::EdgeUninitialized = std::monostate
using blender::bke::mesh::VertEdgeInfo = std::variant<EdgeUninitialized, EdgeOneCorner, EdgeTwoCorners, EdgeSharp>
using blender::bke::mesh::LocalEdgeVectorSet

Functions

static void blender::bke::mesh::mix_normals_corner_to_vert (const Span< float3 > vert_positions, const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face_map, const Span< float3 > corner_normals, MutableSpan< float3 > vert_normals)
static void blender::bke::mesh::mix_normals_vert_to_face (const OffsetIndices< int > faces, const Span< int > corner_verts, const Span< float3 > vert_normals, MutableSpan< float3 > face_normals)
static void blender::bke::mesh::mix_normals_corner_to_face (const OffsetIndices< int > faces, const Span< float3 > corner_normals, MutableSpan< float3 > face_normals)
static CornerNormalSpace blender::bke::mesh::corner_fan_space_define (const float3 &lnor, const float3 &vec_ref, const float3 &vec_other, const Span< float3 > edge_vectors)
static float3 blender::bke::mesh::corner_space_custom_data_to_normal (const CornerNormalSpace &lnor_space, const short2 clnor_data)
static void blender::bke::mesh::mesh_edges_sharp_tag (const OffsetIndices< int > faces, const Span< int > corner_verts, const Span< int > corner_edges, const Span< int > corner_to_face_map, const Span< float3 > face_normals, const Span< bool > sharp_faces, const Span< bool > sharp_edges, const float split_angle, MutableSpan< int2 > edge_to_corners, MutableSpan< bool > r_sharp_edges)
static void blender::bke::mesh::collect_corner_info (const OffsetIndices< int > faces, const Span< int > corner_verts, const Span< int > vert_faces, const int vert, MutableSpan< VertCornerInfo > r_corner_infos)
static void blender::bke::mesh::add_corner_to_edge (const Span< int > corner_edges, const Span< bool > sharp_edges, const int local_corner, const int corner, const int other_corner, const bool winding_torwards_vert, VertEdgeInfo &info)
static void blender::bke::mesh::calc_local_edge_indices (MutableSpan< VertCornerInfo > corner_infos, LocalEdgeVectorSet &r_other_vert_to_edge)
static void blender::bke::mesh::calc_connecting_edge_info (const Span< int > corner_edges, const Span< bool > sharp_edges, const Span< bool > sharp_faces, const Span< VertCornerInfo > corner_infos, MutableSpan< VertEdgeInfo > edge_infos)
static void blender::bke::mesh::traverse_fan_local_corners (const Span< VertCornerInfo > corner_infos, const Span< VertEdgeInfo > edge_infos, const int start_local_corner, Vector< int, 16 > &result_fan)
static void blender::bke::mesh::calc_edge_directions (const Span< float3 > vert_positions, const Span< int > local_edge_by_vert, const float3 &vert_position, MutableSpan< float3 > edge_dirs)
static float3 blender::bke::mesh::accumulate_fan_normal (const Span< VertCornerInfo > corner_infos, const Span< float3 > edge_dirs, const Span< float3 > face_normals, const Span< int > local_corners_in_fan)
static BLI_NOINLINE void blender::bke::mesh::handle_fan_result_and_custom_normals (const Span< short2 > custom_normals, const Span< VertCornerInfo > corner_infos, const Span< float3 > edge_dirs, const Span< int > local_corners_in_fan, float3 &fan_normal, CornerNormalSpaceArray *r_fan_spaces, Vector< CornerSpaceGroup, 0 > *r_local_space_groups)
static void blender::bke::mesh::mesh_normals_corner_custom_set (const Span< float3 > positions, const OffsetIndices< int > faces, const Span< int > corner_verts, const Span< int > corner_edges, const GroupedSpan< int > vert_to_face_map, const Span< float3 > vert_normals, const Span< float3 > face_normals, const Span< bool > sharp_faces, const bool use_vertices, MutableSpan< float3 > r_custom_corner_normals, MutableSpan< bool > sharp_edges, MutableSpan< short2 > r_clnors_data)
static void blender::bke::mesh::mesh_set_custom_normals (Mesh &mesh, MutableSpan< float3 > r_custom_nors, const bool use_vertices)
static void blender::bke::normalize_vecs (MutableSpan< float3 > normals)
void blender::bke::mesh_set_custom_normals (Mesh &mesh, MutableSpan< float3 > corner_normals)
void blender::bke::mesh_set_custom_normals_normalized (Mesh &mesh, MutableSpan< float3 > corner_normals)
void blender::bke::mesh_set_custom_normals_from_verts (Mesh &mesh, MutableSpan< float3 > vert_normals)
void blender::bke::mesh_set_custom_normals_from_verts_normalized (Mesh &mesh, MutableSpan< float3 > vert_normals)
static bke::AttrDomain blender::bke::mesh::normal_domain_to_domain (bke::MeshNormalDomain domain)
Topology Queries
void blender::bke::mesh_vert_normals_assign (Mesh &mesh, Span< float3 > vert_normals)
void blender::bke::mesh_vert_normals_assign (Mesh &mesh, Vector< float3 > vert_normals)
Public Utility Functions

Related to managing normals but not directly related to calculating normals.

bool blender::BKE_mesh_vert_normals_are_dirty (const Mesh *mesh)
bool blender::BKE_mesh_face_normals_are_dirty (const Mesh *mesh)
Mesh Normal Calculation (Polygons)
static float3 blender::bke::mesh::normal_calc_ngon (const Span< float3 > vert_positions, const Span< int > face_verts)
Polygon Data Evaluation
float3 blender::bke::mesh::face_normal_calc (Span< float3 > vert_positions, Span< int > face_verts)
Medium-Level Normals Calculation
void blender::bke::mesh::normals_calc_faces (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, MutableSpan< float3 > face_normals)
void blender::bke::mesh::normals_calc_verts (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face_map, Span< float3 > face_normals, MutableSpan< float3 > vert_normals)
Face Corner Normal Calculation
short2 blender::bke::mesh::corner_space_custom_normal_to_data (const CornerNormalSpace &lnor_space, const float3 &custom_lnor)
void blender::bke::mesh::edges_sharp_from_angle_set (OffsetIndices< int > faces, Span< int > corner_verts, Span< int > corner_edges, Span< float3 > face_normals, Span< int > corner_to_face, Span< bool > sharp_faces, const float split_angle, MutableSpan< bool > sharp_edges)
void blender::bke::mesh::normals_calc_corners (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, Span< int > corner_edges, GroupedSpan< int > vert_to_face_map, Span< float3 > face_normals, Span< bool > sharp_edges, Span< bool > sharp_faces, Span< short2 > custom_normals, CornerNormalSpaceArray *r_fan_spaces, MutableSpan< float3 > r_corner_normals)
void blender::bke::mesh::normals_corner_custom_set (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, Span< int > corner_edges, GroupedSpan< int > vert_to_face_map, Span< float3 > vert_normals, Span< float3 > face_normals, Span< bool > sharp_faces, MutableSpan< bool > sharp_edges, MutableSpan< float3 > r_custom_corner_normals, MutableSpan< short2 > r_clnors_data)
void blender::bke::mesh::normals_corner_custom_set_from_verts (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, Span< int > corner_edges, GroupedSpan< int > vert_to_face_map, Span< float3 > vert_normals, Span< float3 > face_normals, Span< bool > sharp_faces, MutableSpan< bool > sharp_edges, MutableSpan< float3 > r_custom_vert_normals, MutableSpan< short2 > r_clnors_data)
bool blender::bke::mesh::is_corner_fan_normals (const AttributeMetaData &meta_data)

Variables

constexpr AttributeMetaData blender::bke::mesh::CORNER_FAN_META_DATA {AttrDomain::Corner, AttrType::Int16_2D}

Mesh Normal Calculation

#define LNOR_SPACE_TRIGO_THRESHOLD   (1.0f - 1e-4f)
void blender::BKE_lnor_spacearr_init (MLoopNorSpaceArray *lnors_spacearr, int numLoops, char data_type)
void blender::BKE_lnor_spacearr_tls_init (MLoopNorSpaceArray *lnors_spacearr, MLoopNorSpaceArray *lnors_spacearr_tls)
void blender::BKE_lnor_spacearr_tls_join (MLoopNorSpaceArray *lnors_spacearr, MLoopNorSpaceArray *lnors_spacearr_tls)
void blender::BKE_lnor_spacearr_clear (MLoopNorSpaceArray *lnors_spacearr)
void blender::BKE_lnor_spacearr_free (MLoopNorSpaceArray *lnors_spacearr)
MLoopNorSpace * blender::BKE_lnor_space_create (MLoopNorSpaceArray *lnors_spacearr)
void blender::BKE_lnor_space_define (MLoopNorSpace *lnor_space, const float lnor[3], const float vec_ref[3], const float vec_other[3], Span< float3 > edge_vectors)
void blender::BKE_lnor_space_add_loop (MLoopNorSpaceArray *lnors_spacearr, MLoopNorSpace *lnor_space, int corner, void *bm_loop, bool is_single)
MINLINE float blender::unit_short_to_float (const short val)
MINLINE short blender::unit_float_to_short (const float val)
void blender::BKE_lnor_space_custom_data_to_normal (const MLoopNorSpace *lnor_space, const short clnor_data[2], float r_custom_lnor[3])
void blender::BKE_lnor_space_custom_normal_to_data (const MLoopNorSpace *lnor_space, const float custom_lnor[3], short r_clnor_data[2])

Detailed Description

Mesh normal calculation functions.

See also
bmesh_mesh_normals.cc for the equivalent #BMesh functionality.

Definition in file mesh_normals.cc.

Macro Definition Documentation

◆ INDEX_INVALID

#define INDEX_INVALID   -1

Definition at line 832 of file mesh_normals.cc.

Referenced by blender::bke::mesh::mesh_edges_sharp_tag().

◆ INDEX_UNSET

#define INDEX_UNSET   INT_MIN

◆ IS_EDGE_SHARP

#define IS_EDGE_SHARP ( _e2l)
Value:
#define ELEM(...)
#define INDEX_INVALID
#define INDEX_UNSET

Definition at line 834 of file mesh_normals.cc.

Referenced by blender::bke::mesh::mesh_edges_sharp_tag().

◆ LNOR_SPACE_TRIGO_THRESHOLD