[Bf-blender-cvs] [cf9f997d804] temp-T96710-pbvh-pixels: Cleanup: Define new curves normal mode in DNA

Hans Goudey noreply at git.blender.org
Fri Apr 8 11:07:50 CEST 2022


Commit: cf9f997d804098b9d2644c2474371f3d7eec9b60
Author: Hans Goudey
Date:   Thu Apr 7 18:10:05 2022 -0500
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rBcf9f997d804098b9d2644c2474371f3d7eec9b60

Cleanup: Define new curves normal mode in DNA

Don't include the tangent mode for now, since that
was never implemented for geometry nodes curves.

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

M	source/blender/blenkernel/BKE_spline.hh
M	source/blender/blenkernel/intern/curve_eval.cc
M	source/blender/blenkernel/intern/spline_base.cc
M	source/blender/makesdna/DNA_curves_types.h

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

diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh
index 32330244c08..6cbb47dc709 100644
--- a/source/blender/blenkernel/BKE_spline.hh
+++ b/source/blender/blenkernel/BKE_spline.hh
@@ -51,12 +51,7 @@ using SplinePtr = std::unique_ptr<Spline>;
  */
 class Spline {
  public:
-  enum NormalCalculationMode {
-    ZUp,
-    Minimum,
-    Tangent,
-  };
-  NormalCalculationMode normal_mode = Minimum;
+  NormalMode normal_mode = NORMAL_MODE_MINIMUM_TWIST;
 
   blender::bke::CustomDataAttributes attributes;
 
diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc
index 122df12261c..9b1fd510fa8 100644
--- a/source/blender/blenkernel/intern/curve_eval.cc
+++ b/source/blender/blenkernel/intern/curve_eval.cc
@@ -189,18 +189,17 @@ static HandleType handle_type_from_dna_bezt(const eBezTriple_Handle dna_handle_t
   return BEZIER_HANDLE_AUTO;
 }
 
-static Spline::NormalCalculationMode normal_mode_from_dna_curve(const int twist_mode)
+static NormalMode normal_mode_from_dna_curve(const int twist_mode)
 {
   switch (twist_mode) {
     case CU_TWIST_Z_UP:
-      return Spline::NormalCalculationMode::ZUp;
-    case CU_TWIST_MINIMUM:
-      return Spline::NormalCalculationMode::Minimum;
     case CU_TWIST_TANGENT:
-      return Spline::NormalCalculationMode::Tangent;
+      return NORMAL_MODE_Z_UP;
+    case CU_TWIST_MINIMUM:
+      return NORMAL_MODE_MINIMUM_TWIST;
   }
   BLI_assert_unreachable();
-  return Spline::NormalCalculationMode::Minimum;
+  return NORMAL_MODE_MINIMUM_TWIST;
 }
 
 static KnotsMode knots_mode_from_dna_nurb(const short flag)
@@ -333,8 +332,7 @@ std::unique_ptr<CurveEval> curve_eval_from_dna_curve(const Curve &dna_curve,
 
   /* Normal mode is stored separately in each spline to facilitate combining
    * splines from multiple curve objects, where the value may be different. */
-  const Spline::NormalCalculationMode normal_mode = normal_mode_from_dna_curve(
-      dna_curve.twist_mode);
+  const NormalMode normal_mode = normal_mode_from_dna_curve(dna_curve.twist_mode);
   for (SplinePtr &spline : curve->splines()) {
     spline->normal_mode = normal_mode;
   }
diff --git a/source/blender/blenkernel/intern/spline_base.cc b/source/blender/blenkernel/intern/spline_base.cc
index eecb374cd63..7704a74841a 100644
--- a/source/blender/blenkernel/intern/spline_base.cc
+++ b/source/blender/blenkernel/intern/spline_base.cc
@@ -377,19 +377,14 @@ Span<float3> Spline::evaluated_normals() const
 
   /* Only Z up normals are supported at the moment. */
   switch (this->normal_mode) {
-    case ZUp: {
+    case NORMAL_MODE_Z_UP: {
       calculate_normals_z_up(tangents, normals);
       break;
     }
-    case Minimum: {
+    case NORMAL_MODE_MINIMUM_TWIST: {
       calculate_normals_minimum(tangents, is_cyclic_, normals);
       break;
     }
-    case Tangent: {
-      /* Tangent mode is not yet supported. */
-      calculate_normals_z_up(tangents, normals);
-      break;
-    }
   }
 
   /* Rotate the generated normals with the interpolated tilt data. */
diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h
index a1eefca4ab5..0aa4ebc61d0 100644
--- a/source/blender/makesdna/DNA_curves_types.h
+++ b/source/blender/makesdna/DNA_curves_types.h
@@ -49,6 +49,12 @@ typedef enum KnotsMode {
   NURBS_KNOT_MODE_ENDPOINT_BEZIER = 3,
 } KnotsMode;
 
+/** Method used to calculate the normals of a curve's evaluated points. */
+typedef enum NormalMode {
+  NORMAL_MODE_Z_UP = 0,
+  NORMAL_MODE_MINIMUM_TWIST = 1,
+} NormalMode;
+
 /**
  * A reusable data structure for geometry consisting of many curves. All control point data is
  * stored contiguously for better efficiency. Data for each curve is stored as a slice of the



More information about the Bf-blender-cvs mailing list