[Bf-blender-cvs] [aa7c42d5f97] curve-nodes-modifier: Working curve modifier evaluation, nodes modifier uses pre-tessellated deform

Hans Goudey noreply at git.blender.org
Tue Jul 13 01:40:43 CEST 2021


Commit: aa7c42d5f97f4989bf79df724283f2548310c664
Author: Hans Goudey
Date:   Mon Jun 28 13:14:04 2021 -0500
Branches: curve-nodes-modifier
https://developer.blender.org/rBaa7c42d5f97f4989bf79df724283f2548310c664

Working curve modifier evaluation, nodes modifier uses pre-tessellated deform

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

M	source/blender/blenkernel/BKE_curve.h
M	source/blender/blenkernel/BKE_mesh.h
M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/displist.cc
M	source/blender/blenkernel/intern/mesh_convert.c

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

diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index dbff1e23ad7..c7c5f59cab2 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -157,7 +157,7 @@ struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
 const struct ListBase *BKE_curve_editNurbs_get_for_read(const struct Curve *cu);
 
 void BKE_curve_bevelList_free(struct ListBase *bev);
-void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render);
+void BKE_curve_bevelList_make(struct Object *ob, const struct ListBase *nurbs, bool for_render);
 ListBase BKE_curve_bevel_make(const struct Curve *curve);
 
 void BKE_curve_forward_diff_bezier(
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 8ddfb0c8eb2..6d74888b810 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -128,7 +128,8 @@ struct Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference);
 /* These functions construct a new Mesh,
  * contrary to BKE_mesh_from_nurbs which modifies ob itself. */
 struct Mesh *BKE_mesh_new_nomain_from_curve(struct Object *ob);
-struct Mesh *BKE_mesh_new_nomain_from_curve_displist(struct Object *ob, struct ListBase *dispbase);
+struct Mesh *BKE_mesh_new_nomain_from_curve_displist(const struct Object *ob,
+                                                     const struct ListBase *dispbase);
 
 bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me);
 bool BKE_mesh_clear_facemap_customdata(struct Mesh *me);
@@ -151,7 +152,7 @@ int BKE_mesh_nurbs_to_mdata(struct Object *ob,
                             struct MPoly **r_allpoly,
                             int *r_totloop,
                             int *r_totpoly);
-int BKE_mesh_nurbs_displist_to_mdata(struct Object *ob,
+int BKE_mesh_nurbs_displist_to_mdata(const struct Object *ob,
                                      const struct ListBase *dispbase,
                                      struct MVert **r_allvert,
                                      int *r_totvert,
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 3342c397acf..ae3cf6c24d4 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -2655,7 +2655,7 @@ void BKE_curve_bevelList_free(ListBase *bev)
   BLI_listbase_clear(bev);
 }
 
-void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
+void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, bool for_render)
 {
   /*
    * - convert all curves to polys, with indication of resol and flags for double-vertices
@@ -2700,7 +2700,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
     is_editmode = 1;
   }
 
-  LISTBASE_FOREACH (Nurb *, nu, nurbs) {
+  LISTBASE_FOREACH (const Nurb *, nu, nurbs) {
     if (nu->hide && is_editmode) {
       continue;
     }
diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc
index 39f4b6b8732..05202e40c3f 100644
--- a/source/blender/blenkernel/intern/displist.cc
+++ b/source/blender/blenkernel/intern/displist.cc
@@ -539,12 +539,12 @@ void BKE_displist_fill(const ListBase *dispbase,
   /* do not free polys, needed for wireframe display */
 }
 
