diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-11-04 13:17:38 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-11-04 15:03:33 +0300 |
commit | 31a620b9420cab6292b0aa1ea21c9dd1cf70b8bc (patch) | |
tree | 76cf425e110fe1c78930e54f3b56d24e1485877a /intern/cycles/blender/blender_light.cpp | |
parent | a4a848d01b26ad094dabe0e935dd698847ac8f16 (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_light.cpp')
-rw-r--r-- | intern/cycles/blender/blender_light.cpp | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/intern/cycles/blender/blender_light.cpp b/intern/cycles/blender/blender_light.cpp index 6f95821e31e..ff4ecc5a3f9 100644 --- a/intern/cycles/blender/blender_light.cpp +++ b/intern/cycles/blender/blender_light.cpp @@ -42,7 +42,7 @@ void BlenderSync::sync_light(BL::Object &b_parent, if (!light_map.add_or_update(&light, b_ob, b_parent, key)) { Shader *shader; if (!shader_map.add_or_update(&shader, b_light)) { - if (light->is_portal) + if (light->get_is_portal()) *use_portal = true; return; } @@ -52,16 +52,16 @@ void BlenderSync::sync_light(BL::Object &b_parent, switch (b_light.type()) { case BL::Light::type_POINT: { BL::PointLight b_point_light(b_light); - light->size = b_point_light.shadow_soft_size(); - light->type = LIGHT_POINT; + light->set_size(b_point_light.shadow_soft_size()); + light->set_light_type(LIGHT_POINT); break; } case BL::Light::type_SPOT: { BL::SpotLight b_spot_light(b_light); - light->size = b_spot_light.shadow_soft_size(); - light->type = LIGHT_SPOT; - light->spot_angle = b_spot_light.spot_size(); - light->spot_smooth = b_spot_light.spot_blend(); + light->set_size(b_spot_light.shadow_soft_size()); + light->set_light_type(LIGHT_SPOT); + light->set_spot_angle(b_spot_light.spot_size()); + light->set_spot_smooth(b_spot_light.spot_blend()); break; } /* Hemi were removed from 2.8 */ @@ -72,88 +72,88 @@ void BlenderSync::sync_light(BL::Object &b_parent, // } case BL::Light::type_SUN: { BL::SunLight b_sun_light(b_light); - light->angle = b_sun_light.angle(); - light->type = LIGHT_DISTANT; + light->set_angle(b_sun_light.angle()); + light->set_light_type(LIGHT_DISTANT); break; } case BL::Light::type_AREA: { BL::AreaLight b_area_light(b_light); - light->size = 1.0f; - light->axisu = transform_get_column(&tfm, 0); - light->axisv = transform_get_column(&tfm, 1); - light->sizeu = b_area_light.size(); + light->set_size(1.0f); + light->set_axisu(transform_get_column(&tfm, 0)); + light->set_axisv(transform_get_column(&tfm, 1)); + light->set_sizeu(b_area_light.size()); switch (b_area_light.shape()) { case BL::AreaLight::shape_SQUARE: - light->sizev = light->sizeu; - light->round = false; + light->set_sizev(light->get_sizeu()); + light->set_round(false); break; case BL::AreaLight::shape_RECTANGLE: - light->sizev = b_area_light.size_y(); - light->round = false; + light->set_sizev(b_area_light.size_y()); + light->set_round(false); break; case BL::AreaLight::shape_DISK: - light->sizev = light->sizeu; - light->round = true; + light->set_sizev(light->get_sizeu()); + light->set_round(true); break; case BL::AreaLight::shape_ELLIPSE: - light->sizev = b_area_light.size_y(); - light->round = true; + light->set_sizev(b_area_light.size_y()); + light->set_round(true); break; } - light->type = LIGHT_AREA; + light->set_light_type(LIGHT_AREA); break; } } /* strength */ - light->strength = get_float3(b_light.color()); - light->strength *= BL::PointLight(b_light).energy(); + float3 strength = get_float3(b_light.color()) * BL::PointLight(b_light).energy(); + light->set_strength(strength); /* location and (inverted!) direction */ - light->co = transform_get_column(&tfm, 3); - light->dir = -transform_get_column(&tfm, 2); - light->tfm = tfm; + light->set_co(transform_get_column(&tfm, 3)); + light->set_dir(-transform_get_column(&tfm, 2)); + light->set_tfm(tfm); /* shader */ - vector<Shader *> used_shaders; + array<Node *> used_shaders; find_shader(b_light, used_shaders, scene->default_light); - light->shader = used_shaders[0]; + light->set_shader(static_cast<Shader *>(used_shaders[0])); /* shadow */ PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); PointerRNA clight = RNA_pointer_get(&b_light.ptr, "cycles"); - light->cast_shadow = get_boolean(clight, "cast_shadow"); - light->use_mis = get_boolean(clight, "use_multiple_importance_sampling"); + light->set_cast_shadow(get_boolean(clight, "cast_shadow")); + light->set_use_mis(get_boolean(clight, "use_multiple_importance_sampling")); int samples = get_int(clight, "samples"); if (get_boolean(cscene, "use_square_samples")) - light->samples = samples * samples; + light->set_samples(samples * samples); else - light->samples = samples; + light->set_samples(samples); - light->max_bounces = get_int(clight, "max_bounces"); + light->set_max_bounces(get_int(clight, "max_bounces")); if (b_ob != b_ob_instance) { - light->random_id = random_id; + light->set_random_id(random_id); } else { - light->random_id = hash_uint2(hash_string(b_ob.name().c_str()), 0); + light->set_random_id(hash_uint2(hash_string(b_ob.name().c_str()), 0)); } - if (light->type == LIGHT_AREA) - light->is_portal = get_boolean(clight, "is_portal"); + if (light->get_light_type() == LIGHT_AREA) + light->set_is_portal(get_boolean(clight, "is_portal")); else - light->is_portal = false; + light->set_is_portal(false); - if (light->is_portal) + if (light->get_is_portal()) *use_portal = true; /* visibility */ uint visibility = object_ray_visibility(b_ob); - light->use_diffuse = (visibility & PATH_RAY_DIFFUSE) != 0; - light->use_glossy = (visibility & PATH_RAY_GLOSSY) != 0; - light->use_transmission = (visibility & PATH_RAY_TRANSMIT) != 0; - light->use_scatter = (visibility & PATH_RAY_VOLUME_SCATTER) != 0; + light->set_use_diffuse((visibility & PATH_RAY_DIFFUSE) != 0); + light->set_use_glossy((visibility & PATH_RAY_GLOSSY) != 0); + light->set_use_transmission((visibility & PATH_RAY_TRANSMIT) != 0); + light->set_use_scatter((visibility & PATH_RAY_VOLUME_SCATTER) != 0); /* tag */ light->tag_update(scene); @@ -178,25 +178,25 @@ void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal) if (light_map.add_or_update(&light, b_world, b_world, key) || world_recalc || b_world.ptr.data != world_map) { - light->type = LIGHT_BACKGROUND; + light->set_light_type(LIGHT_BACKGROUND); if (sampling_method == SAMPLING_MANUAL) { - light->map_resolution = get_int(cworld, "sample_map_resolution"); + light->set_map_resolution(get_int(cworld, "sample_map_resolution")); } else { - light->map_resolution = 0; + light->set_map_resolution(0); } - light->shader = scene->default_background; - light->use_mis = sample_as_light; - light->max_bounces = get_int(cworld, "max_bounces"); + light->set_shader(scene->default_background); + light->set_use_mis(sample_as_light); + light->set_max_bounces(get_int(cworld, "max_bounces")); /* force enable light again when world is resynced */ - light->is_enabled = true; + light->set_is_enabled(true); int samples = get_int(cworld, "samples"); if (get_boolean(cscene, "use_square_samples")) - light->samples = samples * samples; + light->set_samples(samples * samples); else - light->samples = samples; + light->set_samples(samples); light->tag_update(scene); light_map.set_recalc(b_world); |