Depsgraph and selection: Flush selcol on Depsgraph
Selection code needs to iterate over DEG_OBJECT_ITER otherwise we won't get modifiers, dupli objects, ... Also make selection respect selectability flag. Review by: Sergey Sharybin
This commit is contained in:
@@ -43,6 +43,7 @@ extern "C" {
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_layer_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
@@ -80,12 +81,14 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
|
||||
}
|
||||
|
||||
/* scene objects */
|
||||
FOREACH_SCENE_OBJECT(scene, ob)
|
||||
{
|
||||
/* object itself */
|
||||
build_object(scene, ob);
|
||||
int selection_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++;
|
||||
}
|
||||
}
|
||||
FOREACH_SCENE_OBJECT_END
|
||||
|
||||
/* rigidbody */
|
||||
if (scene->rigidbody_world) {
|
||||
|
||||
@@ -137,6 +137,7 @@ void DAG_objects_iterator_next(Iterator *iter)
|
||||
/* Flushing depsgraph data. */
|
||||
ob->base_flag = (base->flag | BASE_FROM_SET) & data->flag;
|
||||
ob->base_collection_properties = base->collection_properties;
|
||||
ob->base_selection_color = base->selcol;
|
||||
data->base = base;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2109,23 +2109,21 @@ void DRW_draw_select_loop(
|
||||
/* or render properties / materials change */
|
||||
if (cache_is_dirty) {
|
||||
|
||||
int code = 1;
|
||||
|
||||
DRW_engines_cache_init();
|
||||
|
||||
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);
|
||||
Depsgraph *graph = scene->depsgraph; // CTX_data_depsgraph(C);
|
||||
DEG_OBJECT_ITER(graph, ob)
|
||||
{
|
||||
if ((ob->base_flag & BASE_SELECTABLED) != 0) {
|
||||
DRW_select_load_id(ob->base_selection_color);
|
||||
DRW_engines_cache_populate(ob);
|
||||
}
|
||||
}
|
||||
DEG_OBJECT_ITER_END
|
||||
}
|
||||
|
||||
DRW_engines_cache_finish();
|
||||
|
||||
@@ -306,6 +306,8 @@ typedef struct Object {
|
||||
struct IDProperty *base_collection_properties; /* used by depsgraph, flushed from base */
|
||||
|
||||
ListBase drawdata; /* runtime, for draw engine datas */
|
||||
int base_selection_color; /* flushed by depsgraph only */
|
||||
int pad3[3];
|
||||
} Object;
|
||||
|
||||
/* Warning, this is not used anymore because hooks are now modifiers */
|
||||
|
||||
Reference in New Issue
Block a user