Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-01 04:35:48 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-01 04:41:40 +0300
commit69665bc7f06d727499596c87f1c08c1fc064efba (patch)
tree7c22f9d74760275552e0b3d8610469c9a4c9db31 /source
parent795effcbc815ae8c54bf59d31f3315a46e576c86 (diff)
RNA: move cursor into own struct
Without this it's impractical to subscribe to any change to the cursor. Fixes T61969 by having gizmos update on any change to the cursor.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c5
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c18
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_scene.c114
5 files changed, 83 insertions, 71 deletions
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index 52b011cf83e..9884ded4f0a 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -438,18 +438,10 @@ static void gizmo_mesh_spin_init_message_subscribe(
.notify = WM_gizmo_do_msg_notify_tag_refresh,
};
- PointerRNA scene_ptr;
- RNA_id_pointer_create(&scene->id, &scene_ptr);
-
- {
- extern PropertyRNA rna_Scene_cursor_location;
- const PropertyRNA *props[] = {
- &rna_Scene_cursor_location,
- };
- for (int i = 0; i < ARRAY_SIZE(props); i++) {
- WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__);
- }
- }
+ PointerRNA cursor_ptr;
+ RNA_pointer_create(&scene->id, &RNA_View3DCursor, &scene->cursor, &cursor_ptr);
+ /* All cursor properties. */
+ WM_msg_subscribe_rna(mbus, &cursor_ptr, NULL, &msg_sub_value_gz_tag_refresh, __func__);
WM_msg_subscribe_rna_params(
mbus,
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index eeb34bde66d..82d7e4eac4c 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4819,8 +4819,9 @@ void ED_view3d_cursor3d_update(
{
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
- WM_msg_publish_rna_prop(
- mbus, &scene->id, scene, Scene, cursor_location);
+ wmMsgParams_RNA msg_key_params = {{{0}}};
+ RNA_pointer_create(&scene->id, &RNA_View3DCursor, &scene->cursor, &msg_key_params.ptr);
+ WM_msg_publish_rna_params(mbus, &msg_key_params);
}
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index e1066315508..2e6a399d0ea 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -1227,25 +1227,29 @@ static void gizmo_xform_message_subscribe(
TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, orient_flag);
PointerRNA orient_ref_ptr;
RNA_pointer_create(&scene->id, &RNA_TransformOrientationSlot, orient_slot, &orient_ref_ptr);
+ const ToolSettings *ts = scene->toolsettings;
PointerRNA scene_ptr;
RNA_id_pointer_create(&scene->id, &scene_ptr);
{
- const ToolSettings *ts = scene->toolsettings;
extern PropertyRNA rna_Scene_transform_orientation_slots;
- extern PropertyRNA rna_Scene_cursor_location;
const PropertyRNA *props[] = {
&rna_Scene_transform_orientation_slots,
- ((ts->transform_pivot_point == V3D_AROUND_CURSOR) || (orient_slot->type == V3D_ORIENT_CURSOR)) ?
- &rna_Scene_cursor_location : NULL,
};
for (int i = 0; i < ARRAY_SIZE(props); i++) {
- if (props[i]) {
- WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__);
- }
+ WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__);
}
}
+ if ((ts->transform_pivot_point == V3D_AROUND_CURSOR) ||
+ (orient_slot->type == V3D_ORIENT_CURSOR))
+ {
+ /* We could be more specific here, for now subscribe to any cursor change. */
+ PointerRNA cursor_ptr;
+ RNA_pointer_create(&scene->id, &RNA_View3DCursor, &scene->cursor, &cursor_ptr);
+ WM_msg_subscribe_rna(mbus, &cursor_ptr, NULL, &msg_sub_value_gz_tag_refresh, __func__);
+ }
+
{
extern PropertyRNA rna_TransformOrientationSlot_type;
extern PropertyRNA rna_TransformOrientationSlot_use;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index e0d3331c773..5866302a852 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -720,6 +720,7 @@ extern StructRNA RNA_VertexPaint;
extern StructRNA RNA_VertexWeightEditModifier;
extern StructRNA RNA_VertexWeightMixModifier;
extern StructRNA RNA_VertexWeightProximityModifier;
+extern StructRNA RNA_View3DCursor;
extern StructRNA RNA_View3DOverlay;
extern StructRNA RNA_View3DShading;
extern StructRNA RNA_ViewLayer;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 301f7cfd5ea..ecf09837c0a 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1635,10 +1635,9 @@ static void rna_Scene_sync_mode_set(PointerRNA *ptr, int value)
}
}
-static void rna_Scene_cursor_rotation_mode_set(PointerRNA *ptr, int value)
+static void rna_View3DCursor_rotation_mode_set(PointerRNA *ptr, int value)
{
- Scene *scene = ptr->id.data;
- View3DCursor *cursor = &scene->cursor;
+ View3DCursor *cursor = ptr->data;
/* use API Method for conversions... */
BKE_rotMode_change_values(
@@ -1650,18 +1649,16 @@ static void rna_Scene_cursor_rotation_mode_set(PointerRNA *ptr, int value)
cursor->rotation_mode = value;
}
-static void rna_Scene_cursor_rotation_axis_angle_get(PointerRNA *ptr, float *value)
+static void rna_View3DCursor_rotation_axis_angle_get(PointerRNA *ptr, float *value)
{
- Scene *scene = ptr->id.data;
- View3DCursor *cursor = &scene->cursor;
+ View3DCursor *cursor = ptr->data;
value[0] = cursor->rotation_angle;
copy_v3_v3(&value[1], cursor->rotation_axis);
}
-static void rna_Scene_cursor_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
+static void rna_View3DCursor_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
{
- Scene *scene = ptr->id.data;
- View3DCursor *cursor = &scene->cursor;
+ View3DCursor *cursor = ptr->data;
cursor->rotation_angle = value[0];
copy_v3_v3(cursor->rotation_axis, &value[1]);
}
@@ -2348,6 +2345,55 @@ static void rna_def_transform_orientation_slot(BlenderRNA *brna)
RNA_def_function_output(func, parm);
}
+static void rna_def_view3d_cursor(BlenderRNA *brna)
+{
+ static float default_quat[4] = {1, 0, 0, 0}; /* default quaternion values */
+ static float default_axisAngle[4] = {0, 0, 1, 0}; /* default axis-angle rotation values */
+
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "View3DCursor", NULL);
+ RNA_def_struct_sdna(srna, "View3DCursor");
+ RNA_def_struct_ui_text(srna, "3D Cursor", "");
+
+ prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ_LENGTH);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_float_sdna(prop, NULL, "location");
+ RNA_def_property_ui_text(prop, "Location", "");
+ RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
+
+ prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_float_sdna(prop, NULL, "rotation_quaternion");
+ RNA_def_property_float_array_default(prop, default_quat);
+ RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in quaternions (keep normalized)");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
+
+ prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_float_funcs(prop, "rna_View3DCursor_rotation_axis_angle_get",
+ "rna_View3DCursor_rotation_axis_angle_set", NULL);
+ RNA_def_property_float_array_default(prop, default_axisAngle);
+ RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
+
+ prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_float_sdna(prop, NULL, "rotation_euler");
+ RNA_def_property_ui_text(prop, "Euler Rotation", "3D rotation");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
+
+ prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_enum_sdna(prop, NULL, "rotation_mode");
+ RNA_def_property_enum_items(prop, rna_enum_object_rotation_mode_items);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_View3DCursor_rotation_mode_set", NULL);
+ RNA_def_property_ui_text(prop, "Rotation Mode", "");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
+}
static void rna_def_tool_settings(BlenderRNA *brna)
{
@@ -6332,10 +6378,6 @@ void RNA_def_scene(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- static float default_quat[4] = {1, 0, 0, 0}; /* default quaternion values */
- static float default_axisAngle[4] = {0, 0, 1, 0}; /* default axis-angle rotation values */
-
-
/* Struct definition */
srna = RNA_def_struct(brna, "Scene", "ID");
RNA_def_struct_ui_text(srna, "Scene", "Scene data-block, consisting in objects and "
@@ -6363,43 +6405,6 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "World", "World used for rendering the scene");
RNA_def_property_update(prop, NC_SCENE | ND_WORLD, "rna_Scene_world_update");
- prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_float_sdna(prop, NULL, "cursor.location");
- RNA_def_property_ui_text(prop, "Cursor Location", "3D cursor location");
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
- RNA_def_property_update(prop, NC_WINDOW, NULL);
-
- prop = RNA_def_property(srna, "cursor_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_float_sdna(prop, NULL, "cursor.rotation_quaternion");
- RNA_def_property_float_array_default(prop, default_quat);
- RNA_def_property_ui_text(prop, "Cursor Quaternion Rotation", "3D cursor rotation in quaternions (keep normalized)");
- RNA_def_property_update(prop, NC_WINDOW, NULL);
-
- prop = RNA_def_property(srna, "cursor_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_array(prop, 4);
- RNA_def_property_float_funcs(prop, "rna_Scene_cursor_rotation_axis_angle_get",
- "rna_Scene_cursor_rotation_axis_angle_set", NULL);
- RNA_def_property_float_array_default(prop, default_axisAngle);
- RNA_def_property_ui_text(prop, "Cursor Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
- RNA_def_property_update(prop, NC_WINDOW, NULL);
-
- prop = RNA_def_property(srna, "cursor_rotation_euler", PROP_FLOAT, PROP_EULER);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_float_sdna(prop, NULL, "cursor.rotation_euler");
- RNA_def_property_ui_text(prop, "Cursor Euler Rotation", "3D cursor rotation");
- RNA_def_property_update(prop, NC_WINDOW, NULL);
-
- prop = RNA_def_property(srna, "cursor_rotation_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_sdna(prop, NULL, "cursor.rotation_mode");
- RNA_def_property_enum_items(prop, rna_enum_object_rotation_mode_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Scene_cursor_rotation_mode_set", NULL);
- RNA_def_property_ui_text(prop, "Cursor Rotation Mode", "");
- RNA_def_property_update(prop, NC_WINDOW, NULL);
-
prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Objects", "");
@@ -6655,6 +6660,14 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "TransformOrientationSlot");
RNA_def_property_ui_text(prop, "Transform Orientation Slots", "");
+
+ /* 3D View Cursor */
+ prop = RNA_def_property(srna, "cursor", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_pointer_sdna(prop, NULL, "cursor");
+ RNA_def_property_struct_type(prop, "View3DCursor");
+ RNA_def_property_ui_text(prop, "3D Cursor", "");
+
/* Audio Settings */
prop = RNA_def_property(srna, "use_audio", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Scene_use_audio_get", "rna_Scene_use_audio_set");
@@ -6780,6 +6793,7 @@ void RNA_def_scene(BlenderRNA *brna)
rna_def_scene_image_format_data(brna);
rna_def_transform_orientation(brna);
rna_def_transform_orientation_slot(brna);
+ rna_def_view3d_cursor(brna);
rna_def_selected_uv_element(brna);
rna_def_display_safe_areas(brna);
rna_def_scene_display(brna);