Blender V4.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#ifndef __OBJECT_H__
6#define __OBJECT_H__
7
8#include "graph/node.h"
9
10/* included as Object::set_particle_system defined through NODE_SOCKET_API does
11 * not select the right Node::set overload as it does not know that ParticleSystem
12 * is a Node */
13#include "scene/geometry.h"
14#include "scene/particles.h"
15#include "scene/scene.h"
16
17#include "util/array.h"
18#include "util/boundbox.h"
19#include "util/param.h"
20#include "util/thread.h"
21#include "util/transform.h"
22#include "util/types.h"
23#include "util/vector.h"
24
26
27class Device;
28class DeviceScene;
29class Geometry;
30class ParticleSystem;
31class Progress;
32class Scene;
33struct Transform;
35class ObjectManager;
36
37/* Object */
38
39class Object : public Node {
40 public:
42
43 NODE_SOCKET_API(Geometry *, geometry)
46 NODE_SOCKET_API(uint, random_id)
47 NODE_SOCKET_API(int, pass_id)
49 NODE_SOCKET_API(float, alpha)
50 NODE_SOCKET_API(ustring, asset_name)
51 vector<ParamValue> attributes;
52 NODE_SOCKET_API(uint, visibility)
54 NODE_SOCKET_API(bool, hide_on_missing_motion)
55 NODE_SOCKET_API(bool, use_holdout)
56 NODE_SOCKET_API(bool, is_shadow_catcher)
57 NODE_SOCKET_API(float, shadow_terminator_shading_offset)
58 NODE_SOCKET_API(float, shadow_terminator_geometry_offset)
59
60 NODE_SOCKET_API(bool, is_caustics_caster)
61 NODE_SOCKET_API(bool, is_caustics_receiver)
62
63 NODE_SOCKET_API(float3, dupli_generated)
64 NODE_SOCKET_API(float2, dupli_uv)
65
66 NODE_SOCKET_API(ParticleSystem *, particle_system);
68
69 NODE_SOCKET_API(float, ao_distance)
70
72 NODE_SOCKET_API(uint, receiver_light_set)
73 NODE_SOCKET_API(uint64_t, light_set_membership)
74 NODE_SOCKET_API(uint, blocker_shadow_set)
75 NODE_SOCKET_API(uint64_t, shadow_set_membership)
76
77 /* Set during device update. */
79
80 Object();
81 ~Object();
82
83 void tag_update(Scene *scene);
84
85 void compute_bounds(bool motion_blur);
86 void apply_transform(bool apply_to_motion);
87
88 /* Convert between normalized -1..1 motion time and index
89 * in the motion array. */
90 bool use_motion() const;
91 float motion_time(int step) const;
92 int motion_step(float time) const;
93 void update_motion();
94
95 /* Maximum number of motion steps supported (due to Embree). */
96 static const uint MAX_MOTION_STEPS = 129;
97
98 /* Check whether object is traceable and it worth adding it to
99 * kernel scene.
100 */
101 bool is_traceable() const;
102
103 /* Combine object's visibility with all possible internal run-time
104 * determined flags which denotes trace-time visibility.
105 */
107
108 /* Returns the index that is used in the kernel for this object. */
109 int get_device_index() const;
110
111 /* Compute step size from attributes, shaders, transforms. */
112 float compute_volume_step_size() const;
113
114 /* Check whether this object can be used as light-emissive. */
115 bool usable_as_light() const;
116
117 /* Check whether the object participates in light or shadow linking, either as a receiver/blocker
118 * or emitter. */
119 bool has_light_linking() const;
120 bool has_shadow_linking() const;
121
122 protected:
123 /* Specifies the position of the object in scene->objects and
124 * in the device vectors. Gets set in device_update. */
125 int index;
126
127 /* Reference to the attribute map with object attributes,
128 * or 0 if none. Set in update_svm_attributes. */
130
131 friend class ObjectManager;
132 friend class GeometryManager;
133};
134
135/* Object Manager */
136
138 uint32_t update_flags;
139
140 public:
141 enum : uint32_t {
142 PARTICLE_MODIFIED = (1 << 0),
143 GEOMETRY_MANAGER = (1 << 1),
144 MOTION_BLUR_MODIFIED = (1 << 2),
145 OBJECT_ADDED = (1 << 3),
146 OBJECT_REMOVED = (1 << 4),
147 OBJECT_MODIFIED = (1 << 5),
148 HOLDOUT_MODIFIED = (1 << 6),
149 TRANSFORM_MODIFIED = (1 << 7),
150 VISIBILITY_MODIFIED = (1 << 8),
151
152 /* tag everything in the manager for an update */
153 UPDATE_ALL = ~0u,
154
155 UPDATE_NONE = 0u,
156 };
157
159
162
163 void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
164 void device_update_transforms(DeviceScene *dscene, Scene *scene, Progress &progress);
165 void device_update_prim_offsets(Device *device, DeviceScene *dscene, Scene *scene);
166
167 void device_update_flags(Device *device,
168 DeviceScene *dscene,
169 Scene *scene,
170 Progress &progress,
171 bool bounds_valid = true);
172 void device_update_geom_offsets(Device *device, DeviceScene *dscene, Scene *scene);
173
174 void device_free(Device *device, DeviceScene *dscene, bool force_free);
175
176 void tag_update(Scene *scene, uint32_t flag);
177
178 bool need_update() const;
179
180 void apply_static_transforms(DeviceScene *dscene, Scene *scene, Progress &progress);
181
182 string get_cryptomatte_objects(Scene *scene);
183 string get_cryptomatte_assets(Scene *scene);
184
185 protected:
186 void device_update_object_transform(UpdateObjectTransformState *state,
187 Object *ob,
188 bool update_all,
189 const Scene *scene);
192 int *start_index,
193 int *num_objects);
194};
195
197
198#endif /* __OBJECT_H__ */
unsigned int uint
void device_update_object_transform_task(UpdateObjectTransformState *state)
bool device_update_object_transform_pop_work(UpdateObjectTransformState *state, int *start_index, int *num_objects)
#define CCL_NAMESPACE_END
#define NODE_SOCKET_API_ARRAY(type_, name)
Definition graph/node.h:63
#define NODE_SOCKET_API(type_, name)
Definition graph/node.h:55
ccl_device_inline uint particle_index(KernelGlobals kg, int particle)
static ulong state[N]
#define NODE_DECLARE
Definition node_type.h:142
unsigned int uint32_t
Definition stdint.h:80
unsigned __int64 uint64_t
Definition stdint.h:90
void compute_bounds(bool motion_blur)
int motion_step(float time) const
bool use_motion() const
NODE_DECLARE BoundBox bounds
size_t attr_map_offset
bool usable_as_light() const
void update_motion()
int get_device_index() const
void apply_transform(bool apply_to_motion)
friend class ObjectManager
float compute_volume_step_size() const
static const uint MAX_MOTION_STEPS
bool has_light_linking() const
bool is_traceable() const
uint visibility_for_tracing() const
void tag_update(Scene *scene)
float motion_time(int step) const
bool has_shadow_linking() const
struct LightgroupMembership * lightgroup
bool intersects_volume