forked from blender/blender
Code improvements and fixes #26
@ -39,6 +39,8 @@ class Engine {
|
||||
RenderEngine *bl_engine_;
|
||||
|
||||
/* The order is important due to deletion order */
|
||||
pxr::HgiUniquePtr hgi_;
|
||||
pxr::HdDriver hgi_driver_;
|
||||
pxr::HdPluginRenderDelegateUniqueHandle render_delegate_;
|
||||
std::unique_ptr<pxr::HdRenderIndex> render_index_;
|
||||
std::unique_ptr<BlenderSceneDelegate> scene_delegate_;
|
||||
@ -47,8 +49,6 @@ class Engine {
|
||||
std::unique_ptr<SimpleLightTaskDelegate> simple_light_task_delegate_;
|
||||
std::unique_ptr<pxr::HdEngine> engine_;
|
||||
|
||||
pxr::HgiUniquePtr hgi_;
|
||||
pxr::HdDriver hgi_driver_;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -272,7 +272,7 @@ void BlenderSceneDelegate::update_objects(Object *object)
|
||||
}
|
||||
objects_[id] = ObjectData::create(this, object, id);
|
||||
obj_data = object_data(id);
|
||||
obj_data->update_visibility(view3d_);
|
||||
obj_data->update_visibility();
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::update_instancers(Object *object)
|
||||
@ -302,7 +302,7 @@ void BlenderSceneDelegate::update_instancers(Object *object)
|
||||
}
|
||||
instancers_[id] = InstancerData::create(this, object, id);
|
||||
i_data = instancer_data(id);
|
||||
i_data->update_visibility(view3d_);
|
||||
i_data->update_visibility();
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::update_world()
|
||||
@ -503,10 +503,10 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
void BlenderSceneDelegate::update_visibility()
|
||||
{
|
||||
for (auto &it : objects_) {
|
||||
it.second->update_visibility(view3d_);
|
||||
it.second->update_visibility();
|
||||
}
|
||||
for (auto &it : instancers_) {
|
||||
it.second->update_visibility(view3d_);
|
||||
it.second->update_visibility();
|
||||
}
|
||||
|
||||
/* Add objects which were invisible before and not added yet */
|
||||
|
@ -22,7 +22,6 @@ extern struct CLG_LogRef *LOG_BSD; /* BSD - Blender Scene Delegate */
|
||||
|
||||
class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
friend MeshData;
|
||||
friend InstancerData;
|
||||
|
||||
public:
|
||||
enum class EngineType { VIEWPORT = 1, FINAL, PREVIEW };
|
||||
|
@ -101,13 +101,9 @@ pxr::GfMatrix4d InstancerData::transform()
|
||||
return pxr::GfMatrix4d(1.0);
|
||||
}
|
||||
|
||||
bool InstancerData::update_visibility(View3D *view3d)
|
||||
bool InstancerData::update_visibility()
|
||||
{
|
||||
if (!view3d) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = ObjectData::update_visibility(view3d);
|
||||
bool ret = ObjectData::update_visibility();
|
||||
if (ret) {
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(
|
||||
p_id_, pxr::HdChangeTracker::DirtyVisibility);
|
||||
|
@ -32,7 +32,7 @@ class InstancerData : public ObjectData {
|
||||
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
pxr::GfMatrix4d transform() override;
|
||||
bool update_visibility(View3D *view3d) override;
|
||||
bool update_visibility() override;
|
||||
|
||||
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation);
|
||||
pxr::VtIntArray indices(pxr::SdfPath const &id);
|
||||
|
@ -142,9 +142,9 @@ pxr::VtValue LightData::get_data(pxr::TfToken const &key) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool LightData::update_visibility(View3D *view3d)
|
||||
bool LightData::update_visibility()
|
||||
{
|
||||
bool ret = ObjectData::update_visibility(view3d);
|
||||
bool ret = ObjectData::update_visibility();
|
||||
if (ret) {
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id_,
|
||||
pxr::HdLight::DirtyParams);
|
||||
|
@ -23,7 +23,7 @@ class LightData : public ObjectData {
|
||||
void update() override;
|
||||
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
bool update_visibility(View3D *view3d) override;
|
||||
bool update_visibility() override;
|
||||
|
||||
private:
|
||||
pxr::TfToken prim_type(Light *light);
|
||||
|
@ -117,9 +117,9 @@ pxr::VtValue MeshData::get_data(pxr::TfToken const &key) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MeshData::update_visibility(View3D *view3d)
|
||||
bool MeshData::update_visibility()
|
||||
{
|
||||
bool ret = ObjectData::update_visibility(view3d);
|
||||
bool ret = ObjectData::update_visibility();
|
||||
if (ret) {
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkRprimDirty(
|
||||
p_id_, pxr::HdChangeTracker::DirtyVisibility);
|
||||
|
@ -23,7 +23,7 @@ class MeshData : public ObjectData {
|
||||
void update() override;
|
||||
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
bool update_visibility(View3D *view3d) override;
|
||||
bool update_visibility() override;
|
||||
|
||||
pxr::HdMeshTopology mesh_topology();
|
||||
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation);
|
||||
|
@ -69,14 +69,14 @@ pxr::GfMatrix4d ObjectData::transform()
|
||||
return gf_matrix_from_transform(((Object *)id_)->object_to_world);
|
||||
}
|
||||
|
||||
bool ObjectData::update_visibility(View3D *view3d)
|
||||
bool ObjectData::update_visibility()
|
||||
{
|
||||
if (!view3d) {
|
||||
if (!scene_delegate_->view3d_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool prev_visible = visible;
|
||||
visible = BKE_object_is_visible_in_viewport(view3d, (Object *)id_);
|
||||
visible = BKE_object_is_visible_in_viewport(scene_delegate_->view3d_, (Object *)id_);
|
||||
bool ret = visible != prev_visible;
|
||||
if (ret) {
|
||||
ID_LOG(2, "");
|
||||
|
@ -24,7 +24,7 @@ class ObjectData : public IdData {
|
||||
static bool is_supported(Object *object);
|
||||
|
||||
virtual pxr::GfMatrix4d transform();
|
||||
virtual bool update_visibility(View3D *view3d);
|
||||
virtual bool update_visibility();
|
||||
|
||||
bool visible;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user