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