BLEN-335: Export environment light #1

Merged
Bogdan Nagirniak merged 13 commits from BLEN-335 into hydra-render 2023-02-17 14:46:46 +01:00
4 changed files with 33 additions and 27 deletions
Showing only changes of commit 2a3828de41 - Show all commits

View File

@ -61,15 +61,19 @@ void BlenderSceneDelegate::add_update_world(World *world)
LOG(INFO) << "Add world: " << world_light_id; LOG(INFO) << "Add world: " << world_light_id;
if (!world) { if (!world) {
world_data.reset(); world_data = nullptr;
DagerD marked this conversation as resolved
Review

world_data = nullptr;

`world_data = nullptr;`
GetRenderIndex().RemoveSprim(HdPrimTypeTokens->domeLight, world_light_id); GetRenderIndex().RemoveSprim(HdPrimTypeTokens->domeLight, world_light_id);
DagerD marked this conversation as resolved
Review

if (world_data) ...

if (world_data) ...
return; return;
} }
if (!world_data) {
world_data = make_unique<WorldData>(world, (bContext *)b_context->ptr.data); world_data = make_unique<WorldData>(world, (bContext *)b_context->ptr.data);
DagerD marked this conversation as resolved
Review
if (!world_data) {
world_data = make_unique....
insertSprim
}
else {
world_data = make_unique....
changetracker
}
``` if (!world_data) { world_data = make_unique.... insertSprim } else { world_data = make_unique.... changetracker } ```
GetRenderIndex().InsertSprim(HdPrimTypeTokens->domeLight, this, world_light_id); GetRenderIndex().InsertSprim(HdPrimTypeTokens->domeLight, this, world_light_id);
}
else {
world_data = make_unique<WorldData>(world, (bContext *)b_context->ptr.data);
GetRenderIndex().GetChangeTracker().MarkSprimDirty(world_light_id, HdLight::AllDirty); GetRenderIndex().GetChangeTracker().MarkSprimDirty(world_light_id, HdLight::AllDirty);
}
} }
bool BlenderSceneDelegate::GetVisible(SdfPath const &id) bool BlenderSceneDelegate::GetVisible(SdfPath const &id)
@ -464,7 +468,6 @@ VtValue BlenderSceneDelegate::GetLightParamValue(SdfPath const& id, TfToken cons
HdRenderIndex &index = GetRenderIndex(); HdRenderIndex &index = GetRenderIndex();
if (index.HasRprim(id)) {
ObjectData *obj_data = object_data(id); ObjectData *obj_data = object_data(id);
if (obj_data) { if (obj_data) {
if (obj_data->has_data(key)) { if (obj_data->has_data(key)) {
@ -475,7 +478,6 @@ VtValue BlenderSceneDelegate::GetLightParamValue(SdfPath const& id, TfToken cons
ret = 1.0f; ret = 1.0f;
} }
} }
}
else if (id == world_id()) { else if (id == world_id()) {
if (world_data->has_data(key)) { if (world_data->has_data(key)) {
ret = world_data->get_data(key); ret = world_data->get_data(key);

View File

@ -47,7 +47,7 @@ WorldData::WorldData(World *world, bContext *b_context)
bNode *output_node = ntreeShaderOutputNode(world->nodetree, SHD_OUTPUT_ALL); bNode *output_node = ntreeShaderOutputNode(world->nodetree, SHD_OUTPUT_ALL);
bNodeSocket input_socket = output_node->input_by_identifier("Surface"); bNodeSocket input_socket = output_node->input_by_identifier("Surface");
bNodeLink const *link = input_socket.directly_linked_links()[0]; bNodeLink const *link = input_socket.directly_linked_links()[0];
if (!link) { if (input_socket.directly_linked_links().is_empty()) {
return; return;
} }
@ -91,7 +91,7 @@ WorldData::WorldData(World *world, bContext *b_context)
} }
} }
GfMatrix4d WorldData::transform(string renderer_name) GfMatrix4d WorldData::transform(string const &renderer_name)
DagerD marked this conversation as resolved
Review

string const &

`string const &`
{ {
GfMatrix4d transform = GfMatrix4d().SetIdentity(); GfMatrix4d transform = GfMatrix4d().SetIdentity();

View File

@ -22,7 +22,7 @@ public:
WorldData(World *world, bContext *b_context); WorldData(World *world, bContext *b_context);
pxr::TfToken prim_type(); pxr::TfToken prim_type();
pxr::GfMatrix4d transform(std::string renderer_name); pxr::GfMatrix4d transform(std::string const &renderer_name);
pxr::VtValue &get_data(pxr::TfToken const &key); pxr::VtValue &get_data(pxr::TfToken const &key);
template<class T> template<class T>

View File

@ -15,7 +15,6 @@
#include "utils.h" #include "utils.h"
using namespace pxr;
using namespace std; using namespace std;
DagerD marked this conversation as resolved
Review

remove this

remove this
using namespace pxr; using namespace pxr;
@ -34,22 +33,27 @@ string format_duration(chrono::milliseconds millisecs)
{ {
stringstream ss; stringstream ss;
bool neg = millisecs < 0ms; bool neg = millisecs < 0ms;
if (neg) if (neg) {
millisecs = -millisecs; millisecs = -millisecs;
}
auto m = chrono::duration_cast<chrono::minutes>(millisecs); auto m = chrono::duration_cast<chrono::minutes>(millisecs);
millisecs -= m; millisecs -= m;
auto s = chrono::duration_cast<chrono::seconds>(millisecs); auto s = chrono::duration_cast<chrono::seconds>(millisecs);
millisecs -= s; millisecs -= s;
if (neg) if (neg) {
ss << "-"; ss << "-";
DagerD marked this conversation as resolved
Review

add {...}

add {...}
if (m < 10min) }
if (m < 10min) {
ss << "0"; ss << "0";
}
ss << to_string(m / 1min) << ":"; ss << to_string(m / 1min) << ":";
if (s < 10s) if (s < 10s) {
ss << "0"; ss << "0";
}
ss << to_string(s / 1s) << ":"; ss << to_string(s / 1s) << ":";
if (millisecs < 10ms) if (millisecs < 10ms) {
ss << "0"; ss << "0";
}
ss << to_string(millisecs / 1ms / 10); ss << to_string(millisecs / 1ms / 10);
return ss.str(); return ss.str();
} }
@ -86,13 +90,13 @@ string cache_image(Main *bmain,
BLI_path_join(tempfile, sizeof(tempfile), BKE_tempdir_session(), image_name.c_str()); BLI_path_join(tempfile, sizeof(tempfile), BKE_tempdir_session(), image_name.c_str());
STRNCPY(opts->filepath, tempfile); STRNCPY(opts->filepath, tempfile);
if (BKE_image_save(reports, bmain, image, iuser, opts)) { if (!BKE_image_save(reports, bmain, image, iuser, opts)) {
BKE_image_save_options_free(opts); BKE_image_save_options_free(opts);
return tempfile; return "";
}; };
BKE_image_save_options_free(opts); BKE_image_save_options_free(opts);
return ""; return tempfile;
} }
} // namespace blender::render::hydra } // namespace blender::render::hydra