diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-08 15:18:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-08 16:35:04 +0300 |
commit | a48186c5d74b3d353c5c65cd4a930dd98cc9a603 (patch) | |
tree | c49fd2af2aaac151c5fd1265e414392617043253 /source/blender/makesrna | |
parent | 53a56b7b6c169b21df475ae94795208501581489 (diff) |
Orientation for 3D cursor
Currently set when setting the cursor location,
optionally used as an orientation type.
Intended for use by tools too.
See: D3208
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 40 |
2 files changed, 37 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b2fca51ce38..871b260902a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -449,6 +449,7 @@ static const EnumPropertyItem transform_orientation_items[] = { "(bone Y axis for pose mode)"}, {V3D_MANIP_GIMBAL, "GIMBAL", 0, "Gimbal", "Align each axis to the Euler rotation axis as used for input"}, {V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"}, + {V3D_MANIP_CURSOR, "CURSOR", 0, "Cursor", "Align the transformation axes to the 3D cursor"}, // {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"}, {0, NULL, 0, NULL, NULL} }; @@ -5700,11 +5701,16 @@ void RNA_def_scene(BlenderRNA *brna) 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_float_sdna(prop, NULL, "cursor"); + 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", PROP_FLOAT, PROP_QUATERNION); + RNA_def_property_float_sdna(prop, NULL, "cursor.rotation"); + RNA_def_property_ui_text(prop, "Cursor Rotation", "3D cursor rotation in quaternions (keep normalized)"); + 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", ""); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 8dba90d0a2b..20e69932e47 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -443,24 +443,37 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int valu } } -static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values) + +static View3DCursor *rna_View3D_Cursor_get_from_scene_or_localview(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); bScreen *screen = ptr->id.data; Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); - const float *loc = ED_view3d_cursor3d_get(scene, v3d); + return ED_view3d_cursor3d_get(scene, v3d); +} - copy_v3_v3(values, loc); +static void rna_View3D_Cursor_location_get(PointerRNA *ptr, float *values) +{ + const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr); + copy_v3_v3(values, cursor->location); } -static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values) +static void rna_View3D_Cursor_location_set(PointerRNA *ptr, const float *values) { - View3D *v3d = (View3D *)(ptr->data); - bScreen *screen = ptr->id.data; - Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); - float *cursor = ED_view3d_cursor3d_get(scene, v3d); + View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr); + copy_v3_v3(cursor->location, values); +} - copy_v3_v3(cursor, values); +static void rna_View3D_Cursor_rotation_get(PointerRNA *ptr, float *values) +{ + const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr); + copy_qt_qt(values, cursor->rotation); +} + +static void rna_View3D_Cursor_rotation_set(PointerRNA *ptr, const float *values) +{ + View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr); + copy_qt_qt(cursor->rotation, values); } static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr) @@ -2508,12 +2521,19 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH); RNA_def_property_array(prop, 3); - RNA_def_property_float_funcs(prop, "rna_View3D_CursorLocation_get", "rna_View3D_CursorLocation_set", NULL); + RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_location_get", "rna_View3D_Cursor_location_set", NULL); RNA_def_property_ui_text(prop, "3D Cursor Location", "3D cursor location for this view (dependent on local view setting)"); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, RNA_TRANSLATION_PREC_DEFAULT); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "cursor_rotation", PROP_FLOAT, PROP_QUATERNION); + RNA_def_property_array(prop, 4); + RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_rotation_get", "rna_View3D_Cursor_rotation_set", NULL); + RNA_def_property_ui_text(prop, "3D Cursor Rotation", + "Rotation in quaternions (keep normalized)"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_UNIT_CAMERA); RNA_def_property_float_sdna(prop, NULL, "lens"); RNA_def_property_ui_text(prop, "Lens", "Viewport lens angle"); |