Export volumes #58

Merged
Bogdan Nagirniak merged 10 commits from BLEN-384 into hydra-render 2023-07-04 09:57:33 +02:00
Showing only changes of commit f0c4a0a5c9 - Show all commits

View File

@ -33,26 +33,35 @@ void VolumeData::init()
return;
}
filepath_ = BKE_volume_grids_frame_filepath(volume);
if (BKE_volume_is_loaded(volume)) {
BKE_volume_unload(volume);
}
write_transform();
BKE_volume_unload(volume);
}
void VolumeData::insert()
{
ID_LOG(1, "");
scene_delegate_->GetRenderIndex().InsertRprim(
pxr::HdPrimTypeTokens->volume, scene_delegate_, prim_id);
ID_LOG(1, "");
for (auto &desc : volume_field_descriptors()) {
scene_delegate_->GetRenderIndex().InsertBprim(
desc.fieldPrimType, scene_delegate_, desc.fieldId);
ID_LOG(1, "Volume field %s", desc.fieldId.GetText());
}
}
void VolumeData::remove()
{
/* NOTE: Is it possible to manipulate a list of fields in Blender?
* Also something can happen to file.
* Probably we need to store a field list in class. */
for (auto &desc : volume_field_descriptors()) {
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", desc.fieldId.GetText());
scene_delegate_->GetRenderIndex().RemoveBprim(desc.fieldPrimType, desc.fieldId);
}
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", prim_id.GetText());
scene_delegate_->GetRenderIndex().RemoveRprim(prim_id);
}
void VolumeData::update()
@ -79,7 +88,13 @@ pxr::VtValue VolumeData::get_data(pxr::SdfPath const &id, pxr::TfToken const &ke
bool VolumeData::update_visibility()
{
return false;
bool ret = ObjectData::update_visibility();
if (ret) {
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkRprimDirty(
prim_id, pxr::HdChangeTracker::DirtyVisibility);
ID_LOG(1, "");
}
return ret;
}
pxr::HdVolumeFieldDescriptorVector VolumeData::volume_field_descriptors() const
@ -87,6 +102,10 @@ pxr::HdVolumeFieldDescriptorVector VolumeData::volume_field_descriptors() const
Volume *volume = (Volume *)((Object *)id)->data;
Main *main = CTX_data_main(scene_delegate_->context);
if (!volume->runtime.grids) {
return pxr::HdVolumeFieldDescriptorVector();
}
if (!BKE_volume_is_loaded(volume) && !BKE_volume_load(volume, main)) {
return pxr::HdVolumeFieldDescriptorVector();
}