[Bf-blender-cvs] [331dbf38c6f] cycles_procedural_api: use getters and setters for Light

Kévin Dietrich noreply at git.blender.org
Mon Sep 7 05:03:34 CEST 2020


Commit: 331dbf38c6f90fa18dc0cdf5b34895f7d486e6d9
Author: Kévin Dietrich
Date:   Tue Sep 1 06:15:50 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB331dbf38c6f90fa18dc0cdf5b34895f7d486e6d9

use getters and setters for Light

===================================================================

M	intern/cycles/blender/blender_light.cpp
M	intern/cycles/graph/node.cpp
M	intern/cycles/graph/node.h
M	intern/cycles/graph/node_type.cpp
M	intern/cycles/render/integrator.cpp
M	intern/cycles/render/light.cpp
M	intern/cycles/render/light.h
M	intern/cycles/render/shader.cpp

===================================================================

diff --git a/intern/cycles/blender/blender_light.cpp b/intern/cycles/blender/blender_light.cpp
index f1b0a36c78a..77a914e3b8c 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(scene, &light, b_ob, b_parent, key)) {
     Shader *shader;
     if (!shader_map.add_or_update(scene, &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 */
   array<Shader *> used_shaders;
   find_shader(b_light, used_shaders, scene->default_light);
-  light->shader = used_shaders[0];
+  light->set_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(scene, &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);
diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp
index 2755f894c8e..30dc9f8b512 100644
--- a/intern/cycles/graph/node.cpp
+++ b/intern/cycles/graph/node.cpp
@@ -140,6 +140,13 @@ void Node::set(const SocketType &input, Node *value)
   set_if_different(input, value);
 }
 
+// todo(kevin) : Light::set_shader does not select the overload taking Node* but the one with taking bool
+void Node::set(const SocketType &input, Shader *value)
+{
+  assert(input.type == SocketType::NODE);
+  set_if_different(input, value);
+}
+
 /* set array values */
 void Node::set(const SocketType &input, array<bool> &value)
 {
diff --git a/intern/cycles/graph/node.h b/intern/cycles/graph/node.h
index 50eb73f0bfe..4ef68015302 100644
--- a/intern/cycles/graph/node.h
+++ b/intern/cycles/graph/node.h
@@ -46,7 +46,7 @@ struct Transform;
     const SocketType *socket = get_##name##_socket(); \
     return socket_is_modified(*socket); \
   } \
-  const type_ &get_##name() const \
+  type_ const &get_##name() const \
   { \
     const SocketType *socket = get_##name##_socket(); \
     return get_socket_value<type_>(this, *socket); \
@@ -100,6 +100,7 @@ struct Node {
   void set(const SocketType &input, ustring value);
   void set(const SocketType &input, const Transform &value);
   void set(const SocketType &input, Node *value);
+  void set(const SocketType &input, Shader *value);
 
   /* set array values. the memory from the input array will taken over
    * by the node and the input array will be empty after return */
diff --git a/intern/cycles/graph/node_type.cpp b/intern/cycles/graph/node_type.cpp
index 8232cf0b7c3..0ec421023a2 100644
--- a/intern/cycles/graph/node_type.cpp
+++ b/intern/cycles/graph/node_type.cpp
@@ -167,7 +167,7 @@ void NodeType::register_input(ustring name,
   socket.enum_values = enum_values;
   socket.node_type = node_type;
   socket.flags = flags | extra_flags;
-  assert(inputs.size() < std::numeric_limits<SocketModifiedFlag>::digits);
+  assert(inputs.size() < std::numeric_limits<SocketModifiedFlags>::digits);
   socket.modified_flag_bit = (1ul << inputs.size());
   inputs.push_back(socket);
 }
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index 4434032c740..7b10db699db 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -218,7 +218,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
 
   if (method == BRANCHED_PATH) {
     foreach (Light *light, scene->lights)
-      max_samples = max(max_samples, light->samples);
+      max_samples = max(

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list