Blender V5.0
blender::bke::mesh Namespace Reference

Classes

struct  CornerNormalSpace
struct  CornerNormalSpaceArray
class  NormalJoinInfo
struct  VertCornerInfo
struct  EdgeOneCorner
struct  EdgeTwoCorners
struct  EdgeSharp
struct  CornerSpaceGroup
struct  MeshToTangentQuadsTris
struct  SGLSLMeshToTangent
struct  LocalData

Typedefs

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

Functions

int face_corner_prev (const IndexRange face, const int corner)
int face_corner_next (const IndexRange face, const int corner)
int face_find_corner_from_vert (const IndexRange face, const Span< int > corner_verts, const int vert)
int2 face_find_adjacent_verts (const IndexRange face, const Span< int > corner_verts, const int vert)
int face_triangles_num (const int face_size)
IndexRange face_triangles_range (OffsetIndices< int > faces, int face_i)
int edge_other_vert (const int2 edge, const int vert)
Array< int > build_corner_to_face_map (OffsetIndices< int > faces)
GroupedSpan< int > build_vert_to_edge_map (Span< int2 > edges, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
void build_vert_to_face_indices (OffsetIndices< int > faces, Span< int > corner_verts, OffsetIndices< int > offsets, MutableSpan< int > face_indices)
GroupedSpan< int > build_vert_to_face_map (OffsetIndices< int > faces, Span< int > corner_verts, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
Array< int > build_vert_to_corner_indices (Span< int > corner_verts, OffsetIndices< int > offsets)
GroupedSpan< int > build_vert_to_corner_map (Span< int > corner_verts, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
GroupedSpan< int > build_edge_to_corner_map (Span< int > corner_edges, int edges_num, Array< int > &r_offsets, Array< int > &r_indices)
GroupedSpan< int > build_edge_to_face_map (OffsetIndices< int > faces, Span< int > corner_edges, int edges_num, Array< int > &r_offsets, Array< int > &r_indices)
void calc_uv_tangent_tris_quads (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, Span< float3 > corner_normals, Span< float2 > uv_map, MutableSpan< float4 > results, ReportList *reports)
static float3 face_center_calc_ngon (const Span< float3 > vert_positions, const Span< int > face_verts)
static float mesh_calc_face_volume_centroid_with_reference_center (const Span< float3 > positions, const Span< int > face_verts, const float3 &reference_center, float r_cent[3])
static float face_area_centroid_calc (const Span< float3 > positions, const Span< int > face_verts, float r_cent[3])
static Array< int > create_reverse_offsets (const Span< int > indices, const int items_num)
static void sort_small_groups (const OffsetIndices< int > groups, const int grain_size, MutableSpan< int > indices)
static Array< int > reverse_indices_in_groups (const Span< int > group_indices, const OffsetIndices< int > offsets)
static void reverse_group_indices_in_groups (const OffsetIndices< int > groups, const Span< int > group_to_elem, const OffsetIndices< int > offsets, MutableSpan< int > results)
static GroupedSpan< int > gather_groups (const Span< int > group_indices, const int groups_num, Array< int > &r_offsets, Array< int > &r_indices)
static void 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 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 mix_normals_corner_to_face (const OffsetIndices< int > faces, const Span< float3 > corner_normals, MutableSpan< float3 > face_normals)
static CornerNormalSpace corner_fan_space_define (const float3 &lnor, const float3 &vec_ref, const float3 &vec_other, const Span< float3 > edge_vectors)
static float3 corner_space_custom_data_to_normal (const CornerNormalSpace &lnor_space, const short2 clnor_data)
static void 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 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 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 calc_local_edge_indices (MutableSpan< VertCornerInfo > corner_infos, LocalEdgeVectorSet &r_other_vert_to_edge)
static void 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 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 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 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 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 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 mesh_set_custom_normals (Mesh &mesh, MutableSpan< float3 > r_custom_nors, const bool use_vertices)
static bke::AttrDomain normal_domain_to_domain (bke::MeshNormalDomain domain)
Polygon Data Evaluation
float3 face_normal_calc (Span< float3 > vert_positions, Span< int > face_verts)
void corner_tris_calc (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, MutableSpan< int3 > corner_tris)
void corner_tris_calc_with_normals (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, Span< float3 > face_normals, MutableSpan< int3 > corner_tris)
void corner_tris_calc_face_indices (OffsetIndices< int > faces, MutableSpan< int > tri_faces)
void vert_tris_from_corner_tris (Span< int > corner_verts, Span< int3 > corner_tris, MutableSpan< int3 > vert_tris)
int3 corner_tri_get_real_edges (Span< int2 > edges, Span< int > corner_verts, Span< int > corner_edges, const int3 &corner_tri)
float3 face_center_calc (Span< float3 > vert_positions, Span< int > face_verts)
float face_area_calc (Span< float3 > vert_positions, Span< int > face_verts)
void face_angles_calc (Span< float3 > vert_positions, Span< int > face_verts, MutableSpan< float > angles)
Medium-Level Normals Calculation
void normals_calc_faces (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, MutableSpan< float3 > face_normals)
void 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 corner_space_custom_normal_to_data (const CornerNormalSpace &lnor_space, const float3 &custom_lnor)
void 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 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 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)
void 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)
bool is_corner_fan_normals (const AttributeMetaData &meta_data)
Mesh Tangent Calculations (All Layers)
Array< Array< float4 > > calc_uv_tangents (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, Span< int3 > corner_tris, Span< int > corner_tri_faces, Span< bool > sharp_faces, Span< float3 > vert_normals, Span< float3 > face_normals, Span< float3 > corner_normals, Span< Span< float2 > > uv_maps)
Array< float4calc_orco_tangents (Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, Span< int3 > corner_tris, Span< int > corner_tri_faces, Span< bool > sharp_faces, Span< float3 > vert_normals, Span< float3 > face_normals, Span< float3 > corner_normals, Span< float3 > vert_orco)
static void calc_face_as_quad_map (const OffsetIndices< int > faces, const Span< int3 > corner_tris, const Span< int > corner_tri_faces, int &num_face_as_quad_map, int *&face_as_quad_map)
Mesh Normal Calculation (Polygons)
static float3 normal_calc_ngon (const Span< float3 > vert_positions, const Span< int > face_verts)
Face Tessellation

Fill in Corner Triangle Array

BLI_INLINE void mesh_calc_tessellation_for_face_impl (const Span< int > corner_verts, const Span< float3 > positions, const int face_start, const int face_size, int3 *tri, MemArena **pf_arena_p, const bool face_normal, const float normal_precalc[3])
static void mesh_calc_tessellation_for_face (const Span< int > corner_verts, const Span< float3 > positions, const int face_start, const int face_size, int3 *tri, MemArena **pf_arena_p)
static void mesh_calc_tessellation_for_face_with_normal (const Span< int > corner_verts, const Span< float3 > positions, const int face_start, const int face_size, int3 *tri, MemArena **pf_arena_p, const float normal_precalc[3])
static void corner_tris_calc_impl (const Span< float3 > positions, const OffsetIndices< int > faces, const Span< int > corner_verts, const Span< float3 > face_normals, MutableSpan< int3 > corner_tris)

Variables

constexpr AttributeMetaData CORNER_FAN_META_DATA {AttrDomain::Corner, AttrType::Int16_2D}

Typedef Documentation

◆ EdgeUninitialized

using blender::bke::mesh::EdgeUninitialized = std::monostate

The edge hasn't been handled yet while the edge info is being created.

Definition at line 966 of file mesh_normals.cc.

◆ LocalEdgeVectorSet

◆ VertEdgeInfo

Function Documentation

◆ accumulate_fan_normal()

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

◆ add_corner_to_edge()

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

◆ build_corner_to_face_map()

Array< int > blender::bke::mesh::build_corner_to_face_map ( OffsetIndices< int > faces)

◆ build_edge_to_corner_map()

GroupedSpan< int > blender::bke::mesh::build_edge_to_corner_map ( Span< int > corner_edges,
int edges_num,
Array< int > & r_offsets,
Array< int > & r_indices )

◆ build_edge_to_face_map()

◆ build_vert_to_corner_indices()

Array< int > blender::bke::mesh::build_vert_to_corner_indices ( Span< int > corner_verts,
OffsetIndices< int > offsets )

◆ build_vert_to_corner_map()

GroupedSpan< int > blender::bke::mesh::build_vert_to_corner_map ( Span< int > corner_verts,
int verts_num,
Array< int > & r_offsets,
Array< int > & r_indices )

Definition at line 397 of file mesh_mapping.cc.

References build_vert_to_corner_map(), and gather_groups().

Referenced by build_vert_to_corner_map().

◆ build_vert_to_edge_map()

GroupedSpan< int > blender::bke::mesh::build_vert_to_edge_map ( Span< int2 > edges,
int verts_num,
Array< int > & r_offsets,
Array< int > & r_indices )

Definition at line 347 of file mesh_mapping.cc.

References BLI_SCOPED_DEFER, build_vert_to_edge_map(), blender::Span< T >::cast(), create_reverse_offsets(), blender::Span< T >::index_range(), MEM_calloc_arrayN(), MEM_freeN(), blender::threading::parallel_for(), blender::Array< T, InlineBufferCapacity, Allocator >::reinitialize(), blender::offset_indices::OffsetIndices< T >::size(), and blender::offset_indices::OffsetIndices< T >::total_size().

Referenced by base_skin(), BKE_mesh_remap_calc_edges_from_mesh(), blender::nodes::node_geo_blur_attribute_cc::build_edge_to_edge_by_vert_map(), build_vert_to_edge_map(), blender::nodes::node_geo_extrude_mesh_cc::build_vert_to_edge_map(), blender::nodes::node_geo_blur_attribute_cc::build_vert_to_vert_by_edge_map(), blender::bke::compare_geometry::construct_vert_mapping(), blender::draw::DRW_subdivide_loose_geom(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_vertices(), blender::ed::sculpt_paint::expand::geodesic_falloff_create(), blender::nodes::node_geo_input_shortest_edge_paths_cc::ShortestEdgePathsCostFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_shortest_edge_paths_cc::ShortestEdgePathsNextVertFieldInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_edges_of_vertex_cc::EdgesOfVertInput::get_varray_for_context(), blender::ed::object::modifier_skin_armature_create(), blender::geometry::split_edges(), blender::bke::subdiv::subdiv_to_mesh(), and blender::ed::object::vgroup_smooth_subset().

◆ build_vert_to_face_indices()

void blender::bke::mesh::build_vert_to_face_indices ( OffsetIndices< int > faces,
Span< int > corner_verts,
OffsetIndices< int > offsets,
MutableSpan< int > face_indices )

◆ build_vert_to_face_map()

GroupedSpan< int > blender::bke::mesh::build_vert_to_face_map ( OffsetIndices< int > faces,
Span< int > corner_verts,
int verts_num,
Array< int > & r_offsets,
Array< int > & r_indices )

◆ calc_connecting_edge_info()

◆ calc_edge_directions()

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

The edge directions are used to compute factors for the face normals from each corner. Since they involve a normalization it's worth it to compute them once, especially since we've deduplicated the edge indices and can easily index them with VertCornerInfo.

Definition at line 1149 of file mesh_normals.cc.

References calc_edge_directions(), i, blender::Span< T >::index_range(), and blender::math::normalize().

Referenced by calc_edge_directions().

◆ calc_face_as_quad_map()

void blender::bke::mesh::calc_face_as_quad_map ( const OffsetIndices< int > faces,
const Span< int3 > corner_tris,
const Span< int > corner_tri_faces,
int & num_face_as_quad_map,
int *& face_as_quad_map )
static

Definition at line 267 of file mesh_tangent.cc.

References faces, MEM_malloc_arrayN(), blender::Span< T >::size(), and size().

Referenced by calc_uv_tangents().

◆ calc_local_edge_indices()

void blender::bke::mesh::calc_local_edge_indices ( MutableSpan< VertCornerInfo > corner_infos,
LocalEdgeVectorSet & r_other_vert_to_edge )
static

Create a local indexing for the edges connected to the vertex (not including loose edges of course). We could look up the edge indices from the VectorSet as necessary later, but it should be better to just use a bit more space in VertCornerInfo to simplify things instead.

Definition at line 1048 of file mesh_normals.cc.

References calc_local_edge_indices(), blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::index_of_or_add(), blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::reserve(), and blender::MutableSpan< T >::size().

Referenced by calc_local_edge_indices().

◆ calc_orco_tangents()

◆ calc_uv_tangent_tris_quads()

void blender::bke::mesh::calc_uv_tangent_tris_quads ( Span< float3 > vert_positions,
OffsetIndices< int > faces,
Span< int > corner_verts,
Span< float3 > corner_normals,
Span< float2 > uv_map,
MutableSpan< float4 > results,
ReportList * reports )

Compute simplified tangent space normals, i.e. tangent vector + sign of bi-tangent one, which combined with custom normals can be used to recreate the full tangent space.

Note
The mesh should be made of only triangles and quads!

Definition at line 77 of file mesh_tangent.cc.

References BKE_report(), blender::bke::mesh::MeshToTangentQuadsTris::corner_normals, blender::bke::mesh::MeshToTangentQuadsTris::corner_verts, blender::bke::mesh::MeshToTangentQuadsTris::faces, faces, i, blender::bke::mesh::MeshToTangentQuadsTris::positions, RPT_ERROR, size(), blender::bke::mesh::MeshToTangentQuadsTris::tangents, and blender::bke::mesh::MeshToTangentQuadsTris::uv_map.

◆ calc_uv_tangents()

Array< Array< float4 > > blender::bke::mesh::calc_uv_tangents ( Span< float3 > vert_positions,
OffsetIndices< int > faces,
Span< int > corner_verts,
Span< int3 > corner_tris,
Span< int > corner_tri_faces,
Span< bool > sharp_faces,
Span< float3 > vert_normals,
Span< float3 > face_normals,
Span< float3 > corner_normals,
Span< Span< float2 > > uv_maps )

◆ collect_corner_info()

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

Gather data related to all the connected faces / face corners. This makes accessing it simpler later on in the various per-vertex hot loops. It also means we can be sure it will be in CPU caches. Gathering it into a single Vector of an "info" struct rather than multiple vectors is expected to be worth it because there are typically very few connected corners; the overhead of a Vector for each piece of data would be significant.

Definition at line 948 of file mesh_normals.cc.

References collect_corner_info(), face_corner_next(), face_corner_prev(), face_find_corner_from_vert(), faces, i, and blender::Span< T >::index_range().

Referenced by collect_corner_info().

◆ corner_fan_space_define()

◆ corner_space_custom_data_to_normal()

◆ corner_space_custom_normal_to_data()

◆ corner_tri_get_real_edges()

int3 blender::bke::mesh::corner_tri_get_real_edges ( Span< int2 > edges,
Span< int > corner_verts,
Span< int > corner_edges,
const int3 & corner_tri )

Return the triangle's three edge indices they are real edges, otherwise -1.

Definition at line 245 of file mesh_tessellate.cc.

References i.

Referenced by mesh_corner_tris_target_project(), and blender::bke::shrinkwrap::shrinkwrap_build_boundary_data().

◆ corner_tris_calc()

◆ corner_tris_calc_face_indices()

void blender::bke::mesh::corner_tris_calc_face_indices ( OffsetIndices< int > faces,
MutableSpan< int > tri_faces )

◆ corner_tris_calc_impl()

void blender::bke::mesh::corner_tris_calc_impl ( const Span< float3 > positions,
const OffsetIndices< int > faces,
const Span< int > corner_verts,
const Span< float3 > face_normals,
MutableSpan< int3 > corner_tris )
static

◆ corner_tris_calc_with_normals()

void blender::bke::mesh::corner_tris_calc_with_normals ( Span< float3 > vert_positions,
OffsetIndices< int > faces,
Span< int > corner_verts,
Span< float3 > face_normals,
MutableSpan< int3 > corner_tris )

A version of corner_tris_calc which takes pre-calculated face normals (used to avoid having to calculate the face normal for NGON tessellation).

Note
Only use this function if normals have already been calculated, there is no need to calculate normals just to use this function.

Definition at line 226 of file mesh_tessellate.cc.

References BLI_assert, corner_tris_calc_impl(), corner_tris_calc_with_normals(), faces, and blender::Span< T >::is_empty().

Referenced by corner_tris_calc_with_normals(), and mesh_calc_tri_tessface().

◆ create_reverse_offsets()

Array< int > blender::bke::mesh::create_reverse_offsets ( const Span< int > indices,
const int items_num )
static

◆ edge_other_vert()

◆ edges_sharp_from_angle_set()

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 )

Define sharp edges as needed to mimic "auto-smooth" from angle threshold.

Used when defining an empty custom corner normals data layer, to keep same shading as with auto-smooth!

Parameters
sharp_facesOptional array used to mark specific faces for sharp shading.

Definition at line 901 of file mesh_normals.cc.

References edges_sharp_from_angle_set(), faces, M_PI, mesh_edges_sharp_tag(), and blender::MutableSpan< T >::size().

Referenced by edges_sharp_from_angle_set(), and blender::bke::mesh_sharp_edges_set_from_angle().

◆ face_angles_calc()

void blender::bke::mesh::face_angles_calc ( Span< float3 > vert_positions,
Span< int > face_verts,
MutableSpan< float > angles )

Calculate the angles at each of the faces corners.

Definition at line 206 of file mesh_evaluate.cc.

References angle_normalized_v3v3(), copy_v3_v3(), normalize_v3(), blender::Span< T >::size(), and sub_v3_v3v3().

Referenced by wn_corner_angle(), and wn_face_with_angle().

◆ face_area_calc()

float blender::bke::mesh::face_area_calc ( Span< float3 > vert_positions,
Span< int > face_verts )

◆ face_area_centroid_calc()

float blender::bke::mesh::face_area_centroid_calc ( const Span< float3 > positions,
const Span< int > face_verts,
float r_cent[3] )
static
Note
  • Results won't be correct if face is non-planar.
  • This has the advantage over mesh_calc_face_volume_centroid that it doesn't depend on solid geometry, instead it weights the surface by volume.

Definition at line 175 of file mesh_evaluate.cc.

References area_tri_signed_v3(), copy_v3_v3(), face_normal_calc(), i, madd_v3_v3fl(), mid_v3_v3v3v3(), mul_v3_fl(), blender::Span< T >::size(), v2, and zero_v3().

Referenced by BKE_mesh_center_of_surface().

◆ face_center_calc()

◆ face_center_calc_ngon()

float3 blender::bke::mesh::face_center_calc_ngon ( const Span< float3 > vert_positions,
const Span< int > face_verts )
static

Definition at line 39 of file mesh_evaluate.cc.

References float, i, blender::Span< T >::index_range(), blender::Span< T >::size(), and w().

Referenced by face_center_calc().

◆ face_corner_next()

◆ face_corner_prev()

◆ face_find_adjacent_verts()

int2 blender::bke::mesh::face_find_adjacent_verts ( const IndexRange face,
const Span< int > corner_verts,
const int vert )
inline

Return the vertex indices on either side of the given vertex, ordered based on the winding direction of the face. The vertex must be in the face.

Definition at line 338 of file BKE_mesh.hh.

References face_corner_next(), face_corner_prev(), and face_find_corner_from_vert().

Referenced by MeshFairingContext::adjacents_coords_from_loop(), blender::ed::sculpt_paint::append_neighbors_to_vector(), and blender::ed::sculpt_paint::vert_neighbors_get_mesh().

◆ face_find_corner_from_vert()

int blender::bke::mesh::face_find_corner_from_vert ( const IndexRange face,
const Span< int > corner_verts,
const int vert )
inline

Find the index of the corner in the face that uses the given vertex. The index is into the entire corners array, not just the face's corners.

Definition at line 327 of file BKE_mesh.hh.

References blender::Span< T >::first_index(), and blender::Span< T >::slice().

Referenced by adjacent_vertices_index_from_adjacent_edge(), calculate_average_color(), collect_corner_info(), blender::ed::sculpt_paint::color::color_vert_get(), do_vpaint_brush_blur_loops(), do_vpaint_brush_smear(), and face_find_adjacent_verts().

◆ face_normal_calc()

◆ face_triangles_num()

int blender::bke::mesh::face_triangles_num ( const int face_size)
inline

◆ face_triangles_range()

◆ gather_groups()

GroupedSpan< int > blender::bke::mesh::gather_groups ( const Span< int > group_indices,
const int groups_num,
Array< int > & r_offsets,
Array< int > & r_indices )
static

◆ handle_fan_result_and_custom_normals()

◆ is_corner_fan_normals()

bool blender::bke::mesh::is_corner_fan_normals ( const AttributeMetaData & meta_data)

Return true if the type and domain represent the tangent-space custom normals storage.

Definition at line 1717 of file mesh_normals.cc.

References CORNER_FAN_META_DATA, and is_corner_fan_normals().

Referenced by is_corner_fan_normals(), blender::ed::mesh::join_normals(), and blender::geometry::preprocess_meshes().

◆ mesh_calc_face_volume_centroid_with_reference_center()

float blender::bke::mesh::mesh_calc_face_volume_centroid_with_reference_center ( const Span< float3 > positions,
const Span< int > face_verts,
const float3 & reference_center,
float r_cent[3] )
static

A version of mesh_calc_face_volume_centroid that takes an initial reference center, use this to increase numeric stability as the quality of the result becomes very low quality as the value moves away from 0.0, see: #65986.

Definition at line 145 of file mesh_evaluate.cc.

References copy_v3_v3(), i, blender::Span< T >::size(), sub_v3_v3v3(), volume_tri_tetrahedron_signed_v3_6x(), and zero_v3().

Referenced by BKE_mesh_center_of_volume().

◆ mesh_calc_tessellation_for_face()

void blender::bke::mesh::mesh_calc_tessellation_for_face ( const Span< int > corner_verts,
const Span< float3 > positions,
const int face_start,
const int face_size,
int3 * tri,
MemArena ** pf_arena_p )
static

Definition at line 130 of file mesh_tessellate.cc.

References mesh_calc_tessellation_for_face_impl().

◆ mesh_calc_tessellation_for_face_impl()

BLI_INLINE void blender::bke::mesh::mesh_calc_tessellation_for_face_impl ( const Span< int > corner_verts,
const Span< float3 > positions,
const int face_start,
const int face_size,
int3 * tri,
MemArena ** pf_arena_p,
const bool face_normal,
const float normal_precalc[3] )

◆ mesh_calc_tessellation_for_face_with_normal()

void blender::bke::mesh::mesh_calc_tessellation_for_face_with_normal ( const Span< int > corner_verts,
const Span< float3 > positions,
const int face_start,
const int face_size,
int3 * tri,
MemArena ** pf_arena_p,
const float normal_precalc[3] )
static

Definition at line 141 of file mesh_tessellate.cc.

References mesh_calc_tessellation_for_face_impl().

◆ mesh_edges_sharp_tag()

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

◆ mesh_normals_corner_custom_set()

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

Compute internal representation of given custom normals (as an array of float[2]). It also makes sure the mesh matches those custom normals, by setting sharp edges flag as needed to get a same custom lnor for all corners sharing the same smooth fan. If use_vertices if true, r_custom_corner_normals is assumed to be per-vertex, not per-corner (this allows to set whole vert's normals at once, useful in some cases). r_custom_corner_normals is expected to have normalized normals, or zero ones, in which case they will be replaced by default corner/vertex normal.

Definition at line 1406 of file mesh_normals.cc.

References build_corner_to_face_map(), copy_v3_v3(), corner_space_custom_normal_to_data(), blender::bke::mesh::CornerNormalSpaceArray::corner_space_indices, blender::bke::mesh::CornerNormalSpaceArray::corners_by_space, blender::bke::mesh::CornerNormalSpaceArray::create_corners_by_space, dot_v3v3(), face_corner_prev(), faces, blender::bits::BitVector< InlineBufferCapacity, Allocator >::fill(), blender::MutableSpan< T >::fill_indices(), G, G_DEBUG, i, blender::Span< T >::index_range(), blender::Span< T >::is_empty(), is_zero_v3(), blender::IndexRange::last(), blender::Span< T >::last(), LNOR_SPACE_TRIGO_THRESHOLD, mesh_normals_corner_custom_set(), mul_v3_fl(), nor, normals_calc_corners(), printf, blender::Span< T >::size(), and blender::bke::mesh::CornerNormalSpaceArray::spaces.

Referenced by mesh_normals_corner_custom_set(), mesh_set_custom_normals(), normals_corner_custom_set(), and normals_corner_custom_set_from_verts().

◆ mesh_set_custom_normals()

◆ mix_normals_corner_to_face()

void blender::bke::mesh::mix_normals_corner_to_face ( const OffsetIndices< int > faces,
const Span< float3 > corner_normals,
MutableSpan< float3 > face_normals )
static

◆ mix_normals_corner_to_vert()

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

◆ mix_normals_vert_to_face()

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

◆ normal_calc_ngon()

float3 blender::bke::mesh::normal_calc_ngon ( const Span< float3 > vert_positions,
const Span< int > face_verts )
static

◆ normal_domain_to_domain()

◆ normals_calc_corners()

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 )

Compute custom normals, i.e. vertex normals associated with each face. Used to visualize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).

