Remove selection color from the base

Use indirect access to it via object.

It was already flushing from base to object, now we can avoid such flushing.

Still weird to have selection color filled in by dependency graph, but now
there is no synchronization going on at least.
This commit is contained in:
2017-06-07 17:35:23 +02:00
parent d675415eef
commit 23c93873f4
11 changed files with 26 additions and 27 deletions

View File

@@ -81,12 +81,12 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
}
/* scene objects */
int selection_color = 1;
int select_color = 1;
for (SceneLayer *sl = (SceneLayer *)scene->render_layers.first; sl; sl = sl->next) {
for (Base *base = (Base *)sl->object_bases.first; base; base = base->next) {
/* object itself */
build_object(scene, base->object);
base->selcol = selection_color++;
base->object->select_color = select_color++;
}
}

View File

@@ -135,7 +135,6 @@ static void deg_flush_base_flags_and_settings(Object *ob, Base *base, const int
{
ob->base_flag = (base->flag | BASE_FLUSH_FLAGS) & flag;
ob->base_collection_properties = base->collection_properties;
ob->base_selection_color = base->selcol;
}
static bool deg_objects_dupli_iterator_next(BLI_Iterator *iter)

View File

@@ -1297,7 +1297,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
}
if (arm->flag & ARM_POSEMODE) {
index = ob->base_selection_color;
index = ob->select_color;
}
}

View File

