Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-04-26 09:11:37 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-04-26 09:12:01 +0300
commit5634763e5efbf78feb985973272185774c9d25b8 (patch)
treefff8d8c2b822865012a1aa0d7fdf2eb881e3e325 /source/blender
parent82686f0a0c2c1d5c42b07288935440aea4713cad (diff)
Draw Manager: armature editmode selection
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/intern/DRW_render.h3
-rw-r--r--source/blender/draw/intern/draw_armature.c112
-rw-r--r--source/blender/draw/intern/draw_manager.c68
3 files changed, 136 insertions, 47 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index f98f39d7bb3..8b61caf545c 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -318,6 +318,9 @@ void DRW_draw_callbacks_post_scene(void);
void DRW_state_reset(void);
+/* Selection */
+void DRW_select_load_id(unsigned int id);
+
/* Other */
void DRW_get_dfdy_factors(float dfdyfac[2]);
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index c93d69fb33a..c7fad8beadf 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -55,6 +55,8 @@
#include "ED_armature.h"
#include "ED_keyframes_draw.h"
+#include "GPU_select.h"
+
#include "UI_resources.h"
#include "draw_common.h"
@@ -242,7 +244,9 @@ static void draw_axes(EditBone *eBone, bPoseChannel *pchan)
DRW_shgroup_bone_axes(BONE_VAR(eBone, pchan, disp_tail_mat), col);
}
-static void draw_points(EditBone *eBone, bPoseChannel *pchan, bArmature *arm)
+static void draw_points(
+ const EditBone *eBone, const bPoseChannel *pchan, const bArmature *arm,
+ const int select_id)
{
const float *col_solid_root = colorBoneSolid;
const float *col_solid_tail = colorBoneSolid;
@@ -263,6 +267,10 @@ static void draw_points(EditBone *eBone, bPoseChannel *pchan, bArmature *arm)
/* Draw root point if we are not connected and parent are not hidden */
if ((BONE_FLAG(eBone, pchan) & BONE_CONNECTED) == 0) {
+ if (select_id != -1) {
+ DRW_select_load_id(select_id | BONESEL_ROOT);
+ }
+
if (eBone) {
if (!((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent))) {
DRW_shgroup_bone_point_solid(eBone->disp_mat, col_solid_root);
@@ -279,44 +287,71 @@ static void draw_points(EditBone *eBone, bPoseChannel *pchan, bArmature *arm)
}
/* Draw tip point */
+ if (select_id != -1) {
+ DRW_select_load_id(select_id | BONESEL_TIP);
+ }
DRW_shgroup_bone_point_solid(BONE_VAR(eBone, pchan, disp_tail_mat), col_solid_tail);
DRW_shgroup_bone_point_wire(BONE_VAR(eBone, pchan, disp_tail_mat), col_wire_tail);
+
+ if (select_id != -1) {
+ DRW_select_load_id(-1);
+ }
}
-static void draw_bone_custom_shape(EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm))
+static void draw_bone_custom_shape(
+ EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm),
+ const int UNUSED(select_id))
{
/* work in progress -- fclem */
}
-static void draw_bone_envelope(EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm))
+static void draw_bone_envelope(
+ EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm),
+ const int UNUSED(select_id))
{
/* work in progress -- fclem */
}
-static void draw_bone_line(EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm))
+static void draw_bone_line(
+ EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm),
+ const int UNUSED(select_id))
{
/* work in progress -- fclem */
}
-static void draw_bone_wire(EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm))
+static void draw_bone_wire(
+ EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm),
+ const int UNUSED(select_id))
{
/* work in progress -- fclem */
}
-static void draw_bone_box(EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm))
+static void draw_bone_box(
+ EditBone *UNUSED(eBone), bPoseChannel *UNUSED(pchan), bArmature *UNUSED(arm),
+ const int UNUSED(select_id))
{
/* work in progress -- fclem */
}
-static void draw_bone_octahedral(EditBone *eBone, bPoseChannel *pchan, bArmature *arm)
+static void draw_bone_octahedral(
+ EditBone *eBone, bPoseChannel *pchan, bArmature *arm,
+ const int select_id)
{
const float *col_solid = get_bone_solid_color(eBone, pchan, arm);
const float *col_wire = get_bone_wire_color(eBone, pchan, arm);
+ if (select_id != -1) {
+ DRW_select_load_id(select_id | BONESEL_BONE);
+ }
+
DRW_shgroup_bone_octahedral_solid(BONE_VAR(eBone, pchan, disp_mat), col_solid);
DRW_shgroup_bone_octahedral_wire(BONE_VAR(eBone, pchan, disp_mat), col_wire);
- draw_points(eBone, pchan, arm);
+ if (select_id != -1) {
+ DRW_select_load_id(-1);
+ }
+
+ draw_points(eBone, pchan, arm, select_id);
}
static void draw_armature_edit(Object *ob)
@@ -324,29 +359,37 @@ static void draw_armature_edit(Object *ob)
EditBone *eBone;
bArmature *arm = ob->data;
unsigned int index;
+ const bool is_select = DRW_viewport_is_select();
update_color(NULL);
for (eBone = arm->edbo->first, index = 0; eBone; eBone = eBone->next, index++) {
if (eBone->layer & arm->layer) {
if ((eBone->flag & BONE_HIDDEN_A) == 0) {
+ const int select_id = is_select ? index : (unsigned int)-1;
draw_bone_update_disp_matrix(eBone, NULL, arm->drawtype);
- if (arm->drawtype == ARM_ENVELOPE)
- draw_bone_envelope(eBone, NULL, arm);
- else if (arm->drawtype == ARM_LINE)
- draw_bone_line(eBone, NULL, arm);
- else if (arm->drawtype == ARM_WIRE)
- draw_bone_wire(eBone, NULL, arm);
- else if (arm->drawtype == ARM_B_BONE)
- draw_bone_box(eBone, NULL, arm);
- else
- draw_bone_octahedral(eBone, NULL, arm);
+ if (arm->drawtype == ARM_ENVELOPE) {
+ draw_bone_envelope(eBone, NULL, arm, select_id);
+ }
+ else if (arm->drawtype == ARM_LINE) {
+ draw_bone_line(eBone, NULL, arm, select_id);
+ }
+ else if (arm->drawtype == ARM_WIRE) {
+ draw_bone_wire(eBone, NULL, arm, select_id);
+ }
+ else if (arm->drawtype == ARM_B_BONE) {
+ draw_bone_box(eBone, NULL, arm, select_id);
+ }
+ else {
+ draw_bone_octahedral(eBone, NULL, arm, select_id);
+ }
/* Draw additional axes */
- if (arm->flag & ARM_DRAWAXES)
+ if (arm->flag & ARM_DRAWAXES) {
draw_axes(eBone, NULL);
+ }
}
}
}
@@ -376,21 +419,28 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
/* bone must be visible */
if ((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) {
if (bone->layer & arm->layer) {
+ const int select_id = -1; /* TODO: see 'draw_pose_bones' */
draw_bone_update_disp_matrix(NULL, pchan, arm->drawtype);
- if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM))
- draw_bone_custom_shape(NULL, pchan, arm);
- else if (arm->drawtype == ARM_ENVELOPE)
- draw_bone_envelope(NULL, pchan, arm);
- else if (arm->drawtype == ARM_LINE)
- draw_bone_line(NULL, pchan, arm);
- else if (arm->drawtype == ARM_WIRE)
- draw_bone_wire(NULL, pchan, arm);
- else if (arm->drawtype == ARM_B_BONE)
- draw_bone_box(NULL, pchan, arm);
- else
- draw_bone_octahedral(NULL, pchan, arm);
+ if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
+ draw_bone_custom_shape(NULL, pchan, arm, select_id);
+ }
+ else if (arm->drawtype == ARM_ENVELOPE) {
+ draw_bone_envelope(NULL, pchan, arm, select_id);
+ }
+ else if (arm->drawtype == ARM_LINE) {
+ draw_bone_line(NULL, pchan, arm, select_id);
+ }
+ else if (arm->drawtype == ARM_WIRE) {
+ draw_bone_wire(NULL, pchan, arm, select_id);
+ }
+ else if (arm->drawtype == ARM_B_BONE) {
+ draw_bone_box(NULL, pchan, arm, select_id);
+ }
+ else {
+ draw_bone_octahedral(NULL, pchan, arm, select_id);
+ }
/* Draw additional axes */
if (arm->flag & ARM_DRAWAXES)
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 67e2496e09f..0531e94396b 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -82,6 +82,7 @@
#ifdef USE_GPU_SELECT
# include "ED_view3d.h"
+# include "ED_armature.h"
# include "GPU_select.h"
#endif
@@ -235,8 +236,9 @@ ListBase DRW_engines = {NULL, NULL};
#ifdef USE_GPU_SELECT
static unsigned int g_DRW_select_id = (unsigned int)-1;
-static void DRW_select_id_set(unsigned int id)
+void DRW_select_load_id(unsigned int id)
{
+ BLI_assert(G.f & G_PICKSEL);
g_DRW_select_id = id;
}
#endif
@@ -1735,7 +1737,7 @@ static void use_drw_engine(DrawEngineType *engine)
/* TODO revisit this when proper layering is implemented */
/* Gather all draw engines needed and store them in DST.enabled_engines
* That also define the rendering order of engines */
-static void DRW_engines_enable_no_modes(const Scene *scene)
+static void DRW_engines_enable_from_engine(const Scene *scene)
{
/* TODO layers */
RenderEngineType *type = RE_engines_find(scene->r.engine);
@@ -1747,12 +1749,9 @@ static void DRW_engines_enable_no_modes(const Scene *scene)
use_drw_engine(&draw_engine_object_type);
}
-static void DRW_engines_enable(const bContext *C)
+static void DRW_engines_enable_from_mode(int mode)
{
- Scene *scene = CTX_data_scene(C);
- DRW_engines_enable_no_modes(scene);
-
- switch (CTX_data_mode_enum(C)) {
+ switch (mode) {
case CTX_MODE_EDIT_MESH:
use_drw_engine(&draw_engine_edit_mesh_type);
break;
@@ -1794,9 +1793,20 @@ static void DRW_engines_enable(const bContext *C)
break;
case CTX_MODE_OBJECT:
break;
+ default:
+ BLI_assert(0);
+ break;
}
}
+static void DRW_engines_enable(const bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+ const int mode = CTX_data_mode_enum(C);
+ DRW_engines_enable_from_engine(scene);
+ DRW_engines_enable_from_mode(mode);
+}
+
static void DRW_engines_disable(void)
{
BLI_freelistN(&DST.enabled_engines);
@@ -2039,6 +2049,21 @@ void DRW_draw_select_loop(
void *backup_viewport = vc->rv3d->viewport;
rv3d->viewport = NULL;
+ bool use_obedit = false;
+ int obedit_mode = 0;
+ if (vc->obedit && vc->obedit->type == OB_MBALL) {
+ use_obedit = true;
+ DRW_engines_cache_populate(vc->obedit);
+ obedit_mode = CTX_MODE_EDIT_METABALL;
+ }
+ else if ((vc->obedit && vc->obedit->type == OB_ARMATURE)) {
+ /* if not drawing sketch, draw bones */
+ if (!BDR_drawSketchNames(vc)) {
+ use_obedit = true;
+ obedit_mode = CTX_MODE_EDIT_ARMATURE;
+ }
+ }
+
struct GPUViewport *viewport = GPU_viewport_create();
GPU_viewport_size_set(viewport, (const int[2]){BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)});
@@ -2047,7 +2072,12 @@ void DRW_draw_select_loop(
v3d->zbuf = true;
/* Get list of enabled engines */
- DRW_engines_enable_no_modes(scene);
+ if (use_obedit) {
+ DRW_engines_enable_from_mode(obedit_mode);
+ }
+ else {
+ DRW_engines_enable_from_engine(scene);
+ }
/* Setup viewport */
cache_is_dirty = true;
@@ -2069,18 +2099,24 @@ void DRW_draw_select_loop(
/* ideally only refresh when objects are added/removed */
/* or render properties / materials change */
if (cache_is_dirty) {
+
int code = 1;
DRW_engines_cache_init();
- /* TODO, use DEG_OBJECT_ITER or similar.
- * Currently its not well suited for selection
- * since it loops over Objects instead of bases and does so recursively. */
- for (Base *base = sl->object_bases.first; base; base = base->next) {
- base->selcol = code++;
- DRW_select_id_set(base->selcol);
-
- DRW_engines_cache_populate(base->object);
+ if (use_obedit) {
+ DRW_engines_cache_populate(vc->obedit);
+ }
+ else {
+ /* TODO, use DEG_OBJECT_ITER or similar.
+ * Currently its not well suited for selection
+ * since it loops over Objects instead of bases and does so recursively. */
+ for (Base *base = sl->object_bases.first; base; base = base->next) {
+ base->selcol = code++;
+ DRW_select_load_id(base->selcol);
+
+ DRW_engines_cache_populate(base->object);
+ }
}
DRW_engines_cache_finish();