diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-16 06:38:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-16 06:50:00 +0300 |
commit | c9c23a3e44c0648d37396bbb19236e881d33e2cc (patch) | |
tree | 12b7b7f2dc205d1ad373f78396841d5290abcf31 /source/blender/makesrna/intern/rna_scene.c | |
parent | f2144cf298aab7fd173025e490fa9e98b7661a88 (diff) |
RNA: add 3D cursor matrix attribute
Avoids having to check rotation modes to get the orientation.
Diffstat (limited to 'source/blender/makesrna/intern/rna_scene.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ed9db684cd4..b7399202624 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1849,6 +1849,20 @@ static void rna_View3DCursor_rotation_axis_angle_set(PointerRNA *ptr, const floa copy_v3_v3(cursor->rotation_axis, &value[1]); } +static void rna_View3DCursor_matrix_get(PointerRNA *ptr, float *values) +{ + const View3DCursor *cursor = ptr->data; + BKE_scene_cursor_to_mat4(cursor, (float(*)[4])values); +} + +static void rna_View3DCursor_matrix_set(PointerRNA *ptr, const float *values) +{ + View3DCursor *cursor = ptr->data; + float unit_mat[4][4]; + normalize_m4_m4(unit_mat, (const float(*)[4])values); + BKE_scene_cursor_from_mat4(cursor, unit_mat, false); +} + static char *rna_View3DCursor_path(PointerRNA *UNUSED(ptr)) { return BLI_strdup("cursor"); @@ -2586,6 +2600,14 @@ static void rna_def_view3d_cursor(BlenderRNA *brna) 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); + + /* Matrix access to avoid having to check current rotation mode. */ + prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_flag(prop, PROP_THICK_WRAP); /* no reference to original data */ + RNA_def_property_ui_text(prop, "Transform Matrix", "Matrix combining loc/rot of the cursor"); + RNA_def_property_float_funcs( + prop, "rna_View3DCursor_matrix_get", "rna_View3DCursor_matrix_set", NULL); } static void rna_def_tool_settings(BlenderRNA *brna) |