Parameters
sharp_edgesOptional array of sharp edge tags, used to split the evaluated normals on each side of the edge.
sharp_facesOptional array of sharp face tags, used to split the evaluated normals on the face's edges.
r_fan_spacesOptional return data filled with information about the custom normals spaces for each grouped fan of face corners.

Definition at line 1237 of file mesh_normals.cc.

References BLI_assert, faces, blender::Span< T >::index_range(), blender::Span< T >::is_empty(), normals_calc_corners(), blender::offset_indices::GroupedSpan< T >::offsets, blender::threading::parallel_for(), blender::MutableSpan< T >::size(), blender::Span< T >::size(), and blender::OffsetIndices< T >::total_size().

Referenced by apply_weights_vertex_normal(), BKE_keyblock_mesh_calc_normals(), BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(), mesh_normals_corner_custom_set(), normalEditModifier_do(), and normals_calc_corners().

◆ normals_calc_faces()

void blender::bke::mesh::normals_calc_faces ( Span< float3 > vert_positions,
OffsetIndices< int > faces,
Span< int > corner_verts,
MutableSpan< float3 > face_normals )

Calculate face normals directly into a result array.

Note
Usually #Mesh::face_normals() is the preferred way to access face normals, since they may already be calculated and cached on the mesh.

Definition at line 178 of file mesh_normals.cc.

