Blender V4.3
blender::bke::mesh_surface_sample Namespace Reference

Classes

class  BaryWeightFromPositionFn
 
class  BaryWeightSampleFn
 
class  CornerBaryWeightFromPositionFn
 

Functions

void sample_point_attribute (Span< int > corner_verts, Span< int3 > corner_tris, Span< int > tri_indices, Span< float3 > bary_coords, const GVArray &src, const IndexMask &mask, GMutableSpan dst)
 
void sample_point_normals (Span< int > corner_verts, Span< int3 > corner_tris, Span< int > tri_indices, Span< float3 > bary_coords, Span< float3 > src, IndexMask mask, MutableSpan< float3 > dst)
 
void sample_corner_attribute (Span< int3 > corner_tris, Span< int > tri_indices, Span< float3 > bary_coords, const GVArray &src, const IndexMask &mask, GMutableSpan dst)
 
void sample_corner_normals (Span< int3 > corner_tris, Span< int > tri_indices, Span< float3 > bary_coords, Span< float3 > src, const IndexMask &mask, MutableSpan< float3 > dst)
 
void sample_face_attribute (Span< int > corner_tri_faces, Span< int > tri_indices, const GVArray &src, const IndexMask &mask, GMutableSpan dst)
 
int sample_surface_points_spherical (RandomNumberGenerator &rng, const Mesh &mesh, Span< int > tris_to_sample, const float3 &sample_pos, float sample_radius, float approximate_density, Vector< float3 > &r_bary_coords, Vector< int > &r_tri_indices, Vector< float3 > &r_positions)
 
int sample_surface_points_projected (RandomNumberGenerator &rng, const Mesh &mesh, BVHTreeFromMesh &mesh_bvhtree, const float2 &sample_pos_re, float sample_radius_re, FunctionRef< void(const float2 &pos_re, float3 &r_start, float3 &r_end)> region_position_to_ray, bool front_face_only, int tries_num, int max_points, Vector< float3 > &r_bary_coords, Vector< int > &r_tri_indices, Vector< float3 > &r_positions)
 
float3 compute_bary_coord_in_triangle (Span< float3 > vert_positions, Span< int > corner_verts, const int3 &corner_tri, const float3 &position)
 
template<typename T >
T sample_corner_attribute_with_bary_coords (const float3 &bary_weights, const int3 &corner_tri, const Span< T > corner_attribute)
 
template<typename T >
T sample_corner_attribute_with_bary_coords (const float3 &bary_weights, const int3 &corner_tri, const VArray< T > &corner_attribute)
 
template<typename T >
static BLI_NOINLINE void sample_point_attribute (const Span< int > corner_verts, const Span< int3 > corner_tris, const Span< int > tri_indices, const Span< float3 > bary_coords, const VArray< T > &src, const IndexMask &mask, const MutableSpan< T > dst)
 
template<typename T , bool check_indices = false>
static BLI_NOINLINE void sample_corner_attribute (const Span< int3 > corner_tris, const Span< int > tri_indices, const Span< float3 > bary_coords, const VArray< T > &src, const IndexMask &mask, const MutableSpan< T > dst)
 
template<typename T >
void sample_face_attribute (const Span< int > tri_faces, const Span< int > tri_indices, const VArray< T > &src, const IndexMask &mask, const MutableSpan< T > dst)
 
template<bool check_indices = false>
static void sample_barycentric_weights (const Span< float3 > vert_positions, const Span< int > corner_verts, const Span< int3 > corner_tris, const Span< int > tri_indices, const Span< float3 > sample_positions, const IndexMask &mask, MutableSpan< float3 > bary_coords)
 
template<bool check_indices = false>
static void sample_nearest_weights (const Span< float3 > vert_positions, const Span< int > corner_verts, const Span< int3 > corner_tris, const Span< int > tri_indices, const Span< float3 > sample_positions, const IndexMask &mask, MutableSpan< float3 > bary_coords)
 
