[Bf-blender-cvs] [b1e01a2] wiggly-widgets: Draw face map widgets in custom bone color
Julian Eisel
noreply at git.blender.org
Mon Nov 16 00:00:22 CET 2015
Commit: b1e01a2427a5cc06bd317954725c8a74cb610020
Author: Julian Eisel
Date: Sun Nov 15 23:55:39 2015 +0100
Branches: wiggly-widgets
https://developer.blender.org/rBb1e01a2427a5cc06bd317954725c8a74cb610020
Draw face map widgets in custom bone color
Annoying glitch is that changing color/color-set doesn't directly update selected widget, only after all widgets were deselected. Needs separate fix though.
===================================================================
M source/blender/editors/armature/pose_utils.c
M source/blender/editors/include/ED_armature.h
M source/blender/editors/space_view3d/drawarmature.c
M source/blender/editors/space_view3d/view3d_widgets.c
===================================================================
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 2ba1eed..337e935 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -46,6 +46,8 @@
#include "RNA_access.h"
+#include "UI_resources.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -57,7 +59,7 @@
/* *********************************************** */
/* Contents of this File:
*
- * This file contains methods shared between Pose Slide and Pose Lib;
+ * This file mainly contains methods shared between Pose Slide and Pose Lib;
* primarily the functions in question concern Animato <-> Pose
* convenience functions, such as applying/getting pose values
* and/or inserting keyframes for these.
@@ -268,3 +270,36 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con
}
/* *********************************************** */
+
+/**
+ * Get color set to draw \a pchan in.
+ */
+ThemeWireColor *ED_pchan_get_colorset(bArmature *arm, bPose *pose, bPoseChannel *pchan)
+{
+ bActionGroup *grp = NULL;
+ short color_index = 0;
+
+ /* only try to set custom color if enabled for armature */
+ if (arm->flag & ARM_COL_CUSTOM) {
+ /* currently, a bone can only use a custom color set if it's group (if it has one),
+ * has been set to use one */
+ if (pchan->agrp_index) {
+ grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1));
+ if (grp)
+ color_index = grp->customCol;
+ }
+ }
+
+ /* bcolor is a pointer to the color set to use. If NULL, then the default
+ * color set (based on the theme colors for 3d-view) is used. */
+ if (color_index > 0) {
+ bTheme *btheme = UI_GetTheme();
+ return &btheme->tarm[(color_index - 1)];
+ }
+ else if (color_index == -1) {
+ /* use the group's own custom color set */
+ return (grp) ? &grp->cs : NULL;
+ }
+
+ return NULL;
+}
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 35bb12d..e94cb63 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -30,6 +30,8 @@
#ifndef __ED_ARMATURE_H__
#define __ED_ARMATURE_H__
+#include "BLI_compiler_attrs.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -38,6 +40,7 @@ struct bArmature;
struct Base;
struct bContext;
struct Bone;
+struct bPose;
struct bPoseChannel;
struct IDProperty;
struct ListBase;
@@ -209,7 +212,13 @@ int BDR_drawSketchNames(struct ViewContext *vc);
void mesh_deform_bind(struct Scene *scene,
struct MeshDeformModifierData *mmd,
float *vertexcos, int totvert, float cagemat[4][4]);
-
+
+/* pose_utils.c */
+struct ThemeWireColor *ED_pchan_get_colorset(
+ struct bArmature *arm,
+ struct bPose *pose, struct bPoseChannel *pchan)
+ ATTR_WARN_UNUSED_RESULT;
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 6d54b52..f239328 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -89,40 +89,14 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan)
{
bPose *pose = (ob) ? ob->pose : NULL;
bArmature *arm = (ob) ? ob->data : NULL;
- bActionGroup *grp = NULL;
- short color_index = 0;
-
+
/* sanity check */
if (ELEM(NULL, ob, arm, pose, pchan)) {
bcolor = NULL;
return;
}
-
- /* only try to set custom color if enabled for armature */
- if (arm->flag & ARM_COL_CUSTOM) {
- /* currently, a bone can only use a custom color set if it's group (if it has one),
- * has been set to use one
- */
- if (pchan->agrp_index) {
- grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1));
- if (grp)
- color_index = grp->customCol;
- }
- }
-
- /* bcolor is a pointer to the color set to use. If NULL, then the default
- * color set (based on the theme colors for 3d-view) is used.
- */
- if (color_index > 0) {
- bTheme *btheme = UI_GetTheme();
- bcolor = &btheme->tarm[(color_index - 1)];
- }
- else if (color_index == -1) {
- /* use the group's own custom color set */
- bcolor = (grp) ? &grp->cs : NULL;
- }
- else
- bcolor = NULL;
+
+ bcolor = ED_pchan_get_colorset(arm, pose, pchan);
}
/* This function is for brightening/darkening a given color (like UI_ThemeColorShade()) */
diff --git a/source/blender/editors/space_view3d/view3d_widgets.c b/source/blender/editors/space_view3d/view3d_widgets.c
index 1ace45d..b3706e1 100644
--- a/source/blender/editors/space_view3d/view3d_widgets.c
+++ b/source/blender/editors/space_view3d/view3d_widgets.c
@@ -287,8 +287,6 @@ void WIDGETGROUP_armature_facemaps_create(const bContext *C, wmWidgetGroup *wgro
wmWidget *widget;
PointerRNA famapptr;
PropertyRNA *prop;
- const float col[4] = {0.8f, 0.8f, 0.45f, 0.2f};
- const float col_hi[4] = {0.8f, 0.8f, 0.45f, 0.4f};
#ifdef USE_FACEMAP_FROM_BONE
@@ -296,9 +294,18 @@ void WIDGETGROUP_armature_facemaps_create(const bContext *C, wmWidgetGroup *wgro
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->fmap && (pchan->bone->layer & arm->layer)) {
+ ThemeWireColor *bcol = ED_pchan_get_colorset(arm, ob->pose, pchan);
Object *fmap_ob = pchan->fmap_object;
bFaceMap *fmap = pchan->fmap;
PointerRNA *opptr;
+ float col[4] = {0.8f, 0.8f, 0.45f, 0.2f};
+ float col_hi[4] = {0.8f, 0.8f, 0.45f, 0.4f};
+
+ /* get custom bone group color */
+ if (bcol) {
+ rgba_uchar_to_float(col, (unsigned char *)bcol->solid);
+ rgba_uchar_to_float(col_hi, (unsigned char *)bcol->active);
+ }
widget = WIDGET_facemap_new(wgroup, fmap->name, 0, fmap_ob, BLI_findindex(&fmap_ob->fmaps, fmap));
More information about the Bf-blender-cvs
mailing list