Implement instancing for light objects #35

Merged
Bogdan Nagirniak merged 18 commits from BLEN-395 into hydra-render 2023-05-04 15:12:27 +02:00
9 changed files with 10 additions and 47 deletions
Showing only changes of commit 3b1a8d1499 - Show all commits

View File

@ -320,8 +320,10 @@ void BlenderSceneDelegate::update_instancers(Object *object)
if (view3d && !BKE_object_is_visible_in_viewport(view3d, object)) { if (view3d && !BKE_object_is_visible_in_viewport(view3d, object)) {
return; return;
} }
instancers_[id] = InstancerData::create(this, object, id); instancers_[id] = std::make_unique<InstancerData>(this, object, id);
i_data = instancer_data(id); i_data = instancer_data(id);
i_data->init();
i_data->insert();
i_data->update_visibility(); i_data->update_visibility();
} }
@ -330,7 +332,9 @@ void BlenderSceneDelegate::update_world()
World *world = scene->world; World *world = scene->world;
if (!world_data_) { if (!world_data_) {
if (world) { if (world) {
world_data_ = WorldData::create(this, world, world_prim_id()); world_data_ = std::make_unique<WorldData>(this, world, world_prim_id());
world_data_->init();
world_data_->insert();
} }
} }
else { else {

View File

@ -16,16 +16,6 @@ InstancerData::InstancerData(BlenderSceneDelegate *scene_delegate,
{ {
} }
std::unique_ptr<InstancerData> InstancerData::create(BlenderSceneDelegate *scene_delegate,
Object *object,
pxr::SdfPath const &prim_id)
{
auto data = std::make_unique<InstancerData>(scene_delegate, object, prim_id);
data->init();
data->insert();
return data;
}
bool InstancerData::is_supported(Object *object) bool InstancerData::is_supported(Object *object)
{ {
switch (object->type) { switch (object->type) {

View File

@ -24,10 +24,6 @@ class InstancerData : public ObjectData {
public: public:
InstancerData(BlenderSceneDelegate *scene_delegate, Object *object, pxr::SdfPath const &prim_id); InstancerData(BlenderSceneDelegate *scene_delegate, Object *object, pxr::SdfPath const &prim_id);
static std::unique_ptr<InstancerData> create(BlenderSceneDelegate *scene_delegate,
Object *object,
pxr::SdfPath const &prim_id);
static bool is_supported(Object *object); static bool is_supported(Object *object);
void init() override; void init() override;

View File

@ -27,16 +27,6 @@ MaterialData::MaterialData(BlenderSceneDelegate *scene_delegate,
{ {
} }
std::unique_ptr<MaterialData> MaterialData::create(BlenderSceneDelegate *scene_delegate,
Material *material,
pxr::SdfPath const &prim_id)
{
auto data = std::make_unique<MaterialData>(scene_delegate, material, prim_id);
data->init();
data->insert();
return data;
}
void MaterialData::init() void MaterialData::init()
{ {
ID_LOG(2, ""); ID_LOG(2, "");

View File

@ -19,10 +19,6 @@ class MaterialData : public IdData {
Material *material, Material *material,
pxr::SdfPath const &prim_id); pxr::SdfPath const &prim_id);
static std::unique_ptr<MaterialData> create(BlenderSceneDelegate *scene_delegate,
Material *material,
pxr::SdfPath const &prim_id);
void init() override; void init() override;
void insert() override; void insert() override;
void remove() override; void remove() override;

View File

@ -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), parent_(object->parent) : ObjectData(scene_delegate, object, prim_id)
{ {
} }
@ -218,8 +218,10 @@ void MeshData::write_material()
pxr::SdfPath p_id = scene_delegate_->material_prim_id(mat); pxr::SdfPath p_id = scene_delegate_->material_prim_id(mat);
mat_data_ = scene_delegate_->material_data(p_id); mat_data_ = scene_delegate_->material_data(p_id);
if (!mat_data_) { if (!mat_data_) {
scene_delegate_->materials_[p_id] = MaterialData::create(scene_delegate_, mat, p_id); scene_delegate_->materials_[p_id] = std::make_unique<MaterialData>(scene_delegate_, mat, p_id);
mat_data_ = scene_delegate_->material_data(p_id); mat_data_ = scene_delegate_->material_data(p_id);
mat_data_->init();
mat_data_->insert();
} }
} }

View File

@ -42,7 +42,6 @@ class MeshData : public ObjectData {
pxr::VtVec3fArray normals_; pxr::VtVec3fArray normals_;
MaterialData *mat_data_ = nullptr; MaterialData *mat_data_ = nullptr;
Object *parent_;
}; };
} // namespace blender::render::hydra } // namespace blender::render::hydra

View File

@ -34,16 +34,6 @@ WorldData::WorldData(BlenderSceneDelegate *scene_delegate,
{ {
} }
std::unique_ptr<WorldData> WorldData::create(BlenderSceneDelegate *scene_delegate,
World *world,
pxr::SdfPath const &prim_id)
{
auto data = std::make_unique<WorldData>(scene_delegate, world, prim_id);
data->init();
data->insert();
return data;
}
void WorldData::init() void WorldData::init()
{ {
ID_LOG(2, ""); ID_LOG(2, "");

View File

@ -22,10 +22,6 @@ class WorldData : public IdData {
public: public:
WorldData(BlenderSceneDelegate *scene_delegate, World *world, pxr::SdfPath const &prim_id); WorldData(BlenderSceneDelegate *scene_delegate, World *world, pxr::SdfPath const &prim_id);
static std::unique_ptr<WorldData> create(BlenderSceneDelegate *scene_delegate,
World *world,
pxr::SdfPath const &prim_id);
void init() override; void init() override;
void insert() override; void insert() override;
void remove() override; void remove() override;