Export volumes from object modifier (quick effect) #62

Merged
Bogdan Nagirniak merged 28 commits from BLEN-448 into hydra-render 2023-07-20 23:49:25 +02:00
3 changed files with 15 additions and 9 deletions
Showing only changes of commit 1be51ad64d - Show all commits

View File

@ -304,7 +304,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GPUSettings gpuS
true,
wnd,
mHDC,
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
4,
minor,
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),

View File

@ -27,13 +27,15 @@ VolumeData::VolumeData(BlenderSceneDelegate *scene_delegate,
void VolumeData::init()
{
ID_LOG(1, "");
field_descriptors_.clear();
Volume *volume = (Volume *)((Object *)this->id)->data;
Main *main = CTX_data_main(scene_delegate_->context);
if (!BKE_volume_load(volume, main)) {
return;
}
filepath_ = BKE_volume_grids_frame_filepath(volume);
ID_LOG(1, "%s", filepath_.c_str());
if (volume->runtime.grids) {
const int num_grids = BKE_volume_num_grids(volume);
@ -64,14 +66,14 @@ void VolumeData::insert()
for (auto &desc : field_descriptors_) {
scene_delegate_->GetRenderIndex().InsertBprim(
desc.fieldPrimType, scene_delegate_, desc.fieldId);
ID_LOG(1, "Volume field %s", desc.fieldId.GetText());
ID_LOG(2, "Volume field %s", desc.fieldId.GetText());
}
}
void VolumeData::remove()
{
for (auto &desc : field_descriptors_) {
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s", desc.fieldId.GetText());
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, 1, "%s", prim_id.GetText());

View File

@ -39,10 +39,12 @@ bool VolumeModifierData::is_volume_modifier(Object *object)
void VolumeModifierData::init()
{
ID_LOG(1, "");
field_descriptors_.clear();
Object *object = (Object *)this->id;
modifier_ = (FluidModifierData *)BKE_modifiers_findby_type(object, eModifierType_Fluid);
ModifierData *md = BKE_modifiers_findby_type(object, eModifierType_Fluid);
modifier_ = (FluidModifierData *)BKE_modifier_get_evaluated(
scene_delegate_->depsgraph, object, md);
if ((modifier_->domain->cache_data_format & FLUID_DOMAIN_FILE_OPENVDB) == 0) {
CLOG_WARN(LOG_RENDER_HYDRA_SCENE,
@ -53,6 +55,7 @@ void VolumeModifierData::init()
filepath_ = get_cached_file_path(modifier_->domain->cache_directory,
scene_delegate_->scene->r.cfra);
ID_LOG(1, "%s", filepath_.c_str());
for (auto &grid_name : pxr::grid_tokens_->allTokens) {
field_descriptors_.emplace_back(grid_name,
@ -96,9 +99,10 @@ void VolumeModifierData::write_transform()
Object *object = (Object *)this->id;
/* set base scaling */
transform = pxr::GfMatrix4d().SetScale(pxr::GfVec3d(1.0f / modifier_->domain->global_size[0],
1.0f / modifier_->domain->global_size[1],
1.0f / modifier_->domain->global_size[2]));
transform = pxr::GfMatrix4d().SetScale(
pxr::GfVec3d(modifier_->domain->scale / modifier_->domain->global_size[0],
modifier_->domain->scale / modifier_->domain->global_size[1],
modifier_->domain->scale / modifier_->domain->global_size[2]));
/* positioning to center */
transform *= pxr::GfMatrix4d().SetTranslate(pxr::GfVec3d(-1, -1, -1));