Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2020-10-26 23:00:37 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2020-10-27 01:11:14 +0300
commit527f8b32b32187f754e5b176db6377736f9cb8ff (patch)
treeda291ed0d180d105521a03b73107ec6c9c39ff3b /intern/cycles/blender/blender_object.cpp
parentd6180dd2f7e8e9fdfa472f99f7a17bcb487c4b2d (diff)
Cycles API: encapsulate Node socket members
This encapsulates Node socket members behind a set of specific methods; as such it is no longer possible to directly access Node class members from exporters and parts of Cycles. The methods are defined via the NODE_SOCKET_API macros in `graph/ node.h`, and are for getting or setting a specific socket's value, as well as querying or modifying the state of its update flag. The setters will check whether the value has changed and tag the socket as modified appropriately. This will let us know how a Node has changed and what to update, which is the first concrete step toward a more granular scene update system. Since the setters will tag the Node sockets as modified when passed different data, this patch also removes the various `modified` methods on Nodes in favor of `Node::is_modified` which checks the sockets' update flags status. Reviewed By: brecht Maniphest Tasks: T79174 Differential Revision: https://developer.blender.org/D8544
Diffstat (limited to 'intern/cycles/blender/blender_object.cpp')
-rw-r--r--intern/cycles/blender/blender_object.cpp108
1 files changed, 48 insertions, 60 deletions
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 23faacc15da..609ca8f6f79 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -199,11 +199,13 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* Set transform at matching motion time step. */
int time_index = object->motion_step(motion_time);
if (time_index >= 0) {
- object->motion[time_index] = tfm;
+ array<Transform> motion = object->get_motion();
+ motion[time_index] = tfm;
+ object->set_motion(motion);
}
/* mesh deformation */
- if (object->geometry)
+ if (object->get_geometry())
sync_geometry_motion(b_depsgraph,
b_ob_instance,
object,
@@ -225,38 +227,29 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* b_ob is owned by the iterator and will go out of scope at the end of the block.
* b_ob_instance is the original object and will remain valid for deferred geometry
* sync. */
- object->geometry = sync_geometry(b_depsgraph,
- b_ob_instance,
- b_ob_instance,
- object_updated,
- use_particle_hair,
- object_geom_task_pool);
+ Geometry *geometry = sync_geometry(b_depsgraph,
+ b_ob_instance,
+ b_ob_instance,
+ object_updated,
+ use_particle_hair,
+ object_geom_task_pool);
+ object->set_geometry(geometry);
/* special case not tracked by object update flags */
/* holdout */
- if (use_holdout != object->use_holdout) {
- object->use_holdout = use_holdout;
+ object->set_use_holdout(use_holdout);
+ if (object->use_holdout_is_modified()) {
scene->object_manager->tag_update(scene);
- object_updated = true;
}
- if (visibility != object->visibility) {
- object->visibility = visibility;
- object_updated = true;
- }
+ object->set_visibility(visibility);
bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher");
- if (is_shadow_catcher != object->is_shadow_catcher) {
- object->is_shadow_catcher = is_shadow_catcher;
- object_updated = true;
- }
+ object->set_is_shadow_catcher(is_shadow_catcher);
float shadow_terminator_offset = get_float(cobject, "shadow_terminator_offset");
- if (shadow_terminator_offset != object->shadow_terminator_offset) {
- object->shadow_terminator_offset = shadow_terminator_offset;
- object_updated = true;
- }
+ object->set_shadow_terminator_offset(shadow_terminator_offset);
/* sync the asset name for Cryptomatte */
BL::Object parent = b_ob.parent();
@@ -270,48 +263,49 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
else {
parent_name = b_ob.name();
}
- if (object->asset_name != parent_name) {
- object->asset_name = parent_name;
- object_updated = true;
- }
+ object->set_asset_name(parent_name);
/* object sync
* transform comparison should not be needed, but duplis don't work perfect
* in the depsgraph and may not signal changes, so this is a workaround */
- if (object_updated || (object->geometry && object->geometry->need_update) ||
- tfm != object->tfm) {
+ if (object->is_modified() || object_updated ||
+ (object->get_geometry() && object->get_geometry()->is_modified()) ||
+ tfm != object->get_tfm()) {
object->name = b_ob.name().c_str();
- object->pass_id = b_ob.pass_index();
- object->color = get_float3(b_ob.color());
- object->tfm = tfm;
- object->motion.clear();
+ object->set_pass_id(b_ob.pass_index());
+ object->set_color(get_float3(b_ob.color()));
+ object->set_tfm(tfm);
+ array<Transform> motion;
+ object->set_motion(motion);
/* motion blur */
Scene::MotionType need_motion = scene->need_motion();
- if (need_motion != Scene::MOTION_NONE && object->geometry) {
- Geometry *geom = object->geometry;
- geom->use_motion_blur = false;
- geom->motion_steps = 0;
+ if (need_motion != Scene::MOTION_NONE && object->get_geometry()) {
+ Geometry *geom = object->get_geometry();
+ geom->set_use_motion_blur(false);
+ geom->set_motion_steps(0);
uint motion_steps;
if (need_motion == Scene::MOTION_BLUR) {
motion_steps = object_motion_steps(b_parent, b_ob, Object::MAX_MOTION_STEPS);
- geom->motion_steps = motion_steps;
+ geom->set_motion_steps(motion_steps);
if (motion_steps && object_use_deform_motion(b_parent, b_ob)) {
- geom->use_motion_blur = true;
+ geom->set_use_motion_blur(true);
}
}
else {
motion_steps = 3;
- geom->motion_steps = motion_steps;
+ geom->set_motion_steps(motion_steps);
}
- object->motion.clear();
- object->motion.resize(motion_steps, transform_empty());
+ motion.resize(motion_steps, transform_empty());
if (motion_steps) {
- object->motion[motion_steps / 2] = tfm;
+ motion[motion_steps / 2] = tfm;
+
+ /* update motion socket before trying to access object->motion_time */
+ object->set_motion(motion);
for (size_t step = 0; step < motion_steps; step++) {
motion_times.insert(object->motion_time(step));
@@ -321,15 +315,15 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* dupli texture coordinates and random_id */
if (is_instance) {
- object->dupli_generated = 0.5f * get_float3(b_instance.orco()) -
- make_float3(0.5f, 0.5f, 0.5f);
- object->dupli_uv = get_float2(b_instance.uv());
- object->random_id = b_instance.random_id();
+ object->set_dupli_generated(0.5f * get_float3(b_instance.orco()) -
+ make_float3(0.5f, 0.5f, 0.5f));
+ object->set_dupli_uv(get_float2(b_instance.uv()));
+ object->set_random_id(b_instance.random_id());
}
else {
- object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
- object->dupli_uv = make_float2(0.0f, 0.0f);
- object->random_id = hash_uint2(hash_string(object->name.c_str()), 0);
+ object->set_dupli_generated(make_float3(0.0f, 0.0f, 0.0f));
+ object->set_dupli_uv(make_float2(0.0f, 0.0f));
+ object->set_random_id(hash_uint2(hash_string(object->name.c_str()), 0));
}
object->tag_update(scene);
@@ -461,20 +455,18 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
if (b_override)
b_cam = b_override;
- Camera prevcam = *(scene->camera);
-
int frame_center = b_scene.frame_current();
float subframe_center = b_scene.frame_subframe();
float frame_center_delta = 0.0f;
if (scene->need_motion() != Scene::MOTION_PASS &&
- scene->camera->motion_position != Camera::MOTION_POSITION_CENTER) {
- float shuttertime = scene->camera->shuttertime;
- if (scene->camera->motion_position == Camera::MOTION_POSITION_END) {
+ scene->camera->get_motion_position() != Camera::MOTION_POSITION_CENTER) {
+ float shuttertime = scene->camera->get_shuttertime();
+ if (scene->camera->get_motion_position() == Camera::MOTION_POSITION_END) {
frame_center_delta = -shuttertime * 0.5f;
}
else {
- assert(scene->camera->motion_position == Camera::MOTION_POSITION_START);
+ assert(scene->camera->get_motion_position() == Camera::MOTION_POSITION_START);
frame_center_delta = shuttertime * 0.5f;
}
@@ -535,10 +527,6 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
python_thread_state_restore(python_thread_state);
b_engine.frame_set(frame_center, subframe_center);
python_thread_state_save(python_thread_state);
-
- /* tag camera for motion update */
- if (scene->camera->motion_modified(prevcam))
- scene->camera->tag_update();
}
CCL_NAMESPACE_END