forked from blender/blender
BLEN-335: Export environment light #1
@ -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
|
|||||||
GetRenderIndex().RemoveSprim(HdPrimTypeTokens->domeLight, world_light_id);
|
GetRenderIndex().RemoveSprim(HdPrimTypeTokens->domeLight, world_light_id);
|
||||||
DagerD marked this conversation as resolved
Bogdan Nagirniak
commented
if (world_data) ... if (world_data) ...
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
world_data = make_unique<WorldData>(world, (bContext *)b_context->ptr.data);
|
if (!world_data) {
|
||||||
GetRenderIndex().InsertSprim(HdPrimTypeTokens->domeLight, this, world_light_id);
|
world_data = make_unique<WorldData>(world, (bContext *)b_context->ptr.data);
|
||||||
DagerD marked this conversation as resolved
Bogdan Nagirniak
commented
```
if (!world_data) {
world_data = make_unique....
insertSprim
}
else {
world_data = make_unique....
changetracker
}
```
|
|||||||
GetRenderIndex().GetChangeTracker().MarkSprimDirty(world_light_id, HdLight::AllDirty);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BlenderSceneDelegate::GetVisible(SdfPath const &id)
|
bool BlenderSceneDelegate::GetVisible(SdfPath const &id)
|
||||||
@ -464,16 +468,14 @@ 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)) {
|
ret = obj_data->get_data(key);
|
||||||
BogdanNagirniak marked this conversation as resolved
Bogdan Nagirniak
commented
else if (id == world_id()) {....} else if (id == world_id()) {....}
|
|||||||
ret = obj_data->get_data(key);
|
}
|
||||||
}
|
else if (key == HdLightTokens->exposure) {
|
||||||
else if (key == HdLightTokens->exposure) {
|
// TODO: temporary value, it should be delivered through Python UI
|
||||||
// TODO: temporary value, it should be delivered through Python UI
|
ret = 1.0f;
|
||||||
ret = 1.0f;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (id == world_id()) {
|
else if (id == world_id()) {
|
||||||
|
@ -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
Bogdan Nagirniak
commented
`string const &`
|
|||||||
{
|
{
|
||||||
GfMatrix4d transform = GfMatrix4d().SetIdentity();
|
GfMatrix4d transform = GfMatrix4d().SetIdentity();
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
@ -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
Bogdan Nagirniak
commented
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
Bogdan Nagirniak
commented
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
|
||||||
|
Loading…
Reference in New Issue
Block a user
world_data = nullptr;