int sample_surface_points_projected (RandomNumberGenerator &rng, const Mesh &mesh, BVHTreeFromMesh &mesh_bvhtree, const float2 &sample_pos_re, const float sample_radius_re, const FunctionRef< void(const float2 &pos_re, float3 &r_start, float3 &r_end)> region_position_to_ray, const bool front_face_only, const int tries_num, const int max_points, Vector< float3 > &r_bary_coords, Vector< int > &r_tri_indices, Vector< float3 > &r_positions)
 

Function Documentation

◆ compute_bary_coord_in_triangle()

float3 blender::bke::mesh_surface_sample::compute_bary_coord_in_triangle ( Span< float3 > vert_positions,
Span< int > corner_verts,
const int3 & corner_tri,
const float3 & position )

◆ sample_barycentric_weights()

template<bool check_indices = false>
static void blender::bke::mesh_surface_sample::sample_barycentric_weights ( const Span< float3 > vert_positions,
const Span< int > corner_verts,
const Span< int3 > corner_tris,
const Span< int > tri_indices,
const Span< float3 > sample_positions,
const IndexMask & mask,
MutableSpan< float3 > bary_coords )
static

◆ sample_corner_attribute() [1/2]

template<typename T , bool check_indices = false>
static BLI_NOINLINE void blender::bke::mesh_surface_sample::sample_corner_attribute ( const Span< int3 > corner_tris,
const Span< int > tri_indices,
const Span< float3 > bary_coords,
const VArray< T > & src,
const IndexMask & mask,
const MutableSpan< T > dst )
static

Definition at line 71 of file mesh_sample.cc.

References sample_corner_attribute_with_bary_coords().

◆ sample_corner_attribute() [2/2]

◆ sample_corner_attribute_with_bary_coords() [1/2]

template<typename T >
T blender::bke::mesh_surface_sample::sample_corner_attribute_with_bary_coords ( const float3 & bary_weights,
const int3 & corner_tri,
const Span< T > corner_attribute )
inline

◆ sample_corner_attribute_with_bary_coords() [2/2]

template<typename T >
T blender::bke::mesh_surface_sample::sample_corner_attribute_with_bary_coords ( const float3 & bary_weights,
const int3 & corner_tri,
const VArray< T > & corner_attribute )
inline

Definition at line 130 of file BKE_mesh_sample.hh.

References blender::bke::attribute_math::mix3().

◆ sample_corner_normals()

void blender::bke::mesh_surface_sample::sample_corner_normals ( Span< int3 > corner_tris,
Span< int > tri_indices,
Span< float3 > bary_coords,
Span< float3 > src,
const IndexMask & mask,
MutableSpan< float3 > dst )

◆ sample_face_attribute() [1/2]

template<typename T >
void blender::bke::mesh_surface_sample::sample_face_attribute ( const Span< int > tri_faces,
const Span< int > tri_indices,
const VArray< T > & src,
const IndexMask & mask,
const MutableSpan< T > dst )

Definition at line 122 of file mesh_sample.cc.

◆ sample_face_attribute() [2/2]

◆ sample_nearest_weights()

template<bool check_indices = false>
static void blender::bke::mesh_surface_sample::sample_nearest_weights ( const Span< float3 > vert_positions,
const Span< int > corner_verts,
const Span< int3 > corner_tris,
const Span< int > tri_indices,
const Span< float3 > sample_positions,
const IndexMask & mask,
MutableSpan< float3 > bary_coords )
static

◆ sample_point_attribute() [1/2]

template<typename T >
static BLI_NOINLINE void blender::bke::mesh_surface_sample::sample_point_attribute ( const Span< int > corner_verts,
const Span< int3 > corner_tris,
const Span< int > tri_indices,
const Span< float3 > bary_coords,
const VArray< T > & src,
const IndexMask & mask,
const MutableSpan< T > dst )
static

