Blender V4.3
hydra_scene_delegate.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <pxr/base/gf/vec2f.h>
8#include <pxr/imaging/hd/sceneDelegate.h>
9
10#include "BLI_map.hh"
11
12#include "DEG_depsgraph.hh"
13
14#include "CLG_log.h"
15
16#include "curves.hh"
17#include "instancer.hh"
18#include "light.hh"
19#include "mesh.hh"
20#include "object.hh"
21#include "volume.hh"
22#include "volume_modifier.hh"
23#include "world.hh"
24
25struct Depsgraph;
26struct Main;
27struct Scene;
28struct View3D;
29
30namespace blender::io::hydra {
31
32extern struct CLG_LogRef *LOG_HYDRA_SCENE;
33
34class Engine;
35
36class HydraSceneDelegate : public pxr::HdSceneDelegate {
37 friend ObjectData; /* has access to materials */
38 friend MaterialData; /* has access to objects and instancers */
39
40 public:
42 bool use_scene_lights = true;
43 bool use_scene_world = true;
44 std::string studiolight_name;
47
48 bool operator==(const ShadingSettings &other) const;
49 };
50
51 Depsgraph *depsgraph = nullptr;
52 const View3D *view3d = nullptr;
53 Main *bmain = nullptr;
54 Scene *scene = nullptr;
55
57 bool use_materialx = true;
58
59 private:
60 ObjectDataMap objects_;
61 MaterialDataMap materials_;
62 std::unique_ptr<InstancerData> instancer_data_;
63 std::unique_ptr<WorldData> world_data_;
64
65 public:
66 HydraSceneDelegate(pxr::HdRenderIndex *parent_index,
67 pxr::SdfPath const &delegate_id,
68 bool use_materialx);
69 ~HydraSceneDelegate() override = default;
70
71 /* Delegate methods */
72 pxr::HdMeshTopology GetMeshTopology(pxr::SdfPath const &id) override;
73 pxr::HdBasisCurvesTopology GetBasisCurvesTopology(pxr::SdfPath const &id) override;
74 pxr::GfMatrix4d GetTransform(pxr::SdfPath const &id) override;
75 pxr::VtValue Get(pxr::SdfPath const &id, pxr::TfToken const &key) override;
76 pxr::VtValue GetLightParamValue(pxr::SdfPath const &id, pxr::TfToken const &key) override;
77 pxr::HdPrimvarDescriptorVector GetPrimvarDescriptors(
78 pxr::SdfPath const &id, pxr::HdInterpolation interpolation) override;
79 pxr::SdfPath GetMaterialId(pxr::SdfPath const &rprim_id) override;
80 pxr::VtValue GetMaterialResource(pxr::SdfPath const &material_id) override;
81 bool GetVisible(pxr::SdfPath const &id) override;
82 bool GetDoubleSided(pxr::SdfPath const &id) override;
83 pxr::HdCullStyle GetCullStyle(pxr::SdfPath const &id) override;
84 pxr::SdfPath GetInstancerId(pxr::SdfPath const &prim_id) override;
85 pxr::SdfPathVector GetInstancerPrototypes(pxr::SdfPath const &instancer_id) override;
86 pxr::VtIntArray GetInstanceIndices(pxr::SdfPath const &instancer_id,
87 pxr::SdfPath const &prototype_id) override;
88 pxr::GfMatrix4d GetInstancerTransform(pxr::SdfPath const &instancer_id) override;
89 pxr::HdVolumeFieldDescriptorVector GetVolumeFieldDescriptors(
90 pxr::SdfPath const &volume_id) override;
91
92 void populate(Depsgraph *depsgraph, View3D *v3d);
93 void clear();
94
95 private:
96 pxr::SdfPath prim_id(const ID *id, const char *prefix) const;
97 pxr::SdfPath object_prim_id(const Object *object) const;
98 pxr::SdfPath material_prim_id(const Material *mat) const;
99 pxr::SdfPath hair_prim_id(Object *parent_obj, const ParticleSystem *mat) const;
100 pxr::SdfPath instancer_prim_id() const;
101 pxr::SdfPath world_prim_id() const;
102
103 ObjectData *object_data(pxr::SdfPath const &id) const;
104 MeshData *mesh_data(pxr::SdfPath const &id) const;
105 CurvesData *curves_data(pxr::SdfPath const &id) const;
106 VolumeData *volume_data(pxr::SdfPath const &id) const;
107 LightData *light_data(pxr::SdfPath const &id) const;
108 MaterialData *material_data(pxr::SdfPath const &id) const;
109 HairData *hair_data(pxr::SdfPath const &id) const;
110 InstancerData *instancer_data(pxr::SdfPath const &id, bool child_id = false) const;
111
112 void check_updates();
113 void update_collection();
114 bool set_light_shading_settings();
115 bool set_world_shading_settings();
116};
117
118} // namespace blender::io::hydra
pxr::VtValue GetMaterialResource(pxr::SdfPath const &material_id) override
bool GetVisible(pxr::SdfPath const &id) override
pxr::VtIntArray GetInstanceIndices(pxr::SdfPath const &instancer_id, pxr::SdfPath const &prototype_id) override
pxr::HdPrimvarDescriptorVector GetPrimvarDescriptors(pxr::SdfPath const &id, pxr::HdInterpolation interpolation) override
pxr::VtValue GetLightParamValue(pxr::SdfPath const &id, pxr::TfToken const &key) override
HydraSceneDelegate(pxr::HdRenderIndex *parent_index, pxr::SdfPath const &delegate_id, bool use_materialx)
pxr::HdVolumeFieldDescriptorVector GetVolumeFieldDescriptors(pxr::SdfPath const &volume_id) override
pxr::HdCullStyle GetCullStyle(pxr::SdfPath const &id) override
pxr::VtValue Get(pxr::SdfPath const &id, pxr::TfToken const &key) override
void populate(Depsgraph *depsgraph, View3D *v3d)
pxr::SdfPath GetMaterialId(pxr::SdfPath const &rprim_id) override
pxr::GfMatrix4d GetInstancerTransform(pxr::SdfPath const &instancer_id) override
pxr::HdBasisCurvesTopology GetBasisCurvesTopology(pxr::SdfPath const &id) override
pxr::GfMatrix4d GetTransform(pxr::SdfPath const &id) override
pxr::SdfPath GetInstancerId(pxr::SdfPath const &prim_id) override
pxr::SdfPathVector GetInstancerPrototypes(pxr::SdfPath const &instancer_id) override
pxr::HdMeshTopology GetMeshTopology(pxr::SdfPath const &id) override
bool GetDoubleSided(pxr::SdfPath const &id) override
struct CLG_LogRef * LOG_HYDRA_SCENE
Definition DNA_ID.h:413
bool operator==(const ShadingSettings &other) const