forked from blender/blender
Support several instancers on one object #24
@ -65,15 +65,11 @@ pxr::GfMatrix4d BlenderSceneDelegate::GetInstancerTransform(pxr::SdfPath const &
|
||||
return i_data->transform();
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::add_update_object(Object *object)
|
||||
void BlenderSceneDelegate::update_objects(Object *object)
|
||||
{
|
||||
if ((object->transflag & OB_DUPLI) && InstancerData::supported(object)) {
|
||||
add_update_instancer(object);
|
||||
if (!ObjectData::supported(object)) {
|
||||
return;
|
||||
}
|
||||
for (auto &it : instancers) {
|
||||
it.second->check_update(object);
|
||||
}
|
||||
|
||||
pxr::SdfPath id = ObjectData::prim_id(this, object);
|
||||
ObjectData *obj_data = object_data(id);
|
||||
if (obj_data) {
|
||||
@ -88,12 +84,29 @@ void BlenderSceneDelegate::add_update_object(Object *object)
|
||||
obj_data->update_visibility(view3d);
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::add_update_instancer(Object *object)
|
||||
void BlenderSceneDelegate::update_instancers(Object *object)
|
||||
{
|
||||
/* Check object inside instancers */
|
||||
for (auto &it : instancers) {
|
||||
it.second->check_update(object);
|
||||
}
|
||||
|
||||
pxr::SdfPath id = InstancerData::prim_id(this, object);
|
||||
InstancerData *i_data = instancer_data(id);
|
||||
if (i_data) {
|
||||
if (object->transflag & OB_DUPLI) {
|
||||
i_data->update();
|
||||
}
|
||||
else {
|
||||
i_data->remove();
|
||||
instancers.erase(id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ((object->transflag & OB_DUPLI) == 0) {
|
||||
return;
|
||||
}
|
||||
if (view3d && !BKE_object_is_visible_in_viewport(view3d, object)) {
|
||||
return;
|
||||
}
|
||||
instancers[id] = InstancerData::create(this, object);
|
||||
@ -311,10 +324,8 @@ void BlenderSceneDelegate::check_updates()
|
||||
switch (GS(id->name)) {
|
||||
case ID_OB: {
|
||||
Object *object = (Object *)id;
|
||||
if (!ObjectData::supported(object)) {
|
||||
break;
|
||||
}
|
||||
add_update_object(object);
|
||||
update_objects(object);
|
||||
update_instancers(object);
|
||||
} break;
|
||||
|
||||
case ID_MA: {
|
||||
@ -368,7 +379,8 @@ void BlenderSceneDelegate::add_new_objects()
|
||||
continue;
|
||||
}
|
||||
|
||||
add_update_object(object);
|
||||
update_objects(object);
|
||||
update_instancers(object);
|
||||
}
|
||||
ITER_END;
|
||||
}
|
||||
@ -477,7 +489,10 @@ void BlenderSceneDelegate::update_visibility()
|
||||
}
|
||||
|
||||
if (!object_data(ObjectData::prim_id(this, object))) {
|
||||
add_update_object(object);
|
||||
update_objects(object);
|
||||
}
|
||||
if (!instancer_data(InstancerData::prim_id(this, object))) {
|
||||
update_instancers(object);
|
||||
}
|
||||
}
|
||||
ITER_END;
|
||||
|
@ -60,8 +60,8 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
MaterialData *material_data(pxr::SdfPath const &id);
|
||||
InstancerData *instancer_data(pxr::SdfPath const &id);
|
||||
|
||||
void add_update_object(Object *object);
|
||||
void add_update_instancer(Object *object);
|
||||
void update_objects(Object *object);
|
||||
void update_instancers(Object *object);
|
||||
void update_world();
|
||||
void check_updates();
|
||||
void add_new_objects();
|
||||
|
@ -127,7 +127,7 @@ void MaterialData::insert()
|
||||
|
||||
void MaterialData::remove()
|
||||
{
|
||||
ID_LOG(2, "");
|
||||
CLOG_INFO(LOG_BSD, 2, "%s", p_id.GetText());
|
||||
scene_delegate->GetRenderIndex().RemoveSprim(pxr::HdPrimTypeTokens->material, p_id);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user