forked from blender/blender
Export volumes from object modifier (quick effect) #62
@ -6,7 +6,6 @@
|
||||
#include "BKE_mesh.hh"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "DNA_fluid_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_volume_types.h"
|
||||
|
||||
@ -32,10 +31,10 @@ bool VolumeModifierData::is_volume_modifier(Object *object)
|
||||
return false;
|
||||
}
|
||||
|
||||
FluidModifierData *volume_modifier = (FluidModifierData *)BKE_modifiers_findby_type(
|
||||
FluidModifierData *modifier = (FluidModifierData *)BKE_modifiers_findby_type(
|
||||
object, eModifierType_Fluid);
|
||||
return volume_modifier && volume_modifier->type & MOD_FLUID_TYPE_DOMAIN &&
|
||||
volume_modifier->domain->type == FLUID_DOMAIN_TYPE_GAS;
|
||||
return modifier && modifier->type & MOD_FLUID_TYPE_DOMAIN &&
|
||||
modifier->domain->type == FLUID_DOMAIN_TYPE_GAS;
|
||||
}
|
||||
|
||||
void VolumeModifierData::init()
|
||||
@ -43,17 +42,16 @@ void VolumeModifierData::init()
|
||||
ID_LOG(1, "");
|
||||
|
||||
Object *object = (Object *)this->id;
|
||||
FluidModifierData *volume_modifier = (FluidModifierData *)BKE_modifiers_findby_type(
|
||||
object, eModifierType_Fluid);
|
||||
modifier_ = (FluidModifierData *)BKE_modifiers_findby_type(object, eModifierType_Fluid);
|
||||
|
||||
if ((volume_modifier->domain->cache_data_format & FLUID_DOMAIN_FILE_OPENVDB) == 0) {
|
||||
if ((modifier_->domain->cache_data_format & FLUID_DOMAIN_FILE_OPENVDB) == 0) {
|
||||
CLOG_WARN(LOG_RENDER_HYDRA_SCENE,
|
||||
"Volume %s is't exported: only OpenVDB file format supported",
|
||||
prim_id.GetText());
|
||||
return;
|
||||
}
|
||||
|
||||
filepath_ = get_cached_file_path(volume_modifier->domain->cache_directory,
|
||||
filepath_ = get_cached_file_path(modifier_->domain->cache_directory,
|
||||
scene_delegate_->scene->r.cfra);
|
||||
|
||||
for (auto &grid_name : pxr::grid_tokens_->allTokens) {
|
||||
@ -98,12 +96,9 @@ void VolumeModifierData::write_transform()
|
||||
Object *object = (Object *)this->id;
|
||||
|
||||
/* set base scaling */
|
||||
float scale[3];
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
scale[i] = (object->scale[i] != 0.0f) ? 1.0f / object->scale[i] : 1.0f;
|
||||
}
|
||||
transform = pxr::GfMatrix4d().SetScale(pxr::GfVec3d(scale));
|
||||
|
||||
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]));
|
||||
/* positioning to center */
|
||||
transform *= pxr::GfMatrix4d().SetTranslate(pxr::GfVec3d(-1, -1, -1));
|
||||
|
||||
@ -113,7 +108,7 @@ void VolumeModifierData::write_transform()
|
||||
transform *= pxr::GfMatrix4d(1.0f).SetScale(pxr::GfVec3d(texspace_scale)) *
|
||||
pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(texspace_loc));
|
||||
|
||||
/* */
|
||||
/* applying object transform */
|
||||
transform *= gf_matrix_from_transform(object->object_to_world);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include <pxr/imaging/hd/sceneDelegate.h>
|
||||
|
||||
#include "DNA_fluid_types.h"
|
||||
|
||||
#include "volume.h"
|
||||
|
||||
namespace blender::render::hydra {
|
||||
@ -24,6 +26,8 @@ class VolumeModifierData : public VolumeData {
|
||||
void write_transform() override;
|
||||
|
||||
std::string get_cached_file_path(std::string directory, int frame);
|
||||
|
||||
FluidModifierData *modifier_;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
Loading…
Reference in New Issue
Block a user