-static void bevels_to_filledpoly(const Curve *cu, const ListBase *src, ListBase *dst)
+static void bevels_to_filledpoly(const Curve *cu, ListBase *dispbase)
 {
   ListBase front = {nullptr, nullptr};
   ListBase back = {nullptr, nullptr};
 
-  LISTBASE_FOREACH (const DispList *, dl, src) {
+  LISTBASE_FOREACH (const DispList *, dl, dispbase) {
     if (dl->type == DL_SURF) {
 
       /* This should be moved specifically to the surface evaluation functions,
@@ -595,32 +595,28 @@ static void bevels_to_filledpoly(const Curve *cu, const ListBase *src, ListBase
   }
 
   const float z_up[3] = {0.0f, 0.0f, -1.0f};
-  BKE_displist_fill(&front, dst, z_up, true);
-  BKE_displist_fill(&back, dst, z_up, false);
+  BKE_displist_fill(&front, dispbase, z_up, true);
+  BKE_displist_fill(&back, dispbase, z_up, false);
 
   BKE_displist_free(&front);
   BKE_displist_free(&back);
 
-  BKE_displist_fill(src, dst, z_up, false);
+  BKE_displist_fill(dispbase, dispbase, z_up, false);
 }
 
-static ListBase curve_to_filledpoly(const Curve *cu, const ListBase *src)
+static void curve_to_filledpoly(const Curve *cu, ListBase *dispbase)
 {
   if (!CU_DO_2DFILL(cu)) {
     return;
   }
 
-  ListBase dst = {nullptr, nullptr};
-
-  if (src->first && ((DispList *)src->first)->type == DL_SURF) {
-    bevels_to_filledpoly(cu, src, &dst);
+  if (dispbase->first && ((DispList *)dispbase->first)->type == DL_SURF) {
+    bevels_to_filledpoly(cu, dispbase);
   }
   else {
     const float z_up[3] = {0.0f, 0.0f, -1.0f};
-    BKE_displist_fill(src, &dst, z_up, false);
+    BKE_displist_fill(dispbase, dispbase, z_up, false);
   }
-
-  return dst;
 }
 
 /* taper rules:
@@ -873,11 +869,12 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph,
 
   GeometrySet geometry_set;
   if (md && md->type == eModifierType_Nodes && BKE_modifier_is_enabled(scene, md, required_mode)) {
-    geometry_set.replace_curve(curve_eval_from_dna_curve(*cu, *dispbase).release());
+    std::unique_ptr<CurveEval> curve_eval = curve_eval_from_dna_curve(
+        *cu, ob->runtime.curve_cache->deformed_nurbs);
+    geometry_set.replace_curve(curve_eval.release());
   }
   else {
-    const ListBase final_ if (cu->flag & CU_DEFORM_FILL)
-    {
+    if (cu->flag & CU_DEFORM_FILL) {
       curve_to_filledpoly(cu, dispbase);
     }
     Mesh *mesh = BKE_mesh_new_nomain_from_curve_displist(ob, dispbase);
@@ -911,6 +908,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph,
         BKE_mesh_ensure_normals(mesh);
       }
       mti->deformVerts(md, &mectx_deform, mesh, vertex_coords, totvert);
+      BKE_mesh_vert_coords_apply(mesh, vertex_coords);
       MEM_freeN(vertex_coords);
     }
     else {
@@ -1509,10 +1507,6 @@ static void evaluate_curve_type_object(Depsgraph *depsgraph,
 
   *r_geometry_set = curve_calc_modifiers_post(depsgraph, scene, ob, dispbase, for_render);
 
-  if (cu->flag & CU_DEFORM_FILL && !ob->runtime.data_eval) {
-    curve_to_filledpoly(cu, dispbase);
-  }
-
   BKE_nurbList_free(&nubase);
 }
 
@@ -1539,9 +1533,6 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
   else {
     GeometrySet geometry_set;
     evaluate_curve_type_object(depsgraph, scene, ob, dispbase, for_render, &geometry_set);
-    std::cout << "Final has mesh: " << geometry_set.has_mesh() << "\n";
-    std::cout << "Final has points: " << geometry_set.has_pointcloud() << "\n";
-    std::cout << "Final has curve: " << geometry_set.has_curve() << "\n";
     ob->runtime.geometry_set_eval = new GeometrySet(std::move(geometry_set));
   }
 
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index d9097adf424..825963a2210 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -247,7 +247,7 @@ int BKE_mesh_nurbs_to_mdata(Object *ob,
 
 /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */
 /* use specified dispbase */
-int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
+int BKE_mesh_nurbs_displist_to_mdata(const Object *ob,
                                      const ListBase *dispbase,
                                      MVert **r_allvert,
                                      int *r_totvert,
@@ -259,8 +259,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
                                      int *r_totloop,
                                      int *r_totpoly)
 {
-  Curve *cu = ob->data;
-  DispList *dl;
+  const Curve *cu = ob->data;
   MVert *mvert;
   MPoly *mpoly;
   MLoop *mloop;
@@ -276,8 +275,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
       (ob->type == OB_SURF));
 
   /* count */
-  dl = dispbase->first;
-  while (dl) {
+  LISTBASE_FOREACH (const DispList *, dl, dispbase) {
     if (dl->type == DL_SEGM) {
       totvert += dl->parts * dl->nr;
       totedge += dl->parts * (dl->nr - 1);
@@ -305,7 +303,6 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
       totpoly += tot;
       totloop += tot * 3;
     }
-    dl = dl->next;
   }
 
   if (totvert == 0) {
@@ -327,8 +324,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
   /* verts and faces */
   vertcount = 0;
 
-  dl = dispbase->first;
-  while (dl) {
+  LISTBASE_FOREACH (const DispList *, dl, dispbase) {
     const bool is_smooth = (dl->rt & CU_SMOOTH) != 0;
 
     if (dl->type == DL_SEGM) {
@@ -507,8 +503,6 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
         }
       }
     }
-
-    dl = dl->next;
   }
 
   if (totpoly) {
@@ -523,7 +517,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
   return 0;
 }
 
-Mesh *BKE_mesh_new_nomain_from_curve_displist(Object *ob, ListBase *dispbase)
+Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *dispbase)
 {
   Mesh *mesh;
   MVert *allvert;



More information about the Bf-blender-cvs mailing list