63 if (region ==
nullptr) [[unlikely]] {
64 this->win_half = {1.0f, 1.0f};
69 this->win_half = {region->
winx / 2.0f, region->
winy / 2.0f};
75 for (
int i = 0; i < 4; i++) {
76 this->proj_mat[i][0] *= this->win_half[0];
77 this->proj_mat[i][1] *= this->win_half[1];
83 this->proj_mat.
location()[0] -= this->win_half[0];
84 this->proj_mat.
location()[1] -= this->win_half[1];
127 float p[3],
const float v1[3],
const float v2[3],
const float v3[3],
float t)
129 float t_mid, t_delta;
135 if (t_delta < 0.0f) {
145 t_mid = 1.0f - t_mid;
161 mval_dir[1] = 100.0f;
164 float mval_start[2], mval_end[2];
211 const bool use_calc_direction)
216 bool use_occlude_geometry =
false;
246 if (use_occlude_geometry) {
252 t->
depsgraph, scene_eval, obedit_eval, bmbvh_coord_storage);
257 vert_positions.
is_empty() ?
nullptr :
258 vert_positions.
data(),
268 float2 *loop_dir =
nullptr;
269 float *loop_maxdist =
nullptr;
271 if (use_calc_direction) {
274 std::fill_n(loop_maxdist, loop_nr,
FLT_MAX);
277 for (
int i : sld->
sv.index_range()) {
282 if (!is_visible && !use_calc_direction) {
290 sld->
project(sv, sco_a, sco_b);
296 dist_best_sq = dist_sq;
297 mval_dir = sco_b - sco_a;
302 if (use_calc_direction) {
305 if (dist_sq < loop_maxdist[l_nr]) {
306 loop_maxdist[l_nr] = dist_sq;
307 loop_dir[l_nr] = sco_b - sco_a;
312 if (use_calc_direction) {
316 if (
math::dot(loop_dir[l_nr], mval_dir) < 0.0f) {
321 MEM_delete(loop_dir);
322 MEM_delete(loop_maxdist);
334 const bool use_double_side)
345 if (sld->
sv.is_empty()) {
350 if (!use_double_side) {
366 for (TMP &accum : array_len) {
367 accum.accum /= accum.count;
371 if (array_len[sv.
loop_nr].accum[1] > array_len[sv.
loop_nr].accum[0]) {
393 if (sld ==
nullptr) {
399 custom_data->
data =
nullptr;
409 switch (event->
type) {
448 if (sld ==
nullptr) {
475 float co_a[3], co_b[3], co_mark[3];
476 const float fac = (slp->
perc + 1.0f) / 2.0f;
478 const float guide_size = ctrl_size - 0.5f;
479 const int alpha_shade = -30;
500 float *co_test =
nullptr;
512 if (co_test !=
nullptr) {
528 else if (is_clamp ==
false) {
530 const int alpha_shade = -160;
561 const int alpha_shade = -160;
590 float3 co_orig, co_dest[2], dvec, snap_point;
592 co_dest[0] = co_orig + sv->
dir_side[0];
593 co_dest[1] = co_orig + sv->
dir_side[1];
611 side_index = perc < 0.0f;
625 side_index = t_snap >= t_mid;
649 perc = (1.0f - perc) * t_mid;
652 perc = perc * (1.0f - t_mid) + t_mid;
659 perc = (2 * perc) - 1.0f;
671 const float curr_length_fac,
672 const int curr_side_unclamp,
673 const bool use_clamp,
680 if (use_even ==
false) {
682 const int side_index = (fac < 0.0f);
683 const float fac_final =
fabsf(fac);
687 int side_index = curr_side_unclamp;
689 side_index = int(!side_index);
691 const float fac_final = (side_index == (fac < 0.0f) ?
fabsf(fac) : -
fabsf(fac));
707 float co_a[3], co_b[3];
731 const bool use_even = slp->
use_even;
732 const bool use_flip = slp->
flipped;
735 float curr_length_fac = 0.0f;
738 curr_length_fac = sv_active->
edge_len * (((use_flip ? perc : -perc) + 1.0f) / 2.0f);
740 else if (use_clamp) {
747 if (sld ==
nullptr) {
753 sv, perc, curr_length_fac, curr_side_unclamp, use_clamp, use_even, use_flip, sv.
td->
loc);
764 const bool is_constrained = !(is_clamp ==
false ||
hasNumInput(&t->
num));
774 if (is_constrained) {
775 CLAMP(
final, -1.0f, 1.0f);
804 if (t->
keymap ==
nullptr) {
815 const bool flipped = slp->
flipped;
816 const bool use_even = slp->
use_even;
832 status.
item_bool(
IFACE_(
"Clamp"), is_clamp, ICON_EVENT_C, ICON_EVENT_ALT);
841 float delta[3], orig_co[3], final_co[3];
851 float curr_length_fac = 0.0f;
853 curr_length_fac = sv_active.
edge_len * (((slp->
flipped ? fac : -fac) + 1.0f) / 2.0f);
875 TransInfo *t,
bool use_double_side,
bool use_even,
bool flipped,
bool use_clamp)
893 if (use_double_side ==
false) {
903 t->
custom.mode.data = slp;
904 t->
custom.mode.use_free =
true;
910 tc->custom.mode.data = sld;
937 bool use_double_side =
true;
938 bool use_even =
false;
939 bool flipped =
false;
940 bool use_clamp =
true;
973 sld->
project(curr_sv, sco_a, sco_b);
974 float2 mval_dir = sco_b - sco_a;
#define XRAY_ENABLED(v3d)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
constexpr const T * data() const
constexpr bool is_empty() const
void modal_keymap(std::string text, const wmKeyMap &keymap, int propvalue, bool inverted=false)
void item_bool(std::string text, bool inverted, int icon1, int icon2=0)
T length(const VecBase< T, Size > &a)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
VectorT project_point(const MatT &mat, const VectorT &point)
float get_value_f(int colorid)
void view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4]) ATTR_NONNULL()
MINLINE float min_ff(float a, float b)
MINLINE void negate_v3_v3(float r[3], const float a[3])
void BKE_bmbvh_free(BMBVHTree *tree)
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
bool BMBVH_EdgeVisible(const BMBVHTree *tree, const BMEdge *e, const Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const Object *obedit)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
Span< float3 > BKE_editmesh_vert_coords_when_deformed(Depsgraph *depsgraph, Scene *scene, Object *obedit, Array< float3 > &r_alloc)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v2_fl(float r[2], float f)
void immBeginAtMost(GPUPrimType, uint max_vertex_len)
float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
MINLINE void copy_v2_v2(float r[2], const float a[2])
char size_t BLI_strncpy_utf8_rlen(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
GPUVertFormat * immVertexFormat()
void GPU_point_size(float size)
void immBegin(GPUPrimType, uint vertex_len)
bool hasNumInput(const NumInput *n)
ATTR_WARN_UNUSED_RESULT const BMVert * v
MatBase< float, 4, 4 > float4x4
void GPU_matrix_mul(const float m[4][4])
MINLINE void mul_v3_fl(float r[3], float f)
void GPU_line_width(float width)
float dist_squared_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
MINLINE void sub_v3_v3(float r[3], const float a[3])
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void mul_m4_v3(const float M[4][4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
VecBase< float, 2 > float2
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
MINLINE void swap_v3_v3(float a[3], float b[3])
void BKE_report(ReportList *reports, eReportType type, const char *message)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
BMBVHTree * BKE_bmbvh_new_from_editmesh(struct BMEditMesh *em, struct BMesh *bm, int flag, const float3 *cos_cage, bool cos_cage_free)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
void ED_area_status_text(ScrArea *area, const char *str)
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
bool applyNumInput(NumInput *n, float *vec)
BMEditMesh * BKE_editmesh_from_object(Object *ob)
Return the BMEditMesh for a given object.
MINLINE float normalize_v3(float n[3])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3(float r[3], const float a[3])
void immVertex3fv(uint attr_id, const float data[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
MINLINE void copy_v3_fl(float r[3], float f)
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
void GPU_blend(GPUBlend blend)
VecBase< float, 3 > float3
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
size_t BLI_snprintf_utf8_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void GPU_depth_test(GPUDepthTest test)
MINLINE void zero_v2(float r[2])
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
const c_style_mat & ptr() const
static MatBase identity()
ListBaseT< SpaceLink > spacedata