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
5 changed files with 15 additions and 23 deletions
Showing only changes of commit ed7a712371 - Show all commits

View File

@ -45,7 +45,7 @@ static std::string cache_image_file(Image *image,
BKE_image_path_ext_from_imformat(&scene->r.im_format, &r_ext);
opts.im_format = scene->r.im_format;
}
snprintf(file_name, sizeof(file_name), "img_%016llx%s", (uintptr_t)image, r_ext);
file_path = get_cache_file(file_name);

View File

@ -3,7 +3,6 @@
#include "BKE_object.h"
#include "DNA_scene_types.h"
#include "DEG_depsgraph_query.h"
#include "blender_scene_delegate.h"
@ -28,8 +27,7 @@ std::unique_ptr<ObjectData> ObjectData::create(BlenderSceneDelegate *scene_deleg
{
std::unique_ptr<ObjectData> data;
DagerD marked this conversation as resolved Outdated

Propose to create class VolumeModifierData::public VolumeData and separate logic in these two classes

Propose to create `class VolumeModifierData::public VolumeData` and separate logic in these two classes
if (VolumeData::is_volume_modifier(object))
{
if (VolumeData::is_volume_modifier(object)) {
return std::make_unique<VolumeData>(scene_delegate, object, prim_id);
}

View File

@ -8,23 +8,20 @@
#include <pxr/usd/usdVol/tokens.h>
#include <pxr/usdImaging/usdVolImaging/tokens.h>
#include "DNA_scene_types.h"
#include "BKE_material.h"
#include "BLI_path_util.h"
#include "BKE_modifier.h"
#include "DNA_fluid_types.h"
#include "BKE_volume.h"
#include "BLI_index_range.hh"
#include "BKE_object.h"
#include "BLI_path_util.h"
#include "DNA_fluid_types.h"
#include "DNA_scene_types.h"
#include "DNA_volume_types.h"
#include "BKE_mesh.hh"
#include "blender_scene_delegate.h"
#include "volume.h"
PXR_NAMESPACE_OPEN_SCOPE
TF_DEFINE_PRIVATE_TOKENS(grid_tokens_,
(density)(flame)(shadow)(temperature)(velocity));
TF_DEFINE_PRIVATE_TOKENS(grid_tokens_, (density)(flame)(shadow)(temperature)(velocity));
PXR_NAMESPACE_CLOSE_SCOPE
namespace blender::render::hydra {
@ -42,10 +39,12 @@ VolumeData::VolumeData(BlenderSceneDelegate *scene_delegate,
{
}
bool VolumeData::is_volume_modifier(Object *object) {
bool VolumeData::is_volume_modifier(Object *object)
{
FluidModifierData *volume_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 volume_modifier && volume_modifier->type & MOD_FLUID_TYPE_DOMAIN &&
volume_modifier->domain->type == FLUID_DOMAIN_TYPE_GAS;
}
void VolumeData::init()
@ -54,8 +53,7 @@ void VolumeData::init()
if (is_volume_modifier((Object *)this->id)) {
init_from_modifier();
}
else
{
else {
init_from_volume();
}
write_transform();
@ -195,7 +193,8 @@ std::string VolumeData::get_cached_file_path(std::string directory, int frame)
return file_path;
}
void VolumeData::init_from_modifier() {
void VolumeData::init_from_modifier()
{
Object *object = (Object *)this->id;
FluidModifierData *volume_modifier = (FluidModifierData *)BKE_modifiers_findby_type(
object, eModifierType_Fluid);

View File

@ -5,8 +5,6 @@
#include <pxr/imaging/hd/sceneDelegate.h>
#include "BLI_set.hh"
#include "object.h"
namespace blender::render::hydra {

View File

@ -176,11 +176,8 @@ void WorldData::write_transform()
{
transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90), pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180),
pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0),
pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180), pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0), pxr::GfVec3d());
}
} // namespace blender::render::hydra