forked from blender/blender
BLEN-351: Test/fix Hydra addon with different blender scenes #13
@ -9,6 +9,7 @@
|
|||||||
#include "blenderSceneDelegate.h"
|
#include "blenderSceneDelegate.h"
|
||||||
|
|
||||||
using namespace pxr;
|
using namespace pxr;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
@ -149,7 +150,7 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Export of new visible objects which were not exported before */
|
/* Export of new visible objects which were not exported before */
|
||||||
std::set<SdfPath> available_objects;
|
set<SdfPath> available_objects;
|
||||||
SdfPath id;
|
SdfPath id;
|
||||||
|
|
||||||
DEGObjectIterSettings settings = {0};
|
DEGObjectIterSettings settings = {0};
|
||||||
@ -197,7 +198,7 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* remove unused materials */
|
/* remove unused materials */
|
||||||
std::set<SdfPath> available_materials;
|
set<SdfPath> available_materials;
|
||||||
for (auto &obj : objects) {
|
for (auto &obj : objects) {
|
||||||
MeshData *m_data = dynamic_cast<MeshData *>(obj.second.get());
|
MeshData *m_data = dynamic_cast<MeshData *>(obj.second.get());
|
||||||
if (m_data && !m_data->material_id.IsEmpty()) {
|
if (m_data && !m_data->material_id.IsEmpty()) {
|
||||||
@ -220,7 +221,11 @@ void BlenderSceneDelegate::add_update_object(Object *object, bool geometry, bool
|
|||||||
SdfPath id = ObjectData::prim_id(this, object);
|
SdfPath id = ObjectData::prim_id(this, object);
|
||||||
ObjectData *obj_data = object_data(id);
|
ObjectData *obj_data = object_data(id);
|
||||||
if (!obj_data) {
|
if (!obj_data) {
|
||||||
objects[id] = ObjectData::init(this, object);
|
unique_ptr<ObjectData> new_object = ObjectData::init(this, object);
|
||||||
|
if (!new_object) {
|
||||||
BogdanNagirniak marked this conversation as resolved
|
|||||||
|
return;
|
||||||
|
}
|
||||||
|
objects[id] = move(new_object);
|
||||||
obj_data = object_data(id);
|
obj_data = object_data(id);
|
||||||
obj_data->update_visibility(view3d);
|
obj_data->update_visibility(view3d);
|
||||||
obj_data->insert_prim();
|
obj_data->insert_prim();
|
||||||
@ -232,7 +237,11 @@ void BlenderSceneDelegate::add_update_object(Object *object, bool geometry, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
objects[id] = ObjectData::init(this, object);
|
unique_ptr<ObjectData> new_object = ObjectData::init(this, object);
|
||||||
|
if (!new_object) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
objects[id] = move(new_object);
|
||||||
obj_data = object_data(id);
|
obj_data = object_data(id);
|
||||||
obj_data->update_visibility(view3d);
|
obj_data->update_visibility(view3d);
|
||||||
MeshData *m_data = dynamic_cast<MeshData *>(obj_data);
|
MeshData *m_data = dynamic_cast<MeshData *>(obj_data);
|
||||||
|
@ -28,6 +28,9 @@ MeshData::MeshData(BlenderSceneDelegate *scene_delegate, Object *object)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
|
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
|
||||||
|
if (!mesh) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
set_mesh(mesh);
|
set_mesh(mesh);
|
||||||
BKE_object_to_mesh_clear(object);
|
BKE_object_to_mesh_clear(object);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user
It shouldn't be nullptr here, please check.