[Bf-blender-cvs] [fac0a317cbc] lanpr-under-gp: Port smooth countour modifier to 2.90

Sebastian Parborg noreply at git.blender.org
Sat Jul 25 06:16:53 CEST 2020


Commit: fac0a317cbc6db14893f2ad822fbd4203301a8d3
Author: Sebastian Parborg
Date:   Mon Jul 6 03:05:16 2020 +0200
Branches: lanpr-under-gp
https://developer.blender.org/rBfac0a317cbc6db14893f2ad822fbd4203301a8d3

Port smooth countour modifier to 2.90

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

M	intern/opensubdiv/internal/evaluator/evaluator_capi.cc
M	intern/opensubdiv/internal/evaluator/evaluator_impl.cc
M	intern/opensubdiv/internal/evaluator/evaluator_impl.h
M	intern/opensubdiv/opensubdiv_evaluator_capi.h
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/MOD_modifiertypes.h
A	source/blender/modifiers/intern/MOD_smooth_contour.c
M	source/blender/modifiers/intern/MOD_util.c

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

diff --git a/intern/opensubdiv/internal/evaluator/evaluator_capi.cc b/intern/opensubdiv/internal/evaluator/evaluator_capi.cc
index 4b12206e103..31be17983c4 100644
--- a/intern/opensubdiv/internal/evaluator/evaluator_capi.cc
+++ b/intern/opensubdiv/internal/evaluator/evaluator_capi.cc
@@ -101,6 +101,21 @@ void evaluateLimit(OpenSubdiv_Evaluator *evaluator,
   evaluator->impl->eval_output->evaluateLimit(ptex_face_index, face_u, face_v, P, dPdu, dPdv);
 }
 
