69 for (
const int i :
verts.index_range()) {
72 xy_positions[
i] = position.
xy();
73 z_positions[
i] = position.z;
88 xy_positions[
i] = position.
xy();
89 z_positions[
i] = position.z;
104 const float local_z = z_positions[
i];
107 factors[
i] *=
math::max(0.0f, local_z * (1.0f - local_z));
122 if (!use_plane_trim) {
158 tls.xy_positions.resize(
verts.size());
159 tls.z_positions.resize(
verts.size());
213 tls.xy_positions.resize(positions.
size());
214 tls.z_positions.resize(positions.
size());
267 tls.xy_positions.resize(positions.
size());
268 tls.z_positions.resize(positions.
size());
304 const float3 &plane_normal,
305 const float3 &plane_center)
319 brush, *ss.
cache, plane_normal, plane_center, flip);
323 switch (pbvh.
type()) {
348 SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
372namespace clay_strips {
385 const float3 center_diff = brush_center - node_center;
387 const float3 brush_half_lengths =
float3(1.0f, 1.0f, 0.5f);
395 auto axis_separates_boxes = [&](
const float3 &axis) {
403 return projection > radius1 + radius2;
406 const std::array<float3, 3> brush_axes = {
408 const std::array<float3, 3> node_axes = {node_x_axis, node_y_axis, node_z_axis};
417 for (
const float3 &axis : brush_axes) {
418 if (axis_separates_boxes(axis)) {
424 for (
const float3 &axis : node_axes) {
425 if (axis_separates_boxes(axis)) {
431 for (
const float3 &brush_axis : brush_axes) {
432 for (
const float3 &node_axis : node_axes) {
433 if (axis_separates_boxes(
math::cross(brush_axis, node_axis))) {
445 const float3 &plane_normal,
446 const float3 &plane_center,
452 mat.
z_axis() = plane_normal;
481 (flip ? -1.0f : 1.0f);
491 initial_radius_squared,
499 plane_center += plane_normal * ss.
cache->
scale * displace;
503 return {
IndexMask(), plane_center, plane_normal};
516 return {plane_mask, plane_center, plane_normal};
void BKE_brush_calc_curve_factors(eBrushCurvePreset preset, const CurveMapping *cumap, blender::Span< float > distances, float brush_radius, blender::MutableSpan< float > factors)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
A BVH for high poly meshes.
const blender::Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(blender::bke::pbvh::BMeshNode *node)
Object is a sort of wrapper for general info.
BPy_StructRNA * depsgraph
void resize(const int64_t new_size)
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
const Bounds< float3 > & bounds() const
void tag_positions_changed(const IndexMask &node_mask)
Span< NodeT > nodes() const
void flush_bounds_to_parents()
void foreach_index(Fn &&fn) const
pbvh::Tree * pbvh_get(Object &object)
IndexMask search_nodes(const Tree &pbvh, IndexMaskMemory &memory, FunctionRef< bool(const Node &)> filter_fn)
void update_node_bounds_bmesh(BMeshNode &node)
void update_node_bounds_mesh(Span< float3 > positions, MeshNode &node)
Span< float3 > vert_normals_eval(const Depsgraph &depsgraph, const Object &object_orig)
void update_node_bounds_grids(int grid_area, Span< float3 > positions, GridsNode &node)
void calc_vert_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::MeshNode &node, Span< int > verts, MutableSpan< float > factors)
void calc_grids_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::GridsNode &node, Span< int > grids, MutableSpan< float > factors)
static void calc_bmesh(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const Brush &brush, const float3 &direction, const float strength, bke::pbvh::BMeshNode &node, LocalData &tls)
static void calc_faces(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const float4 &test_plane, const float strength, const MeshAttributeData &attribute_data, const Span< float3 > vert_normals, const bke::pbvh::MeshNode &node, Object &object, LocalData &tls, const PositionDeformData &position_data)
static void calc_grids(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const Brush &brush, const float4 &test_plane, const float strength, bke::pbvh::GridsNode &node, LocalData &tls)
static void apply_z_axis_factors(const Span< float > z_positions, const MutableSpan< float > factors)
static void calc_faces(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const float4x4 &mat, const float3 &offset, const Span< float3 > vert_normals, const MeshAttributeData &attribute_data, const bke::pbvh::MeshNode &node, Object &object, LocalData &tls, const PositionDeformData &position_data)
static void calc_bmesh(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const Brush &brush, const float4x4 &mat, const float3 &offset, bke::pbvh::BMeshNode &node, LocalData &tls)
static void calc_grids(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const Brush &brush, const float4x4 &mat, const float3 &offset, const bke::pbvh::GridsNode &node, LocalData &tls)
static void calc_local_positions(const Span< float3 > vert_positions, const Span< int > verts, const float4x4 &mat, const MutableSpan< float2 > xy_positions, const MutableSpan< float > z_positions)
static void apply_plane_trim_factors(const Brush &brush, const Span< float > z_positions, const MutableSpan< float > factors)
float4x4 calc_local_matrix(const Brush &brush, const StrokeCache &cache, const float3 &plane_normal, const float3 &plane_center, const bool flip)
CursorSampleResult calc_node_mask(const Depsgraph &depsgraph, Object &ob, const Brush &brush, IndexMaskMemory &memory)
static bool node_in_box(const float4x4 &mat, const Bounds< float3 > &bounds)
static BLI_NOINLINE void fill_factor_from_hide_and_mask(const Mesh &mesh, const Span< int > face_indices, const MutableSpan< float > r_factors)
void do_clay_strips_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask, const float3 &plane_normal, const float3 &plane_center)
MutableSpan< float3 > gather_grids_positions(const SubdivCCG &subdiv_ccg, const Span< int > grids, Vector< float3 > &positions)
void gather_bmesh_positions(const Set< BMVert *, 0 > &verts, MutableSpan< float3 > positions)
template void calc_brush_cube_distances< float2 >(const Brush &brush, const Span< float2 > positions, MutableSpan< float > r_distances)
void apply_hardness_to_distances(float radius, float hardness, MutableSpan< float > distances)
bool node_fully_masked_or_hidden(const bke::pbvh::Node &node)
void filter_distances_with_radius(float radius, Span< float > distances, MutableSpan< float > factors)
void filter_region_clip_factors(const SculptSession &ss, Span< float3 > vert_positions, Span< int > verts, MutableSpan< float > factors)
void clip_and_lock_translations(const Sculpt &sd, const SculptSession &ss, Span< float3 > positions, Span< int > verts, MutableSpan< float3 > translations)
IndexMask gather_nodes(const bke::pbvh::Tree &pbvh, const eBrushFalloffShape falloff_shape, const bool use_original, const float3 &location, const float radius_sq, const std::optional< float3 > &ray_direction, IndexMaskMemory &memory)
void calc_brush_plane(const Depsgraph &depsgraph, const Brush &brush, Object &ob, const IndexMask &node_mask, float3 &r_area_no, float3 &r_area_co)
void apply_translations(Span< float3 > translations, Span< int > verts, MutableSpan< float3 > positions)
void calc_brush_texture_factors(const SculptSession &ss, const Brush &brush, Span< float3 > vert_positions, Span< int > vert, MutableSpan< float > factors)
float brush_plane_offset_get(const Brush &brush, const SculptSession &ss)
void calc_front_face(const float3 &view_normal, Span< float3 > normals, MutableSpan< float > factors)
void translations_from_offset_and_factors(const float3 &offset, Span< float > factors, MutableSpan< float3 > r_translations)
float3 tilt_apply_to_normal(const Object &object, const float4x4 &view_inverse, const float3 &normal, const float2 &tilt, const float tilt_strength)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
CartesianBasis invert(const CartesianBasis &basis)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
MatT from_scale(const VecBase< typename MatT::base_type, ScaleDim > &scale)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
T max(const T &a, const T &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
VecBase< float, 3 > float3
float tilt_strength_factor
struct CurveMapping * curve_distance_falloff
int curve_distance_falloff_preset
blender::ed::sculpt_paint::StrokeCache * cache
blender::Array< blender::float3 > positions
static MatBase identity()
VecBase< T, 2 > xy() const
Span< int > grids() const
Span< int > verts() const
VArraySpan< bool > hide_vert
std::unique_ptr< auto_mask::Cache > automasking
Vector< float > distances
Vector< float3 > positions
Vector< float3 > translations
Vector< float3 > positions
Vector< float > distances
Vector< float > z_positions
Vector< float2 > xy_positions
Vector< float3 > translations