Blender V5.3
world.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/matrix4d.h>
8#include <pxr/imaging/hd/dataSource.h>
9#include <pxr/usd/sdf/path.h>
10
11#include "BLI_string.hh"
12
13#include "DNA_space_enums.h"
14
15namespace blender {
16
17struct Main;
18struct Scene;
19struct View3D;
20struct World;
21
22namespace io::hydra {
23
24struct PopulateContext;
25
27pxr::HdContainerDataSourceHandle build_world_data_source(Main *bmain,
28 Scene *scene,
29 const View3D *view3d,
30 pxr::GfMatrix4d *r_transform);
31
32/* Caches the inputs that feed the world dome-light prim so we can skip rebuilding it (and
33 * dirtying its texture binding every frame) when nothing relevant has changed. Updates to the
34 * World ID itself are caught via `ID_RECALC_SHADING`; the rest captures view3d state that is
35 * not reflected in any recalc.
36 * TODO: an image reloaded outside the World shader graph won't invalidate this. */
38 public:
39 /* Emit the world prim into `ctx` (or skip if cached inputs match). `world_shading_changed`
40 * should be true when `ID_RECALC_SHADING` is set on `scene->world`. */
41 void emit(PopulateContext &ctx,
42 Main *bmain,
43 Scene *scene,
44 const View3D *view3d,
45 const pxr::SdfPath &world_path,
46 bool world_shading_changed);
47
48 void clear();
49
50 private:
51 struct Inputs {
52 const World *world = nullptr;
53 bool use_scene_world = true;
54 int shading_type = 0;
55 char studiolight[FILE_MAXFILE] = {0};
56 float studiolight_intensity = 0.0f;
57 float studiolight_rot_z = 0.0f;
58
59 bool operator==(const Inputs &other) const
60 {
61 return world == other.world && use_scene_world == other.use_scene_world &&
62 shading_type == other.shading_type && STREQ(studiolight, other.studiolight) &&
63 studiolight_intensity == other.studiolight_intensity &&
64 studiolight_rot_z == other.studiolight_rot_z;
65 }
66 };
67
68 Inputs cached_inputs_;
69 bool used_ = false;
70};
71
72} // namespace io::hydra
73} // namespace blender
#define FILE_MAXFILE
#define STREQ(a, b)
void emit(PopulateContext &ctx, Main *bmain, Scene *scene, const View3D *view3d, const pxr::SdfPath &world_path, bool world_shading_changed)
pxr::HdContainerDataSourceHandle build_world_data_source(Main *bmain, Scene *scene, const View3D *view3d, pxr::GfMatrix4d *r_transform)
bool operator==(const PersistentID &persistent_id_a, const PersistentID &persistent_id_b)
BMesh Iterators.