+void evaluateLimit2(OpenSubdiv_Evaluator *evaluator,
+                    const int ptex_face_index,
+                    const float face_u,
+                    const float face_v,
+                    float P[3],
+                    float dPdu[3],
+                    float dPdv[3],
+                    float dPduu[3],
+                    float dPduv[3],
+                    float dPdvv[3])
+{
+  evaluator->impl->eval_output->evaluateLimit2(
+      ptex_face_index, face_u, face_v, P, dPdu, dPdv, dPduu, dPduv, dPdvv);
+}
+
 void evaluatePatchesLimit(OpenSubdiv_Evaluator *evaluator,
                           const OpenSubdiv_PatchCoord *patch_coords,
                           const int num_patch_coords,
@@ -145,6 +160,7 @@ void assignFunctionPointers(OpenSubdiv_Evaluator *evaluator)
   evaluator->refine = refine;
 
   evaluator->evaluateLimit = evaluateLimit;
+  evaluator->evaluateLimit2 = evaluateLimit2;
   evaluator->evaluateVarying = evaluateVarying;
   evaluator->evaluateFaceVarying = evaluateFaceVarying;
 
diff --git a/intern/opensubdiv/internal/evaluator/evaluator_impl.cc b/intern/opensubdiv/internal/evaluator/evaluator_impl.cc
index 341e8dbc233..de05c9d2a93 100644
--- a/intern/opensubdiv/internal/evaluator/evaluator_impl.cc
+++ b/intern/opensubdiv/internal/evaluator/evaluator_impl.cc
@@ -453,18 +453,71 @@ class VolatileEvalOutput {
     RawDataWrapperBuffer<float> dPdu_data(dPdu), dPdv_data(dPdv);
     // TODO(sergey): Support interleaved vertex-varying data.
     BufferDescriptor P_desc(0, 3, 3);
-    BufferDescriptor dpDu_desc(0, 3, 3), pPdv_desc(0, 3, 3);
+    BufferDescriptor dPdu_desc(0, 3, 3), dPdv_desc(0, 3, 3);
     ConstPatchCoordWrapperBuffer patch_coord_buffer(patch_coord, num_patch_coords);
     const EVALUATOR *eval_instance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
-        evaluator_cache_, src_desc_, P_desc, dpDu_desc, pPdv_desc, device_context_);
+        evaluator_cache_, src_desc_, P_desc, dPdu_desc, dPdv_desc, device_context_);
     EVALUATOR::EvalPatches(src_data_,
                            src_desc_,
                            &P_data,
                            P_desc,
                            &dPdu_data,
-                           dpDu_desc,
+                           dPdu_desc,
                            &dPdv_data,
-                           pPdv_desc,
+                           dPdv_desc,
+                           patch_coord_buffer.GetNumVertices(),
+                           &patch_coord_buffer,
+                           patch_table_,
+                           eval_instance,
+                           device_context_);
+  }
+
+  // NOTE: P, dPdu, dPdv, etc must point to a memory of at least float[3]*num_patch_coords.
+  void evalPatchesWithDerivatives2(const PatchCoord *patch_coord,
+                                   const int num_patch_coords,
+                                   float *P,
+                                   float *dPdu,
+                                   float *dPdv,
+                                   float *dPduu,
+                                   float *dPduv,
+                                   float *dPdvv)
+  {
+    assert(dPdu);
+    assert(dPdv);
+    assert(dPduu);
+    assert(dPduv);
+    assert(dPdvv);
+    RawDataWrapperBuffer<float> P_data(P);
+    RawDataWrapperBuffer<float> dPdu_data(dPdu), dPdv_data(dPdv), dPduu_data(dPduu),
+        dPduv_data(dPduv), dPdvv_data(dPdvv);
+    // TODO(sergey): Support interleaved vertex-varying data.
+    BufferDescriptor P_desc(0, 3, 3);
+    BufferDescriptor dPdu_desc(0, 3, 3), dPdv_desc(0, 3, 3), dPduu_desc(0, 3, 3),
+        dPduv_desc(0, 3, 3), dPdvv_desc(0, 3, 3);
+    ConstPatchCoordWrapperBuffer patch_coord_buffer(patch_coord, num_patch_coords);
+    const EVALUATOR *eval_instance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(evaluator_cache_,
+                                                                              src_desc_,
+                                                                              P_desc,
+                                                                              dPdu_desc,
+                                                                              dPdv_desc,
+                                                                              dPduu_desc,
+                                                                              dPduv_desc,
+                                                                              dPdvv_desc,
+                                                                              device_context_);
+    EVALUATOR::EvalPatches(src_data_,
+                           src_desc_,
+                           &P_data,
+                           P_desc,
+                           &dPdu_data,
+                           dPdu_desc,
+                           &dPdv_data,
+                           dPdv_desc,
+                           &dPduu_data,
+                           dPduu_desc,
+                           &dPduv_data,
+                           dPduv_desc,
+                           &dPdvv_data,
+                           dPdvv_desc,
                            patch_coord_buffer.GetNumVertices(),
                            &patch_coord_buffer,
                            patch_table_,
@@ -686,6 +739,31 @@ void CpuEvalOutputAPI::evaluateLimit(const int ptex_face_index,
   }
 }
 
+void CpuEvalOutputAPI::evaluateLimit2(const int ptex_face_index,
+                                      float face_u,
+                                      float face_v,
+                                      float P[3],
+                                      float dPdu[3],
+                                      float dPdv[3],
+                                      float dPduu[3],
+                                      float dPduv[3],
+                                      float dPdvv[3])
+{
+  assert(face_u >= 0.0f);
+  assert(face_u <= 1.0f);
+  assert(face_v >= 0.0f);
+  assert(face_v <= 1.0f);
+  const PatchTable::PatchHandle *handle = patch_map_->FindPatch(ptex_face_index, face_u, face_v);
+  PatchCoord patch_coord(*handle, face_u, face_v);
+  if (dPdu != NULL || dPdv != NULL || dPduu != NULL || dPduv != NULL || dPdvv != NULL) {
+    implementation_->evalPatchesWithDerivatives2(
+        &patch_coord, 1, P, dPdu, dPdv, dPduu, dPduv, dPdvv);
+  }
+  else {
+    implementation_->evalPatches(&patch_coord, 1, P);
+  }
+}
+
 void CpuEvalOutputAPI::evaluateVarying(const int ptex_face_index,
                                        float face_u,
                                        float face_v,
diff --git a/intern/opensubdiv/internal/evaluator/evaluator_impl.h b/intern/opensubdiv/internal/evaluator/evaluator_impl.h
index 6a3682efa62..391b4451c9f 100644
--- a/intern/opensubdiv/internal/evaluator/evaluator_impl.h
+++ b/intern/opensubdiv/internal/evaluator/evaluator_impl.h
@@ -107,6 +107,16 @@ class CpuEvalOutputAPI {
                      float dPdu[3],
                      float dPdv[3]);
 
+  void evaluateLimit2(const int ptex_face_index,
+                      float face_u,
+                      float face_v,
+                      float P[3],
+                      float dPdu[3],
+                      float dPdv[3],
+                      float dPduu[3],
+                      float dPduv[3],
+                      float dPdvv[3]);
+
   // Evaluate varying data at a given bilinear coordinate of given ptex face.
   void evaluateVarying(const int ptes_face_index, float face_u, float face_v, float varying[3]);
 
diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.h b/intern/opensubdiv/opensubdiv_evaluator_capi.h
index b860ae8db2e..eaf7c3866cb 100644
--- a/intern/opensubdiv/opensubdiv_evaluator_capi.h
+++ b/intern/opensubdiv/opensubdiv_evaluator_capi.h
@@ -93,6 +93,17 @@ typedef struct OpenSubdiv_Evaluator {
                         float dPdu[3],
                         float dPdv[3]);
 
+  void (*evaluateLimit2)(struct OpenSubdiv_Evaluator *evaluator,
+                         const int ptex_face_index,
+                         float face_u,
+                         float face_v,
+                         float P[3],
+                         float dPdu[3],
+                         float dPdv[3],
+                         float dPduu[3],
+                         float dPduv[3],
+                         float dPdvv[3]);
+
   // Evaluate varying data at a given bilinear coordinate of given ptex face.
   void (*evaluateVarying)(struct OpenSubdiv_Evaluator *evaluator,
                           const int ptex_face_index,
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 47215f3ccda..553b039f166 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2174,6 +2174,9 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
             case eModifierType_Simulation:
               data.icon = ICON_PHYSICS; /* TODO: Use correct icon. */
               break;
+            case eModifierType_SmoothContour:
+              data.icon = ICON_SMOOTHCURVE; /* TODO: Use correct icon. */
+              break;
               /* Default */
             case eModifierType_None:
             case eModifierType_ShapeKey:
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 60ad0eae576..d0413958c09 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -95,6 +95,7 @@ typedef enum ModifierType {
   eModifierType_Weld = 55,
   eModifierType_Fluid = 56,
   eModifierType_Simulation = 57,
+  eModifierType_SmoothContour = 58,
   NUM_MODIFIER_T

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list