58 if (region ==
nullptr) [[unlikely]] {
59 this->win_half = {1.0f, 1.0f};
64 this->win_half = {region->
winx / 2.0f, region->
winy / 2.0f};
70 for (
int i = 0; i < 4; i++) {
71 this->proj_mat[i][0] *= this->win_half[0];
72 this->proj_mat[i][1] *= this->win_half[1];
78 this->proj_mat.
location()[0] -= this->win_half[0];
79 this->proj_mat.
location()[1] -= this->win_half[1];
98 if (
sv.co_link_orig_3d.size() <= 1) {
102 const float3 v_co_orig =
sv.co_orig_3d();
105 int co_link_curr_best = -1;
107 for (
int j :
sv.co_link_orig_3d.index_range()) {
108 const float3 &loc_dst =
sv.co_link_orig_3d[j];
118 const float3 dir_local = loc_dst - v_co_orig;
123 if (dir_dot > dir_dot_best) {
124 dir_dot_best = dir_dot;
125 co_link_curr_best = j;
129 if (co_link_curr_best != -1) {
130 sv.co_link_curr = co_link_curr_best;
147 if (dist_sq < dist_min_sq) {
148 dist_min_sq = dist_sq;
149 this->curr_sv_index = i;
175 int mval_ofs[2], mval_start[2], mval_end[2];
181 ARRAY_SET_ITEMS(mval_start, co_orig_2d[0] + mval_ofs[0], co_orig_2d[1] + mval_ofs[1]);
182 ARRAY_SET_ITEMS(mval_end, co_curr_2d[0] + mval_ofs[0], co_curr_2d[1] + mval_ofs[1]);
212 if (sld->
sv.is_empty()) {
233 custom_data->
data =
nullptr;
241 custom_data->
data =
nullptr;
252 if (is_event_handled) {
258 switch (event->
type) {
292 const float3 &dir_unit = *dir3_opt;
335 const int alpha_shade = -160;
404 float3 co_orig_3d_cpy = co_orig_3d_act;
406 co_orig_3d_cpy[0] /= t->
aspect[0];
407 co_orig_3d_cpy[1] /= t->
aspect[1];
420 float viewport_size[4];
422 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
451 if (use_even ==
false) {
478 const bool use_even = slp->
use_even;
482 if (sld ==
nullptr) {
490 tperc *= edge_len_curr;
507 float snap_point[3], dvec[3];
537 const bool is_constrained = !(is_clamp ==
false ||
hasNumInput(&t->
num));
547 if (is_constrained) {
548 CLAMP(
final, 0.0f, 1.0f);
577 if (t->
keymap ==
nullptr) {
588 const bool flipped = slp->
flipped;
589 const bool use_even = slp->
use_even;
605 status.
item_bool(
IFACE_(
"Clamp"), is_clamp, ICON_EVENT_C, ICON_EVENT_ALT);
625 const float edge_len_curr =
len_v3v3(orig_co, loc_dst_act);
626 tperc *= edge_len_curr;
673 t->
custom.mode.data = slp;
674 t->
custom.mode.use_free =
false;
679 const float3 init_dir = [&t]() {
681 if (std::optional<float3> dir = slp->
dir_3d; dir) {
698 tc->custom.mode.data = sld;
725 bool use_even =
false;
726 bool flipped =
false;
727 bool use_clamp =
true;
#define ARRAY_SET_ITEMS(...)
IndexRange index_range() 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 dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
VectorT project_point(const MatT &mat, const VectorT &point)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
float get_value_f(int colorid)
void view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4]) ATTR_NONNULL()
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void negate_v3_v3(float r[3], const float a[3])
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
void wmOrtho2_region_pixelspace(const ARegion *region)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void immUniform2f(const char *name, float x, float y)
float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
void GPU_matrix_identity_set()
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)
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
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)
void GPU_matrix_scale_2f(float x, float y)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
MINLINE void sub_v3_v3(float r[3], const float a[3])
VecBase< float, 4 > float4
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void mul_m4_v3(const float M[4][4], float r[3])
VecBase< float, 2 > float2
void immUniform1f(const char *name, float x)
void GPU_viewport_size_get_f(float coords[4])
void BKE_report(ReportList *reports, eReportType type, const char *message)
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_POINT_UNIFORM_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
void immUniformColor4f(float r, float g, float b, float a)
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)
MINLINE float normalize_v3(float n[3])
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])
MINLINE void copy_v3_fl(float r[3], float f)
void GPU_matrix_pop_projection()
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
void GPU_blend(GPUBlend blend)
void immUniform1i(const char *name, int x)
VecBase< float, 3 > float3
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void immVertex2fv(uint attr_id, const float data[2])
void GPU_matrix_push_projection()
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)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
MINLINE bool compare_v2v2(const float v1[2], const float v2[2], float limit) ATTR_WARN_UNUSED_RESULT
const c_style_mat & ptr() const
static MatBase identity()