Export volumes #58

Merged
Bogdan Nagirniak merged 10 commits from BLEN-384 into hydra-render 2023-07-04 09:57:33 +02:00
5 changed files with 20 additions and 16 deletions
Showing only changes of commit 5909ec8465 - Show all commits

View File

@ -39,7 +39,9 @@ void PreviewEngine::update_render_result(std::vector<float> &pixels)
RenderLayer *layer = (RenderLayer *)result->layers.first; RenderLayer *layer = (RenderLayer *)result->layers.first;
RenderPass *pass = (RenderPass *)layer->passes.first; RenderPass *pass = (RenderPass *)layer->passes.first;
memcpy(pass->buffer.data, pixels.data(), sizeof(float) * pass->rectx * pass->recty * pass->channels); memcpy(pass->buffer.data,
pixels.data(),
sizeof(float) * pass->rectx * pass->recty * pass->channels);
RE_engine_end_result(bl_engine_, result, false, false, false); RE_engine_end_result(bl_engine_, result, false, false, false);
} }

View File

@ -288,7 +288,9 @@ pxr::SdfPath BlenderSceneDelegate::world_prim_id() const
ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id) const ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id) const
{ {
pxr::SdfPath p_id = (id.GetName().find("SM_") == 0 || id.GetName().find("VF_") == 0) ? id.GetParentPath() : id; pxr::SdfPath p_id = (id.GetName().find("SM_") == 0 || id.GetName().find("VF_") == 0) ?
id.GetParentPath() :
id;
auto obj_data = objects_.lookup_ptr(p_id); auto obj_data = objects_.lookup_ptr(p_id);
if (obj_data) { if (obj_data) {
return obj_data->get(); return obj_data->get();

View File

@ -17,8 +17,8 @@
#include "light.h" #include "light.h"
#include "mesh.h" #include "mesh.h"
#include "object.h" #include "object.h"
#include "world.h"
#include "volume.h" #include "volume.h"
#include "world.h"
namespace blender::render::hydra { namespace blender::render::hydra {

View File

@ -1,17 +1,17 @@
/* SPDX-License-Identifier: Apache-2.0 /* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */ * Copyright 2011-2022 Blender Foundation */
#include <pxr/imaging/hd/tokens.h>
#include <pxr/imaging/hd/bprim.h> #include <pxr/imaging/hd/bprim.h>
#include <pxr/imaging/hd/tokens.h>
#include <pxr/imaging/hd/volumeFieldSchema.h> #include <pxr/imaging/hd/volumeFieldSchema.h>
#include <pxr/usd/usdHydra/tokens.h> #include <pxr/usd/usdHydra/tokens.h>
#include <pxr/usd/usdVol/tokens.h> #include <pxr/usd/usdVol/tokens.h>
#include <pxr/usdImaging/usdVolImaging/tokens.h> #include <pxr/usdImaging/usdVolImaging/tokens.h>
#include "BKE_volume.h"
#include "BKE_material.h" #include "BKE_material.h"
#include "DNA_volume_types.h" #include "BKE_volume.h"
#include "BLI_index_range.hh" #include "BLI_index_range.hh"
#include "DNA_volume_types.h"
#include "blender_scene_delegate.h" #include "blender_scene_delegate.h"
#include "volume.h" #include "volume.h"
@ -19,8 +19,8 @@
namespace blender::render::hydra { namespace blender::render::hydra {
VolumeData::VolumeData(BlenderSceneDelegate *scene_delegate, VolumeData::VolumeData(BlenderSceneDelegate *scene_delegate,
Object *object, Object *object,
pxr::SdfPath const &prim_id) pxr::SdfPath const &prim_id)
: ObjectData(scene_delegate, object, prim_id) : ObjectData(scene_delegate, object, prim_id)
{ {
} }
@ -144,8 +144,8 @@ pxr::HdVolumeFieldDescriptorVector VolumeData::volume_field_descriptors() const
const std::string grid_name = BKE_volume_grid_name(grid); const std::string grid_name = BKE_volume_grid_name(grid);
volume_field_descriptors.emplace_back(pxr::TfToken(grid_name), volume_field_descriptors.emplace_back(pxr::TfToken(grid_name),
pxr::UsdVolImagingTokens->openvdbAsset, pxr::UsdVolImagingTokens->openvdbAsset,
prim_id.AppendElementString("VF_" + grid_name)); prim_id.AppendElementString("VF_" + grid_name));
} }
BKE_volume_unload(volume); BKE_volume_unload(volume);

View File

@ -27,10 +27,10 @@ class VolumeData : public ObjectData {
void available_materials(Set<pxr::SdfPath> &paths) const; void available_materials(Set<pxr::SdfPath> &paths) const;
private: private:
void write_materials(); void write_materials();
std::string filepath_; std::string filepath_;
MaterialData *mat_data_ = nullptr; MaterialData *mat_data_ = nullptr;
}; };
} // namespace blender::render::hydra } // namespace blender::render::hydra