Fix instances update when parent object is changed #33

Merged
Bogdan Nagirniak merged 3 commits from BLEN-394 into hydra-render 2023-05-03 21:18:52 +02:00
3 changed files with 7 additions and 13 deletions
Showing only changes of commit 73aff3e5e0 - Show all commits

View File

@ -307,15 +307,6 @@ void BlenderSceneDelegate::update_instancers(Object *object)
i_data->update_visibility();
}
void BlenderSceneDelegate::update_instancer_as_parent(Object *object)
{
pxr::SdfPath id = instancer_prim_id(object);
InstancerData *i_data = instancer_data(id);
if (i_data) {
i_data->update_as_parent();
}
}
void BlenderSceneDelegate::update_world()
{
World *world = scene->world;

View File

@ -21,7 +21,7 @@ namespace blender::render::hydra {
extern struct CLG_LogRef *LOG_RENDER_HYDRA_SCENE; /* BSD - Blender Scene Delegate */
class BlenderSceneDelegate : public pxr::HdSceneDelegate {
friend MeshData; /* has access to materials_*/
friend MeshData; /* has access to materials and instances */
public:
enum class EngineType { VIEWPORT = 1, FINAL, PREVIEW };
@ -74,7 +74,6 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
void update_objects(Object *object);
void update_instancers(Object *object);
void update_instancer_as_parent(Object *object);
void update_world();
void check_updates();
void add_new_objects();

View File

@ -66,11 +66,15 @@ void MeshData::remove()
void MeshData::update()
{
Object *object = (Object *)id;
if ((id->recalc & ID_RECALC_TRANSFORM) && parent_ != object->parent) {
if (parent_ != object->parent) {
/* parent was changed */
parent_ = object->parent;
if (parent_) {
scene_delegate_->update_instancer_as_parent(parent_);
pxr::SdfPath i_id = scene_delegate_->instancer_prim_id(parent_);
InstancerData *i_data = scene_delegate_->instancer_data(i_id);
if (i_data) {
i_data->update_as_parent();
}
}
}