Editors: move code to C++ #110267
@ -20,23 +20,23 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
gizmo_draw_utils.c
|
||||
gizmo_draw_utils.cc
|
||||
gizmo_geometry.h
|
||||
gizmo_library_intern.h
|
||||
gizmo_library_presets.c
|
||||
gizmo_library_utils.c
|
||||
geometry/geom_arrow_gizmo.c
|
||||
geometry/geom_cube_gizmo.c
|
||||
geometry/geom_dial_gizmo.c
|
||||
gizmo_types/arrow3d_gizmo.c
|
||||
gizmo_types/blank3d_gizmo.c
|
||||
gizmo_types/button2d_gizmo.c
|
||||
gizmo_types/cage2d_gizmo.c
|
||||
gizmo_types/cage3d_gizmo.c
|
||||
gizmo_types/dial3d_gizmo.c
|
||||
gizmo_types/move3d_gizmo.c
|
||||
gizmo_types/primitive3d_gizmo.c
|
||||
gizmo_types/snap3d_gizmo.c
|
||||
gizmo_library_presets.cc
|
||||
gizmo_library_utils.cc
|
||||
geometry/geom_arrow_gizmo.cc
|
||||
geometry/geom_cube_gizmo.cc
|
||||
geometry/geom_dial_gizmo.cc
|
||||
gizmo_types/arrow3d_gizmo.cc
|
||||
gizmo_types/blank3d_gizmo.cc
|
||||
gizmo_types/button2d_gizmo.cc
|
||||
gizmo_types/cage2d_gizmo.cc
|
||||
gizmo_types/cage3d_gizmo.cc
|
||||
gizmo_types/dial3d_gizmo.cc
|
||||
gizmo_types/move3d_gizmo.cc
|
||||
gizmo_types/primitive3d_gizmo.cc
|
||||
gizmo_types/snap3d_gizmo.cc
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
@ -52,9 +52,9 @@ static ushort indices[] = {
|
||||
};
|
||||
|
||||
GizmoGeomInfo wm_gizmo_geom_data_arrow = {
|
||||
.nverts = 25,
|
||||
.ntris = 46,
|
||||
.verts = verts,
|
||||
.normals = normals,
|
||||
.indices = indices,
|
||||
/*nverts*/ 25,
|
||||
/*ntris*/ 46,
|
||||
/*verts*/ verts,
|
||||
/*normals*/ normals,
|
||||
/*indices*/ indices,
|
||||
};
|
@ -36,9 +36,9 @@ static const ushort indices[] = {
|
||||
};
|
||||
|
||||
GizmoGeomInfo wm_gizmo_geom_data_cube = {
|
||||
.nverts = 8,
|
||||
.ntris = 12,
|
||||
.verts = verts,
|
||||
.normals = normals,
|
||||
.indices = indices,
|
||||
/*nverts*/ 8,
|
||||
/*ntris*/ 12,
|
||||
/*verts*/ verts,
|
||||
/*normals*/ normals,
|
||||
/*indices*/ indices,
|
||||
};
|
@ -271,9 +271,9 @@ static const ushort indices[] = {
|
||||
};
|
||||
|
||||
GizmoGeomInfo wm_gizmo_geom_data_dial = {
|
||||
.nverts = 192,
|
||||
.ntris = 384,
|
||||
.verts = verts,
|
||||
.normals = normals,
|
||||
.indices = indices,
|
||||
/*nverts*/ 192,
|
||||
/*ntris*/ 384,
|
||||
/*verts*/ verts,
|
||||
/*normals*/ normals,
|
||||
/*indices*/ indices,
|
||||
};
|
@ -30,7 +30,7 @@
|
||||
#include "gizmo_library_intern.h"
|
||||
|
||||
void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info,
|
||||
const bool UNUSED(select),
|
||||
const bool /*select*/,
|
||||
const float color[4])
|
||||
{
|
||||
/* TODO: store the Batches inside the GizmoGeomInfo and updated it when geom changes
|
||||
@ -62,8 +62,8 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info,
|
||||
|
||||
GPU_batch_uniform_4fv(batch, "color", color);
|
||||
|
||||
/* We may want to re-visit this, for now disable
|
||||
* since it causes issues leaving the GL state modified. */
|
||||
/* We may want to re-visit this, for now disable
|
||||
* since it causes issues leaving the GL state modified. */
|
||||
#if 0
|
||||
GPU_face_culling(GPU_CULL_BACK);
|
||||
GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
|
||||
@ -108,7 +108,7 @@ void wm_gizmo_vec_draw(
|
||||
immEnd();
|
||||
}
|
||||
else {
|
||||
immBegin(primitive_type, vert_count);
|
||||
immBegin(GPUPrimType(primitive_type), vert_count);
|
||||
for (int i = 0; i < vert_count; i++) {
|
||||
immVertex3fv(pos, verts[i]);
|
||||
}
|
@ -16,6 +16,10 @@
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct GizmoGeomInfo {
|
||||
int nverts;
|
||||
int ntris;
|
||||
@ -32,3 +36,7 @@ extern GizmoGeomInfo wm_gizmo_geom_data_cube;
|
||||
|
||||
/* dial gizmo */
|
||||
extern GizmoGeomInfo wm_gizmo_geom_data_dial;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -8,6 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gizmo_geometry.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DIAL_RESOLUTION 48
|
||||
|
||||
/**
|
||||
@ -86,8 +92,6 @@ struct wmGizmo *gizmo_find_from_properties(const struct IDProperty *properties,
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Gizmo drawing */
|
||||
|
||||
#include "gizmo_geometry.h"
|
||||
|
||||
/**
|
||||
* Main draw call for #GizmoGeomInfo data
|
||||
*/
|
||||
@ -96,3 +100,7 @@ void wm_gizmo_geometryinfo_draw(const struct GizmoGeomInfo *info,
|
||||
const float color[4]);
|
||||
void wm_gizmo_vec_draw(
|
||||
const float color[4], const float (*verts)[3], uint vert_count, uint pos, uint primitive_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -109,10 +109,10 @@ void gizmo_property_data_update(wmGizmo *gz,
|
||||
const bool constrained,
|
||||
const bool inverted)
|
||||
{
|
||||
if (gz_prop->custom_func.value_get_fn != NULL) {
|
||||
if (gz_prop->custom_func.value_get_fn != nullptr) {
|
||||
/* Pass. */
|
||||
}
|
||||
else if (gz_prop->prop != NULL) {
|
||||
else if (gz_prop->prop != nullptr) {
|
||||
/* Pass. */
|
||||
}
|
||||
else {
|
||||
@ -169,7 +169,7 @@ bool gizmo_window_project_2d(
|
||||
float mat[4][4], imat[4][4];
|
||||
{
|
||||
float mat_identity[4][4];
|
||||
struct WM_GizmoMatrixParams params = {NULL};
|
||||
struct WM_GizmoMatrixParams params = {nullptr};
|
||||
if (use_offset == false) {
|
||||
unit_m4(mat_identity);
|
||||
params.matrix_offset = mat_identity;
|
||||
@ -214,7 +214,7 @@ bool gizmo_window_project_3d(
|
||||
float mat[4][4], imat[4][4];
|
||||
{
|
||||
float mat_identity[4][4];
|
||||
struct WM_GizmoMatrixParams params = {NULL};
|
||||
struct WM_GizmoMatrixParams params = {nullptr};
|
||||
if (use_offset == false) {
|
||||
unit_m4(mat_identity);
|
||||
params.matrix_offset = mat_identity;
|
||||
@ -255,13 +255,15 @@ wmGizmo *gizmo_find_from_properties(const IDProperty *properties,
|
||||
const int spacetype,
|
||||
const int regionid)
|
||||
{
|
||||
for (bScreen *screen = G_MAIN->screens.first; screen; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(G_MAIN->screens.first); screen;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
if (!ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
|
||||
continue;
|
||||
}
|
||||
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
||||
if (region->gizmo_map == NULL) {
|
||||
if (region->gizmo_map == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (!ELEM(regionid, RGN_TYPE_ANY, region->regiontype)) {
|
||||
@ -278,7 +280,7 @@ wmGizmo *gizmo_find_from_properties(const IDProperty *properties,
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "DNA_view3d_types.h"
|
||||
@ -54,15 +55,15 @@
|
||||
/* Margin to add when selecting the arrow. */
|
||||
#define ARROW_SELECT_THRESHOLD_PX (5)
|
||||
|
||||
typedef struct ArrowGizmo3D {
|
||||
struct ArrowGizmo3D {
|
||||
wmGizmo gizmo;
|
||||
GizmoCommonData data;
|
||||
} ArrowGizmo3D;
|
||||
};
|
||||
|
||||
typedef struct ArrowGizmoInteraction {
|
||||
struct ArrowGizmoInteraction {
|
||||
GizmoInteraction inter;
|
||||
float init_arrow_length;
|
||||
} ArrowGizmoInteraction;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@ -236,27 +237,28 @@ static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool
|
||||
GPU_matrix_pop();
|
||||
|
||||
if (gz->interaction_data) {
|
||||
ArrowGizmoInteraction *arrow_inter = gz->interaction_data;
|
||||
ArrowGizmoInteraction *arrow_inter = static_cast<ArrowGizmoInteraction *>(
|
||||
gz->interaction_data);
|
||||
|
||||
GPU_matrix_push();
|
||||
GPU_matrix_mul(arrow_inter->inter.init_matrix_final);
|
||||
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
arrow_draw_geom(
|
||||
arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, arrow_inter->init_arrow_length);
|
||||
arrow, select, blender::float4{0.5f, 0.5f, 0.5f, 0.5f}, arrow_inter->init_arrow_length);
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
|
||||
GPU_matrix_pop();
|
||||
}
|
||||
}
|
||||
|
||||
static void gizmo_arrow_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id)
|
||||
static void gizmo_arrow_draw_select(const bContext * /*C*/, wmGizmo *gz, int select_id)
|
||||
{
|
||||
GPU_select_load_id(select_id);
|
||||
arrow_draw_intern((ArrowGizmo3D *)gz, true, false);
|
||||
}
|
||||
|
||||
static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz)
|
||||
static void gizmo_arrow_draw(const bContext * /*C*/, wmGizmo *gz)
|
||||
{
|
||||
arrow_draw_intern((ArrowGizmo3D *)gz, false, (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0);
|
||||
}
|
||||
@ -264,7 +266,7 @@ static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz)
|
||||
/**
|
||||
* Selection for 2D views.
|
||||
*/
|
||||
static int gizmo_arrow_test_select(bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
|
||||
static int gizmo_arrow_test_select(bContext * /*C*/, wmGizmo *gz, const int mval[2])
|
||||
{
|
||||
/* This following values are based on manual inspection of `verts[]` defined in
|
||||
* geom_arrow_gizmo.c */
|
||||
@ -293,7 +295,7 @@ static int gizmo_arrow_test_select(bContext *UNUSED(C), wmGizmo *gz, const int m
|
||||
const float stem_width = ARROW_SELECT_THRESHOLD_PX * scale_final * stem_geo_x;
|
||||
float select_threshold_base = gz->line_width * U.pixelsize;
|
||||
|
||||
const float mval_fl[2] = {UNPACK2(mval)};
|
||||
const float mval_fl[2] = {float(mval[0]), float(mval[1])};
|
||||
|
||||
/* Distance to arrow head. */
|
||||
if (len_squared_v2v2(mval_fl, arrow_end) < square_f(select_threshold_base + head_width)) {
|
||||
@ -327,22 +329,22 @@ static int gizmo_arrow_modal(bContext *C,
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
|
||||
GizmoInteraction *inter = gz->interaction_data;
|
||||
GizmoInteraction *inter = static_cast<GizmoInteraction *>(gz->interaction_data);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = region->regiondata;
|
||||
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||
|
||||
float offset[3];
|
||||
float facdir = 1.0f;
|
||||
|
||||
/* (src, dst) */
|
||||
struct {
|
||||
float mval[2];
|
||||
blender::float2 mval;
|
||||
float ray_origin[3], ray_direction[3];
|
||||
float location[3];
|
||||
} proj[2] = {
|
||||
{.mval = {UNPACK2(inter->init_mval)}},
|
||||
{.mval = {UNPACK2(event->mval)}},
|
||||
};
|
||||
} proj[2]{};
|
||||
|
||||
proj[0].mval = {UNPACK2(inter->init_mval)};
|
||||
proj[1].mval = {float(event->mval[0]), float(event->mval[1])};
|
||||
|
||||
float arrow_co[3];
|
||||
float arrow_no[3];
|
||||
@ -422,10 +424,11 @@ static void gizmo_arrow_setup(wmGizmo *gz)
|
||||
arrow->data.range_fac = 1.0f;
|
||||
}
|
||||
|
||||
static int gizmo_arrow_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
|
||||
static int gizmo_arrow_invoke(bContext * /*C*/, wmGizmo *gz, const wmEvent *event)
|
||||
{
|
||||
ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
|
||||
GizmoInteraction *inter = MEM_callocN(sizeof(ArrowGizmoInteraction), __func__);
|
||||
GizmoInteraction *inter = static_cast<GizmoInteraction *>(
|
||||
MEM_callocN(sizeof(ArrowGizmoInteraction), __func__));
|
||||
wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
|
||||
|
||||
/* Some gizmos don't use properties. */
|
||||
@ -465,7 +468,7 @@ static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
|
||||
const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop);
|
||||
|
||||
if (cancel) {
|
||||
GizmoInteraction *inter = gz->interaction_data;
|
||||
GizmoInteraction *inter = static_cast<GizmoInteraction *>(gz->interaction_data);
|
||||
if (is_prop_valid) {
|
||||
gizmo_property_value_reset(C, gz, inter, gz_prop);
|
||||
}
|
||||
@ -542,17 +545,17 @@ static void GIZMO_GT_arrow_3d(wmGizmoType *gzt)
|
||||
{ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
|
||||
{ED_GIZMO_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
|
||||
{ED_GIZMO_ARROW_STYLE_PLANE, "PLANE", 0, "Plane", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
static EnumPropertyItem rna_enum_draw_options_items[] = {
|
||||
{ED_GIZMO_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
|
||||
{ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN, "ORIGIN", 0, "Origin", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
static EnumPropertyItem rna_enum_transform_items[] = {
|
||||
{ED_GIZMO_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
|
||||
{ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
RNA_def_enum(gzt->srna,
|
||||
@ -572,7 +575,7 @@ static void GIZMO_GT_arrow_3d(wmGizmoType *gzt)
|
||||
RNA_def_float(
|
||||
gzt->srna, "length", 1.0f, -FLT_MAX, FLT_MAX, "Arrow Line Length", "", -FLT_MAX, FLT_MAX);
|
||||
RNA_def_float_vector(
|
||||
gzt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);
|
||||
gzt->srna, "aspect", 2, nullptr, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);
|
||||
|
||||
WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1);
|
||||
}
|
@ -19,21 +19,17 @@
|
||||
|
||||
/* own includes */
|
||||
|
||||
static void gizmo_blank_draw(const bContext *UNUSED(C), wmGizmo *UNUSED(gz))
|
||||
static void gizmo_blank_draw(const bContext * /*C*/, wmGizmo * /*gz*/)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
static int gizmo_blank_invoke(bContext *UNUSED(C),
|
||||
wmGizmo *UNUSED(gz),
|
||||
const wmEvent *UNUSED(event))
|
||||
static int gizmo_blank_invoke(bContext * /*C*/, wmGizmo * /*gz*/, const wmEvent * /*event*/)
|
||||
{
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
static int gizmo_blank_test_select(bContext *UNUSED(C),
|
||||
wmGizmo *UNUSED(gz),
|
||||
const int UNUSED(mval[2]))
|
||||
static int gizmo_blank_test_select(bContext * /*C*/, wmGizmo * /*gz*/, const int[2] /*mval*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
||||
@ -51,13 +52,13 @@
|
||||
/** \name Internal Types
|
||||
* \{ */
|
||||
|
||||
typedef struct ButtonGizmo2D {
|
||||
struct ButtonGizmo2D {
|
||||
wmGizmo gizmo;
|
||||
bool is_init;
|
||||
/* Use an icon or shape */
|
||||
int icon;
|
||||
GPUBatch *shape_batch[2];
|
||||
} ButtonGizmo2D;
|
||||
};
|
||||
|
||||
/** \} */
|
||||
|
||||
@ -141,13 +142,13 @@ static void button2d_draw_intern(const bContext *C,
|
||||
else {
|
||||
prop = RNA_struct_find_property(gz->ptr, "shape");
|
||||
const uint polys_len = RNA_property_string_length(gz->ptr, prop);
|
||||
/* We shouldn't need the +1, but a NULL char is set. */
|
||||
char *polys = MEM_mallocN(polys_len + 1, __func__);
|
||||
/* We shouldn't need the +1, but a nullptr char is set. */
|
||||
char *polys = static_cast<char *>(MEM_mallocN(polys_len + 1, __func__));
|
||||
RNA_property_string_get(gz->ptr, prop, polys);
|
||||
button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded(
|
||||
(uchar *)polys, polys_len, NULL);
|
||||
(uchar *)polys, polys_len, nullptr);
|
||||
button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded(
|
||||
(uchar *)polys, polys_len, NULL);
|
||||
(uchar *)polys, polys_len, nullptr);
|
||||
MEM_freeN(polys);
|
||||
}
|
||||
}
|
||||
@ -207,7 +208,7 @@ static void button2d_draw_intern(const bContext *C,
|
||||
button2d_geom_draw_backdrop(gz, color, fill_alpha, select, screen_scale);
|
||||
}
|
||||
|
||||
if (button->shape_batch[0] != NULL) {
|
||||
if (button->shape_batch[0] != nullptr) {
|
||||
GPU_line_smooth(true);
|
||||
GPU_polygon_smooth(false);
|
||||
for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) {
|
||||
@ -299,13 +300,14 @@ static int gizmo_button2d_test_select(bContext *C, wmGizmo *gz, const int mval[2
|
||||
|
||||
if (0) {
|
||||
/* correct, but unnecessarily slow. */
|
||||
if (gizmo_window_project_2d(C, gz, (const float[2]){UNPACK2(mval)}, 2, true, point_local) ==
|
||||
false) {
|
||||
if (gizmo_window_project_2d(
|
||||
C, gz, blender::float2{blender::int2(mval)}, 2, true, point_local) == false)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
copy_v2_v2(point_local, (float[2]){UNPACK2(mval)});
|
||||
copy_v2_v2(point_local, blender::float2{blender::int2(mval)});
|
||||
sub_v2_v2(point_local, gz->matrix_basis[3]);
|
||||
mul_v2_fl(point_local, 1.0f / gz->scale_final);
|
||||
}
|
||||
@ -330,7 +332,7 @@ static bool gizmo_button2d_bounds(bContext *C, wmGizmo *gz, rcti *r_bounding_box
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
float rad = CIRCLE_RESOLUTION_3D * UI_SCALE_FAC / 2.0f;
|
||||
const float *co = NULL;
|
||||
const float *co = nullptr;
|
||||
float matrix_final[4][4];
|
||||
float co_proj[3];
|
||||
WM_gizmo_calc_matrix_final(gz, matrix_final);
|
||||
@ -341,7 +343,7 @@ static bool gizmo_button2d_bounds(bContext *C, wmGizmo *gz, rcti *r_bounding_box
|
||||
V3D_PROJ_RET_OK)
|
||||
{
|
||||
float matrix_final_no_offset[4][4];
|
||||
const RegionView3D *rv3d = region->regiondata;
|
||||
const RegionView3D *rv3d = static_cast<const RegionView3D *>(region->regiondata);
|
||||
WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset);
|
||||
const float factor = ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_final_no_offset[3]) /
|
||||
ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_final[3]);
|
||||
@ -358,7 +360,7 @@ static bool gizmo_button2d_bounds(bContext *C, wmGizmo *gz, rcti *r_bounding_box
|
||||
co = matrix_final[3];
|
||||
}
|
||||
|
||||
if (co != NULL) {
|
||||
if (co != nullptr) {
|
||||
r_bounding_box->xmin = co[0] + area->totrct.xmin - rad;
|
||||
r_bounding_box->ymin = co[1] + area->totrct.ymin - rad;
|
||||
r_bounding_box->xmax = r_bounding_box->xmin + rad;
|
||||
@ -403,7 +405,7 @@ static void GIZMO_GT_button_2d(wmGizmoType *gzt)
|
||||
{ED_GIZMO_BUTTON_SHOW_OUTLINE, "OUTLINE", 0, "Outline", ""},
|
||||
{ED_GIZMO_BUTTON_SHOW_BACKDROP, "BACKDROP", 0, "Backdrop", ""},
|
||||
{ED_GIZMO_BUTTON_SHOW_HELPLINE, "HELPLINE", 0, "Help Line", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
PropertyRNA *prop;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "BLI_dial_2d.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_base_safe.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_rect.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
@ -151,12 +152,12 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
|
||||
switch (highlighted) {
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X: {
|
||||
rctf r = {
|
||||
.xmin = -size[0],
|
||||
.xmax = -size[0] + margin[0],
|
||||
.ymin = -size[1] + margin[1],
|
||||
.ymax = size[1] - margin[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = -size[0];
|
||||
r.xmax = -size[0] + margin[0];
|
||||
r.ymin = -size[1] + margin[1];
|
||||
r.ymax = size[1] - margin[1];
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin);
|
||||
ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymax);
|
||||
verts_len = 2;
|
||||
@ -172,12 +173,12 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
break;
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X: {
|
||||
rctf r = {
|
||||
.xmin = size[0] - margin[0],
|
||||
.xmax = size[0],
|
||||
.ymin = -size[1] + margin[1],
|
||||
.ymax = size[1] - margin[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = size[0] - margin[0];
|
||||
r.xmax = size[0];
|
||||
r.ymin = -size[1] + margin[1];
|
||||
r.ymax = size[1] - margin[1];
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymin);
|
||||
ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax);
|
||||
verts_len = 2;
|
||||
@ -193,12 +194,12 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
break;
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y: {
|
||||
rctf r = {
|
||||
.xmin = -size[0] + margin[0],
|
||||
.xmax = size[0] - margin[0],
|
||||
.ymin = -size[1],
|
||||
.ymax = -size[1] + margin[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = -size[0] + margin[0];
|
||||
r.xmax = size[0] - margin[0];
|
||||
r.ymin = -size[1];
|
||||
r.ymax = -size[1] + margin[1];
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin);
|
||||
ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymin);
|
||||
verts_len = 2;
|
||||
@ -214,12 +215,12 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
break;
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y: {
|
||||
rctf r = {
|
||||
.xmin = -size[0] + margin[0],
|
||||
.xmax = size[0] - margin[0],
|
||||
.ymin = size[1] - margin[1],
|
||||
.ymax = size[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = -size[0] + margin[0];
|
||||
r.xmax = size[0] - margin[0];
|
||||
r.ymin = size[1] - margin[1];
|
||||
r.ymax = size[1];
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymax);
|
||||
ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax);
|
||||
verts_len = 2;
|
||||
@ -235,12 +236,12 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
break;
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y: {
|
||||
rctf r = {
|
||||
.xmin = -size[0],
|
||||
.xmax = -size[0] + margin[0],
|
||||
.ymin = -size[1],
|
||||
.ymax = -size[1] + margin[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = -size[0];
|
||||
r.xmax = -size[0] + margin[0];
|
||||
r.ymin = -size[1];
|
||||
r.ymax = -size[1] + margin[1];
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymin);
|
||||
ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymax);
|
||||
ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax);
|
||||
@ -256,12 +257,12 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
break;
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y: {
|
||||
rctf r = {
|
||||
.xmin = -size[0],
|
||||
.xmax = -size[0] + margin[0],
|
||||
.ymin = size[1] - margin[1],
|
||||
.ymax = size[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = -size[0];
|
||||
r.xmax = -size[0] + margin[0];
|
||||
r.ymin = size[1] - margin[1];
|
||||
r.ymax = size[1];
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r.xmax, r.ymax);
|
||||
ARRAY_SET_ITEMS(verts[1], r.xmax, r.ymin);
|
||||
ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymin);
|
||||
@ -277,12 +278,12 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
break;
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y: {
|
||||
rctf r = {
|
||||
.xmin = size[0] - margin[0],
|
||||
.xmax = size[0],
|
||||
.ymin = -size[1],
|
||||
.ymax = -size[1] + margin[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = size[0] - margin[0];
|
||||
r.xmax = size[0];
|
||||
r.ymin = -size[1];
|
||||
r.ymax = -size[1] + margin[1];
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymin);
|
||||
ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymax);
|
||||
ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax);
|
||||
@ -298,12 +299,12 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
break;
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y: {
|
||||
rctf r = {
|
||||
.xmin = size[0] - margin[0],
|
||||
.xmax = size[0],
|
||||
.ymin = size[1] - margin[1],
|
||||
.ymax = size[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = size[0] - margin[0];
|
||||
r.xmax = size[0];
|
||||
r.ymin = size[1] - margin[1];
|
||||
r.ymax = size[1];
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r.xmin, r.ymax);
|
||||
ARRAY_SET_ITEMS(verts[1], r.xmin, r.ymin);
|
||||
ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin);
|
||||
@ -320,12 +321,11 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
}
|
||||
case ED_GIZMO_CAGE2D_PART_ROTATE: {
|
||||
const float rotate_pt[2] = {0.0f, size[1] + margin[1]};
|
||||
const rctf r_rotate = {
|
||||
.xmin = rotate_pt[0] - margin[0] / 2.0f,
|
||||
.xmax = rotate_pt[0] + margin[0] / 2.0f,
|
||||
.ymin = rotate_pt[1] - margin[1] / 2.0f,
|
||||
.ymax = rotate_pt[1] + margin[1] / 2.0f,
|
||||
};
|
||||
rctf r_rotate{};
|
||||
r_rotate.xmin = rotate_pt[0] - margin[0] / 2.0f;
|
||||
r_rotate.xmax = rotate_pt[0] + margin[0] / 2.0f;
|
||||
r_rotate.ymin = rotate_pt[1] - margin[1] / 2.0f;
|
||||
r_rotate.ymax = rotate_pt[1] + margin[1] / 2.0f;
|
||||
|
||||
ARRAY_SET_ITEMS(verts[0], r_rotate.xmin, r_rotate.ymin);
|
||||
ARRAY_SET_ITEMS(verts[1], r_rotate.xmin, r_rotate.ymax);
|
||||
@ -382,10 +382,9 @@ static void cage2d_draw_box_interaction(const float color[4],
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
struct {
|
||||
uint pos, col;
|
||||
} attr_id = {
|
||||
.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT),
|
||||
.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT),
|
||||
};
|
||||
} attr_id{};
|
||||
attr_id.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
attr_id.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(is_solid ? GPU_SHADER_3D_FLAT_COLOR : GPU_SHADER_3D_POLYLINE_FLAT_COLOR);
|
||||
|
||||
{
|
||||
@ -687,7 +686,7 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz,
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
|
||||
immUniformColor4f(1, 1, 1, 0.5f);
|
||||
float s = 0.5f;
|
||||
immRectf(pos, -s, -s, s, s);
|
||||
immUnbindProgram();
|
||||
@ -740,12 +739,12 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz,
|
||||
}
|
||||
}
|
||||
else {
|
||||
const rctf r = {
|
||||
.xmin = -size_real[0],
|
||||
.ymin = -size_real[1],
|
||||
.xmax = size_real[0],
|
||||
.ymax = size_real[1],
|
||||
};
|
||||
rctf r;
|
||||
r.xmin = -size_real[0];
|
||||
r.ymin = -size_real[1];
|
||||
r.xmax = size_real[0];
|
||||
r.ymax = size_real[1];
|
||||
|
||||
if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) {
|
||||
float color[4], black[3] = {0, 0, 0};
|
||||
gizmo_color_get(gz, highlight, color);
|
||||
@ -822,12 +821,12 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz,
|
||||
/**
|
||||
* For when we want to draw 2d cage in 3d views.
|
||||
*/
|
||||
static void gizmo_cage2d_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id)
|
||||
static void gizmo_cage2d_draw_select(const bContext * /*C*/, wmGizmo *gz, int select_id)
|
||||
{
|
||||
gizmo_cage2d_draw_intern(gz, true, false, select_id);
|
||||
}
|
||||
|
||||
static void gizmo_cage2d_draw(const bContext *UNUSED(C), wmGizmo *gz)
|
||||
static void gizmo_cage2d_draw(const bContext * /*C*/, wmGizmo *gz)
|
||||
{
|
||||
const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
|
||||
gizmo_cage2d_draw_intern(gz, false, is_highlight, -1);
|
||||
@ -851,7 +850,7 @@ static int gizmo_cage2d_get_cursor(wmGizmo *gz)
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y:
|
||||
return WM_CURSOR_NSEW_SCROLL;
|
||||
|
||||
/* TODO: diagonal cursor. */
|
||||
/* TODO: diagonal cursor. */
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y:
|
||||
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y:
|
||||
return WM_CURSOR_NSEW_SCROLL;
|
||||
@ -872,8 +871,9 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
|
||||
RNA_float_get_array(gz->ptr, "dimensions", dims);
|
||||
const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
|
||||
|
||||
if (gizmo_window_project_2d(C, gz, (const float[2]){UNPACK2(mval)}, 2, true, point_local) ==
|
||||
false) {
|
||||
if (gizmo_window_project_2d(C, gz, blender::float2(blender::int2(mval)), 2, true, point_local) ==
|
||||
false)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -908,30 +908,29 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
|
||||
|
||||
/* if gizmo does not have a scale intersection, don't do it */
|
||||
if (transform_flag & (ED_GIZMO_CAGE_XFORM_FLAG_SCALE | ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM)) {
|
||||
const rctf r_xmin = {
|
||||
.xmin = -size[0],
|
||||
.ymin = -size[1],
|
||||
.xmax = -size[0] + margin[0],
|
||||
.ymax = size[1],
|
||||
};
|
||||
const rctf r_xmax = {
|
||||
.xmin = size[0] - margin[0],
|
||||
.ymin = -size[1],
|
||||
.xmax = size[0],
|
||||
.ymax = size[1],
|
||||
};
|
||||
const rctf r_ymin = {
|
||||
.xmin = -size[0],
|
||||
.ymin = -size[1],
|
||||
.xmax = size[0],
|
||||
.ymax = -size[1] + margin[1],
|
||||
};
|
||||
const rctf r_ymax = {
|
||||
.xmin = -size[0],
|
||||
.ymin = size[1] - margin[1],
|
||||
.xmax = size[0],
|
||||
.ymax = size[1],
|
||||
};
|
||||
rctf r_xmin{};
|
||||
r_xmin.xmin = -size[0];
|
||||
r_xmin.ymin = -size[1];
|
||||
r_xmin.xmax = -size[0] + margin[0];
|
||||
r_xmin.ymax = size[1];
|
||||
|
||||
rctf r_xmax{};
|
||||
r_xmax.xmin = size[0] - margin[0];
|
||||
r_xmax.ymin = -size[1];
|
||||
r_xmax.xmax = size[0];
|
||||
r_xmax.ymax = size[1];
|
||||
|
||||
rctf r_ymin{};
|
||||
r_ymin.xmin = -size[0];
|
||||
r_ymin.ymin = -size[1];
|
||||
r_ymin.xmax = size[0];
|
||||
r_ymin.ymax = -size[1] + margin[1];
|
||||
|
||||
rctf r_ymax{};
|
||||
r_ymax.xmin = -size[0];
|
||||
r_ymax.ymin = size[1] - margin[1];
|
||||
r_ymax.xmax = size[0];
|
||||
r_ymax.ymax = size[1];
|
||||
|
||||
if (BLI_rctf_isect_pt_v(&r_xmin, point_local)) {
|
||||
if (BLI_rctf_isect_pt_v(&r_ymin, point_local)) {
|
||||
@ -966,12 +965,11 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
|
||||
* | |
|
||||
* +---+ */
|
||||
const float r_rotate_pt[2] = {0.0f, size_real[1] + (margin[1] * GIZMO_MARGIN_OFFSET_SCALE)};
|
||||
const rctf r_rotate = {
|
||||
.xmin = r_rotate_pt[0] - margin[0] / 2.0f,
|
||||
.xmax = r_rotate_pt[0] + margin[0] / 2.0f,
|
||||
.ymin = r_rotate_pt[1] - margin[1] / 2.0f,
|
||||
.ymax = r_rotate_pt[1] + margin[1] / 2.0f,
|
||||
};
|
||||
rctf r_rotate{};
|
||||
r_rotate.xmin = r_rotate_pt[0] - margin[0] / 2.0f;
|
||||
r_rotate.xmax = r_rotate_pt[0] + margin[0] / 2.0f;
|
||||
r_rotate.ymin = r_rotate_pt[1] - margin[1] / 2.0f;
|
||||
r_rotate.ymax = r_rotate_pt[1] + margin[1] / 2.0f;
|
||||
|
||||
if (BLI_rctf_isect_pt_v(&r_rotate, point_local)) {
|
||||
return ED_GIZMO_CAGE2D_PART_ROTATE;
|
||||
@ -981,17 +979,17 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
|
||||
return -1;
|
||||
}
|
||||
|
||||
typedef struct RectTransformInteraction {
|
||||
struct RectTransformInteraction {
|
||||
float orig_mouse[2];
|
||||
float orig_matrix_offset[4][4];
|
||||
float orig_matrix_final_no_offset[4][4];
|
||||
Dial *dial;
|
||||
bool use_temp_uniform;
|
||||
} RectTransformInteraction;
|
||||
};
|
||||
|
||||
static int gizmo_cage2d_transform_flag_get(const wmGizmo *gz)
|
||||
{
|
||||
RectTransformInteraction *data = gz->interaction_data;
|
||||
RectTransformInteraction *data = static_cast<RectTransformInteraction *>(gz->interaction_data);
|
||||
int transform_flag = RNA_enum_get(gz->ptr, "transform");
|
||||
if (data) {
|
||||
if (data->use_temp_uniform) {
|
||||
@ -1008,14 +1006,14 @@ static void gizmo_cage2d_setup(wmGizmo *gz)
|
||||
|
||||
static int gizmo_cage2d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
|
||||
{
|
||||
RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction),
|
||||
"cage_interaction");
|
||||
RectTransformInteraction *data = static_cast<RectTransformInteraction *>(
|
||||
MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"));
|
||||
|
||||
copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset);
|
||||
WM_gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset);
|
||||
|
||||
if (gizmo_window_project_2d(
|
||||
C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0)
|
||||
C, gz, blender::float2(blender::int2(event->mval)), 2, false, data->orig_mouse) == 0)
|
||||
{
|
||||
zero_v2(data->orig_mouse);
|
||||
}
|
||||
@ -1084,9 +1082,9 @@ static void gizmo_pivot_from_scale_part(int part, float r_pt[2])
|
||||
static int gizmo_cage2d_modal(bContext *C,
|
||||
wmGizmo *gz,
|
||||
const wmEvent *event,
|
||||
eWM_GizmoFlagTweak UNUSED(tweak_flag))
|
||||
eWM_GizmoFlagTweak /*tweak_flag*/)
|
||||
{
|
||||
RectTransformInteraction *data = gz->interaction_data;
|
||||
RectTransformInteraction *data = static_cast<RectTransformInteraction *>(gz->interaction_data);
|
||||
int transform_flag = RNA_enum_get(gz->ptr, "transform");
|
||||
if ((transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM) == 0) {
|
||||
/* WARNING: Checking the events modifier only makes sense as long as `tweak_flag`
|
||||
@ -1119,7 +1117,7 @@ static int gizmo_cage2d_modal(bContext *C,
|
||||
/* The mouse coords are projected into the matrix so we don't need to worry about axis
|
||||
* alignment. */
|
||||
bool ok = gizmo_window_project_2d(
|
||||
C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local);
|
||||
C, gz, blender::float2(blender::int2(event->mval)), 2, false, point_local);
|
||||
copy_m4_m4(gz->matrix_offset, matrix_back);
|
||||
if (!ok) {
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@ -1129,7 +1127,7 @@ static int gizmo_cage2d_modal(bContext *C,
|
||||
wmGizmoProperty *gz_prop;
|
||||
|
||||
gz_prop = WM_gizmo_target_property_find(gz, "matrix");
|
||||
if (gz_prop->type != NULL) {
|
||||
if (gz_prop->type != nullptr) {
|
||||
WM_gizmo_target_property_float_get_array(gz, gz_prop, &gz->matrix_offset[0][0]);
|
||||
}
|
||||
|
||||
@ -1144,12 +1142,11 @@ static int gizmo_cage2d_modal(bContext *C,
|
||||
else if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_ROTATE) {
|
||||
|
||||
#define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \
|
||||
mul_v3_m4v3( \
|
||||
test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0}))
|
||||
mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, blender::float3{UNPACK2(mouse_co), 0.0})
|
||||
|
||||
float test_co[3];
|
||||
|
||||
if (data->dial == NULL) {
|
||||
if (data->dial == nullptr) {
|
||||
MUL_V2_V3_M4_FINAL(test_co, data->orig_matrix_offset[3]);
|
||||
|
||||
data->dial = BLI_dial_init(test_co, FLT_EPSILON);
|
||||
@ -1259,11 +1256,11 @@ static int gizmo_cage2d_modal(bContext *C,
|
||||
mul_v3_fl(matrix_scale[0], scale[0]);
|
||||
mul_v3_fl(matrix_scale[1], scale[1]);
|
||||
|
||||
transform_pivot_set_m4(matrix_scale, (const float[3]){UNPACK2(pivot), 0.0f});
|
||||
transform_pivot_set_m4(matrix_scale, blender::float3(UNPACK2(pivot), 0.0f));
|
||||
mul_m4_m4_post(gz->matrix_offset, matrix_scale);
|
||||
}
|
||||
|
||||
if (gz_prop->type != NULL) {
|
||||
if (gz_prop->type != nullptr) {
|
||||
WM_gizmo_target_property_float_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]);
|
||||
}
|
||||
|
||||
@ -1291,7 +1288,7 @@ static void gizmo_cage2d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
|
||||
|
||||
static void gizmo_cage2d_exit(bContext *C, wmGizmo *gz, const bool cancel)
|
||||
{
|
||||
RectTransformInteraction *data = gz->interaction_data;
|
||||
RectTransformInteraction *data = static_cast<RectTransformInteraction *>(gz->interaction_data);
|
||||
|
||||
MEM_SAFE_FREE(data->dial);
|
||||
|
||||
@ -1303,7 +1300,7 @@ static void gizmo_cage2d_exit(bContext *C, wmGizmo *gz, const bool cancel)
|
||||
|
||||
/* reset properties */
|
||||
gz_prop = WM_gizmo_target_property_find(gz, "matrix");
|
||||
if (gz_prop->type != NULL) {
|
||||
if (gz_prop->type != nullptr) {
|
||||
WM_gizmo_target_property_float_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]);
|
||||
}
|
||||
|
||||
@ -1337,18 +1334,18 @@ static void GIZMO_GT_cage_2d(wmGizmoType *gzt)
|
||||
{ED_GIZMO_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""},
|
||||
{ED_GIZMO_CAGE2D_STYLE_BOX_TRANSFORM, "BOX_TRANSFORM", 0, "Box Transform", ""},
|
||||
{ED_GIZMO_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
static EnumPropertyItem rna_enum_transform[] = {
|
||||
{ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Move", ""},
|
||||
{ED_GIZMO_CAGE_XFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""},
|
||||
{ED_GIZMO_CAGE_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
|
||||
{ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
static EnumPropertyItem rna_enum_draw_options[] = {
|
||||
{ED_GIZMO_CAGE_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
static float unit_v2[2] = {1.0f, 1.0f};
|
||||
RNA_def_float_vector(
|
@ -16,6 +16,7 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
||||
@ -46,7 +47,7 @@ static void gizmo_calc_matrix_final_no_offset(const wmGizmo *gz,
|
||||
bool use_space)
|
||||
{
|
||||
float mat_identity[4][4];
|
||||
struct WM_GizmoMatrixParams params = {NULL};
|
||||
struct WM_GizmoMatrixParams params = {nullptr};
|
||||
unit_m4(mat_identity);
|
||||
if (use_space == false) {
|
||||
params.matrix_basis = mat_identity;
|
||||
@ -134,7 +135,7 @@ static void cage3d_draw_box_corners(const float r[3],
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", line_width * U.pixelsize);
|
||||
|
||||
imm_draw_cube_wire_3d(pos, (float[3]){0}, r);
|
||||
imm_draw_cube_wire_3d(pos, blender::float3(0.0f), r);
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
@ -215,7 +216,7 @@ static void cage3d_draw_circle_wire(const float r[3],
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", line_width * U.pixelsize);
|
||||
|
||||
imm_draw_cube_wire_3d(pos, (const float[3]){0}, r);
|
||||
imm_draw_cube_wire_3d(pos, blender::float3(0.0f), r);
|
||||
|
||||
#if 0
|
||||
if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE) {
|
||||
@ -301,7 +302,7 @@ static void gizmo_cage3d_draw_intern(
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
|
||||
immUniformColor4f(1, 1, 1, 0.5f);
|
||||
float s = 0.5f;
|
||||
immRectf(pos, -s, -s, s, s);
|
||||
immUnbindProgram();
|
||||
@ -309,7 +310,7 @@ static void gizmo_cage3d_draw_intern(
|
||||
}
|
||||
|
||||
if (select) {
|
||||
/* Expand for hot-spot. */
|
||||
/* Expand for hot-spot. */
|
||||
#if 0
|
||||
const float size[3] = {
|
||||
size_real[0] + margin[0] / 2,
|
||||
@ -341,12 +342,11 @@ static void gizmo_cage3d_draw_intern(
|
||||
}
|
||||
else {
|
||||
#if 0
|
||||
const rctf _r = {
|
||||
.xmin = -size_real[0],
|
||||
.ymin = -size_real[1],
|
||||
.xmax = size_real[0],
|
||||
.ymax = size_real[1],
|
||||
};
|
||||
rctf _r {}
|
||||
_r.xmin = -size_real[0];
|
||||
_r.ymin = -size_real[1];
|
||||
_r.xmax = size_real[0];
|
||||
_r.ymax = size_real[1];
|
||||
#endif
|
||||
if (draw_style == ED_GIZMO_CAGE3D_STYLE_BOX) {
|
||||