Commit: 37f8c03ab3c1341d0be689c5b7d96b05c33b5c16
Author: Campbell Barton
Date:   Fri Jun 9 20:41:17 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rB37f8c03ab3c1341d0be689c5b7d96b05c33b5c16

Add arrow and dial manipulators with RNA access

===================================================================

M       source/blender/editors/include/ED_manipulator_library.h
M       source/blender/editors/manipulator_library/CMakeLists.txt
M       source/blender/editors/manipulator_library/manipulator_library_presets.c
M       source/blender/makesrna/intern/rna_wm_manipulator_api.c

===================================================================

diff --git a/source/blender/editors/include/ED_manipulator_library.h 
b/source/blender/editors/include/ED_manipulator_library.h
index 7ca7c36e4bc..39733e9248e 100644
--- a/source/blender/editors/include/ED_manipulator_library.h
+++ b/source/blender/editors/include/ED_manipulator_library.h
@@ -51,6 +51,10 @@ struct wmManipulatorGroup;
 /* manipulator_library_presets.c */
 void ED_manipulator_draw_preset_box(
         const struct wmManipulator *manipulator, float mat[4][4], int 
select_id);
+void ED_manipulator_draw_preset_arrow(
+        const struct wmManipulator *manipulator, float mat[4][4], int axis, 
int select_id);
+void ED_manipulator_draw_preset_circle(
+        const struct wmManipulator *manipulator, float mat[4][4], int axis, 
int select_id);
 void ED_manipulator_draw_preset_facemap(
         const struct wmManipulator *mpr, struct Scene *scene, struct Object 
*ob,  const int facemap, int select_id);
 
