[Bf-blender-cvs] [98e50c0881e] custom-manipulators: RNA: Expose face-map manipulator to Python
Campbell Barton
noreply at git.blender.org
Fri Jun 9 08:26:55 CEST 2017
Commit: 98e50c0881e4b9452e152c751b5e72521cedf7ec
Author: Campbell Barton
Date: Fri Jun 9 16:26:33 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rB98e50c0881e4b9452e152c751b5e72521cedf7ec
RNA: Expose face-map manipulator to Python
===================================================================
M source/blender/editors/include/ED_manipulator_library.h
M source/blender/editors/manipulator_library/manipulator_library_presets.c
M source/blender/editors/space_view3d/drawobject.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 284f476e62e..7ca7c36e4bc 100644
--- a/source/blender/editors/include/ED_manipulator_library.h
+++ b/source/blender/editors/include/ED_manipulator_library.h
@@ -49,7 +49,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_box(
+ const struct wmManipulator *manipulator, float mat[4][4], 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/manipulator_library_presets.c b/source/blender/editors/manipulator_library/manipulator_library_presets.c
index 069b9e54c23..eb26927fd4e 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_presets.c
+++ b/source/blender/editors/manipulator_library/manipulator_library_presets.c
@@ -34,6 +34,7 @@
#include "DNA_manipulator_types.h"
#include "DNA_view3d_types.h"
+#include "DNA_object_types.h"
#include "ED_view3d.h"
#include "ED_screen.h"
@@ -81,3 +82,27 @@ void ED_manipulator_draw_preset_box(
GPU_select_load_id(-1);
}
}
+
+void ED_manipulator_draw_preset_facemap(
+ const struct wmManipulator *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id)
+{
+ const bool is_select = (select_id != -1);
+ const bool is_highlight = is_select && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
+
+ float color[4];
+ manipulator_color_get(mpr, is_highlight, color);
+
+ if (is_select) {
+ GPU_select_load_id(select_id);
+ }
+
+ gpuPushMatrix();
+ gpuMultMatrix(ob->obmat);
+ ED_draw_object_facemap(scene, ob, color, facemap);
+ gpuPopMatrix();
+
+ if (is_select) {
+ GPU_select_load_id(-1);
+ }
+}
+
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 1bb8937c338..126217057e5 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -9812,9 +9812,6 @@ void ED_draw_object_facemap(Scene *scene, Object *ob, const float col[4], const
#else
- (void)facemap;
- (void)col;
-
/* Just to create the data to pass to immediate mode, grr! */
Mesh *me = ob->data;
const int *facemap_data = CustomData_get_layer(&me->pdata, CD_FACEMAP);
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator_api.c b/source/blender/makesrna/intern/rna_wm_manipulator_api.c
index 646d0ebc902..2e1155c616b 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator_api.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator_api.c
@@ -44,11 +44,19 @@
#include "ED_manipulator_library.h"
-static void rna_manipulator_draw_preset_box(wmManipulator *mpr, float matrix[16], int select_id)
+static void rna_manipulator_draw_preset_box(
+ wmManipulator *mpr, float matrix[16], int select_id)
{
ED_manipulator_draw_preset_box(mpr, (float (*)[4])matrix, select_id);
}
+static void rna_manipulator_draw_preset_facemap(
+ wmManipulator *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id)
+{
+ struct Scene *scene = CTX_data_scene(C);
+ ED_manipulator_draw_preset_facemap(mpr, scene, ob, facemap, select_id);
+}
+
#else
void RNA_api_manipulator(StructRNA *srna)
@@ -62,14 +70,23 @@ void RNA_api_manipulator(StructRNA *srna)
FunctionRNA *func;
PropertyRNA *parm;
- /* draw */
+ /* 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");
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_int(func, "select_id", 0, 0, INT_MAX, "Zero when not selecting", "", 0, INT_MAX);
+ RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX);
+
+ /* 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");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ parm = RNA_def_pointer(func, "object", "Object", "", "Object");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ RNA_def_int(func, "facemap", 0, 0, INT_MAX, "Face map index", "", 0, INT_MAX);
+ RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX);
}
More information about the Bf-blender-cvs
mailing list