forked from blender/blender
Support several instancers on one object #24
@ -55,9 +55,6 @@ bool BlenderSceneDelegate::GetVisible(pxr::SdfPath const &id)
|
|||||||
pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id)
|
pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id)
|
||||||
{
|
{
|
||||||
CLOG_INFO(LOG_BSD, 3, "%s", prim_id.GetText());
|
CLOG_INFO(LOG_BSD, 3, "%s", prim_id.GetText());
|
||||||
if (prim_id.GetParentPath() == GetDelegateID()) {
|
|
||||||
return pxr::SdfPath();
|
|
||||||
}
|
|
||||||
InstancerData *i_data = instancer_data(prim_id.GetParentPath());
|
InstancerData *i_data = instancer_data(prim_id.GetParentPath());
|
||||||
if (i_data) {
|
if (i_data) {
|
||||||
return i_data->p_id;
|
return i_data->p_id;
|
||||||
@ -69,7 +66,8 @@ pxr::SdfPathVector BlenderSceneDelegate::GetInstancerPrototypes(pxr::SdfPath con
|
|||||||
{
|
{
|
||||||
CLOG_INFO(LOG_BSD, 3, "%s", instancer_id.GetText());
|
CLOG_INFO(LOG_BSD, 3, "%s", instancer_id.GetText());
|
||||||
pxr::SdfPathVector paths;
|
pxr::SdfPathVector paths;
|
||||||
paths.push_back(instancer_id.GetParentPath());
|
InstancerData *i_data = instancer_data(instancer_id);
|
||||||
|
paths.push_back(i_data->m_data->p_id);
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,24 +194,29 @@ void BlenderSceneDelegate::add_update_object(Object *object)
|
|||||||
void BlenderSceneDelegate::add_update_instancer(Object *object)
|
void BlenderSceneDelegate::add_update_instancer(Object *object)
|
||||||
{
|
{
|
||||||
pxr::SdfPath id = InstancerData::prim_id(this, object);
|
pxr::SdfPath id = InstancerData::prim_id(this, object);
|
||||||
InstancerData *i_data = instancer_data(id, true);
|
InstancerData *i_data = instancer_data(id);
|
||||||
if (i_data) {
|
if (i_data) {
|
||||||
i_data->update();
|
i_data->update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
objects[id] = InstancerData::create(this, object);
|
objects[id] = InstancerData::create(this, object);
|
||||||
i_data = instancer_data(id, true);
|
i_data = instancer_data(id);
|
||||||
i_data->update_visibility(view3d);
|
i_data->update_visibility(view3d);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id)
|
ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id)
|
||||||
{
|
{
|
||||||
auto it = objects.find(id);
|
auto it = objects.find(id);
|
||||||
if (it == objects.end()) {
|
if (it != objects.end()) {
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return it->second.get();
|
return it->second.get();
|
||||||
}
|
}
|
||||||
|
it = objects.find(id.GetParentPath());
|
||||||
|
if (it != objects.end()) {
|
||||||
|
InstancerData *i_data = (InstancerData *)it->second.get();
|
||||||
|
return i_data->m_data.get();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
MeshData *BlenderSceneDelegate::mesh_data(pxr::SdfPath const &id)
|
MeshData *BlenderSceneDelegate::mesh_data(pxr::SdfPath const &id)
|
||||||
{
|
{
|
||||||
@ -234,13 +237,10 @@ MaterialData *BlenderSceneDelegate::material_data(pxr::SdfPath const &id)
|
|||||||
return it->second.get();
|
return it->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id, bool base_prim)
|
InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id)
|
||||||
{
|
{
|
||||||
if (base_prim) {
|
|
||||||
return dynamic_cast<InstancerData *>(object_data(id));
|
return dynamic_cast<InstancerData *>(object_data(id));
|
||||||
}
|
}
|
||||||
return dynamic_cast<InstancerData *>(object_data(id.GetParentPath()));
|
|
||||||
}
|
|
||||||
|
|
||||||
InstancerData *BlenderSceneDelegate::instancer_data(Object *object)
|
InstancerData *BlenderSceneDelegate::instancer_data(Object *object)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
|||||||
MeshData *mesh_data(pxr::SdfPath const &id);
|
MeshData *mesh_data(pxr::SdfPath const &id);
|
||||||
LightData *light_data(pxr::SdfPath const &id);
|
LightData *light_data(pxr::SdfPath const &id);
|
||||||
MaterialData *material_data(pxr::SdfPath const &id);
|
MaterialData *material_data(pxr::SdfPath const &id);
|
||||||
InstancerData *instancer_data(pxr::SdfPath const &id, bool base_prim = false);
|
InstancerData *instancer_data(pxr::SdfPath const &id);
|
||||||
InstancerData *instancer_data(Object *object);
|
InstancerData *instancer_data(Object *object);
|
||||||
|
|
||||||
void add_update_object(Object *object);
|
void add_update_object(Object *object);
|
||||||
|
@ -101,6 +101,7 @@ pxr::VtValue MaterialData::get_data(pxr::TfToken const &key) const
|
|||||||
|
|
||||||
pxr::VtValue MaterialData::material_resource()
|
pxr::VtValue MaterialData::material_resource()
|
||||||
{
|
{
|
||||||
|
return material_network_map;
|
||||||
if (material_network_map.IsEmpty()) {
|
if (material_network_map.IsEmpty()) {
|
||||||
const std::string &path = mtlx_path.GetResolvedPath();
|
const std::string &path = mtlx_path.GetResolvedPath();
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user