forked from blender/blender
BLEN-359: Implement updates for instances in viewport #20
@ -219,32 +219,29 @@ void BlenderSceneDelegate::add_update_object(Object *object,
|
|||||||
obj_data = object_data(id);
|
obj_data = object_data(id);
|
||||||
obj_data->update_visibility(view3d);
|
obj_data->update_visibility(view3d);
|
||||||
obj_data->insert();
|
obj_data->insert();
|
||||||
MeshData *m_data = dynamic_cast<MeshData *>(obj_data);
|
|
||||||
if (m_data) {
|
|
||||||
set_material(*m_data);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geometry) {
|
|
||||||
objects[id] = ObjectData::create(this, object);
|
|
||||||
obj_data = object_data(id);
|
|
||||||
obj_data->update_visibility(view3d);
|
|
||||||
MeshData *m_data = dynamic_cast<MeshData *>(obj_data);
|
|
||||||
if (m_data) {
|
|
||||||
set_material(*m_data);
|
|
||||||
}
|
|
||||||
obj_data->update(IdData::DirtyBits::ALL_DIRTY);
|
obj_data->update(IdData::DirtyBits::ALL_DIRTY);
|
||||||
return;
|
//if (geometry) {
|
||||||
}
|
// objects[id] = ObjectData::create(this, object);
|
||||||
|
// obj_data = object_data(id);
|
||||||
|
// obj_data->update_visibility(view3d);
|
||||||
|
// MeshData *m_data = dynamic_cast<MeshData *>(obj_data);
|
||||||
|
// if (m_data) {
|
||||||
|
// set_material(*m_data);
|
||||||
|
// }
|
||||||
|
// obj_data->update(IdData::DirtyBits::ALL_DIRTY);
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
if (transform) {
|
//if (transform) {
|
||||||
obj_data->update(IdData::DirtyBits::DIRTY_TRANSFORM);
|
// obj_data->update(IdData::DirtyBits::DIRTY_TRANSFORM);
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (shading) {
|
//if (shading) {
|
||||||
obj_data->update(IdData::DirtyBits::DIRTY_MATERIAL);
|
// obj_data->update(IdData::DirtyBits::DIRTY_MATERIAL);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlenderSceneDelegate::add_update_instance(DupliObject *dupli)
|
void BlenderSceneDelegate::add_update_instance(DupliObject *dupli)
|
||||||
|
@ -18,6 +18,7 @@ namespace blender::render::hydra {
|
|||||||
LightData::LightData(BlenderSceneDelegate *scene_delegate, Object *object)
|
LightData::LightData(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||||
: ObjectData(scene_delegate, object)
|
: ObjectData(scene_delegate, object)
|
||||||
{
|
{
|
||||||
|
CLOG_INFO(LOG_BSD, 2, "%s id=%s", id->name, p_id.GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightData::init()
|
void LightData::init()
|
||||||
@ -139,38 +140,44 @@ pxr::VtValue LightData::get_data(pxr::TfToken const &key) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LightData::update_visibility(View3D *view3d)
|
||||||
|
{
|
||||||
|
bool ret = ObjectData::update_visibility(view3d);
|
||||||
|
if (ret) {
|
||||||
|
scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id,
|
||||||
|
pxr::HdLight::DirtyParams);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void LightData::insert()
|
void LightData::insert()
|
||||||
{
|
{
|
||||||
|
CLOG_INFO(LOG_BSD, 2, "%s", id->name);
|
||||||
scene_delegate->GetRenderIndex().InsertSprim(prim_type(), scene_delegate, p_id);
|
scene_delegate->GetRenderIndex().InsertSprim(prim_type(), scene_delegate, p_id);
|
||||||
CLOG_INFO(LOG_BSD, 2, "Add: %s id=%s", name().c_str(), p_id.GetString().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightData::remove()
|
void LightData::remove()
|
||||||
{
|
{
|
||||||
|
CLOG_INFO(LOG_BSD, 2, "%s", id->name);
|
||||||
scene_delegate->GetRenderIndex().RemoveSprim(prim_type(), p_id);
|
scene_delegate->GetRenderIndex().RemoveSprim(prim_type(), p_id);
|
||||||
CLOG_INFO(LOG_BSD, 2, "Remove: %s", name().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightData::update(DirtyBits dirty_bits)
|
void LightData::update(DirtyBits dirty_bits)
|
||||||
{
|
{
|
||||||
/* TODO: prim_type was changed we have to do remove..add light */
|
/* TODO: prim_type was changed we have to do remove..add light */
|
||||||
|
|
||||||
|
CLOG_INFO(LOG_BSD, 2, "%s", id->name);
|
||||||
|
|
||||||
pxr::HdDirtyBits bits = pxr::HdLight::Clean;
|
pxr::HdDirtyBits bits = pxr::HdLight::Clean;
|
||||||
switch (dirty_bits) {
|
if (id->recalc & ID_RECALC_GEOMETRY) {
|
||||||
case DirtyBits::DIRTY_TRANSFORM:
|
data.clear();
|
||||||
bits = pxr::HdLight::DirtyTransform;
|
init();
|
||||||
break;
|
|
||||||
case DirtyBits::DIRTY_VISIBILITY:
|
|
||||||
bits = pxr::HdLight::DirtyParams;
|
|
||||||
break;
|
|
||||||
case DirtyBits::ALL_DIRTY:
|
|
||||||
bits = pxr::HdLight::AllDirty;
|
bits = pxr::HdLight::AllDirty;
|
||||||
break;
|
}
|
||||||
default:
|
else if (id->recalc & ID_RECALC_TRANSFORM) {
|
||||||
break;
|
bits = pxr::HdLight::DirtyTransform;
|
||||||
}
|
}
|
||||||
scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id, bits);
|
scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id, bits);
|
||||||
CLOG_INFO(LOG_BSD, 2, "Update: [%d] %s", dirty_bits, name().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
@ -20,6 +20,7 @@ class LightData : public ObjectData {
|
|||||||
void remove() override;
|
void remove() override;
|
||||||
void update(DirtyBits dirty_bits) override;
|
void update(DirtyBits dirty_bits) override;
|
||||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||||
|
bool update_visibility(View3D *view3d) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<pxr::TfToken, pxr::VtValue> data;
|
std::map<pxr::TfToken, pxr::VtValue> data;
|
||||||
|
@ -41,7 +41,7 @@ MaterialData::MaterialData(BlenderSceneDelegate *scene_delegate, Material *mater
|
|||||||
: IdData(scene_delegate, (ID *)material)
|
: IdData(scene_delegate, (ID *)material)
|
||||||
{
|
{
|
||||||
p_id = prim_id(scene_delegate, material);
|
p_id = prim_id(scene_delegate, material);
|
||||||
CLOG_INFO(LOG_BSD, 2, "%s - %s", id->name, p_id.GetText());
|
CLOG_INFO(LOG_BSD, 2, "%s, id=%s", id->name, p_id.GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialData::init()
|
void MaterialData::init()
|
||||||
|
@ -18,6 +18,7 @@ namespace blender::render::hydra {
|
|||||||
MeshData::MeshData(BlenderSceneDelegate *scene_delegate, Object *object)
|
MeshData::MeshData(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||||
: ObjectData(scene_delegate, object)
|
: ObjectData(scene_delegate, object)
|
||||||
{
|
{
|
||||||
|
CLOG_INFO(LOG_BSD, 2, "%s, id=%s", id->name, p_id.GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
pxr::VtValue MeshData::get_data(pxr::TfToken const &key) const
|
pxr::VtValue MeshData::get_data(pxr::TfToken const &key) const
|
||||||
@ -38,6 +39,16 @@ pxr::VtValue MeshData::get_data(pxr::TfToken const &key) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MeshData::update_visibility(View3D *view3d)
|
||||||
|
{
|
||||||
|
bool ret = ObjectData::update_visibility(view3d);
|
||||||
|
if (ret) {
|
||||||
|
scene_delegate->GetRenderIndex().GetChangeTracker().MarkRprimDirty(
|
||||||
|
p_id, pxr::HdChangeTracker::DirtyVisibility);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
Material *MeshData::material()
|
Material *MeshData::material()
|
||||||
{
|
{
|
||||||
Object *object = (Object *)id;
|
Object *object = (Object *)id;
|
||||||
@ -205,6 +216,8 @@ void MeshData::init()
|
|||||||
}
|
}
|
||||||
BKE_object_to_mesh_clear(object);
|
BKE_object_to_mesh_clear(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scene_delegate->set_material(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshData::insert()
|
void MeshData::insert()
|
||||||
@ -213,8 +226,8 @@ void MeshData::insert()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CLOG_INFO(LOG_BSD, 2, "%s", id->name);
|
||||||
scene_delegate->GetRenderIndex().InsertRprim(pxr::HdPrimTypeTokens->mesh, scene_delegate, p_id);
|
scene_delegate->GetRenderIndex().InsertRprim(pxr::HdPrimTypeTokens->mesh, scene_delegate, p_id);
|
||||||
CLOG_INFO(LOG_BSD, 2, "Add: %s id=%s", name().c_str(), p_id.GetString().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshData::remove()
|
void MeshData::remove()
|
||||||
@ -223,12 +236,36 @@ void MeshData::remove()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CLOG_INFO(LOG_BSD, 2, "%s", id->name);
|
||||||
scene_delegate->GetRenderIndex().RemoveRprim(p_id);
|
scene_delegate->GetRenderIndex().RemoveRprim(p_id);
|
||||||
CLOG_INFO(LOG_BSD, 2, "Remove: %s", name().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshData::update(DirtyBits dirty_bits)
|
void MeshData::update(DirtyBits dirty_bits)
|
||||||
{
|
{
|
||||||
|
pxr::HdDirtyBits bits = pxr::HdChangeTracker::Clean;
|
||||||
|
Object *object = (Object *)id;
|
||||||
|
if ((id->recalc & ID_RECALC_GEOMETRY) || (((ID *)object->data)->recalc & ID_RECALC_GEOMETRY)) {
|
||||||
|
material_id = pxr::SdfPath::EmptyPath();
|
||||||
|
instancer_id = pxr::SdfPath::EmptyPath();
|
||||||
|
face_vertex_counts.clear();
|
||||||
|
face_vertex_indices.clear();
|
||||||
|
vertices.clear();
|
||||||
|
normals.clear();
|
||||||
|
uvs.clear();
|
||||||
|
|
||||||
|
init();
|
||||||
|
bits = pxr::HdChangeTracker::AllDirty;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (id->recalc & ID_RECALC_SHADING) {
|
||||||
|
scene_delegate->set_material(*this);
|
||||||
|
bits |= pxr::HdChangeTracker::DirtyMaterialId;
|
||||||
|
}
|
||||||
|
if (id->recalc & ID_RECALC_TRANSFORM) {
|
||||||
|
bits |= pxr::HdChangeTracker::DirtyTransform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!scene_delegate->GetRenderIndex().HasRprim(p_id)) {
|
if (!scene_delegate->GetRenderIndex().HasRprim(p_id)) {
|
||||||
/* Trying to insert prim */
|
/* Trying to insert prim */
|
||||||
insert();
|
insert();
|
||||||
@ -240,26 +277,8 @@ void MeshData::update(DirtyBits dirty_bits)
|
|||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
CLOG_INFO(LOG_BSD, 2, "%s", id->name);
|
||||||
pxr::HdDirtyBits bits = pxr::HdChangeTracker::Clean;
|
|
||||||
switch (dirty_bits) {
|
|
||||||
case DirtyBits::DIRTY_TRANSFORM:
|
|
||||||
bits = pxr::HdChangeTracker::DirtyTransform;
|
|
||||||
break;
|
|
||||||
case DirtyBits::DIRTY_VISIBILITY:
|
|
||||||
bits = pxr::HdChangeTracker::DirtyVisibility;
|
|
||||||
break;
|
|
||||||
case DirtyBits::DIRTY_MATERIAL:
|
|
||||||
bits = pxr::HdChangeTracker::DirtyMaterialId;
|
|
||||||
break;
|
|
||||||
case DirtyBits::ALL_DIRTY:
|
|
||||||
bits = pxr::HdChangeTracker::AllDirty;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
scene_delegate->GetRenderIndex().GetChangeTracker().MarkRprimDirty(p_id, bits);
|
scene_delegate->GetRenderIndex().GetChangeTracker().MarkRprimDirty(p_id, bits);
|
||||||
CLOG_INFO(LOG_BSD, 2, "Update: [%d] %s", dirty_bits, name().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
@ -20,8 +20,8 @@ class MeshData : public ObjectData {
|
|||||||
void insert() override;
|
void insert() override;
|
||||||
void remove() override;
|
void remove() override;
|
||||||
void update(DirtyBits dirty_bits) override;
|
void update(DirtyBits dirty_bits) override;
|
||||||
|
|
||||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||||
|
bool update_visibility(View3D *view3d) override;
|
||||||
|
|
||||||
Material *material();
|
Material *material();
|
||||||
pxr::HdMeshTopology mesh_topology();
|
pxr::HdMeshTopology mesh_topology();
|
||||||
|
@ -70,11 +70,6 @@ ObjectData::ObjectData(BlenderSceneDelegate *scene_delegate, Object *object)
|
|||||||
p_id = prim_id(scene_delegate, object);
|
p_id = prim_id(scene_delegate, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObjectData::type()
|
|
||||||
{
|
|
||||||
return ((Object *)id)->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
pxr::GfMatrix4d ObjectData::transform()
|
pxr::GfMatrix4d ObjectData::transform()
|
||||||
{
|
{
|
||||||
return gf_matrix_from_transform(((Object *)id)->object_to_world);
|
return gf_matrix_from_transform(((Object *)id)->object_to_world);
|
||||||
|
@ -22,9 +22,8 @@ class ObjectData : public IdData {
|
|||||||
|
|
||||||
ObjectData(BlenderSceneDelegate *scene_delegate, Object *object);
|
ObjectData(BlenderSceneDelegate *scene_delegate, Object *object);
|
||||||
|
|
||||||
int type();
|
|
||||||
pxr::GfMatrix4d transform();
|
pxr::GfMatrix4d transform();
|
||||||
bool update_visibility(View3D *view3d);
|
virtual bool update_visibility(View3D *view3d);
|
||||||
|
|
||||||
bool visible;
|
bool visible;
|
||||||
};
|
};
|
||||||
|
@ -46,7 +46,7 @@ WorldData::WorldData(BlenderSceneDelegate *scene_delegate, World *world, bContex
|
|||||||
: IdData(scene_delegate, (ID *)world), context(context)
|
: IdData(scene_delegate, (ID *)world), context(context)
|
||||||
{
|
{
|
||||||
p_id = prim_id(scene_delegate);
|
p_id = prim_id(scene_delegate);
|
||||||
CLOG_INFO(LOG_BSD, 2, "%s - %s", id->name, p_id.GetText());
|
CLOG_INFO(LOG_BSD, 2, "%s, id=%s", id->name, p_id.GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldData::init()
|
void WorldData::init()
|
||||||
|
Loading…
Reference in New Issue
Block a user