Definition at line 17 of file mesh_sample.cc.

References blender::bke::attribute_math::mix3().

◆ sample_point_attribute() [2/2]

void blender::bke::mesh_surface_sample::sample_point_attribute ( Span< int > corner_verts,
Span< int3 > corner_tris,
Span< int > tri_indices,
Span< float3 > bary_coords,
const GVArray & src,
const IndexMask & mask,
GMutableSpan dst )

◆ sample_point_normals()

void blender::bke::mesh_surface_sample::sample_point_normals ( Span< int > corner_verts,
Span< int3 > corner_tris,
Span< int > tri_indices,
Span< float3 > bary_coords,
Span< float3 > src,
IndexMask mask,
MutableSpan< float3 > dst )

◆ sample_surface_points_projected() [1/2]

int blender::bke::mesh_surface_sample::sample_surface_points_projected ( RandomNumberGenerator & rng,
const Mesh & mesh,
BVHTreeFromMesh & mesh_bvhtree,
const float2 & sample_pos_re,
const float sample_radius_re,
const FunctionRef< void(const float2 &pos_re, float3 &r_start, float3 &r_end)> region_position_to_ray,
const bool front_face_only,
const int tries_num,
const int max_points,
Vector< float3 > & r_bary_coords,
Vector< int > & r_tri_indices,
Vector< float3 > & r_positions )

◆ sample_surface_points_projected() [2/2]

int blender::bke::mesh_surface_sample::sample_surface_points_projected ( RandomNumberGenerator & rng,
const Mesh & mesh,
BVHTreeFromMesh & mesh_bvhtree,
const float2 & sample_pos_re,
float sample_radius_re,
FunctionRef< void(const float2 &pos_re, float3 &r_start, float3 &r_end)> region_position_to_ray,
bool front_face_only,
int tries_num,
int max_points,
Vector< float3 > & r_bary_coords,
Vector< int > & r_tri_indices,
Vector< float3 > & r_positions )

Find randomly distributed points on the surface of a mesh within a circle that is projected on the mesh. This does not result in an exact number of points because that would come with extra overhead and is not always possible. If an exact number of points is required, that has to be implemented at a higher level.

Parameters
region_position_to_rayFunction that converts a 2D position into a 3D ray that is used to find positions on the mesh.
mesh_bvhtreeBVH tree of the triangles in the mesh. Passed in so that it does not have to be retrieved again.
tries_numNumber of 2d positions that are sampled. The maximum number of new samples.
Returns
The number of added points.

Referenced by blender::ed::sculpt_paint::AddOperationExecutor::sample_projected().

◆ sample_surface_points_spherical()

int blender::bke::mesh_surface_sample::sample_surface_points_spherical ( RandomNumberGenerator & rng,
const Mesh & mesh,
Span< int > tris_to_sample,
const float3 & sample_pos,
float sample_radius,
float approximate_density,
Vector< float3 > & r_bary_coords,
Vector< int > & r_tri_indices,
Vector< float3 > & r_positions )

Find randomly distributed points on the surface of a mesh within a 3D sphere. This does not sample an exact number of points because it comes with extra overhead to avoid bias that is only required in some cases. If an exact number of points is required, that has to be implemented at a higher level.

Parameters
approximate_densityRoughly the number of points per unit of area.
Returns
The number of added points.

Definition at line 200 of file mesh_sample.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), area_tri_v3(), blender::math::cross(), blender::math::distance_squared(), blender::RandomNumberGenerator::get_barycentric_coordinates(), blender::RandomNumberGenerator::get_float(), interp_weights_tri_v3(), isect_point_tri_prism_v3(), M_PI, blender::bke::attribute_math::mix3(), normal_tri_v3(), blender::math::normalize(), pow2f(), project_v3_plane(), blender::RandomNumberGenerator::round_probabilistic(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), v2, and y.