References BLI_assert, faces, normals_calc_faces(), blender::threading::parallel_for(), and blender::MutableSpan< T >::size().

Referenced by BKE_keyblock_mesh_calc_normals(), normals_calc_faces(), and blender::bke::pbvh::update_normals_mesh().

◆ normals_calc_verts()

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 )

Calculate vertex normals directly into the result array.

Note
Vertex and face normals can be calculated at the same time with #normals_calc_faces_and_verts, which can have performance benefits in some cases.
Usually #Mesh::vert_normals() is the preferred way to access vertex normals, since they may already be calculated and cached on the mesh.

Definition at line 191 of file mesh_normals.cc.

References faces, blender::Span< T >::index_range(), normals_calc_verts(), and blender::threading::parallel_for().

Referenced by BKE_keyblock_mesh_calc_normals(), normals_calc_verts(), and blender::bke::pbvh::update_normals_mesh().

◆ normals_corner_custom_set()

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 )
Parameters
sharp_facesOptional array used to mark specific faces for sharp shading.

Definition at line 1597 of file mesh_normals.cc.

References faces, mesh_normals_corner_custom_set(), and normals_corner_custom_set().

Referenced by apply_weights_vertex_normal(), data_transfer_dtdata_type_postprocess(), normalEditModifier_do_directional(), normalEditModifier_do_radial(), and normals_corner_custom_set().

