Cleanup: Convert some Paint BVH functions to Node member functions
Turns both `bounds_` and `bounds_orig_` accessor functions to be const `inline` functions that return `const` references. Pull Request: https://projects.blender.org/blender/blender/pulls/136861
This commit is contained in:
@@ -105,6 +105,9 @@ class Node : NonCopyable {
|
||||
|
||||
/** \todo Move storage of image painting data to #Tree or elsewhere. */
|
||||
pixels::NodeData *pixels_ = nullptr;
|
||||
|
||||
const Bounds<float3> &bounds() const;
|
||||
const Bounds<float3> &bounds_orig() const;
|
||||
};
|
||||
|
||||
ENUM_OPERATORS(Node::Flags, Node::Flags::TopologyUpdated);
|
||||
@@ -496,13 +499,8 @@ Span<int> node_face_indices_calc_grids(const SubdivCCG &subdiv_ccg,
|
||||
const GridsNode &node,
|
||||
Vector<int> &faces);
|
||||
|
||||
Bounds<float3> node_bounds(const Node &node);
|
||||
|
||||
} // namespace blender::bke::pbvh
|
||||
|
||||
blender::Bounds<blender::float3> BKE_pbvh_node_get_original_BB(
|
||||
const blender::bke::pbvh::Node *node);
|
||||
|
||||
float BKE_pbvh_node_get_tmin(const blender::bke::pbvh::Node *node);
|
||||
|
||||
const blender::Set<BMVert *, 0> &BKE_pbvh_bmesh_node_unique_verts(
|
||||
@@ -611,6 +609,16 @@ void update_node_bounds_mesh(Span<float3> positions, MeshNode &node);
|
||||
void update_node_bounds_grids(int grid_area, Span<float3> positions, GridsNode &node);
|
||||
void update_node_bounds_bmesh(BMeshNode &node);
|
||||
|
||||
inline const Bounds<float3> &Node::bounds() const
|
||||
{
|
||||
return bounds_;
|
||||
}
|
||||
|
||||
inline const Bounds<float3> &Node::bounds_orig() const
|
||||
{
|
||||
return bounds_orig_;
|
||||
}
|
||||
|
||||
inline Span<int> MeshNode::faces() const
|
||||
{
|
||||
return this->face_indices_;
|
||||
|
||||
@@ -1569,21 +1569,6 @@ Span<int> node_face_indices_calc_grids(const SubdivCCG &subdiv_ccg,
|
||||
|
||||
} // namespace blender::bke::pbvh
|
||||
|
||||
namespace blender::bke::pbvh {
|
||||
|
||||
Bounds<float3> node_bounds(const Node &node)
|
||||
{
|
||||
return node.bounds_;
|
||||
}
|
||||
|
||||
} // namespace blender::bke::pbvh
|
||||
|
||||
blender::Bounds<blender::float3> BKE_pbvh_node_get_original_BB(
|
||||
const blender::bke::pbvh::Node *node)
|
||||
{
|
||||
return node->bounds_orig_;
|
||||
}
|
||||
|
||||
void BKE_pbvh_node_get_bm_orco_data(const blender::bke::pbvh::BMeshNode &node,
|
||||
blender::Span<blender::float3> &r_orig_positions,
|
||||
blender::Span<blender::int3> &r_orig_tris)
|
||||
@@ -1995,10 +1980,10 @@ void clip_ray_ortho(
|
||||
const float offset_vec[3] = {1e-3f, 1e-3f, 1e-3f};
|
||||
|
||||
if (original) {
|
||||
bb_root = BKE_pbvh_node_get_original_BB(&first_node(pbvh));
|
||||
bb_root = first_node(pbvh).bounds_orig();
|
||||
}
|
||||
else {
|
||||
bb_root = node_bounds(first_node(pbvh));
|
||||
bb_root = first_node(pbvh).bounds();
|
||||
}
|
||||
|
||||
/* Calc rough clipping to avoid overflow later. See #109555. */
|
||||
|
||||
@@ -2442,8 +2442,7 @@ bool node_in_sphere(const bke::pbvh::Node &node,
|
||||
const float radius_sq,
|
||||
const bool original)
|
||||
{
|
||||
const Bounds<float3> bounds = original ? BKE_pbvh_node_get_original_BB(&node) :
|
||||
bke::pbvh::node_bounds(node);
|
||||
const Bounds<float3> &bounds = original ? node.bounds_orig() : node.bounds();
|
||||
const float3 nearest = math::clamp(location, bounds.min, bounds.max);
|
||||
return math::distance_squared(location, nearest) < radius_sq;
|
||||
}
|
||||
@@ -2453,8 +2452,7 @@ bool node_in_cylinder(const DistRayAABB_Precalc &ray_dist_precalc,
|
||||
const float radius_sq,
|
||||
const bool original)
|
||||
{
|
||||
const Bounds<float3> bounds = (original) ? BKE_pbvh_node_get_original_BB(&node) :
|
||||
bke::pbvh::node_bounds(node);
|
||||
const Bounds<float3> &bounds = original ? node.bounds_orig() : node.bounds();
|
||||
|
||||
float dummy_co[3], dummy_depth;
|
||||
const float dist_sq = dist_squared_ray_to_aabb_v3(
|
||||
|
||||
Reference in New Issue
Block a user