forked from blender/blender
Export volumes #58
@ -205,7 +205,7 @@ pxr::HdVolumeFieldDescriptorVector BlenderSceneDelegate::GetVolumeFieldDescripto
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", volume_id.GetText());
|
||||
VolumeData *v_data = volume_data(volume_id);
|
||||
return v_data->volume_field_descriptors();
|
||||
return v_data->field_descriptors();
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
|
@ -34,8 +34,23 @@ void VolumeData::init()
|
||||
return;
|
||||
}
|
||||
filepath_ = BKE_volume_grids_frame_filepath(volume);
|
||||
|
||||
if (volume->runtime.grids) {
|
||||
const int num_grids = BKE_volume_num_grids(volume);
|
||||
if (num_grids) {
|
||||
for (const int i : IndexRange(num_grids)) {
|
||||
const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, i);
|
||||
const std::string grid_name = BKE_volume_grid_name(grid);
|
||||
|
||||
field_descriptors_.emplace_back(pxr::TfToken(grid_name),
|
||||
pxr::UsdVolImagingTokens->openvdbAsset,
|
||||
prim_id.AppendElementString("VF_" + grid_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
write_transform();
|
||||
write_materials();
|
||||
|
||||
BKE_volume_unload(volume);
|
||||
}
|
||||
|
||||
@ -46,7 +61,7 @@ void VolumeData::insert()
|
||||
|
||||
ID_LOG(1, "");
|
||||
|
||||
for (auto &desc : volume_field_descriptors()) {
|
||||
for (auto &desc : field_descriptors_) {
|
||||
scene_delegate_->GetRenderIndex().InsertBprim(
|
||||
desc.fieldPrimType, scene_delegate_, desc.fieldId);
|
||||
ID_LOG(1, "Volume field %s", desc.fieldId.GetText());
|
||||
@ -55,10 +70,7 @@ void VolumeData::insert()
|
||||
|
||||
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()) {
|
||||
for (auto &desc : field_descriptors_) {
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", desc.fieldId.GetText());
|
||||
|
||||
scene_delegate_->GetRenderIndex().RemoveBprim(desc.fieldPrimType, desc.fieldId);
|
||||
}
|
||||
@ -120,36 +132,9 @@ bool VolumeData::update_visibility()
|
||||
return ret;
|
||||
}
|
||||
|
||||
pxr::HdVolumeFieldDescriptorVector VolumeData::volume_field_descriptors() const
|
||||
pxr::HdVolumeFieldDescriptorVector VolumeData::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();
|
||||
}
|
||||
|
||||
const int num_grids = BKE_volume_num_grids(volume);
|
||||
if (!num_grids) {
|
||||
return pxr::HdVolumeFieldDescriptorVector();
|
||||
}
|
||||
|
||||
pxr::HdVolumeFieldDescriptorVector volume_field_descriptors;
|
||||
for (const int i : IndexRange(num_grids)) {
|
||||
const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, i);
|
||||
const std::string grid_name = BKE_volume_grid_name(grid);
|
||||
|
||||
volume_field_descriptors.emplace_back(pxr::TfToken(grid_name),
|
||||
pxr::UsdVolImagingTokens->openvdbAsset,
|
||||
prim_id.AppendElementString("VF_" + grid_name));
|
||||
}
|
||||
|
||||
BKE_volume_unload(volume);
|
||||
return volume_field_descriptors;
|
||||
return field_descriptors_;
|
||||
}
|
||||
|
||||
pxr::SdfPath VolumeData::material_id() const
|
||||
|
@ -22,7 +22,7 @@ class VolumeData : public ObjectData {
|
||||
pxr::VtValue get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const;
|
||||
bool update_visibility() override;
|
||||
|
||||
pxr::HdVolumeFieldDescriptorVector volume_field_descriptors() const;
|
||||
pxr::HdVolumeFieldDescriptorVector field_descriptors() const;
|
||||
pxr::SdfPath material_id() const;
|
||||
void available_materials(Set<pxr::SdfPath> &paths) const;
|
||||
|
||||
@ -30,6 +30,7 @@ class VolumeData : public ObjectData {
|
||||
void write_materials();
|
||||
|
||||
std::string filepath_;
|
||||
pxr::HdVolumeFieldDescriptorVector field_descriptors_;
|
||||
MaterialData *mat_data_ = nullptr;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
log level 1 for remove