◆ normals_corner_custom_set_from_verts()

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 )
Parameters
sharp_facesOptional array used to mark specific faces for sharp shading.

Definition at line 1623 of file mesh_normals.cc.

References faces, mesh_normals_corner_custom_set(), and normals_corner_custom_set_from_verts().

Referenced by apply_weights_vertex_normal(), and normals_corner_custom_set_from_verts().

◆ reverse_group_indices_in_groups()

◆ reverse_indices_in_groups()

◆ sort_small_groups()

void blender::bke::mesh::sort_small_groups ( const OffsetIndices< int > groups,
const int grain_size,
MutableSpan< int > indices )
static

◆ traverse_fan_local_corners()

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

From a starting corner, follow the connected edges to find the other corners "fanning" around the vertex. Crucially, we've removed ambiguity from the process already by marking edges connected to three faces and edges between faces with opposite winding direction sharp.

Definition at line 1095 of file mesh_normals.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Vector< T, InlineBufferCapacity, Allocator >::as_mutable_span(), b, blender::Vector< T, InlineBufferCapacity, Allocator >::begin(), edge_other_vert(), blender::Vector< T, InlineBufferCapacity, Allocator >::end(), and traverse_fan_local_corners().

Referenced by traverse_fan_local_corners().

◆ vert_tris_from_corner_tris()

void blender::bke::mesh::vert_tris_from_corner_tris ( Span< int > corner_verts,
Span< int3 > corner_tris,
MutableSpan< int3 > vert_tris )

Variable Documentation

◆ CORNER_FAN_META_DATA

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