forked from blender/blender
Support several instancers on one object #24
@ -9,7 +9,7 @@
|
||||
namespace blender::render::hydra {
|
||||
|
||||
IdData::IdData(BlenderSceneDelegate *scene_delegate, ID *id)
|
||||
: scene_delegate(scene_delegate), id(id)
|
||||
: id(id), scene_delegate(scene_delegate)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,9 @@ void InstancerData::init()
|
||||
{
|
||||
ID_LOG(2, "");
|
||||
set_instances();
|
||||
for (auto &it : instances) {
|
||||
it.second.obj_data->init();
|
||||
}
|
||||
}
|
||||
|
||||
pxr::GfMatrix4d InstancerData::transform()
|
||||
@ -131,8 +134,10 @@ void InstancerData::set_instances()
|
||||
auto it = instances.find(path);
|
||||
if (it == instances.end()) {
|
||||
inst = &instances[path];
|
||||
inst->obj_data = ObjectData::create(scene_delegate, dupli->ob);
|
||||
inst->obj_data->p_id = path;
|
||||
if (!supported(dupli->ob)) {
|
||||
continue;
|
||||
}
|
||||
inst->obj_data = std::make_unique<InstanceMeshData>(scene_delegate, dupli->ob, path);
|
||||
}
|
||||
else {
|
||||
inst = &it->second;
|
||||
@ -183,4 +188,17 @@ void InstancerData::update()
|
||||
}
|
||||
}
|
||||
|
||||
InstanceMeshData::InstanceMeshData(BlenderSceneDelegate *scene_delegate,
|
||||
Object *object,
|
||||
pxr::SdfPath const &p_id)
|
||||
: MeshData(scene_delegate, object)
|
||||
{
|
||||
this->p_id = p_id;
|
||||
}
|
||||
|
||||
pxr::GfMatrix4d InstanceMeshData::transform()
|
||||
{
|
||||
return pxr::GfMatrix4d(1.0);
|
||||
}
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "BKE_duplilist.h"
|
||||
|
||||
#include "object.h"
|
||||
#include "mesh.h"
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
@ -43,4 +43,10 @@ class InstancerData : public ObjectData {
|
||||
pxr::VtMatrix4dArray transforms;
|
||||
};
|
||||
|
||||
class InstanceMeshData : public MeshData {
|
||||
public:
|
||||
InstanceMeshData(BlenderSceneDelegate *scene_delegate, Object *object, pxr::SdfPath const &p_id);
|
||||
pxr::GfMatrix4d transform() override;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
Loading…
Reference in New Issue
Block a user