184 const float plane[4],
186 const float *plane_fallback,
191 if (plane_fallback !=
nullptr) {
193 region, plane, mval, do_clip, plane_fallback, r_out);
203 const float dir_test[3],
206 int index_found = -1;
207 float dot_best = -1.0f;
208 for (
int i = 0; i < dirs_len; i++) {
209 float dot_test =
dot_v3v3(dirs[i], dir_test);
210 if (is_signed ==
false) {
211 dot_test =
fabsf(dot_test);
213 if ((index_found == -1) || (dot_test > dot_best)) {
222 idp_gizmogroup_from_region)(
ARegion *region)
224 wmGizmoMap *gzmap = region->runtime->gizmo_map;
237 if (grid_size == 0.0f) [[unlikely]] {
242 co_relative =
nullptr;
245 if (co_relative !=
nullptr) {
253 if (co_relative !=
nullptr) {
271 gpu::VertBuf *vert = GPU_vertbuf_create_with_format(*format);
274 for (
int i = 0; i < coords_len; i++) {
298 const float color[4])
303 gpu::VertBuf *vert = GPU_vertbuf_create_with_format(*format);
306 for (
int i = 0; i < coords_len; i++) {
333 const int edges[12][2] = {
349 gpu::VertBuf *vert = GPU_vertbuf_create_with_format(*format);
352 for (
int i = 0, j = 0; i <
ARRAY_SIZE(edges); i++) {
382 float matrix_orient_inv[3][3];
388 float quad_base[4][3];
389 float quad_secondary[4][3];
395 float fixed_aspect_dimension;
400 float delta_local[3];
405 mul_m3_v3(matrix_orient_inv, delta_local);
412 delta_a[x_axis] = 0.0f;
413 delta_b[y_axis] = 0.0f;
416 fixed_aspect_dimension =
max_ff(
fabsf(delta_a[y_axis]),
fabsf(delta_b[x_axis]));
418 if (ipd->
step[0].is_fixed_aspect) {
419 delta_a[y_axis] =
copysignf(fixed_aspect_dimension, delta_a[y_axis]);
420 delta_b[x_axis] =
copysignf(fixed_aspect_dimension, delta_b[x_axis]);
426 if (ipd->
step[0].is_fixed_aspect) {
437 if (ipd->
step[0].is_centered) {
439 float base_co_dst[3];
441 for (
int i = 0; i <
ARRAY_SIZE(quad_base); i++) {
446 fixed_aspect_dimension *= 2.0f;
451 float delta_local[3];
459 if (ipd->
step[1].is_fixed_aspect) {
465 if (ipd->
step[1].is_centered) {
467 if (ipd->
step[1].is_fixed_aspect) {
475 for (
int i = 0; i <
ARRAY_SIZE(quad_base); i++) {
484 for (
int i = 0; i <
ARRAY_SIZE(quad_base); i++) {
485 add_v3_v3v3(quad_secondary[i], quad_base[i], delta_local);
495 for (
int i = 0; i < 4; i++) {
507 const int resolution,
508 const float color[4])
511 const float quad[4][2] = {
519 for (
int i = 0; i <= resolution; i++) {
520 float theta = ((2.0f *
M_PI) * (
float(i) /
float(resolution))) + 0.01f;
521 float x =
cosf(theta);
522 float y =
sinf(theta);
523 const float pt[2] = {
x,
y};
527 float *co = coords[i];
546 const float color[4],
582 const float *base_plane = ipd->
step[0].plane;
583 for (
int i = 0; i < 4; i++) {
605 float coords_a[4][3];
606 float coords_b[4][3];
608 for (
int i = 0; i < 4; i++) {
623 float v01[3], v12[3], v23[3], v30[3];
629 float v45[3], v56[3], v67[3], v74[3];
635 float v04[3], v15[3], v26[3], v37[3];
677 if (depth_test_enabled ==
false) {
694 float r_matrix_orient[3][3],
696 bool *r_is_snap_invert)
700 if (r_matrix_orient) {
706 if (r_is_snap_invert) {
723 const int plane_axis = tool_settings->
plane_axis;
739 if (snap_state_new) {
740 ipd->
snap_state = snap_state = snap_state_new;
767 for (
int i = 0; i < 2; i++) {
769 ipd->
step[i].is_centered = ipd->
step[i].is_centered_init;
772 ipd->
step[i].is_fixed_aspect = ipd->
step[i].is_fixed_aspect_init;
807 for (
int i = 0; i < 2; i++) {
808 if (ipd->
step[i].is_degenerate_view_align) {
809 const int degenerate_axis =
816 float axis_fallback[4][3];
817 const int x_axis = (degenerate_axis + 1) % 3;
818 const int y_axis = (degenerate_axis + 2) % 3;
829 ipd->
step[i].degenerate_axis = degenerate_axis;
838 ipd->
step[i].degenerate_diagonal :
841 copy_v3_v3(ipd->
step[i].degenerate_diagonal_display, ipd->
step[i].degenerate_diagonal);
842 if (degenerate_axis_is_flip) {
866 if (tref &&
STREQ(tref->
idname,
"builtin.primitive_cube_add")) {
869 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_cylinder_add")) {
872 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_cone_add")) {
875 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_uv_sphere_add")) {
878 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_ico_sphere_add")) {
881 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_quad_sphere_add")) {
909 status.
item(
IFACE_(
"Cancel"), ICON_EVENT_ESC);
935 if (wait_for_input) {
960 if (ipd->
region !=
nullptr) {
986 {0,
nullptr, 0,
nullptr,
nullptr},
989 const char *keymap_name =
"View3D Placement Modal";
1011 bool do_redraw =
false;
1012 bool do_cursor_update =
false;
1016 bool is_fallthrough =
false;
1017 switch (event->
val) {
1019 is_fallthrough =
true;
1024 is_fallthrough ^ ipd->
step[ipd->
step_index].is_fixed_aspect_init;
1029 is_fallthrough =
true;
1039 is_fallthrough =
true;
1046 do_cursor_update =
true;
1052 switch (event->
type) {
1061 do_cursor_update =
true;
1095 float no[3], no_temp[3];
1114 if (ipd->
step[0].is_centered != ipd->
step[0].is_centered_init) {
1115 ipd->
step[1].is_centered = !ipd->
step[1].is_centered;
1117 if (ipd->
step[0].is_fixed_aspect != ipd->
step[0].is_fixed_aspect_init) {
1118 ipd->
step[1].is_fixed_aspect = !ipd->
step[1].is_fixed_aspect;
1137 float matrix_orient_axis[3][3];
1141 swap_v3_v3(matrix_orient_axis[0], matrix_orient_axis[1]);
1158 const int cube_verts[3] = {3, 1, 4};
1159 for (
int i = 0; i < 3; i++) {
1184 if (ot !=
nullptr) {
1191 std::swap(temp_props, op_props);
1237 if (do_cursor_update) {
1245 C, event, ipd->
snap_co,
nullptr,
nullptr,
nullptr);
1297 float close[3], delta[3];
1330 ot->
name =
"Add Primitive Object";
1332 ot->
idname =
"VIEW3D_OT_interactive_add";
1355 {0,
nullptr, 0,
nullptr,
nullptr},
1367 {0,
nullptr, 0,
nullptr,
nullptr},
1369 const char *identifiers[2] = {
"plane_origin_base",
"plane_origin_depth"};
1370 for (
int i = 0; i < 2; i++) {
1383 {0,
nullptr, 0,
nullptr,
nullptr},
1385 const char *identifiers[2] = {
"plane_aspect_base",
"plane_aspect_depth"};
1386 for (
int i = 0; i < 2; i++) {
1452 gzgt->
name =
"Placement Widget";
#define REGION_DRAW_POST_VIEW
#define XRAY_ENABLED(v3d)
#define GPU_batch_uniform_1f(batch, name, x)
#define GPU_batch_uniform_2fv(batch, name, val)
#define GPU_batch_uniform_4fv(batch, name, val)
Read Blender memory allocation and freeing.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void item(std::string text, int icon1, int icon2=0)
void opmodal(std::string text, const wmOperatorType *ot, int propvalue, bool inverted=false)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float3x3 scale(float3x3 mat, float2 scale)
void get_color_3fv(int colorid, float col[3])
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static bool view3d_interactive_add_calc_snap(bContext *, const wmEvent *, float r_co_src[3], float r_matrix_orient[3][3], bool *r_is_enabled, bool *r_is_snap_invert)
MINLINE void negate_v3_v3(float r[3], const float a[3])
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
void mul_m3_v3(const float M[3][3], float r[3])
ScrArea * CTX_wm_area(const bContext *C)
static const char * view3d_gzgt_placement_id
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void WM_event_drag_start_mval_fl(const wmEvent *event, const ARegion *region, float r_mval[2])
gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, gpu::VertBuf *vertex_buf, gpu::IndexBuf *index_buf, GPUBatchFlag owns_flag)
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
@ PLACE_PRIMITIVE_TYPE_CONE
@ PLACE_PRIMITIVE_TYPE_CUBE
@ PLACE_PRIMITIVE_TYPE_SPHERE_UV
@ PLACE_PRIMITIVE_TYPE_CYLINDER
@ PLACE_PRIMITIVE_TYPE_SPHERE_ICO
@ PLACE_PRIMITIVE_TYPE_SPHERE_QUAD
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
V3DSnapCursorState * ED_view3d_cursor_snap_state_create()
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
bool BKE_object_sculpt_use_dyntopo(const Object *object)
void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
MultiresModifierData * BKE_sculpt_multires_active(const Scene *scene, Object *ob)
MINLINE void copy_v3_v3(float r[3], const float a[3])
static void preview_plane_free_fn(void *customdata)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
V3DSnapCursorState * ED_view3d_cursor_snap_state_active_get()
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
GPUDepthTest GPU_depth_test_get()
static wmOperatorStatus view3d_interactive_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void copy_m3_m3(float m1[3][3], const float m2[3][3])
void WM_operator_properties_free(PointerRNA *ptr)
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
GPUVertFormat * immVertexFormat()
static bool view3d_interactive_add_poll(bContext *C)
static bool snap_cursor_poll(ARegion *region, void *data)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
static bool calc_bbox(InteractivePlaceData *ipd, BoundBox *bounds)
static void draw_line_bounds(const BoundBox *bounds, const float color[4])
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
void GPU_batch_discard(gpu::Batch *batch)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
static void view3d_interactive_add_status(wmOperator *op, bContext *C)
void ED_region_tag_redraw(ARegion *region)
void closest_to_plane_normalized_v3(float r_close[3], const float plane[4], const float pt[3])
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
MINLINE void mul_v3_fl(float r[3], float f)
static const float eps_view_align
static void draw_line_pairs(const float coords_a[][3], float coords_b[][3], int coords_len, const float color[4])
MINLINE void sub_v3_v3(float r[3], const float a[3])
V3DSnapCursorData * ED_view3d_cursor_snap_data_get()
static bool idp_snap_calc_incremental(Scene *scene, View3D *v3d, ARegion *region, const float co_relative[3], float co[3])
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
static UNUSED_FUNCTION_WITH_RETURN_TYPE(wmGizmoGroup *, idp_gizmogroup_from_region)(ARegion *region)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
static void draw_circle_in_quad(const float v1[3], const float v2[3], const float v3[3], const float v4[3], const int resolution, const float color[4])
void ED_view3d_cursor_snap_state_free(V3DSnapCursorState *state)
static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEvent *event)
static void draw_primitive_view(const bContext *C, ARegion *, void *arg)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
void GPU_viewport_size_get_f(float coords[4])
MINLINE void swap_v3_v3(float a[3], float b[3])
static void view3d_interactive_add_exit(bContext *C, wmOperator *op)
BMesh const char void * data
bool ED_view3d_win_to_3d_on_plane(const ARegion *region, const float plane[4], const float mval[2], bool do_clip, float r_out[3])
void GPU_vertbuf_attr_set(gpu::VertBuf *, uint a_idx, uint v_idx, const void *data)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
void VIEW3D_GGT_placement(wmGizmoGroupType *gzgt)
float ED_view3d_grid_view_scale(const Scene *scene, const View3D *v3d, const ARegion *region, const char **r_grid_unit)
void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const float v3[2], const float v4[2], const float co[2], float w[4])
void viewplace_modal_keymap(wmKeyConfig *keyconf)
void mat3_to_eul(float eul[3], const float mat[3][3])
wmGizmoGroup * WM_gizmomap_group_find_ptr(wmGizmoMap *gzmap, const wmGizmoGroupType *gzgt)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
MINLINE void negate_v3(float r[3])
static wmOperatorStatus view3d_interactive_add_modal(bContext *C, wmOperator *op, const wmEvent *event)
void GPU_batch_draw(gpu::Batch *batch)
void ED_view3d_cursor_snap_data_update(V3DSnapCursorState *state, const bContext *C, const ARegion *region, const int2 &mval)
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
MINLINE void zero_v3(float r[3])
static bool WIDGETGROUP_placement_poll(const bContext *C, wmGizmoGroupType *gzgt)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
static int dot_v3_array_find_max_index(const float dirs[][3], const int dirs_len, const float dir_test[3], bool is_signed)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void GPU_batch_program_set_builtin(gpu::Batch *batch, GPUBuiltinShader shader_id)
static void WIDGETGROUP_placement_setup(const bContext *, wmGizmoGroup *gzgroup)
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void ED_view3d_cursor_snap_state_prevpoint_set(V3DSnapCursorState *state, const float prev_point[3])
@ WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL
@ WM_GIZMOGROUPTYPE_SCALE
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
static void draw_primitive_view_impl(const bContext *C, InteractivePlaceData *ipd, const float color[4], int flatten_axis)
MINLINE float normalize_v3(float n[3])
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_toolsystem_ref_properties_init_for_keymap(bToolRef *tref, PointerRNA *dst_ptr, PointerRNA *src_ptr, wmOperatorType *ot)
MINLINE void add_v3_v3(float r[3], const float a[3])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
bool WM_gizmo_group_type_ensure(const StringRef idname)
MINLINE bool compare_v3v3(const float v1[3], const float v2[3], float limit) ATTR_WARN_UNUSED_RESULT
Main * CTX_data_main(const bContext *C)
@ PLACE_MODAL_PIVOT_CENTER_OFF
@ PLACE_MODAL_FIXED_ASPECT_ON
@ PLACE_MODAL_FIXED_ASPECT_OFF
@ PLACE_MODAL_PIVOT_CENTER_ON
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void VIEW3D_OT_interactive_add(wmOperatorType *ot)
MINLINE float max_ff(float a, float b)
MINLINE float normalize_v3_length(float n[3], float unit_length)
static void draw_line_loop(const float coords[][3], int coords_len, const float color[4])
static bool view3d_win_to_3d_on_plane_maybe_fallback(const ARegion *region, const float plane[4], const float mval[2], const float *plane_fallback, float r_out[3])
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
wmGizmoGroup * WM_gizmomap_group_find(wmGizmoMap *gzmap, const char *idname)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
bool ED_view3d_win_to_3d_on_plane_with_fallback(const ARegion *region, const float plane[4], const float mval[2], bool do_clip, const float plane_fallback[4], float r_out[3])
Scene * CTX_data_scene(const bContext *C)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
void GPU_blend(GPUBlend blend)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
bool ED_gizmo_poll_or_unlink_delayed_from_tool(const bContext *C, wmGizmoGroupType *gzgt)
int WM_userdef_event_type_from_keymap_type(int kmitype)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
void GPU_depth_test(GPUDepthTest test)
Object * CTX_data_active_object(const bContext *C)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
static void view3d_interactive_add_cancel(bContext *C, wmOperator *op)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
View3D * CTX_wm_view3d(const bContext *C)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::ARegionRuntime * runtime
float degenerate_diagonal_display[3]
bool is_fixed_aspect_init
float degenerate_diagonal[3]
bool is_degenerate_view_align
V3DSnapCursorState * snap_state
eSnapMode snap_to_restore
float matrix_orient[3][3]
enum ePlace_PrimType primitive_type
struct blender::InteractivePlaceData::@262236072047070366215036140021023227272173351323 step[2]
struct ToolSettings * toolsettings
bool(*) poll(ARegion *region, void *custom_poll_data)
struct ARegionType * type
wmGizmoMapType_Params gzmap_params
eWM_GizmoFlagGroupTypeFlag flag
void(*) customdata_free(void *)
void(*) cancel(bContext *C, wmOperator *op)
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct wmOperatorType * type