forked from blender/blender
Export volumes #58
@ -87,6 +87,8 @@ set(SRC
|
|||||||
scene_delegate/instancer.cc
|
scene_delegate/instancer.cc
|
||||||
scene_delegate/image.h
|
scene_delegate/image.h
|
||||||
scene_delegate/image.cc
|
scene_delegate/image.cc
|
||||||
|
scene_delegate/volume.h
|
||||||
|
scene_delegate/volume.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(LIB
|
set(LIB
|
||||||
|
@ -192,6 +192,14 @@ pxr::GfMatrix4d BlenderSceneDelegate::GetInstancerTransform(pxr::SdfPath const &
|
|||||||
return i_data->transform;
|
return i_data->transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pxr::HdVolumeFieldDescriptorVector BlenderSceneDelegate::GetVolumeFieldDescriptors(
|
||||||
|
pxr::SdfPath const &volume_Id)
|
||||||
|
{
|
||||||
|
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", volume_Id.GetText());
|
||||||
|
VolumeData *v_data = volume_data(volume_Id);
|
||||||
|
return v_data->volume_field_descriptors();
|
||||||
|
}
|
||||||
|
|
||||||
void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||||
{
|
{
|
||||||
bool is_populated = depsgraph != nullptr;
|
bool is_populated = depsgraph != nullptr;
|
||||||
@ -333,6 +341,11 @@ InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id, bool
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VolumeData *BlenderSceneDelegate::volume_data(pxr::SdfPath const &id) const
|
||||||
|
{
|
||||||
|
return dynamic_cast<VolumeData *>(object_data(id));
|
||||||
|
}
|
||||||
|
|
||||||
void BlenderSceneDelegate::update_objects(Object *object)
|
void BlenderSceneDelegate::update_objects(Object *object)
|
||||||
{
|
{
|
||||||
if (!ObjectData::is_supported(object)) {
|
if (!ObjectData::is_supported(object)) {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
#include "volume.h"
|
||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
@ -60,6 +61,8 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
|||||||
pxr::VtIntArray GetInstanceIndices(pxr::SdfPath const &instancer_id,
|
pxr::VtIntArray GetInstanceIndices(pxr::SdfPath const &instancer_id,
|
||||||
pxr::SdfPath const &prototype_id) override;
|
pxr::SdfPath const &prototype_id) override;
|
||||||
pxr::GfMatrix4d GetInstancerTransform(pxr::SdfPath const &instancer_id) override;
|
pxr::GfMatrix4d GetInstancerTransform(pxr::SdfPath const &instancer_id) override;
|
||||||
|
pxr::HdVolumeFieldDescriptorVector GetVolumeFieldDescriptors(
|
||||||
|
pxr::SdfPath const &volume_Id) override;
|
||||||
|
|
||||||
void populate(Depsgraph *depsgraph, bContext *context);
|
void populate(Depsgraph *depsgraph, bContext *context);
|
||||||
void clear();
|
void clear();
|
||||||
@ -85,6 +88,7 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
|||||||
LightData *light_data(pxr::SdfPath const &id) const;
|
LightData *light_data(pxr::SdfPath const &id) const;
|
||||||
MaterialData *material_data(pxr::SdfPath const &id) const;
|
MaterialData *material_data(pxr::SdfPath const &id) const;
|
||||||
InstancerData *instancer_data(pxr::SdfPath const &id, bool child_id = false) const;
|
InstancerData *instancer_data(pxr::SdfPath const &id, bool child_id = false) const;
|
||||||
|
VolumeData *volume_data(pxr::SdfPath const &id) const;
|
||||||
|
|
||||||
void update_objects(Object *object);
|
void update_objects(Object *object);
|
||||||
void update_instancers(Object *object);
|
void update_instancers(Object *object);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "light.h"
|
#include "light.h"
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
|
#include "volume.h"
|
||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
@ -39,7 +40,9 @@ std::unique_ptr<ObjectData> ObjectData::create(BlenderSceneDelegate *scene_deleg
|
|||||||
case OB_LAMP:
|
case OB_LAMP:
|
||||||
data = std::make_unique<LightData>(scene_delegate, object, prim_id);
|
data = std::make_unique<LightData>(scene_delegate, object, prim_id);
|
||||||
break;
|
break;
|
||||||
|
case OB_VOLUME:
|
||||||
|
data = std::make_unique<VolumeData>(scene_delegate, object, prim_id);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -56,6 +59,7 @@ bool ObjectData::is_supported(Object *object)
|
|||||||
case OB_CURVES_LEGACY:
|
case OB_CURVES_LEGACY:
|
||||||
case OB_MBALL:
|
case OB_MBALL:
|
||||||
case OB_LAMP:
|
case OB_LAMP:
|
||||||
|
case OB_VOLUME:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
64
source/blender/render/hydra/scene_delegate/volume.cc
Normal file
64
source/blender/render/hydra/scene_delegate/volume.cc
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* SPDX-License-Identifier: Apache-2.0
|
||||||
|
* Copyright 2011-2022 Blender Foundation */
|
||||||
|
|
||||||
|
#include <pxr/imaging/hd/tokens.h>
|
||||||
|
#include <pxr/imaging/hd/volume.h>
|
||||||
|
|
||||||
|
#include "BKE_object.h"
|
||||||
|
#include "DNA_volume_types.h"
|
||||||
|
|
||||||
|
#include "blender_scene_delegate.h"
|
||||||
|
#include "volume.h"
|
||||||
|
|
||||||
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
|
VolumeData::VolumeData(BlenderSceneDelegate *scene_delegate,
|
||||||
|
Object *object,
|
||||||
|
pxr::SdfPath const &prim_id)
|
||||||
|
: ObjectData(scene_delegate, object, prim_id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VolumeData::init()
|
||||||
|
{
|
||||||
|
ID_LOG(1, "");
|
||||||
|
scene_delegate_->GetRenderIndex().InsertRprim(
|
||||||
|
pxr::HdPrimTypeTokens->volume, scene_delegate_, prim_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VolumeData::insert()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VolumeData::remove()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VolumeData::update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
pxr::VtValue VolumeData::get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const
|
||||||
|
{
|
||||||
|
return pxr::VtValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VolumeData::update_visibility()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pxr::HdVolumeFieldDescriptorVector VolumeData::volume_field_descriptors() const
|
||||||
|
{
|
||||||
|
pxr::HdVolumeFieldDescriptorVector volume_field_descriptors;
|
||||||
|
Volume *volume = (Volume *)((Object *)id)->data;
|
||||||
|
|
||||||
|
//pxr::HdVolumeFieldDescriptor density = pxr::HdVolumeFieldDescriptor(pxr::TfToken("density"),)
|
||||||
|
//TfToken fieldName;
|
||||||
|
//TfToken fieldPrimType;
|
||||||
|
//SdfPath fieldId;
|
||||||
|
|
||||||
|
return volume_field_descriptors;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace blender::render::hydra
|
31
source/blender/render/hydra/scene_delegate/volume.h
Normal file
31
source/blender/render/hydra/scene_delegate/volume.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* SPDX-License-Identifier: Apache-2.0
|
||||||
|
* Copyright 2011-2022 Blender Foundation */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <pxr/imaging/hd/sceneDelegate.h>
|
||||||
|
|
||||||
|
#include "object.h"
|
||||||
|
|
||||||
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
|
class VolumeData : public ObjectData {
|
||||||
|
|
||||||
|
public:
|
||||||
|
VolumeData(BlenderSceneDelegate *scene_delegate, Object *object, pxr::SdfPath const &prim_id);
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
void insert() override;
|
||||||
|
void remove() override;
|
||||||
|
void update() override;
|
||||||
|
|
||||||
|
pxr::VtValue get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const;
|
||||||
|
bool update_visibility() override;
|
||||||
|
|
||||||
|
pxr::HdVolumeFieldDescriptorVector volume_field_descriptors() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace blender::render::hydra
|
Loading…
Reference in New Issue
Block a user