Blender V5.0
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)
44 NODE_SOCKET_API(uint, random_id)
45 NODE_SOCKET_API(int, pass_id)
47 NODE_SOCKET_API(float, alpha)
48 NODE_SOCKET_API(ustring, asset_name)
49 vector<ParamValue> attributes;
50 NODE_SOCKET_API(uint, visibility)
52 NODE_SOCKET_API(bool, hide_on_missing_motion)
53 NODE_SOCKET_API(bool, use_holdout)
54 NODE_SOCKET_API(bool, is_shadow_catcher)
57
58 NODE_SOCKET_API(bool, is_caustics_caster)
59 NODE_SOCKET_API(bool, is_caustics_receiver)
60
61 NODE_SOCKET_API(bool, is_bake_target)
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 /* Specifies the position of the object in scene->objects and
81 * in the device vectors. Gets set in device_update. */
82 int index;
83
84 Object();
86
87 void tag_update(Scene *scene);
88
89 void compute_bounds(bool motion_blur);
90 void apply_transform(bool apply_to_motion);
91
92 /* Convert between normalized -1..1 motion time and index
93 * in the motion array. */
94 bool use_motion() const;
95 float motion_time(const int step) const;
96 int motion_step(const float time) const;
97 void update_motion();
98
99 /* Maximum number of motion steps supported (due to Embree). */
100 static const uint MAX_MOTION_STEPS = 129;
101
102 /* Check whether object is traceable and it worth adding it to
103 * kernel scene.
104 */
105 bool is_traceable() const;
106
107 /* Combine object's visibility with all possible internal run-time
108 * determined flags which denotes trace-time visibility.
109 */
111
112 /* Returns the index that is used in the kernel for this object. */
113 int get_device_index() const;
114
115 /* Compute step size from attributes, shaders, transforms. */
116 float compute_volume_step_size() const;
117
118 /* Check whether this object can be used as light-emissive. */
119 bool usable_as_light() const;
120
121 /* Check whether the object participates in light or shadow linking, either as a receiver/blocker
122 * or emitter. */
123 bool has_light_linking() const;
124 bool has_shadow_linking() const;
125
126 protected:
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 {
145 OBJECT_ADDED = (1 << 3),
146 OBJECT_REMOVED = (1 << 4),
147 OBJECT_MODIFIED = (1 << 5),
151
152 /* tag everything in the manager for an update */
154
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, const 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:
187 Object *ob,
188 bool update_all,
189 const Scene *scene);
192 int *start_index,
193 int *num_objects);
194};
195
unsigned int uint
unsigned long long int uint64_t
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)
#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:63
#define NODE_SOCKET_API(type_, name)
Definition graph/node.h:55
ccl_device_inline uint particle_index(KernelGlobals kg, const int particle)
static ulong state[N]
#define NODE_DECLARE
Definition node_type.h:145
void compute_bounds(bool motion_blur)
bool use_motion() const
NODE_DECLARE BoundBox bounds
size_t attr_map_offset
bool usable_as_light() const
float shadow_terminator_shading_offset
friend class GeometryManager
NODE_SOCKET_API(ParticleSystem *, particle_system)
vector< ParamValue > attributes
void update_motion()
int get_device_index() const
int motion_step(const float time) 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
float shadow_terminator_geometry_offset
bool is_traceable() const
uint visibility_for_tracing() const
void tag_update(Scene *scene)
float color[4]
float motion_time(const int step) const
bool has_shadow_linking() const
struct LightgroupMembership * lightgroup
bool intersects_volume
bool override
Definition wm_files.cc:1192
uint8_t flag
Definition wm_window.cc:145