BLEN-365: Improve creation algorithm of PreviewEngine #21

Merged
Bogdan Nagirniak merged 11 commits from BLEN-365 into hydra-render 2023-04-10 12:44:48 +02:00
2 changed files with 15 additions and 5 deletions
Showing only changes of commit 5cbc5ff6d4 - Show all commits

View File

@ -80,15 +80,17 @@ void LightData::init()
break;
}
p_type = light->type;
p_shape = light->area_shape;
/* TODO: temporary value, it should be delivered through Python UI */
data[pxr::HdLightTokens->exposure] = 1.0f;
}
pxr::TfToken LightData::prim_type()
{
Light *light = (Light *)((Object *)id)->data;
pxr::TfToken ret;
switch (light->type) {
switch (p_type) {
case LA_LOCAL:
case LA_SPOT:
ret = pxr::HdPrimTypeTokens->sphereLight;
@ -99,7 +101,7 @@ pxr::TfToken LightData::prim_type()
break;
case LA_AREA:
switch (light->area_shape) {
switch (p_shape) {
case LA_AREA_SQUARE:
case LA_AREA_RECT:
ret = pxr::HdPrimTypeTokens->rectLight;
@ -166,10 +168,16 @@ void LightData::remove()
void LightData::update()
{
/* TODO: prim_type was changed we have to do remove..add light */
CLOG_INFO(LOG_BSD, 2, "%s", id->name);
Light *light = (Light *)((Object *)id)->data;
if (light->type != p_type || light->area_shape != p_shape) {
remove();
init();
insert();
return;
}
pxr::HdDirtyBits bits = pxr::HdLight::Clean;
if (id->recalc & ID_RECALC_GEOMETRY) {
init();

View File

@ -24,6 +24,8 @@ class LightData : public ObjectData {
private:
std::map<pxr::TfToken, pxr::VtValue> data;
short p_type;
short p_shape;
DagerD marked this conversation as resolved Outdated

pxr::TfToken p_type;
make prim_type() with Light * parameter

`pxr::TfToken p_type;` make prim_type() with `Light *` parameter
pxr::TfToken prim_type();
};