@@ -3052,7 +3052,7 @@ void DRW_draw_select_loop(
DEG_OBJECT_ITER(graph, ob, DEG_OBJECT_ITER_FLAG_DUPLI)
{
if ((ob->base_flag & BASE_SELECTABLED) != 0) {
DRW_select_load_id(ob->base_selection_color);
DRW_select_load_id(ob->select_color);
DRW_engines_cache_populate(ob);
}
}

View File

@@ -98,7 +98,7 @@ void *get_bone_from_selectbuffer(
/* Determine what the current bone is */
if (obedit == NULL || base->object != obedit) {
/* no singular posemode, so check for correct object */
if (base->selcol == (hitresult & 0xFFFF)) {
if (base->object->select_color == (hitresult & 0xFFFF)) {
bone = get_indexed_bone(base->object, hitresult);
if (findunsel)

View File

@@ -2001,7 +2001,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
/* if solid we draw that first, with selection codes, but without names, axes etc */
if (dt > OB_WIRE) {
if (arm->flag & ARM_POSEMODE)
index = base->selcol;
index = base->object->select_color;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bone = pchan->bone;
@@ -2104,7 +2104,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
(draw_wire || (dt <= OB_WIRE)) )
{
if (arm->flag & ARM_POSEMODE)
index = base->selcol;
index = base->object->select_color;
/* only draw custom bone shapes that need to be drawn as wires */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -2175,7 +2175,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
/* draw line check first. we do selection indices */
if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
if (arm->flag & ARM_POSEMODE)
index = base->selcol;
index = base->object->select_color;
}
/* if solid && posemode, we draw again with polygonoffset */
else if ((dt > OB_WIRE) && (arm->flag & ARM_POSEMODE)) {
@@ -2184,7 +2184,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
else {
/* and we use selection indices if not done yet */
if (arm->flag & ARM_POSEMODE)
index = base->selcol;
index = base->object->select_color;
}
if (is_cull_enabled == false) {

View File

@@ -1727,7 +1727,7 @@ static void draw_viewport_object_reconstruction(
continue;
if (dflag & DRAW_PICKING)
GPU_select_load_id(base->selcol + (tracknr << 16));
GPU_select_load_id(base->object->select_color + (tracknr << 16));
gpuPushMatrix();
gpuTranslate3fv(track->bundle_pos);
@@ -1889,7 +1889,7 @@ static void draw_viewport_reconstruction(
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
if (dflag & DRAW_PICKING)
GPU_select_load_id(base->selcol);
GPU_select_load_id(base->object->select_color);
}
/* camera frame */

View File

@@ -914,7 +914,7 @@ static void view3d_draw_xray_select(Scene *scene, SceneLayer *sl, ARegion *ar, V
v3d->xray = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
if (GPU_select_load_id(v3da->base->selcol)) {
if (GPU_select_load_id(v3da->base->object->select_color)) {
draw_object_select(scene, sl, ar, v3d, v3da->base, v3da->dflag);
}
MEM_freeN(v3da);
@@ -1301,10 +1301,10 @@ void ED_view3d_draw_select_loop(
if (((base->flag & BASE_SELECTABLED) == 0) ||
(use_obedit_skip && (scene->obedit->data == base->object->data)))
{
base->selcol = 0;
base->object->select_color = 0;
}
else {
base->selcol = code;
base->object->select_color = code;
if (use_nearest && (base->object->dtx & OB_DRAWXRAY)) {
ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);

View File

@@ -906,7 +906,7 @@ static unsigned int samplerect(unsigned int *buf, int size, unsigned int dontdo)
base = LASTBASE;
if (base == 0) return 0;
maxob = base->selcol;
maxob = base->object->select_color;
len = (size - 1) / 2;
rc = 0;
@@ -1068,7 +1068,7 @@ static Base *object_mouse_select_menu(
bool ok;
LinkNode *linklist = NULL;
/* handle base->selcol */
/* handle base->object->select_color */
CTX_DATA_BEGIN (C, Base *, base, selectable_bases)
{
ok = false;
@@ -1077,7 +1077,7 @@ static Base *object_mouse_select_menu(
if (buffer) {
for (int a = 0; a < hits; a++) {
/* index was converted */
if (base->selcol == (buffer[(4 * a) + 3] & ~0xFFFF0000)) {
if (base->object->select_color == (buffer[(4 * a) + 3] & ~0xFFFF0000)) {
ok = true;
break;
}
@@ -1286,7 +1286,9 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
}
else {
/* only exclude active object when it is selected... */
if (BASACT_NEW && (BASACT_NEW->flag & BASE_SELECTED) && hits > 1) notcol = BASACT_NEW->selcol;
if (BASACT_NEW && (BASACT_NEW->flag & BASE_SELECTED) && hits > 1) {
notcol = BASACT_NEW->object->select_color;
}
for (a = 0; a < hits; a++) {
if (min > buffer[4 * a + 1] && notcol != (buffer[4 * a + 3] & 0xFFFF)) {
@@ -1299,7 +1301,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
base = FIRSTBASE_NEW;
while (base) {
if (BASE_SELECTABLE_NEW(base)) {
if (base->selcol == selcol) break;
if (base->object->select_color == selcol) break;
}
base = base->next;
}
@@ -1322,12 +1324,12 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
if (has_bones) {
/* skip non-bone objects */
if ((buffer[4 * a + 3] & 0xFFFF0000)) {
if (base->selcol == (buffer[(4 * a) + 3] & 0xFFFF))
if (base->object->select_color == (buffer[(4 * a) + 3] & 0xFFFF))
basact = base;
}
}
else {
if (base->selcol == (buffer[(4 * a) + 3] & 0xFFFF))
if (base->object->select_color == (buffer[(4 * a) + 3] & 0xFFFF))
basact = base;
}
}
@@ -1481,7 +1483,7 @@ static bool ed_object_select_pick(
/* if there's bundles in buffer select bundles first,
* so non-camera elements should be ignored in buffer */
if (basact->selcol != (hitresult & 0xFFFF)) {
if (basact->object->select_color != (hitresult & 0xFFFF)) {
continue;
}
@@ -2071,7 +2073,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
*/
for (base = vc->scene_layer->object_bases.first; base && hits; base = base->next) {
if (BASE_SELECTABLE_NEW(base)) {
while (base->selcol == (*col & 0xFFFF)) { /* we got an object */
while (base->object->select_color == (*col & 0xFFFF)) { /* we got an object */
if (*col & 0xFFFF0000) { /* we got a bone */
bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY));
if (bone) {

View File

@@ -39,10 +39,8 @@ typedef struct Base {
short refcount;
short sx, sy;
struct Object *object;
unsigned int selcol;
unsigned int lay;
int flag_legacy;
int pad;
struct IDProperty *collection_properties; /* used by depsgraph, flushed from collection-tree */
} Base;

View File

@@ -325,7 +325,7 @@ typedef struct Object {
ListBase drawdata; /* runtime, ObjectEngineData */
int deg_update_flag; /* what has been updated in this object */
int base_selection_color; /* flushed by depsgraph only */
int select_color;
int pad3[2];
} Object;