forked from blender/blender
Export volumes #58
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
@ -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 {
|
||||||
|
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ void VolumeData::insert()
|
|||||||
void VolumeData::remove()
|
void VolumeData::remove()
|
||||||
{
|
{
|
||||||
/* NOTE: Is it possible to manipulate a list of fields in Blender?
|
/* NOTE: Is it possible to manipulate a list of fields in Blender?
|
||||||
* Also something can happen to file.
|
* Also something can happen to file.
|
||||||
* Probably we need to store a field list in class. */
|
* Probably we need to store a field list in class. */
|
||||||
|
|||||||
for (auto &desc : volume_field_descriptors()) {
|
for (auto &desc : volume_field_descriptors()) {
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", desc.fieldId.GetText());
|
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", desc.fieldId.GetText());
|
||||||
@ -92,7 +92,7 @@ void VolumeData::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
pxr::VtValue VolumeData::get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const
|
pxr::VtValue VolumeData::get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const
|
||||||
{
|
{
|
||||||
if (key == pxr::HdVolumeFieldSchemaTokens->filePath) {
|
if (key == pxr::HdVolumeFieldSchemaTokens->filePath) {
|
||||||
return pxr::VtValue(pxr::SdfAssetPath(filepath_, filepath_));
|
return pxr::VtValue(pxr::SdfAssetPath(filepath_, filepath_));
|
||||||
}
|
}
|
||||||
@ -142,10 +142,10 @@ pxr::HdVolumeFieldDescriptorVector VolumeData::volume_field_descriptors() const
|
|||||||
for (const int i : IndexRange(num_grids)) {
|
for (const int i : IndexRange(num_grids)) {
|
||||||
const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, i);
|
const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, i);
|
||||||
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);
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user
Yes, move volume_field_descriptors to private field
VolumeData::field_descriptors_