forked from blender/blender
BLEN-359: Implement updates for instances in viewport #20
@ -275,7 +275,10 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
unsigned int scene_recalc = ((ID *)scene)->recalc;
|
||||
if (scene_recalc) {
|
||||
/* Checking scene updates */
|
||||
CLOG_INFO(LOG_BSD, 2, "Update: %s [%s]", ((ID *)scene)->name,
|
||||
CLOG_INFO(LOG_BSD,
|
||||
2,
|
||||
"Update: %s [%s]",
|
||||
((ID *)scene)->name,
|
||||
std::bitset<32>(scene_recalc).to_string().c_str());
|
||||
|
||||
if (scene_recalc & ID_RECALC_BASE_FLAGS) {
|
||||
@ -301,8 +304,8 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
ITER_BEGIN (
|
||||
DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id) {
|
||||
|
||||
CLOG_INFO(LOG_BSD, 2, "Update: %s [%s]", id->name,
|
||||
std::bitset<32>(id->recalc).to_string().c_str());
|
||||
CLOG_INFO(
|
||||
LOG_BSD, 2, "Update: %s [%s]", id->name, std::bitset<32>(id->recalc).to_string().c_str());
|
||||
|
||||
switch (GS(id->name)) {
|
||||
case ID_OB: {
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include "blender_scene_delegate.h"
|
||||
#include "instancer.h"
|
||||
|
||||
using namespace pxr;
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
bool InstancerData::supported(Object *object)
|
||||
@ -36,7 +34,7 @@ std::unique_ptr<InstancerData> InstancerData::create(BlenderSceneDelegate *scene
|
||||
return data;
|
||||
}
|
||||
|
||||
SdfPath InstancerData::prim_id(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||
pxr::SdfPath InstancerData::prim_id(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||
{
|
||||
/* Making id of instancer in form like I_<pointer in 16 hex digits format>. Example:
|
||||
* I_000002073e369608 */
|
||||
@ -62,7 +60,7 @@ void InstancerData::init()
|
||||
MeshData::init();
|
||||
}
|
||||
|
||||
GfMatrix4d InstancerData::transform()
|
||||
pxr::GfMatrix4d InstancerData::transform()
|
||||
{
|
||||
return pxr::GfMatrix4d(1.0);
|
||||
}
|
||||
@ -83,30 +81,30 @@ bool InstancerData::update_visibility(View3D *view3d)
|
||||
return ret;
|
||||
}
|
||||
|
||||
VtValue InstancerData::get_data(TfToken const &key) const
|
||||
pxr::VtValue InstancerData::get_data(pxr::TfToken const &key) const
|
||||
{
|
||||
CLOG_INFO(LOG_BSD, 3, "%s [%s]", id->name, key.GetText());
|
||||
|
||||
if (key == HdInstancerTokens->instanceTransform) {
|
||||
return VtValue(transforms);
|
||||
if (key == pxr::HdInstancerTokens->instanceTransform) {
|
||||
return pxr::VtValue(transforms);
|
||||
}
|
||||
return MeshData::get_data(key);
|
||||
}
|
||||
|
||||
HdPrimvarDescriptorVector InstancerData::instancer_primvar_descriptors(
|
||||
HdInterpolation interpolation)
|
||||
pxr::HdPrimvarDescriptorVector InstancerData::instancer_primvar_descriptors(
|
||||
pxr::HdInterpolation interpolation)
|
||||
{
|
||||
HdPrimvarDescriptorVector primvars;
|
||||
if (interpolation == HdInterpolationInstance) {
|
||||
pxr::HdPrimvarDescriptorVector primvars;
|
||||
if (interpolation == pxr::HdInterpolationInstance) {
|
||||
primvars.emplace_back(
|
||||
HdInstancerTokens->instanceTransform, interpolation, HdPrimvarRoleTokens->none);
|
||||
pxr::HdInstancerTokens->instanceTransform, interpolation, pxr::HdPrimvarRoleTokens->none);
|
||||
}
|
||||
return primvars;
|
||||
}
|
||||
|
||||
VtIntArray InstancerData::instance_indices()
|
||||
pxr::VtIntArray InstancerData::instance_indices()
|
||||
{
|
||||
VtIntArray ret(transforms.size());
|
||||
pxr::VtIntArray ret(transforms.size());
|
||||
for (size_t i = 0; i < ret.size(); ++i) {
|
||||
ret[i] = i;
|
||||
}
|
||||
@ -130,6 +128,9 @@ bool InstancerData::set_instances()
|
||||
Instances should be created for all objects */
|
||||
id = (ID *)dupli->ob;
|
||||
}
|
||||
if (id != (ID *)dupli->ob) {
|
||||
continue;
|
||||
}
|
||||
transforms.push_back(gf_matrix_from_transform(dupli->mat));
|
||||
CLOG_INFO(
|
||||
LOG_BSD, 2, "Instance %s (%s) %d", id->name, ((ID *)dupli->ob)->name, dupli->random_id);
|
||||
|
Loading…
Reference in New Issue
Block a user