Cleanup: Make depth naming variables consistent
Follow up to 5d40992fe8.
In the PBVH API, some contexts that take a `float *` parameter named
`depth` use it purely as a return value, other places, however, read
from and write to this parameter.
In the former case, this commit either adds or keeps the `r_` prefix, in
the latter, this commit ensures the parameter has no prefix to avoid
misleading future readers.
Pull Request: https://projects.blender.org/blender/blender/pulls/127886
This commit is contained in:
@@ -332,7 +332,7 @@ bool raycast_node(Tree &pbvh,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
IsectRayPrecalc *isect_precalc,
|
||||
float *r_depth,
|
||||
float *depth,
|
||||
PBVHVertRef *r_active_vertex,
|
||||
int &r_active_face_grid_index,
|
||||
float3 &r_face_normal);
|
||||
|
||||
@@ -1658,16 +1658,16 @@ bool ray_face_intersection_quad(const float3 &ray_start,
|
||||
const float3 &t1,
|
||||
const float3 &t2,
|
||||
const float3 &t3,
|
||||
float *r_depth)
|
||||
float *depth)
|
||||
{
|
||||
float depth_test;
|
||||
|
||||
if ((isect_ray_tri_watertight_v3(ray_start, isect_precalc, t0, t1, t2, &depth_test, nullptr) &&
|
||||
(depth_test < *r_depth)) ||
|
||||
(depth_test < *depth)) ||
|
||||
(isect_ray_tri_watertight_v3(ray_start, isect_precalc, t0, t2, t3, &depth_test, nullptr) &&
|
||||
(depth_test < *r_depth)))
|
||||
(depth_test < *depth)))
|
||||
{
|
||||
*r_depth = depth_test;
|
||||
*depth = depth_test;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1679,13 +1679,13 @@ bool ray_face_intersection_tri(const float3 &ray_start,
|
||||
const float3 &t0,
|
||||
const float3 &t1,
|
||||
const float3 &t2,
|
||||
float *r_depth)
|
||||
float *depth)
|
||||
{
|
||||
float depth_test;
|
||||
if (isect_ray_tri_watertight_v3(ray_start, isect_precalc, t0, t1, t2, &depth_test, nullptr) &&
|
||||
(depth_test < *r_depth))
|
||||
(depth_test < *depth))
|
||||
{
|
||||
*r_depth = depth_test;
|
||||
*depth = depth_test;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1724,7 +1724,7 @@ bool ray_face_nearest_quad(const float3 &ray_start,
|
||||
const float3 &t1,
|
||||
const float3 &t2,
|
||||
const float3 &t3,
|
||||
float *depth,
|
||||
float *r_depth,
|
||||
float *dist_sq)
|
||||
{
|
||||
float dist_sq_test;
|
||||
@@ -1735,12 +1735,12 @@ bool ray_face_nearest_quad(const float3 &ray_start,
|
||||
ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq)
|
||||
{
|
||||
*dist_sq = dist_sq_test;
|
||||
*depth = depth_test;
|
||||
*r_depth = depth_test;
|
||||
if ((dist_sq_test = dist_squared_ray_to_tri_v3_fast(
|
||||
ray_start, ray_normal, t0, t2, t3, co, &depth_test)) < *dist_sq)
|
||||
{
|
||||
*dist_sq = dist_sq_test;
|
||||
*depth = depth_test;
|
||||
*r_depth = depth_test;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1753,7 +1753,7 @@ bool ray_face_nearest_tri(const float3 &ray_start,
|
||||
const float3 &t0,
|
||||
const float3 &t1,
|
||||
const float3 &t2,
|
||||
float *depth,
|
||||
float *r_depth,
|
||||
float *dist_sq)
|
||||
{
|
||||
float dist_sq_test;
|
||||
@@ -1764,7 +1764,7 @@ bool ray_face_nearest_tri(const float3 &ray_start,
|
||||
ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq)
|
||||
{
|
||||
*dist_sq = dist_sq_test;
|
||||
*depth = depth_test;
|
||||
*r_depth = depth_test;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1814,7 +1814,7 @@ static bool pbvh_faces_node_raycast(const MeshNode &node,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
IsectRayPrecalc *isect_precalc,
|
||||
float *r_depth,
|
||||
float *depth,
|
||||
PBVHVertRef *r_active_vertex,
|
||||
int &r_active_face_index,
|
||||
float3 &r_face_normal)
|
||||
@@ -1834,7 +1834,7 @@ static bool pbvh_faces_node_raycast(const MeshNode &node,
|
||||
const std::array<const float *, 3> co{{vert_positions[corner_verts[tri[0]]],
|
||||
vert_positions[corner_verts[tri[1]]],
|
||||
vert_positions[corner_verts[tri[2]]]}};
|
||||
if (ray_face_intersection_tri(ray_start, isect_precalc, co[0], co[1], co[2], r_depth)) {
|
||||
if (ray_face_intersection_tri(ray_start, isect_precalc, co[0], co[1], co[2], depth)) {
|
||||
hit = true;
|
||||
calc_mesh_intersect_data(corner_verts,
|
||||
corner_tris,
|
||||
@@ -1843,7 +1843,7 @@ static bool pbvh_faces_node_raycast(const MeshNode &node,
|
||||
face_i,
|
||||
tri_i,
|
||||
co,
|
||||
r_depth,
|
||||
depth,
|
||||
r_active_vertex,
|
||||
r_active_face_index,
|
||||
r_face_normal);
|
||||
@@ -1865,7 +1865,7 @@ static bool pbvh_faces_node_raycast(const MeshNode &node,
|
||||
{node_positions[vert_map.index_of(corner_verts[tri[0]])],
|
||||
node_positions[vert_map.index_of(corner_verts[tri[1]])],
|
||||
node_positions[vert_map.index_of(corner_verts[tri[2]])]}};
|
||||
if (ray_face_intersection_tri(ray_start, isect_precalc, co[0], co[1], co[2], r_depth)) {
|
||||
if (ray_face_intersection_tri(ray_start, isect_precalc, co[0], co[1], co[2], depth)) {
|
||||
hit = true;
|
||||
calc_mesh_intersect_data(corner_verts,
|
||||
corner_tris,
|
||||
@@ -1874,7 +1874,7 @@ static bool pbvh_faces_node_raycast(const MeshNode &node,
|
||||
face_i,
|
||||
tri_i,
|
||||
co,
|
||||
r_depth,
|
||||
depth,
|
||||
r_active_vertex,
|
||||
r_active_face_index,
|
||||
r_face_normal);
|
||||
@@ -1893,7 +1893,7 @@ static void calc_grids_intersect_data(const CCGKey &key,
|
||||
const short x,
|
||||
const short y,
|
||||
const std::array<const float *, 4> co,
|
||||
float *r_depth,
|
||||
float *depth,
|
||||
PBVHVertRef *r_active_vertex,
|
||||
int &r_active_grid_index,
|
||||
float3 &r_face_normal)
|
||||
@@ -1903,7 +1903,7 @@ static void calc_grids_intersect_data(const CCGKey &key,
|
||||
normal_quad_v3(r_face_normal, co[0], co[1], co[2], co[3]);
|
||||
|
||||
if (r_active_vertex) {
|
||||
const float3 location = ray_start + ray_normal * *r_depth;
|
||||
const float3 location = ray_start + ray_normal * *depth;
|
||||
|
||||
const int x_it[4] = {0, 1, 1, 0};
|
||||
const int y_it[4] = {1, 1, 0, 0};
|
||||
@@ -1932,7 +1932,7 @@ static bool pbvh_grids_node_raycast(const SubdivCCG &subdiv_ccg,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
const IsectRayPrecalc *isect_precalc,
|
||||
float *r_depth,
|
||||
float *depth,
|
||||
PBVHVertRef *r_active_vertex,
|
||||
int &r_active_grid_index,
|
||||
float3 &r_face_normal)
|
||||
@@ -1960,7 +1960,7 @@ static bool pbvh_grids_node_raycast(const SubdivCCG &subdiv_ccg,
|
||||
grid_positions[CCG_grid_xy_to_index(grid_size, x + 1, y)],
|
||||
grid_positions[CCG_grid_xy_to_index(grid_size, x, y)]}};
|
||||
if (ray_face_intersection_quad(
|
||||
ray_start, isect_precalc, co[0], co[1], co[2], co[3], r_depth))
|
||||
ray_start, isect_precalc, co[0], co[1], co[2], co[3], depth))
|
||||
{
|
||||
hit = true;
|
||||
calc_grids_intersect_data(key,
|
||||
@@ -1970,7 +1970,7 @@ static bool pbvh_grids_node_raycast(const SubdivCCG &subdiv_ccg,
|
||||
x,
|
||||
y,
|
||||
co,
|
||||
r_depth,
|
||||
depth,
|
||||
r_active_vertex,
|
||||
r_active_grid_index,
|
||||
r_face_normal);
|
||||
@@ -1995,7 +1995,7 @@ static bool pbvh_grids_node_raycast(const SubdivCCG &subdiv_ccg,
|
||||
grid_positions[y * grid_size + x + 1],
|
||||
grid_positions[y * grid_size + x]};
|
||||
if (ray_face_intersection_quad(
|
||||
ray_start, isect_precalc, co[0], co[1], co[2], co[3], r_depth))
|
||||
ray_start, isect_precalc, co[0], co[1], co[2], co[3], depth))
|
||||
{
|
||||
hit = true;
|
||||
calc_grids_intersect_data(key,
|
||||
@@ -2005,7 +2005,7 @@ static bool pbvh_grids_node_raycast(const SubdivCCG &subdiv_ccg,
|
||||
x,
|
||||
y,
|
||||
co,
|
||||
r_depth,
|
||||
depth,
|
||||
r_active_vertex,
|
||||
r_active_grid_index,
|
||||
r_face_normal);
|
||||
@@ -2031,7 +2031,7 @@ bool raycast_node(Tree &pbvh,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
IsectRayPrecalc *isect_precalc,
|
||||
float *r_depth,
|
||||
float *depth,
|
||||
PBVHVertRef *r_active_vertex,
|
||||
int &r_active_face_grid_index,
|
||||
float3 &r_face_normal)
|
||||
@@ -2051,7 +2051,7 @@ bool raycast_node(Tree &pbvh,
|
||||
ray_start,
|
||||
ray_normal,
|
||||
isect_precalc,
|
||||
r_depth,
|
||||
depth,
|
||||
r_active_vertex,
|
||||
r_active_face_grid_index,
|
||||
r_face_normal);
|
||||
@@ -2062,7 +2062,7 @@ bool raycast_node(Tree &pbvh,
|
||||
ray_start,
|
||||
ray_normal,
|
||||
isect_precalc,
|
||||
r_depth,
|
||||
depth,
|
||||
r_active_vertex,
|
||||
r_active_face_grid_index,
|
||||
r_face_normal);
|
||||
@@ -2071,7 +2071,7 @@ bool raycast_node(Tree &pbvh,
|
||||
ray_start,
|
||||
ray_normal,
|
||||
isect_precalc,
|
||||
r_depth,
|
||||
depth,
|
||||
use_origco,
|
||||
r_active_vertex,
|
||||
r_face_normal);
|
||||
@@ -2216,7 +2216,7 @@ static bool pbvh_faces_node_nearest_to_ray(const MeshNode &node,
|
||||
const Span<bool> hide_poly,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
float *depth,
|
||||
float *r_depth,
|
||||
float *dist_sq)
|
||||
{
|
||||
const Span<int> face_indices = node.faces();
|
||||
@@ -2236,7 +2236,7 @@ static bool pbvh_faces_node_nearest_to_ray(const MeshNode &node,
|
||||
vert_positions[corner_verts[corner_tri[0]]],
|
||||
vert_positions[corner_verts[corner_tri[1]]],
|
||||
vert_positions[corner_verts[corner_tri[2]]],
|
||||
depth,
|
||||
r_depth,
|
||||
dist_sq);
|
||||
}
|
||||
}
|
||||
@@ -2256,7 +2256,7 @@ static bool pbvh_faces_node_nearest_to_ray(const MeshNode &node,
|
||||
node_positions[vert_map.index_of(corner_verts[corner_tri[0]])],
|
||||
node_positions[vert_map.index_of(corner_verts[corner_tri[1]])],
|
||||
node_positions[vert_map.index_of(corner_verts[corner_tri[2]])],
|
||||
depth,
|
||||
r_depth,
|
||||
dist_sq);
|
||||
}
|
||||
}
|
||||
@@ -2270,7 +2270,7 @@ static bool pbvh_grids_node_nearest_to_ray(const SubdivCCG &subdiv_ccg,
|
||||
const Span<float3> node_positions,
|
||||
const float ray_start[3],
|
||||
const float ray_normal[3],
|
||||
float *depth,
|
||||
float *r_depth,
|
||||
float *dist_sq)
|
||||
{
|
||||
const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
|
||||
@@ -2297,7 +2297,7 @@ static bool pbvh_grids_node_nearest_to_ray(const SubdivCCG &subdiv_ccg,
|
||||
grid_positions[CCG_grid_xy_to_index(grid_size, x + 1, y)],
|
||||
grid_positions[CCG_grid_xy_to_index(grid_size, x + 1, y + 1)],
|
||||
grid_positions[CCG_grid_xy_to_index(grid_size, x, y + 1)],
|
||||
depth,
|
||||
r_depth,
|
||||
dist_sq);
|
||||
}
|
||||
}
|
||||
@@ -2320,7 +2320,7 @@ static bool pbvh_grids_node_nearest_to_ray(const SubdivCCG &subdiv_ccg,
|
||||
grid_positions[y * grid_size + x + 1],
|
||||
grid_positions[(y + 1) * grid_size + x + 1],
|
||||
grid_positions[(y + 1) * grid_size + x],
|
||||
depth,
|
||||
r_depth,
|
||||
dist_sq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1856,7 +1856,7 @@ bool bmesh_node_raycast(BMeshNode &node,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
IsectRayPrecalc *isect_precalc,
|
||||
float *r_depth,
|
||||
float *depth,
|
||||
bool use_original,
|
||||
PBVHVertRef *r_active_vertex,
|
||||
float *r_face_normal)
|
||||
@@ -1874,7 +1874,7 @@ bool bmesh_node_raycast(BMeshNode &node,
|
||||
cos[1] = node.orig_positions_[node.orig_tris_[tri_idx][1]];
|
||||
cos[2] = node.orig_positions_[node.orig_tris_[tri_idx][2]];
|
||||
|
||||
if (ray_face_intersection_tri(ray_start, isect_precalc, cos[0], cos[1], cos[2], r_depth)) {
|
||||
if (ray_face_intersection_tri(ray_start, isect_precalc, cos[0], cos[1], cos[2], depth)) {
|
||||
hit = true;
|
||||
|
||||
if (r_face_normal) {
|
||||
@@ -1883,7 +1883,7 @@ bool bmesh_node_raycast(BMeshNode &node,
|
||||
|
||||
if (r_active_vertex) {
|
||||
float3 location(0.0f);
|
||||
madd_v3_v3v3fl(location, ray_start, ray_normal, *r_depth);
|
||||
madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
|
||||
for (const int i : IndexRange(3)) {
|
||||
if (i == 0 ||
|
||||
len_squared_v3v3(location, cos[i]) < len_squared_v3v3(location, nearest_vertex_co))
|
||||
@@ -1905,7 +1905,7 @@ bool bmesh_node_raycast(BMeshNode &node,
|
||||
|
||||
BM_face_as_array_vert_tri(f, v_tri);
|
||||
if (ray_face_intersection_tri(
|
||||
ray_start, isect_precalc, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, r_depth))
|
||||
ray_start, isect_precalc, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth))
|
||||
{
|
||||
hit = true;
|
||||
|
||||
@@ -1915,7 +1915,7 @@ bool bmesh_node_raycast(BMeshNode &node,
|
||||
|
||||
if (r_active_vertex) {
|
||||
float3 location(0.0f);
|
||||
madd_v3_v3v3fl(location, ray_start, ray_normal, *r_depth);
|
||||
madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
|
||||
for (const int i : IndexRange(3)) {
|
||||
if (i == 0 || len_squared_v3v3(location, v_tri[i]->co) <
|
||||
len_squared_v3v3(location, nearest_vertex_co))
|
||||
@@ -1979,7 +1979,7 @@ bool bmesh_node_raycast_detail(BMeshNode &node,
|
||||
bool bmesh_node_nearest_to_ray(BMeshNode &node,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
float *depth,
|
||||
float *r_depth,
|
||||
float *dist_sq,
|
||||
bool use_original)
|
||||
{
|
||||
@@ -1993,7 +1993,7 @@ bool bmesh_node_nearest_to_ray(BMeshNode &node,
|
||||
node.orig_positions_[t[0]],
|
||||
node.orig_positions_[t[1]],
|
||||
node.orig_positions_[t[2]],
|
||||
depth,
|
||||
r_depth,
|
||||
dist_sq);
|
||||
}
|
||||
}
|
||||
@@ -2005,7 +2005,7 @@ bool bmesh_node_nearest_to_ray(BMeshNode &node,
|
||||
|
||||
BM_face_as_array_vert_tri(f, v_tri);
|
||||
hit |= ray_face_nearest_tri(
|
||||
ray_start, ray_normal, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth, dist_sq);
|
||||
ray_start, ray_normal, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, r_depth, dist_sq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ bool ray_face_intersection_quad(const float3 &ray_start,
|
||||
const float3 &t1,
|
||||
const float3 &t2,
|
||||
const float3 &t3,
|
||||
float *r_depth);
|
||||
float *depth);
|
||||
bool ray_face_intersection_tri(const float3 &ray_start,
|
||||
const IsectRayPrecalc *isect_precalc,
|
||||
const float3 &t0,
|
||||
const float3 &t1,
|
||||
const float3 &t2,
|
||||
float *r_depth);
|
||||
float *depth);
|
||||
|
||||
bool ray_face_nearest_quad(const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
@@ -50,14 +50,14 @@ bool bmesh_node_raycast(blender::bke::pbvh::BMeshNode &node,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
IsectRayPrecalc *isect_precalc,
|
||||
float *r_depth,
|
||||
float *depth,
|
||||
bool use_original,
|
||||
PBVHVertRef *r_active_vertex,
|
||||
float *r_face_normal);
|
||||
bool bmesh_node_nearest_to_ray(blender::bke::pbvh::BMeshNode &node,
|
||||
const float3 &ray_start,
|
||||
const float3 &ray_normal,
|
||||
float *depth,
|
||||
float *r_depth,
|
||||
float *dist_sq,
|
||||
bool use_original);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user