173 const float plane[4],
175 const float *plane_fallback,
180 if (plane_fallback !=
nullptr) {
182 region, plane, mval, do_clip, plane_fallback, r_out);
192 const float dir_test[3],
195 int index_found = -1;
196 float dot_best = -1.0f;
197 for (
int i = 0; i < dirs_len; i++) {
198 float dot_test =
dot_v3v3(dirs[i], dir_test);
199 if (is_signed ==
false) {
200 dot_test =
fabsf(dot_test);
202 if ((index_found == -1) || (dot_test > dot_best)) {
211 idp_gizmogroup_from_region)(
ARegion *region)
231 co_relative =
nullptr;
234 if (co_relative !=
nullptr) {
238 co[0] = roundf(co[0]);
239 co[1] = roundf(co[1]);
240 co[2] = roundf(co[2]);
242 if (co_relative !=
nullptr) {
263 for (
int i = 0; i < coords_len; i++) {
288 const float color[4])
296 for (
int i = 0; i < coords_len; i++) {
324 const int edges[12][2] = {
343 for (
int i = 0, j = 0; i <
ARRAY_SIZE(edges); i++) {
374 float matrix_orient_inv[3][3];
380 float quad_base[4][3];
381 float quad_secondary[4][3];
387 float fixed_aspect_dimension;
392 float delta_local[3];
397 mul_m3_v3(matrix_orient_inv, delta_local);
404 delta_a[x_axis] = 0.0f;
405 delta_b[y_axis] = 0.0f;
408 fixed_aspect_dimension =
max_ff(
fabsf(delta_a[y_axis]),
fabsf(delta_b[x_axis]));
411 delta_a[y_axis] =
copysignf(fixed_aspect_dimension, delta_a[y_axis]);
412 delta_b[x_axis] =
copysignf(fixed_aspect_dimension, delta_b[x_axis]);
431 float base_co_dst[3];
433 for (
int i = 0; i <
ARRAY_SIZE(quad_base); i++) {
438 fixed_aspect_dimension *= 2.0f;
443 float delta_local[3];
467 for (
int i = 0; i <
ARRAY_SIZE(quad_base); i++) {
476 for (
int i = 0; i <
ARRAY_SIZE(quad_base); i++) {
477 add_v3_v3v3(quad_secondary[i], quad_base[i], delta_local);
487 for (
int i = 0; i < 4; i++) {
499 const int resolution,
500 const float color[4])
503 const float quad[4][2] = {
510 float(*coords)[3] =
static_cast<float(*)[3]
>(
511 MEM_mallocN(
sizeof(
float[3]) * (resolution + 1), __func__));
512 for (
int i = 0; i <= resolution; i++) {
513 float theta = ((2.0f *
M_PI) * (
float(i) /
float(resolution))) + 0.01f;
514 float x =
cosf(theta);
515 float y =
sinf(theta);
516 const float pt[2] = {
x,
y};
520 float *co = coords[i];
539 const float color[4],
575 const float *base_plane = ipd->
step[0].
plane;
576 for (
int i = 0; i < 4; i++) {
598 float coords_a[4][3];
599 float coords_b[4][3];
601 for (
int i = 0; i < 4; i++) {
615 float v01[3], v12[3], v23[3], v30[3];
621 float v45[3], v56[3], v67[3], v74[3];
627 float v04[3], v15[3], v26[3], v37[3];
669 if (depth_test_enabled ==
false) {
686 float r_matrix_orient[3][3],
688 bool *r_is_snap_invert)
692 if (r_matrix_orient) {
698 if (r_is_snap_invert) {
715 const int plane_axis = tool_settings->
plane_axis;
731 if (snap_state_new) {
732 ipd->
snap_state = snap_state = snap_state_new;
759 for (
int i = 0; i < 2; i++) {
799 for (
int i = 0; i < 2; i++) {
801 const int degenerate_axis =
808 float axis_fallback[4][3];
809 const int x_axis = (degenerate_axis + 1) % 3;
810 const int y_axis = (degenerate_axis + 2) % 3;
834 if (degenerate_axis_is_flip) {
858 if (tref &&
STREQ(tref->
idname,
"builtin.primitive_cube_add")) {
861 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_cylinder_add")) {
864 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_cone_add")) {
867 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_uv_sphere_add")) {
870 else if (tref &&
STREQ(tref->
idname,
"builtin.primitive_ico_sphere_add")) {
896 if (wait_for_input) {
919 if (ipd->
region !=
nullptr) {
952 {0,
nullptr, 0,
nullptr,
nullptr},
955 const char *keymap_name =
"View3D Placement Modal";
975 bool do_redraw =
false;
976 bool do_cursor_update =
false;
980 bool is_fallthrough =
false;
981 switch (event->
val) {
983 is_fallthrough =
true;
993 is_fallthrough =
true;
1003 is_fallthrough =
true;
1010 do_cursor_update =
true;
1016 switch (event->
type) {
1023 do_cursor_update =
true;
1054 float no[3], no_temp[3];
1096 float matrix_orient_axis[3][3];
1100 swap_v3_v3(matrix_orient_axis[0], matrix_orient_axis[1]);
1117 const int cube_verts[3] = {3, 1, 4};
1118 for (
int i = 0; i < 3; i++) {
1142 if (
ot !=
nullptr) {
1149 std::swap(temp_props, op_props);
1194 if (do_cursor_update) {
1202 C, event, ipd->
snap_co,
nullptr,
nullptr,
nullptr);
1254 float close[3], delta[3];
1279 ot->name =
"Add Primitive Object";
1280 ot->description =
"Interactively add an object";
1281 ot->idname =
"VIEW3D_OT_interactive_add";
1303 {0,
nullptr, 0,
nullptr,
nullptr},
1315 {0,
nullptr, 0,
nullptr,
nullptr},
1317 const char *identifiers[2] = {
"plane_origin_base",
"plane_origin_depth"};
1318 for (
int i = 0; i < 2; i++) {
1331 {0,
nullptr, 0,
nullptr,
nullptr},
1333 const char *identifiers[2] = {
"plane_aspect_base",
"plane_aspect_depth"};
1334 for (
int i = 0; i < 2; i++) {
1387 gzgt->
name =
"Placement Widget";
ScrArea * CTX_wm_area(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ToolSettings * CTX_data_tool_settings(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
MINLINE float max_ff(float a, float b)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
void closest_to_plane_normalized_v3(float r_close[3], const float plane[4], const float pt[3])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
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 mul_m3_v3(const float M[3][3], float r[3])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
void mat3_to_eul(float eul[3], const float mat[3][3])
void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE bool compare_v3v3(const float v1[3], const float v2[3], float limit) ATTR_WARN_UNUSED_RESULT
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void swap_v3_v3(float a[3], float b[3])
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3_length(float n[3], float unit_length)
MINLINE float normalize_v3(float n[3])
#define UNUSED_FUNCTION_WITH_RETURN_TYPE(rtype, x)
bool ED_gizmo_poll_or_unlink_delayed_from_tool(const bContext *C, wmGizmoGroupType *gzgt)
void ED_region_tag_redraw(ARegion *region)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
#define REGION_DRAW_POST_VIEW
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
void ED_view3d_cursor_snap_data_update(V3DSnapCursorState *state, const bContext *C, const ARegion *region, int x, int y)
V3DSnapCursorState * ED_view3d_cursor_snap_state_create()
#define XRAY_ENABLED(v3d)
float ED_view3d_grid_view_scale(const Scene *scene, const View3D *v3d, const ARegion *region, const char **r_grid_unit)
V3DSnapCursorState * ED_view3d_cursor_snap_state_active_get()
void ED_view3d_cursor_snap_state_prevpoint_set(V3DSnapCursorState *state, const float prev_point[3])
void ED_view3d_cursor_snap_state_free(V3DSnapCursorState *state)
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])
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])
V3DSnapCursorData * ED_view3d_cursor_snap_data_get()
blender::gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
#define GPU_batch_uniform_1f(batch, name, x)
void GPU_batch_discard(blender::gpu::Batch *batch)
#define GPU_batch_uniform_2fv(batch, name, val)
void GPU_batch_program_set_builtin(blender::gpu::Batch *batch, eGPUBuiltinShader shader_id)
void GPU_batch_draw(blender::gpu::Batch *batch)
#define GPU_batch_uniform_4fv(batch, name, val)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
eGPUDepthTest GPU_depth_test_get()
void GPU_depth_test(eGPUDepthTest test)
void GPU_viewport_size_get_f(float coords[4])
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_attr_set(blender::gpu::VertBuf *, uint a_idx, uint v_idx, const void *data)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
void UI_GetThemeColor3fv(int colorid, float col[3])
@ WM_GIZMOGROUPTYPE_SCALE
@ WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
draw_view in_light_buf[] float
blender::gpu::Batch * quad
struct @157336070235062372277311340362362342103123126032::@262166344314164341202215145112231240022370055142 batch
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
static bool snap_cursor_poll(ARegion *region, void *data)
struct wmGizmoMap * gizmo_map
struct ARegionType * type
enum ePlace_PrimType primitive_type
float degenerate_diagonal_display[3]
float matrix_orient[3][3]
bool is_degenerate_view_align
bool is_fixed_aspect_init
struct InteractivePlaceData::@034017351343133047004175364132332026014162110035 step[2]
eSnapMode snap_to_restore
float degenerate_diagonal[3]
V3DSnapCursorState * snap_state
struct ToolSettings * toolsettings
bool(* poll)(ARegion *region, void *custom_poll_data)
wmGizmoMapType_Params gzmap_params
eWM_GizmoFlagGroupTypeFlag flag
void(* customdata_free)(void *)
static const float eps_view_align
static int dot_v3_array_find_max_index(const float dirs[][3], const int dirs_len, const float dir_test[3], bool is_signed)
static bool calc_bbox(InteractivePlaceData *ipd, BoundBox *bounds)
static void draw_line_pairs(const float coords_a[][3], float coords_b[][3], int coords_len, const float color[4])
@ PLACE_PRIMITIVE_TYPE_SPHERE_ICO
@ PLACE_PRIMITIVE_TYPE_CONE
@ PLACE_PRIMITIVE_TYPE_CUBE
@ PLACE_PRIMITIVE_TYPE_SPHERE_UV
@ PLACE_PRIMITIVE_TYPE_CYLINDER
@ PLACE_MODAL_FIXED_ASPECT_OFF
@ PLACE_MODAL_FIXED_ASPECT_ON
@ PLACE_MODAL_PIVOT_CENTER_OFF
@ PLACE_MODAL_PIVOT_CENTER_ON
static const char * view3d_gzgt_placement_id
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])
static void draw_line_loop(const float coords[][3], int coords_len, const float color[4])
static void draw_line_bounds(const BoundBox *bounds, const float color[4])
static void view3d_interactive_add_cancel(bContext *C, wmOperator *op)
static bool idp_snap_calc_incremental(Scene *scene, View3D *v3d, ARegion *region, const float co_relative[3], float co[3])
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])
static bool view3d_interactive_add_poll(bContext *C)
static void preview_plane_free_fn(void *customdata)
static int view3d_interactive_add_modal(bContext *C, wmOperator *op, const wmEvent *event)
void VIEW3D_GGT_placement(wmGizmoGroupType *gzgt)
static void WIDGETGROUP_placement_setup(const bContext *, wmGizmoGroup *gzgroup)
void VIEW3D_OT_interactive_add(wmOperatorType *ot)
static void draw_primitive_view(const bContext *C, ARegion *, void *arg)
static int view3d_interactive_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void view3d_interactive_add_exit(bContext *C, wmOperator *op)
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)
static bool snap_cursor_poll(ARegion *region, void *data)
static void draw_primitive_view_impl(const bContext *C, InteractivePlaceData *ipd, const float color[4], int flatten_axis)
static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEvent *event)
void viewplace_modal_keymap(wmKeyConfig *keyconf)
void WM_event_drag_start_mval_fl(const wmEvent *event, const ARegion *region, float r_mval[2])
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
int WM_userdef_event_type_from_keymap_type(int kmitype)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
bool WM_gizmo_group_type_ensure(const char *idname)
wmGizmoGroup * WM_gizmomap_group_find_ptr(wmGizmoMap *gzmap, const wmGizmoGroupType *gzgt)
wmGizmoGroup * WM_gizmomap_group_find(wmGizmoMap *gzmap, const char *idname)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
void WM_operator_properties_free(PointerRNA *ptr)