Cleanup: Sculpt: Use const for gesture data, rename variables
This commit is contained in:
parent
a7c7e58a4c
commit
cbb60190b4
@ -17,6 +17,7 @@
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix_types.hh"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_math_vector.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_vector.hh"
|
||||
@ -379,12 +380,12 @@ static void update_affected_nodes(GestureData &gesture_data)
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_affected_lasso(GestureData &gesture_data, const float co[3])
|
||||
static bool is_affected_lasso(const GestureData &gesture_data, const float3 &position)
|
||||
{
|
||||
int scr_co_s[2];
|
||||
float co_final[3];
|
||||
|
||||
flip_v3_v3(co_final, co, gesture_data.symmpass);
|
||||
flip_v3_v3(co_final, position, gesture_data.symmpass);
|
||||
|
||||
/* First project point to 2d space. */
|
||||
const float2 scr_co_f = ED_view3d_project_float_v2_m4(
|
||||
@ -394,15 +395,15 @@ static bool is_affected_lasso(GestureData &gesture_data, const float co[3])
|
||||
scr_co_s[1] = scr_co_f[1];
|
||||
|
||||
/* Clip against lasso boundbox. */
|
||||
LassoData *lasso = &gesture_data.lasso;
|
||||
if (!BLI_rcti_isect_pt(&lasso->boundbox, scr_co_s[0], scr_co_s[1])) {
|
||||
const LassoData &lasso = gesture_data.lasso;
|
||||
if (!BLI_rcti_isect_pt(&lasso.boundbox, scr_co_s[0], scr_co_s[1])) {
|
||||
return gesture_data.selection_type == SelectionType::Outside;
|
||||
}
|
||||
|
||||
scr_co_s[0] -= lasso->boundbox.xmin;
|
||||
scr_co_s[1] -= lasso->boundbox.ymin;
|
||||
scr_co_s[0] -= lasso.boundbox.xmin;
|
||||
scr_co_s[1] -= lasso.boundbox.ymin;
|
||||
|
||||
const bool bitmap_result = lasso->mask_px[scr_co_s[1] * lasso->width + scr_co_s[0]].test();
|
||||
const bool bitmap_result = lasso.mask_px[scr_co_s[1] * lasso.width + scr_co_s[0]].test();
|
||||
switch (gesture_data.selection_type) {
|
||||
case SelectionType::Inside:
|
||||
return bitmap_result;
|
||||
@ -413,9 +414,9 @@ static bool is_affected_lasso(GestureData &gesture_data, const float co[3])
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_affected(GestureData &gesture_data, const float3 &co, const float3 &vertex_normal)
|
||||
bool is_affected(const GestureData &gesture_data, const float3 &position, const float3 &normal)
|
||||
{
|
||||
float dot = dot_v3v3(gesture_data.view_normal, vertex_normal);
|
||||
float dot = math::dot(gesture_data.view_normal, normal);
|
||||
const bool is_effected_front_face = !(gesture_data.front_faces_only && dot < 0.0f);
|
||||
|
||||
if (!is_effected_front_face) {
|
||||
@ -424,19 +425,19 @@ bool is_affected(GestureData &gesture_data, const float3 &co, const float3 &vert
|
||||
|
||||
switch (gesture_data.shape_type) {
|
||||
case ShapeType::Box: {
|
||||
const bool is_contained = isect_point_planes_v3(gesture_data.clip_planes, 4, co);
|
||||
const bool is_contained = isect_point_planes_v3(gesture_data.clip_planes, 4, position);
|
||||
return ((is_contained && gesture_data.selection_type == SelectionType::Inside) ||
|
||||
(!is_contained && gesture_data.selection_type == SelectionType::Outside));
|
||||
}
|
||||
case ShapeType::Lasso:
|
||||
return is_affected_lasso(gesture_data, co);
|
||||
return is_affected_lasso(gesture_data, position);
|
||||
case ShapeType::Line:
|
||||
if (gesture_data.line.use_side_planes) {
|
||||
return plane_point_side_v3(gesture_data.line.plane, co) > 0.0f &&
|
||||
plane_point_side_v3(gesture_data.line.side_plane[0], co) > 0.0f &&
|
||||
plane_point_side_v3(gesture_data.line.side_plane[1], co) > 0.0f;
|
||||
return plane_point_side_v3(gesture_data.line.plane, position) > 0.0f &&
|
||||
plane_point_side_v3(gesture_data.line.side_plane[0], position) > 0.0f &&
|
||||
plane_point_side_v3(gesture_data.line.side_plane[1], position) > 0.0f;
|
||||
}
|
||||
return plane_point_side_v3(gesture_data.line.plane, co) > 0.0f;
|
||||
return plane_point_side_v3(gesture_data.line.plane, position) > 0.0f;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1792,7 +1792,7 @@ struct Operation {
|
||||
};
|
||||
|
||||
/* Determines whether or not a gesture action should be applied. */
|
||||
bool is_affected(GestureData &gesture_data, const float3 &co, const float3 &vertex_normal);
|
||||
bool is_affected(const GestureData &gesture_data, const float3 &position, const float3 &normal);
|
||||
|
||||
/* Initialization functions. */
|
||||
std::unique_ptr<GestureData> init_from_box(bContext *C, wmOperator *op);
|
||||
|
Loading…
Reference in New Issue
Block a user