forked from blender/blender
Implement instancing for light objects #35
@ -320,8 +320,10 @@ void BlenderSceneDelegate::update_instancers(Object *object)
|
||||
if (view3d && !BKE_object_is_visible_in_viewport(view3d, object)) {
|
||||
return;
|
||||
}
|
||||
instancers_[id] = InstancerData::create(this, object, id);
|
||||
instancers_[id] = std::make_unique<InstancerData>(this, object, id);
|
||||
i_data = instancer_data(id);
|
||||
i_data->init();
|
||||
i_data->insert();
|
||||
i_data->update_visibility();
|
||||
}
|
||||
|
||||
@ -330,7 +332,9 @@ void BlenderSceneDelegate::update_world()
|
||||
World *world = scene->world;
|
||||
if (!world_data_) {
|
||||
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 {
|
||||
|
@ -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)
|
||||
{
|
||||
switch (object->type) {
|
||||
|
@ -24,10 +24,6 @@ class InstancerData : public ObjectData {
|
||||
|
||||
public:
|
||||
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);
|
||||
|
||||
void init() override;
|
||||
|
@ -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()
|
||||
{
|
||||
ID_LOG(2, "");
|
||||
|
@ -19,10 +19,6 @@ class MaterialData : public IdData {
|
||||
Material *material,
|
||||
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 insert() override;
|
||||
void remove() override;
|
||||
|
@ -17,7 +17,7 @@ namespace blender::render::hydra {
|
||||
MeshData::MeshData(BlenderSceneDelegate *scene_delegate,
|
||||
Object *object,
|
||||
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);
|
||||
mat_data_ = scene_delegate_->material_data(p_id);
|
||||
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_->init();
|
||||
mat_data_->insert();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,6 @@ class MeshData : public ObjectData {
|
||||
pxr::VtVec3fArray normals_;
|
||||
|
||||
MaterialData *mat_data_ = nullptr;
|
||||
Object *parent_;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -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()
|
||||
{
|
||||
ID_LOG(2, "");
|
||||
|
@ -22,10 +22,6 @@ class WorldData : public IdData {
|
||||
public:
|
||||
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 insert() override;
|
||||
void remove() override;
|
||||
|
Loading…
Reference in New Issue
Block a user