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
Showing only changes of commit 69345afd33 - Show all commits

View File

@ -7,17 +7,14 @@
#include <pxr/usd/usdHydra/tokens.h>
#include <pxr/usd/usdVol/tokens.h>
#include <pxr/usdImaging/usdVolImaging/tokens.h>
#include <pxr/base/gf/matrix3d.h>
#include <pxr/base/gf/rotation.h>
#include "BKE_material.h"
#include "BKE_mesh.hh"
#include "BKE_object.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_volume.h"
#include "BLI_index_range.hh"
#include "BLI_path_util.h"
#include "BLI_math_rotation.h"
#include "DNA_fluid_types.h"
#include "DNA_scene_types.h"
#include "DNA_volume_types.h"
@ -242,7 +239,8 @@ void VolumeData::init_from_volume()
BKE_volume_unload(volume);
}
void VolumeData::assign_volume_transform() {
void VolumeData::assign_volume_transform()
{
Object *object = (Object *)this->id;
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
@ -264,13 +262,9 @@ void VolumeData::assign_volume_transform() {
pxr::GfMatrix4d scale_matrix = pxr::GfMatrix4d(1.0f).SetScale(
pxr::GfVec3d(scale[0], scale[1], scale[2]));
pxr::GfMatrix4d texture_trans = pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(
mesh->texspace_location[0],
mesh->texspace_location[1],
mesh->texspace_location[2]));
mesh->texspace_location[0], mesh->texspace_location[1], mesh->texspace_location[2]));
pxr::GfMatrix4d texture_scale = pxr::GfMatrix4d(1.0f).SetScale(
pxr::GfVec3d(mesh->texspace_size[0],
mesh->texspace_size[1],
mesh->texspace_size[2]));
pxr::GfVec3d(mesh->texspace_size[0], mesh->texspace_size[1], mesh->texspace_size[2]));
transform = scale_matrix * inversed * texture_scale * texture_trans * transform;