forked from blender/blender
Fix instances update when parent object is changed #33
@ -17,7 +17,7 @@ namespace blender::render::hydra {
|
|||||||
MeshData::MeshData(BlenderSceneDelegate *scene_delegate,
|
MeshData::MeshData(BlenderSceneDelegate *scene_delegate,
|
||||||
Object *object,
|
Object *object,
|
||||||
pxr::SdfPath const &prim_id)
|
pxr::SdfPath const &prim_id)
|
||||||
: ObjectData(scene_delegate, object, prim_id)
|
: ObjectData(scene_delegate, object, prim_id), parent_(object->parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,13 +67,15 @@ void MeshData::update()
|
|||||||
{
|
{
|
||||||
Object *object = (Object *)id;
|
Object *object = (Object *)id;
|
||||||
if (parent_ != object->parent) {
|
if (parent_ != object->parent) {
|
||||||
/* parent was changed */
|
|
||||||
parent_ = object->parent;
|
parent_ = object->parent;
|
||||||
if (parent_) {
|
|
||||||
pxr::SdfPath i_id = scene_delegate_->instancer_prim_id(parent_);
|
/* Looking for corresponded instancer and update it as parent */
|
||||||
|
for (Object *ob = parent_; ob != nullptr; ob = ob->parent) {
|
||||||
|
pxr::SdfPath i_id = scene_delegate_->instancer_prim_id(ob);
|
||||||
InstancerData *i_data = scene_delegate_->instancer_data(i_id);
|
InstancerData *i_data = scene_delegate_->instancer_data(i_id);
|
||||||
if (i_data) {
|
if (i_data) {
|
||||||
i_data->update_as_parent();
|
i_data->update_as_parent();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class MeshData : public ObjectData {
|
|||||||
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const;
|
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const;
|
||||||
pxr::SdfPath material_id() const;
|
pxr::SdfPath material_id() const;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void write_mesh(Mesh *mesh);
|
void write_mesh(Mesh *mesh);
|
||||||
void write_material();
|
void write_material();
|
||||||
void write_uv_maps(Mesh *mesh);
|
void write_uv_maps(Mesh *mesh);
|
||||||
@ -43,6 +43,7 @@ class MeshData : public ObjectData {
|
|||||||
pxr::VtMatrix4dArray instances_;
|
pxr::VtMatrix4dArray instances_;
|
||||||
|
|
||||||
MaterialData *mat_data_ = nullptr;
|
MaterialData *mat_data_ = nullptr;
|
||||||
|
Object *parent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
@ -13,10 +13,7 @@ namespace blender::render::hydra {
|
|||||||
ObjectData::ObjectData(BlenderSceneDelegate *scene_delegate,
|
ObjectData::ObjectData(BlenderSceneDelegate *scene_delegate,
|
||||||
Object *object,
|
Object *object,
|
||||||
pxr::SdfPath const &prim_id)
|
pxr::SdfPath const &prim_id)
|
||||||
: IdData(scene_delegate, (ID *)object, prim_id),
|
: IdData(scene_delegate, (ID *)object, prim_id), transform(pxr::GfMatrix4d(1.0)), visible(true)
|
||||||
transform(pxr::GfMatrix4d(1.0)),
|
|
||||||
visible(true),
|
|
||||||
parent_(object->parent)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,7 @@ class ObjectData : public IdData {
|
|||||||
bool visible;
|
bool visible;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void write_transform();
|
void write_transform();
|
||||||
|
|
||||||
Object *parent_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using ObjectDataMap =
|
using ObjectDataMap =
|
||||||
|
Loading…
Reference in New Issue
Block a user