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