Commit: 3eff6f7a5ed5f04745b372625d0dc58f0a52be9a
Author: Bastien Montagne
Date:   Thu Jun 28 15:42:00 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB3eff6f7a5ed5f04745b372625d0dc58f0a52be9a

Cleanup: some moar DM kicking, in armature edit code.

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

M       source/blender/blenkernel/BKE_mesh_iterators.h
M       source/blender/blenkernel/intern/mesh_iterators.c
M       source/blender/editors/armature/armature_skinning.c
M       source/blender/editors/armature/meshlaplacian.c

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

diff --git a/source/blender/blenkernel/BKE_mesh_iterators.h 
b/source/blender/blenkernel/BKE_mesh_iterators.h
index edd5ad783d2..70c10806350 100644
--- a/source/blender/blenkernel/BKE_mesh_iterators.h
+++ b/source/blender/blenkernel/BKE_mesh_iterators.h
@@ -62,4 +62,6 @@ void BKE_mesh_foreach_mapped_face_center(
         void *userData,
         MeshForeachFlag flag);
 
+void BKE_mesh_foreach_mapped_vert_coords_get(struct Mesh *me_eval, float 
(*r_cos)[3], const int totcos);
+
 #endif  /* __BKE_MESH_ITERATORS_H__ */
diff --git a/source/blender/blenkernel/intern/mesh_iterators.c 
b/source/blender/blenkernel/intern/mesh_iterators.c
index 48f6b1820f8..f96a91c6e4d 100644
--- a/source/blender/blenkernel/intern/mesh_iterators.c
+++ b/source/blender/blenkernel/intern/mesh_iterators.c
@@ -33,6 +33,10 @@
 #include "BKE_mesh.h"
 #include "BKE_mesh_iterators.h"
 
+#include "BLI_bitmap.h"
+#include "BLI_math.h"
+
+#include "MEM_guardedalloc.h"
 
 /* Copied from cdDM_foreachMappedVert */
 void BKE_mesh_foreach_mapped_vert(
@@ -152,3 +156,36 @@ void BKE_mesh_foreach_mapped_face_center(
        }
 
 }
+
+
+/* Helpers based on above foreach loopers> */
+
+typedef struct MappedVCosData {
+       float (*vertexcos)[3];
+       BLI_bitmap *vertex_visit;
+} MappedVCosData;
+
+static void get_vertexcos__mapFunc(
+        void *user_data, int index, const float co[3],
+        const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
+{
+       MappedVCosData *mapped_vcos_data = (MappedVCosData *)user_data;
+
+       if (BLI_BITMAP_TEST(mapped_vcos_data->vertex_visit, index) == 0) {
+               /* We need coord from prototype vertex, not from copies,
+                * we assume they stored in the beginning of vertex array 
stored in evaluated mesh
+                * (mirror modifier for eg does this). */
+               copy_v3_v3(mapped_vcos_data->vertexcos[index], co);
+               BLI_BITMAP_ENABLE(mapped_vcos_data->vertex_visit, index);
+       }
+}
+
+void BKE_mesh_foreach_mapped_vert_coords_get(Mesh *me_eval, float (*r_cos)[3], 
const int totcos)
+{
+       MappedVCosData user_data;
+       memset(r_cos, 0, sizeof(*r_cos) * totcos);
+       user_data.vertexcos = r_cos;
+       user_data.vertex_visit = BLI_BITMAP_NEW(totcos, __func__);
+       BKE_mesh_foreach_mapped_vert(me_eval, get_vertexcos__mapFunc, 
&user_data, MESH_FOREACH_NOP);
+       MEM_freeN(user_data.vertex_visit);
+}
diff --git a/source/blender/editors/armature/armature_skinning.c 
b/source/blender/editors/armature/armature_skinning.c
index 87a66514417..63068e61ba3 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -45,11 +45,12 @@
 #include "BKE_armature.h"
 #include "BKE_context.h"
 #include "BKE_deform.h"
+#include "BKE_mesh_iterators.h"
 #include "BKE_mesh_runtime.h"
+#include "BKE_modifier.h"
 #include "BKE_object_deform.h"
 #include "BKE_report.h"
 #include "BKE_subsurf.h"
-#include "BKE_modifier.h"
 
 #include "DEG_depsgraph.h"
 
@@ -259,7 +260,7 @@ static void add_verts_to_dgroups(
         * into account and vertex weights can be mirrored.
         *
         * The mesh vertex positions used are either the final deformed coords
-        * from the derivedmesh in weightpaint mode, the final subsurf coords
+        * from the evaluated mesh in weightpaint mode, the final subsurf coords
         * when parenting, or simply the original mesh coords.
         */
 
@@ -373,15 +374,11 @@ static void add_verts_to_dgroups(
        verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts");
 
        if (wpmode) {
-               /* if in weight paint mode, use final verts from derivedmesh */
-               DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, 
CD_MASK_BAREMESH);
+               /* if in weight paint mode, use final verts from evaluated mesh 
*/
+               Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, 
CD_MASK_BAREMESH);
 
-               if (dm->foreachMappedVert) {
-                       mesh_get_mapped_verts_coords(dm, verts, mesh->totvert);
-                       vertsfilled = 1;
-               }
-
-               dm->release(dm);
+               BKE_mesh_foreach_mapped_vert_coords_get(me_eval, verts, 
mesh->totvert);
+               vertsfilled = 1;
        }
        else if (modifiers_findByType(ob, eModifierType_Subsurf)) {
                /* is subsurf on? Lets use the verts on the limit surface then.
diff --git a/source/blender/editors/armature/meshlaplacian.c 
b/source/blender/editors/armature/meshlaplacian.c
index 1f01def5133..001c8ce215f 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -29,6 +29,7 @@
 
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
 #include "DNA_scene_types.h"
 
 #include "BLI_math.h"
@@ -39,10 +40,10 @@
 
 #include "BLT_translation.h"
 
-#include "BKE_DerivedMesh.h"
-#include "BKE_modifier.h"
+#include "BKE_bvhutils.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_runtime.h"
+#include "BKE_modifier.h"
 
 #include "ED_mesh.h"
 #include "ED_armature.h"

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to