diff --git a/source/blender/editors/manipulator_library/CMakeLists.txt 
b/source/blender/editors/manipulator_library/CMakeLists.txt
index e54e7d7f58f..05c67b7cb21 100644
--- a/source/blender/editors/manipulator_library/CMakeLists.txt
+++ b/source/blender/editors/manipulator_library/CMakeLists.txt
@@ -44,6 +44,7 @@ set(SRC
        facemap3d_manipulator.c
        geom_arrow_manipulator.c
        geom_cube_manipulator.c
+       geom_dial_manipulator.c
        manipulator_draw_utils.c
        manipulator_library_presets.c
        manipulator_library_utils.c
diff --git 
a/source/blender/editors/manipulator_library/manipulator_library_presets.c 
b/source/blender/editors/manipulator_library/manipulator_library_presets.c
index eb26927fd4e..bd2aaee8d7a 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_presets.c
+++ b/source/blender/editors/manipulator_library/manipulator_library_presets.c
@@ -60,8 +60,30 @@
 
 /* TODO, this is to be used by RNA. might move to ED_manipulator_library */
 
-void ED_manipulator_draw_preset_box(
-        const struct wmManipulator *mpr, float mat[4][4], int select_id)
+/**
+ * Given a single axis, orient the matrix to a different direction.
+ */
+static void single_axis_convert(
+        int src_axis, float src_mat[4][4],
+        int dst_axis, float dst_mat[4][4])
+{
+       copy_m4_m4(dst_mat, src_mat);
+       if (src_axis == dst_axis) {
+               return;
+       }
+
+       float rotmat[3][3];
+       mat3_from_axis_conversion_single(src_axis, dst_axis, rotmat);
+       transpose_m3(rotmat);
+       mul_m4_m4m3(dst_mat, src_mat, rotmat);
+}
+
+/**
+ * Use for all geometry.
+ */
+static void ed_manipulator_draw_preset_geometry(
+        const struct wmManipulator *mpr, float mat[4][4], int select_id,
+        const ManipulatorGeomInfo *info)
 {
        const bool is_select = (select_id != -1);
        const bool is_highlight = is_select && (mpr->state & 
WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
@@ -75,7 +97,7 @@ void ED_manipulator_draw_preset_box(
 
        gpuPushMatrix();
        gpuMultMatrix(mat);
-       wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_cube, 
is_select, color);
+       wm_manipulator_geometryinfo_draw(info, is_select, color);
        gpuPopMatrix();
 
        if (is_select) {
@@ -83,6 +105,28 @@ void ED_manipulator_draw_preset_box(
        }
 }
 
+void ED_manipulator_draw_preset_box(
+        const struct wmManipulator *mpr, float mat[4][4], int select_id)
+{
+       ed_manipulator_draw_preset_geometry(mpr, mat, select_id, 
&wm_manipulator_geom_data_cube);
+}
+
+void ED_manipulator_draw_preset_arrow(
+        const struct wmManipulator *mpr, float mat[4][4], int axis, int 
select_id)
+{
+       float mat_rotate[4][4];
+       single_axis_convert(OB_POSZ, mat, axis, mat_rotate);
+       ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, 
&wm_manipulator_geom_data_arrow);
+}
+
+void ED_manipulator_draw_preset_circle(
+        const struct wmManipulator *mpr, float mat[4][4], int axis, int 
select_id)
+{
+       float mat_rotate[4][4];
+       single_axis_convert(OB_POSZ, mat, axis, mat_rotate);
+       ed_manipulator_draw_preset_geometry(mpr, mat_rotate, select_id, 
&wm_manipulator_geom_data_dial);
+}
+
 void ED_manipulator_draw_preset_facemap(
         const struct wmManipulator *mpr, struct Scene *scene, Object *ob,  
const int facemap, int select_id)
 {
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator_api.c 
b/source/blender/makesrna/intern/rna_wm_manipulator_api.c
index 2e1155c616b..dd678a278d1 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator_api.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator_api.c
@@ -50,6 +50,18 @@ static void rna_manipulator_draw_preset_box(
        ED_manipulator_draw_preset_box(mpr, (float (*)[4])matrix, select_id);
 }
 
+static void rna_manipulator_draw_preset_arrow(
+        wmManipulator *mpr, float matrix[16], int axis, int select_id)
+{
+       ED_manipulator_draw_preset_arrow(mpr, (float (*)[4])matrix, axis, 
select_id);
+}
+
+static void rna_manipulator_draw_preset_circle(
+        wmManipulator *mpr, float matrix[16], int axis, int select_id)
+{
+       ED_manipulator_draw_preset_circle(mpr, (float (*)[4])matrix, axis, 
select_id);
+}
+
 static void rna_manipulator_draw_preset_facemap(
         wmManipulator *mpr, struct bContext *C, struct Object *ob, int 
facemap, int select_id)
 {
@@ -70,6 +82,9 @@ void RNA_api_manipulator(StructRNA *srna)
        FunctionRNA *func;
        PropertyRNA *parm;
 
+       /* -------------------------------------------------------------------- 
*/
+       /* Primitive Shapes */
+
        /* draw_preset_box */
        func = RNA_def_function(srna, "draw_preset_box", 
"rna_manipulator_draw_preset_box");
        RNA_def_function_ui_description(func, "Draw a box");
@@ -79,6 +94,28 @@ void RNA_api_manipulator(StructRNA *srna)
        RNA_def_property_ui_text(parm, "", "The matrix to transform");
        RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not 
selecting", "", -1, INT_MAX);
 
+       /* draw_preset_box */
+       func = RNA_def_function(srna, "draw_preset_arrow", 
"rna_manipulator_draw_preset_arrow");
+       RNA_def_function_ui_description(func, "Draw a box");
+       parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
+       RNA_def_property_flag(parm, PARM_REQUIRED);
+       RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4);
+       RNA_def_property_ui_text(parm, "", "The matrix to transform");
+       RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow 
Orientation");
+       RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not 
selecting", "", -1, INT_MAX);
+
+       func = RNA_def_function(srna, "draw_preset_circle", 
"rna_manipulator_draw_preset_circle");
+       RNA_def_function_ui_description(func, "Draw a box");
+       parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
+       RNA_def_property_flag(parm, PARM_REQUIRED);
+       RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4);
+       RNA_def_property_ui_text(parm, "", "The matrix to transform");
+       RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow 
Orientation");
+       RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not 
selecting", "", -1, INT_MAX);
+
+       /* -------------------------------------------------------------------- 
*/
+       /* Other Shapes */
+
        /* draw_preset_facemap */
        func = RNA_def_function(srna, "draw_preset_facemap", 
"rna_manipulator_draw_preset_facemap");
        RNA_def_function_ui_description(func, "Draw the face-map of a mesh 
object");

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to