Blender V5.3
scene/object.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "graph/node.h"
8
9/* included as Object::set_particle_system defined through NODE_SOCKET_API does
10 * not select the right Node::set overload as it does not know that ParticleSystem
11 * is a Node */
12#include "scene/geometry.h"
13#include "scene/particles.h"
14#include "scene/scene.h"
15
16#include "util/array.h"
17#include "util/boundbox.h"
18#include "util/param.h"
19#include "util/transform.h"
20#include "util/types.h"
21#include "util/vector.h"
22
24
25class Device;
26class DeviceScene;
27class Geometry;
28class ParticleSystem;
29class Progress;
30class Scene;
31struct Transform;
33class ObjectManager;
34
35/* Object */
36
37class Object : public Node {
38 public:
40
41 NODE_SOCKET_API(Geometry *, geometry)
42 /* Use base API because we need custom setter for tfm. */
45 NODE_SOCKET_API(uint, random_id)
46 NODE_SOCKET_API(int, pass_id)
48 NODE_SOCKET_API(float, alpha)
49 NODE_SOCKET_API(ustring, asset_name)
50 vector<ParamValue> attributes;
51 NODE_SOCKET_API(uint, visibility)
53 NODE_SOCKET_API(bool, hide_on_missing_motion)
54 NODE_SOCKET_API(bool, use_holdout)
55 NODE_SOCKET_API(bool, is_shadow_catcher)
56 NODE_SOCKET_API(float, shadow_terminator_shading_offset)
57 NODE_SOCKET_API(float, shadow_terminator_geometry_offset)
58
59 NODE_SOCKET_API(bool, is_caustics_caster)
60 NODE_SOCKET_API(bool, is_caustics_receiver)
61
62 NODE_SOCKET_API(bool, is_bake_target)
63
64 NODE_SOCKET_API(float3, dupli_generated)
65 NODE_SOCKET_API(float2, dupli_uv)
66
67 NODE_SOCKET_API(ParticleSystem *, particle_system);
69
70 NODE_SOCKET_API(float, ao_distance)
71
72 NODE_SOCKET_API(ustring, lightgroup)
73 NODE_SOCKET_API(uint, receiver_light_set)
74 NODE_SOCKET_API(uint64_t, light_set_membership)
75 NODE_SOCKET_API(uint, blocker_shadow_set)
76 NODE_SOCKET_API(uint64_t, shadow_set_membership)
77
78 /* Set during device update. */
80
81 /* Specifies the position of the object in scene->objects and
82 * in the device vectors. Gets set in device_update. */
83 int index;
84
85 Object();
86 ~Object() override;
87
88 void tag_update(Scene *scene);
89
90 void compute_bounds(bool motion_blur);
91 void apply_transform(bool apply_to_motion);
92
93 /* Convert between normalized -1..1 motion time and index
94 * in the motion array. */
95 bool use_motion() const;
96 float motion_time(const int step) const;
97 int motion_step(const float time) const;
98 void update_motion(Scene::MotionType need_motion);
99
100 /* Maximum number of motion steps supported (due to Embree). */
101 static const uint MAX_MOTION_STEPS = 129;
102
103 /* Check whether object is traceable and it worth adding it to
104 * kernel scene.
105 */
106 bool is_traceable() const;
107
108 /* Combine object's visibility with all possible internal run-time
109 * determined flags which denotes trace-time visibility.
110 */
111 uint visibility_for_tracing() const;
112
113 /* Returns the index that is used in the kernel for this object. */
114 int get_device_index() const;
115
116 /* Compute step size from attributes, shaders, transforms. */
117 float compute_volume_step_size(Progress &progress) const;
118
119 /* Check whether this object can be used as light-emissive. */
120 bool usable_as_light() const;
121
122 /* Check whether the object participates in light or shadow linking, either as a receiver/blocker
123 * or emitter. */
124 bool has_light_linking() const;
125 bool has_shadow_linking() const;
126
127 /* Transform of some object types need to be modified to prevent render issues. */
128 void adjust_volume_tfm(Transform &tfm);
129 void set_tfm(Transform tfm);
130 bool tfm_equals(Transform tfm);
131 void set_motion_tfm(Transform tfm, const int step_index);
132
133 protected:
134 /* Reference to the attribute map with object attributes,
135 * or 0 if none. Set in update_svm_attributes. */
137
138 friend class ObjectManager;
139 friend class GeometryManager;
140};
141
142/* Object Manager */
143
145 uint32_t update_flags;
146
147 public:
148 enum : uint32_t {
152 OBJECT_ADDED = (1 << 3),
153 OBJECT_REMOVED = (1 << 4),
154 OBJECT_MODIFIED = (1 << 5),
158
159 /* tag everything in the manager for an update */
161
163 };
164
166
169
170 void update_interactive_motion(Scene *scene);
171
172 void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
173 void device_update_transforms(DeviceScene *dscene, Scene *scene, Progress &progress);
174 void device_update_prim_offsets(Device *device, DeviceScene *dscene, Scene *scene);
175
176 void device_update_flags(Device *device,
177 DeviceScene *dscene,
178 Scene *scene,
179 Progress &progress,
180 bool bounds_valid = true);
181 void device_update_geom_offsets(Device *device, DeviceScene *dscene, Scene *scene);
182
183 void device_free(Device *device, DeviceScene *dscene, bool force_free);
184
185 void tag_update(Scene *scene, const uint32_t flag);
186
187 bool need_update() const;
188
189 void apply_static_transforms(DeviceScene *dscene, Scene *scene, Progress &progress);
190
191 string get_cryptomatte_objects(Scene *scene);
192 string get_cryptomatte_assets(Scene *scene);
193
194 protected:
196 Object *ob,
197 bool update_all,
198 const Scene *scene);
201 int *start_index,
202 int *num_objects);
203};
204
unsigned long long int uint64_t
void tag_update(Scene *scene, const uint32_t flag)
string get_cryptomatte_objects(Scene *scene)
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void device_update_object_transform(UpdateObjectTransformState *state, Object *ob, bool update_all, const Scene *scene)
void device_update_object_transform_task(UpdateObjectTransformState *state)
void device_free(Device *device, DeviceScene *dscene, bool force_free)
string get_cryptomatte_assets(Scene *scene)
bool need_update() const
void device_update_geom_offsets(Device *device, DeviceScene *dscene, Scene *scene)
void device_update_prim_offsets(Device *device, DeviceScene *dscene, Scene *scene)
void device_update_transforms(DeviceScene *dscene, Scene *scene, Progress &progress)
bool device_update_object_transform_pop_work(UpdateObjectTransformState *state, int *start_index, int *num_objects)
void apply_static_transforms(DeviceScene *dscene, Scene *scene, Progress &progress)
void device_update_flags(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress, bool bounds_valid=true)
void update_interactive_motion(Scene *scene)
void compute_bounds(bool motion_blur)
void update_motion(Scene::MotionType need_motion)
bool use_motion() const
NODE_DECLARE BoundBox bounds
size_t attr_map_offset
bool usable_as_light() const
int index
void set_motion_tfm(Transform tfm, const int step_index)
friend class GeometryManager
NODE_SOCKET_API(ParticleSystem *, particle_system)
vector< ParamValue > attributes
int get_device_index() const
int motion_step(const float time) const
void set_tfm(Transform tfm)
void apply_transform(bool apply_to_motion)
friend class ObjectManager
static const uint MAX_MOTION_STEPS
bool has_light_linking() const
bool tfm_equals(Transform tfm)
bool is_traceable() const
float compute_volume_step_size(Progress &progress) const
uint visibility_for_tracing() const
void tag_update(Scene *scene)
float motion_time(const int step) const
bool has_shadow_linking() const
void adjust_volume_tfm(Transform &tfm)
bool intersects_volume
Definition scene.h:133
#define CCL_NAMESPACE_END
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define NODE_SOCKET_API_ARRAY(type_, name)
Definition graph/node.h:64
#define NODE_SOCKET_API_BASE(type_, name, string_name)
Definition graph/node.h:49
const int state
ccl_device_inline uint particle_index(KernelGlobals kg, const int particle)
#define NODE_DECLARE
Definition node_type.h:150
Node(const NodeType *type, ustring name=ustring())