Blender  V3.3
Classes | Enumerations | Functions
blender::bke::mesh_surface_sample Namespace Reference

Classes

class  MeshAttributeInterpolator
 

Enumerations

enum class  eAttributeMapMode { INTERPOLATED , NEAREST }
 

Functions

void sample_point_attribute (const Mesh &mesh, Span< int > looptri_indices, Span< float3 > bary_coords, const GVArray &data_in, const IndexMask mask, GMutableSpan data_out)
 
void sample_corner_attribute (const Mesh &mesh, Span< int > looptri_indices, Span< float3 > bary_coords, const GVArray &data_in, const IndexMask mask, GMutableSpan data_out)
 
void sample_face_attribute (const Mesh &mesh, Span< int > looptri_indices, const GVArray &data_in, const IndexMask mask, GMutableSpan data_out)
 
int sample_surface_points_spherical (RandomNumberGenerator &rng, const Mesh &mesh, Span< int > looptri_indices_to_sample, const float3 &sample_pos, float sample_radius, float approximate_density, Vector< float3 > &r_bary_coords, Vector< int > &r_looptri_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_looptri_indices, Vector< float3 > &r_positions)
 
float3 compute_bary_coord_in_triangle (const Mesh &mesh, const MLoopTri &looptri, const float3 &position)
 
template<typename T >
T sample_corner_attrribute_with_bary_coords (const float3 &bary_weights, const MLoopTri &looptri, const Span< T > corner_attribute)
 
template<typename T >
static BLI_NOINLINE void sample_point_attribute (const Mesh &mesh, const Span< int > looptri_indices, const Span< float3 > bary_coords, const VArray< T > &data_in, const IndexMask mask, const MutableSpan< T > data_out)
 
template<typename T >
static BLI_NOINLINE void sample_corner_attribute (const Mesh &mesh, const Span< int > looptri_indices, const Span< float3 > bary_coords, const VArray< T > &data_in, const IndexMask mask, const MutableSpan< T > data_out)
 
template<typename T >
void sample_face_attribute (const Mesh &mesh, const Span< int > looptri_indices, const VArray< T > &data_in, const IndexMask mask, const MutableSpan< T > data_out)
 
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_looptri_indices, Vector< float3 > &r_positions)
 

Enumeration Type Documentation

◆ eAttributeMapMode

Enumerator
INTERPOLATED 
NEAREST 

Definition at line 47 of file BKE_mesh_sample.hh.

Function Documentation

◆ compute_bary_coord_in_triangle()

float3 blender::bke::mesh_surface_sample::compute_bary_coord_in_triangle ( const Mesh &  mesh,
const MLoopTri &  looptri,
const float3 &  position 
)

◆ sample_corner_attribute() [1/2]

template<typename T >
static BLI_NOINLINE void blender::bke::mesh_surface_sample::sample_corner_attribute ( const Mesh &  mesh,
const Span< int >  looptri_indices,
const Span< float3 >  bary_coords,
const VArray< T > &  data_in,
const IndexMask  mask,
const MutableSpan< T >  data_out 
)
static

◆ sample_corner_attribute() [2/2]

void blender::bke::mesh_surface_sample::sample_corner_attribute ( const Mesh &  mesh,
Span< int >  looptri_indices,
Span< float3 >  bary_coords,
const GVArray &  data_in,
const IndexMask  mask,
GMutableSpan  data_out 
)

◆ sample_corner_attrribute_with_bary_coords()

template<typename T >
T blender::bke::mesh_surface_sample::sample_corner_attrribute_with_bary_coords ( const float3 &  bary_weights,
const MLoopTri &  looptri,
const Span< T >  corner_attribute 
)
inline

◆ sample_face_attribute() [1/2]

template<typename T >
void blender::bke::mesh_surface_sample::sample_face_attribute ( const Mesh &  mesh,
const Span< int >  looptri_indices,
const VArray< T > &  data_in,
const IndexMask  mask,
const MutableSpan< T >  data_out 
)

◆ sample_face_attribute() [2/2]

void blender::bke::mesh_surface_sample::sample_face_attribute ( const Mesh &  mesh,
Span< int >  looptri_indices,
const GVArray &  data_in,
const IndexMask  mask,
GMutableSpan  data_out 
)

◆ sample_point_attribute() [1/2]

template<typename T >
static BLI_NOINLINE void blender::bke::mesh_surface_sample::sample_point_attribute ( const Mesh &  mesh,
const Span< int >  looptri_indices,
const Span< float3 >  bary_coords,
const VArray< T > &  data_in,
const IndexMask  mask,
const MutableSpan< T >  data_out 
)
static

◆ sample_point_attribute() [2/2]

void blender::bke::mesh_surface_sample::sample_point_attribute ( const Mesh &  mesh,
Span< int >  looptri_indices,
Span< float3 >  bary_coords,
const GVArray &  data_in,
const IndexMask  mask,
GMutableSpan  data_out 
)

◆ 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_looptri_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_looptri_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(), and blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_projected_with_symmetry().

◆ sample_surface_points_spherical()

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