[Bf-blender-cvs] [fe1816f67fb] master: Curves: Rename "Hair" types, variables, and functions to "Curves"

Hans Goudey noreply at git.blender.org
Mon Feb 7 18:57:26 CET 2022


Commit: fe1816f67fbc6aaf383ec77847d668367335d093
Author: Hans Goudey
Date:   Mon Feb 7 11:55:54 2022 -0600
Branches: master
https://developer.blender.org/rBfe1816f67fbc6aaf383ec77847d668367335d093

Curves: Rename "Hair" types, variables, and functions to "Curves"

Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".

This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.

The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.

Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
  existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
  since that is also used by the old hair particle system.

Differential Revision: https://developer.blender.org/D14007

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

M	intern/cycles/blender/curves.cpp
M	intern/cycles/blender/geometry.cpp
M	intern/cycles/blender/object.cpp
M	release/scripts/startup/bl_ui/__init__.py
R074	release/scripts/startup/bl_ui/properties_data_hair.py	release/scripts/startup/bl_ui/properties_data_curves.py
M	release/scripts/startup/bl_ui/space_dopesheet.py
M	release/scripts/startup/bl_ui/space_outliner.py
M	release/scripts/startup/bl_ui/space_userpref.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/CMakeLists.txt
M	source/blender/blenkernel/BKE_attribute.h
A	source/blender/blenkernel/BKE_curves.h
D	source/blender/blenkernel/BKE_hair.h
M	source/blender/blenkernel/BKE_idtype.h
M	source/blender/blenkernel/BKE_main.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/anim_data.c
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/attribute.c
A	source/blender/blenkernel/intern/curves.cc
M	source/blender/blenkernel/intern/customdata.cc
D	source/blender/blenkernel/intern/hair.cc
M	source/blender/blenkernel/intern/idtype.c
M	source/blender/blenkernel/intern/lib_query.c
M	source/blender/blenkernel/intern/lib_remap.c
M	source/blender/blenkernel/intern/main.c
M	source/blender/blenkernel/intern/material.c
M	source/blender/blenkernel/intern/object.cc
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/blentranslation/BLT_translation.h
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc
M	source/blender/draw/CMakeLists.txt
M	source/blender/draw/engines/eevee/eevee_cryptomatte.c
M	source/blender/draw/engines/eevee/eevee_data.c
M	source/blender/draw/engines/eevee/eevee_engine.c
M	source/blender/draw/engines/eevee/eevee_materials.c
M	source/blender/draw/engines/eevee/eevee_private.h
M	source/blender/draw/engines/eevee/eevee_render.c
M	source/blender/draw/engines/overlay/overlay_engine.c
M	source/blender/draw/engines/overlay/overlay_extra.c
M	source/blender/draw/engines/workbench/workbench_engine.c
M	source/blender/draw/intern/draw_cache.c
M	source/blender/draw/intern/draw_cache.h
M	source/blender/draw/intern/draw_cache_impl.h
R067	source/blender/draw/intern/draw_cache_impl_hair.cc	source/blender/draw/intern/draw_cache_impl_curves.cc
M	source/blender/draw/intern/draw_common.c
M	source/blender/draw/intern/draw_manager.c
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/include/UI_icons.h
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/object/CMakeLists.txt
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_modifier.c
M	source/blender/editors/object/object_ops.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/render/render_opengl.cc
M	source/blender/editors/space_buttons/CMakeLists.txt
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_info/info_stats.cc
M	source/blender/editors/space_outliner/outliner_draw.cc
M	source/blender/editors/space_outliner/outliner_intern.hh
M	source/blender/editors/space_outliner/outliner_select.cc
M	source/blender/editors/space_outliner/outliner_tools.cc
M	source/blender/editors/space_outliner/outliner_tree.cc
M	source/blender/editors/space_outliner/tree/tree_element_id.cc
M	source/blender/editors/space_view3d/view3d_buttons.c
M	source/blender/makesdna/DNA_ID.h
M	source/blender/makesdna/DNA_ID_enums.h
R094	source/blender/makesdna/DNA_hair_defaults.h	source/blender/makesdna/DNA_curves_defaults.h
R097	source/blender/makesdna/DNA_hair_types.h	source/blender/makesdna/DNA_curves_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesdna/intern/CMakeLists.txt
M	source/blender/makesdna/intern/dna_defaults.c
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/makesrna/intern/rna_action.c
M	source/blender/makesrna/intern/rna_attribute.c
R079	source/blender/makesrna/intern/rna_hair.c	source/blender/makesrna/intern/rna_curves.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_main.c
M	source/blender/makesrna/intern/rna_main_api.c
M	source/blender/makesrna/intern/rna_material.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/modifiers/CMakeLists.txt

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

diff --git a/intern/cycles/blender/curves.cpp b/intern/cycles/blender/curves.cpp
index 4206a1d8a8b..102ddf5ee32 100644
--- a/intern/cycles/blender/curves.cpp
+++ b/intern/cycles/blender/curves.cpp
@@ -626,11 +626,11 @@ void BlenderSync::sync_particle_hair(
   }
 }
 
