forked from blender/blender
BLEN-359: Implement updates for instances in viewport #20
@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2011-2022 Blender Foundation */
|
||||
|
||||
#include <bitset>
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
@ -22,14 +24,6 @@ BlenderSceneDelegate::BlenderSceneDelegate(pxr::HdRenderIndex *parent_index,
|
||||
{
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::update_material(Material *material)
|
||||
{
|
||||
MaterialData *mat_data = material_data(MaterialData::prim_id(this, material));
|
||||
if (mat_data) {
|
||||
mat_data->update();
|
||||
}
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::update_world()
|
||||
{
|
||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||
@ -154,7 +148,7 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
||||
}
|
||||
|
||||
if (!object_data(id)) {
|
||||
add_update_object(object, true, true, true);
|
||||
add_update_object(object);
|
||||
}
|
||||
}
|
||||
ITER_END;
|
||||
@ -193,10 +187,7 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
||||
}
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::add_update_object(Object *object,
|
||||
bool geometry,
|
||||
bool transform,
|
||||
bool shading)
|
||||
void BlenderSceneDelegate::add_update_object(Object *object)
|
||||
{
|
||||
pxr::SdfPath id = ObjectData::prim_id(this, object);
|
||||
ObjectData *obj_data = object_data(id);
|
||||
@ -214,7 +205,7 @@ void BlenderSceneDelegate::add_update_instance(DupliObject *dupli)
|
||||
{
|
||||
pxr::SdfPath id = ObjectData::prim_id(this, dupli->ob);
|
||||
if (!object_data(id)) {
|
||||
add_update_object(dupli->ob, true, true, true);
|
||||
add_update_object(dupli->ob);
|
||||
}
|
||||
|
||||
MeshData *m_data = mesh_data(id);
|
||||
@ -269,7 +260,6 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
bool do_update_collection = false;
|
||||
bool do_update_visibility = false;
|
||||
bool do_update_world = false;
|
||||
bool transform, geometry, shading;
|
||||
|
||||
DEGIDIterData data = {0};
|
||||
data.graph = depsgraph;
|
||||
@ -277,11 +267,7 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
ITER_BEGIN (
|
||||
DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id) {
|
||||
|
||||
transform = (id->recalc & ID_RECALC_TRANSFORM) != 0;
|
||||
shading = (id->recalc & (ID_RECALC_SHADING | ID_RECALC_ANIMATION)) != 0;
|
||||
geometry = (id->recalc & ID_RECALC_GEOMETRY) != 0;
|
||||
|
||||
CLOG_INFO(LOG_BSD, 1, "Update: %s [%d%d%d]", id->name, transform, geometry, shading);
|
||||
CLOG_INFO(LOG_BSD, 2, "Update: %s [%s]", id->name, std::bitset<32>(id->recalc).to_string().c_str());
|
||||
|
||||
switch (GS(id->name)) {
|
||||
case ID_OB: {
|
||||
@ -289,39 +275,42 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
if (!ObjectData::supported(object)) {
|
||||
break;
|
||||
}
|
||||
geometry |= (((ID *)object->data)->recalc & ID_RECALC_GEOMETRY) != 0;
|
||||
add_update_object(object, geometry, transform, shading);
|
||||
add_update_object(object);
|
||||
} break;
|
||||
|
||||
case ID_MA:
|
||||
if (shading) {
|
||||
Material *material = (Material *)id;
|
||||
update_material(material);
|
||||
case ID_MA: {
|
||||
MaterialData *mat_data = material_data(MaterialData::prim_id(this, (Material *)id));
|
||||
if (mat_data) {
|
||||
mat_data->update();
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
|
||||
case ID_GR:
|
||||
if (transform && geometry) {
|
||||
//case ID_GR:
|
||||
// if (id->recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY)) {
|
||||
// do_update_collection = true;
|
||||
// }
|
||||
// break;
|
||||
|
||||
case ID_SCE: {
|
||||
if (id->recalc & ID_RECALC_BASE_FLAGS) {
|
||||
do_update_visibility = true;
|
||||
}
|
||||
if (id->recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY)) {
|
||||
do_update_collection = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_SCE:
|
||||
if (!geometry && !transform && !shading) {
|
||||
if (id->recalc & ID_RECALC_AUDIO_VOLUME) {
|
||||
Scene *scene = (Scene *)id;
|
||||
do_update_visibility = true;
|
||||
|
||||
if ((scene->world && !world_data) || (!scene->world && world_data)) {
|
||||
do_update_world = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
|
||||
case ID_WO:
|
||||
if (shading) {
|
||||
case ID_WO: {
|
||||
if (id->recalc & ID_RECALC_SHADING) {
|
||||
do_update_world = true;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -61,9 +61,8 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
LightData *light_data(pxr::SdfPath const &id);
|
||||
MaterialData *material_data(pxr::SdfPath const &id);
|
||||
|
||||
void add_update_object(Object *object, bool geometry, bool transform, bool shading);
|
||||
void add_update_object(Object *object);
|
||||
void add_update_instance(DupliObject *dupli);
|
||||
void update_material(Material *material);
|
||||
void update_world();
|
||||
void update_collection(bool remove, bool visibility);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user