-#ifdef WITH_HAIR_NODES
+#ifdef WITH_NEW_CURVES_TYPE
 
-static std::optional<BL::FloatAttribute> find_curves_radius_attribute(BL::Hair b_hair)
+static std::optional<BL::FloatAttribute> find_curves_radius_attribute(BL::Curves b_curves)
 {
-  for (BL::Attribute &b_attribute : b_hair.attributes) {
+  for (BL::Attribute &b_attribute : b_curves.attributes) {
     if (b_attribute.name() != "radius") {
       continue;
     }
@@ -645,16 +645,16 @@ static std::optional<BL::FloatAttribute> find_curves_radius_attribute(BL::Hair b
   return std::nullopt;
 }
 
-static float4 hair_point_as_float4(BL::Hair b_hair,
+static float4 hair_point_as_float4(BL::Curves b_curves,
                                    std::optional<BL::FloatAttribute> b_attr_radius,
                                    const int index)
 {
-  float4 mP = float3_to_float4(get_float3(b_hair.position_data[index].vector()));
+  float4 mP = float3_to_float4(get_float3(b_curves.position_data[index].vector()));
   mP.w = b_attr_radius ? b_attr_radius->data[index].value() : 0.0f;
   return mP;
 }
 
-static float4 interpolate_hair_points(BL::Hair b_hair,
+static float4 interpolate_hair_points(BL::Curves b_curves,
                                       std::optional<BL::FloatAttribute> b_attr_radius,
                                       const int first_point_index,
                                       const int num_points,
@@ -664,12 +664,12 @@ static float4 interpolate_hair_points(BL::Hair b_hair,
   const int point_a = clamp((int)curve_t, 0, num_points - 1);
   const int point_b = min(point_a + 1, num_points - 1);
   const float t = curve_t - (float)point_a;
-  return lerp(hair_point_as_float4(b_hair, b_attr_radius, first_point_index + point_a),
-              hair_point_as_float4(b_hair, b_attr_radius, first_point_index + point_b),
+  return lerp(hair_point_as_float4(b_curves, b_attr_radius, first_point_index + point_a),
+              hair_point_as_float4(b_curves, b_attr_radius, first_point_index + point_b),
               t);
 }
 
-static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair)
+static void export_hair_curves(Scene *scene, Hair *hair, BL::Curves b_curves)
 {
   /* TODO: optimize so we can straight memcpy arrays from Blender? */
 
@@ -689,19 +689,19 @@ static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair)
   }
 
   /* Reserve memory. */
-  const int num_keys = b_hair.points.length();
-  const int num_curves = b_hair.curves.length();
+  const int num_keys = b_curves.points.length();
+  const int num_curves = b_curves.curves.length();
 
   hair->reserve_curves(num_curves, num_keys);
 
-  std::optional<BL::FloatAttribute> b_attr_radius = find_curves_radius_attribute(b_hair);
+  std::optional<BL::FloatAttribute> b_attr_radius = find_curves_radius_attribute(b_curves);
 
   /* Export curves and points. */
   vector<float> points_length;
 
   for (int i = 0; i < num_curves; i++) {
-    const int first_point_index = b_hair.curve_offset_data[i].value();
-    const int num_points = b_hair.curve_offset_data[i + 1].value() - first_point_index;
+    const int first_point_index = b_curves.curve_offset_data[i].value();
+    const int num_points = b_curves.curve_offset_data[i + 1].value() - first_point_index;
 
     float3 prev_co = zero_float3();
     float length = 0.0f;
@@ -712,7 +712,7 @@ static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair)
 
     /* Position and radius. */
     for (int i = 0; i < num_points; i++) {
-      const float3 co = get_float3(b_hair.position_data[first_point_index + i].vector());
+      const float3 co = get_float3(b_curves.position_data[first_point_index + i].vector());
       const float radius = b_attr_radius ? b_attr_radius->data[first_point_index + i].value() :
                                            0.0f;
       hair->add_curve_key(co, radius);
@@ -748,7 +748,7 @@ static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair)
   }
 }
 
-static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_step)
+static void export_hair_curves_motion(Hair *hair, BL::Curves b_curves, int motion_step)
 {
   /* Find or add attribute. */
   Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -761,17 +761,17 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st
 
   /* Export motion keys. */
   const int num_keys = hair->get_curve_keys().size();
-  const int num_curves = b_hair.curves.length();
+  const int num_curves = b_curves.curves.length();
   float4 *mP = attr_mP->data_float4() + motion_step * num_keys;
   bool have_motion = false;
   int num_motion_keys = 0;
   int curve_index = 0;
 
-  std::optional<BL::FloatAttribute> b_attr_radius = find_curves_radius_attribute(b_hair);
+  std::optional<BL::FloatAttribute> b_attr_radius = find_curves_radius_attribute(b_curves);
 
   for (int i = 0; i < num_curves; i++) {
-    const int first_point_index = b_hair.curve_offset_data[i].value();
-    const int num_points = b_hair.curve_offset_data[i + 1].value() - first_point_index;
+    const int first_point_index = b_curves.curve_offset_data[i].value();
+    const int num_points = b_curves.curve_offset_data[i + 1].value() - first_point_index;
 
     Hair::Curve curve = hair->get_curve(curve_index);
     curve_index++;
@@ -782,7 +782,7 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st
         int point_index = first_point_index + i;
 
         if (point_index < num_keys) {
-          mP[num_motion_keys] = hair_point_as_float4(b_hair, b_attr_radius, point_index);
+          mP[num_motion_keys] = hair_point_as_float4(b_curves, b_attr_radius, point_index);
           num_motion_keys++;
 
           if (!have_motion) {
@@ -802,7 +802,7 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st
       for (int i = 0; i < curve.num_keys; i++) {
         const float step = i * step_size;
         mP[num_motion_keys] = interpolate_hair_points(
-            b_hair, b_attr_radius, first_point_index, num_points, step);
+            b_curves, b_attr_radius, first_point_index, num_points, step);
         num_motion_keys++;
       }
       have_motion = true;
@@ -819,12 +819,12 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st
 void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int motion_step)
 {
   /* Convert Blender hair to Cycles curves. */
-  BL::Hair b_hair(b_ob_info.object_data);
+  BL::Curves b_curves(b_ob_info.object_data);
   if (motion) {
-    export_hair_curves_motion(hair, b_hair, motion_step);
+    export_hair_curves_motion(hair, b_curves, motion_step);
   }
   else {
-    export_hair_curves(scene, hair, b_hair);
+    export_hair_curves(scene, hair, b_curves);
   }
 }
 #else
@@ -847,8 +847,8 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, H
   new_hair.set_used_shaders(used_shaders);
 
   if (view_layer.use_hair) {
-#ifdef WITH_HAIR_NODES
-    if (b_ob_info.object_data.is_a(&RNA_Hair)) {
+#ifdef WITH_NEW_CURVES_TYPE
+    if (b_ob_info.object_data.is_a(&RNA_Curves)) {
       /* Hair object. */
       sync_hair(&new_hair, b_ob_info, false);
     }
@@ -901,8 +901,8 @@ void BlenderSync::sync_hair_motion(BL::Depsgraph b_depsgraph,
 
   /* Export deformed coordinates. */
   if (ccl::BKE_object_is_deform_modified(b_ob_info, b_scene, preview)) {
-#ifdef WITH_HAIR_NODES
-    if (b_ob_info.object_data.is_a(&RNA_Hair)) {
+#ifdef WITH_NEW_CURVES_TYPE
+    if (b_ob_info.object_data.is_a(&RNA_Curves)) {
       /* Hair object. */
       sync_hair(hair, b_ob_info, true, motion_step);
       return;
diff --git a/intern/cycles/blender/geometry.cpp b/intern/cycles/blender/geometry.cpp
index 78c803b7adb..a9b61f2578f 100644
--- a/intern/cycles/blender/geometry.cpp
+++ b/intern/cycles/blender/geometry.cpp
@@ -32,8 +32,8 @@ CCL_NAMESPACE_BEGIN
 
 static Geometry::Type determine_geom_type(BObjectInfo &b_ob_info, bool use_particle_hair)
 {
-#ifdef WITH_HAIR_NODES
-  if (b_ob_info.object_data.is_a(&RNA_Hair) || use_particle_hair) {
+#ifdef WITH_NEW_CURVES_TYPE
+  if (b_ob_info.object_data.is_a(&RNA_Curves) || use_particle_hair) {
 #else
   if (use_particle_hair) {
 #endif
@@ -231,8 +231,8 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
     if (progress.get_cancel())
       return;
 
-#ifdef WITH_HAIR_NODES
-    if (b_ob_info.object_data.is_a(&RNA_Hair) || use_particle_hair) {
+#ifdef WITH_NEW_CURVES_TYPE
+    if (b_ob_info.object_data.is_a(&RNA_Curves) || use_particle_hair) {
 #else
     if (use_particle_hair) {
 #endif
diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp
index 65a04a39660..22acc09c538 100644
--- a/intern/cycles/blender/object.cpp
+++ b/intern/cycles/blender/object.cpp
@@ -72,7 +72,7 @@ bool BlenderSync::object_is_geometry(BObjectInfo &b_ob_info)
 
   BL::Object::type_enum type = b_ob_info.iter_object.type();
 
-  if (type == BL::Object::type_VOLUME || type == BL::Object::type_HAIR ||
+  if (type == BL::Object::type_VOLUME || type == BL::Object::type_CURVES ||
       type == BL::Object::type_POINTCLOUD) {
     /* Will be exported attached to mesh. */
     return true;
@@ -97,7 +97,7 @@ bool BlenderSync::object_can_have_geometry(BL::Object &b_ob)
     case BL::Object::type_SURFACE:
     case BL::Object::type_META:
     case BL::Object::type_FONT:
-    case BL::Object::type_HAIR:
+    case BL::Object::type_CURVES:
     case BL::Object::type_POINTCLOUD:
     case BL::Object::type_VOLUME:
       return true;
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 1fb40ad8bc8..7c254596683 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -33,9 +33,9 @@ _modules = [
     "properties_data_bone",
     "properties_data_camera",
     "properties_data_curve",
+    "properties_data_curves",
   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list