Cleanup: remove another bunch of DM usages, includes etc.
authorBastien Montagne <montagne29@wanadoo.fr>
Fri, 29 Jun 2018 12:56:38 +0000 (14:56 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Fri, 29 Jun 2018 12:57:02 +0000 (14:57 +0200)
18 files changed:
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_undo.c
source/blender/editors/render/render_update.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_view3d/drawvolume.c
source/blender/editors/space_view3d/view3d_draw_legacy.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/transform/transform_conversions.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/modifiers/intern/MOD_particlesystem.c

index 65946d7188c662911705d89dfe9ab95cdf777cb7..3099875c145c60a3f2637d87863d8bd9caf4fe97 100644 (file)
@@ -566,7 +566,6 @@ void makeDerivedMesh(
         struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
         CustomDataMask dataMask, const bool build_shapekey_layers);
 
-void weight_to_rgb(float r_rgb[3], const float weight);
 /** Update the weight MCOL preview layer.
  * If weights are NULL, use object's active vgroup(s).
  * Else, weights must be an array of weight float values.
index a20c5a4240c9a799be8272c5c3e3197156cdf251..a29f4197299550cfc80eb104a7d7f34eb5ee5d45 100644 (file)
@@ -116,4 +116,6 @@ void BKE_defvert_extract_vgroup_to_polyweights(
         struct MDeformVert *dvert, const int defgroup, const int num_verts, struct MLoop *loops, const int num_loops,
         struct MPoly *polys, const int num_polys, float *r_weights, const bool invert_vgroup);
 
+void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight);
+
 #endif  /* __BKE_DEFORM_H__ */
index a77e6ec12c7afb81c0fefa8a24282f0538c5fe90..4aee616580e2a7fa6210bb7f8d26a853b983036b 100644 (file)
@@ -1394,39 +1394,6 @@ static void add_orco_mesh(
  * happens on enter/exit wpaint.
  */
 
-void weight_to_rgb(float r_rgb[3], const float weight)
-{
-       const float blend = ((weight / 2.0f) + 0.5f);
-
-       if (weight <= 0.25f) {    /* blue->cyan */
-               r_rgb[0] = 0.0f;
-               r_rgb[1] = blend * weight * 4.0f;
-               r_rgb[2] = blend;
-       }
-       else if (weight <= 0.50f) {  /* cyan->green */
-               r_rgb[0] = 0.0f;
-               r_rgb[1] = blend;
-               r_rgb[2] = blend * (1.0f - ((weight - 0.25f) * 4.0f));
-       }
-       else if (weight <= 0.75f) {  /* green->yellow */
-               r_rgb[0] = blend * ((weight - 0.50f) * 4.0f);
-               r_rgb[1] = blend;
-               r_rgb[2] = 0.0f;
-       }
-       else if (weight <= 1.0f) {  /* yellow->red */
-               r_rgb[0] = blend;
-               r_rgb[1] = blend * (1.0f - ((weight - 0.75f) * 4.0f));
-               r_rgb[2] = 0.0f;
-       }
-       else {
-               /* exceptional value, unclamped or nan,
-                * avoid uninitialized memory use */
-               r_rgb[0] = 1.0f;
-               r_rgb[1] = 0.0f;
-               r_rgb[2] = 1.0f;
-       }
-}
-
 /* draw_flag's for calc_weightpaint_vert_color */
 enum {
        /* only one of these should be set, keep first (for easy bit-shifting) */
@@ -1461,7 +1428,7 @@ static void weightpaint_color(unsigned char r_col[4], MERuntimeWeightColorInfo *
                BKE_colorband_evaluate(dm_wcinfo->coba, input, colf);
        }
        else {
-               weight_to_rgb(colf, input);
+               BKE_defvert_weight_to_rgb(colf, input);
        }
 
        /* don't use rgb_float_to_uchar() here because
index 2da157d5b88db7a17146d01f5b02c248b3b71c86..d08e3643ca793ef6cdffa1261000c362f7a25a90 100644 (file)
@@ -1293,3 +1293,43 @@ bool data_transfer_layersmapping_vgroups(
 }
 
 /** \} */
+
+/* -------------------------------------------------------------------- */
+
+/** \name Various utils & helpers.
+ * \{ */
+
+void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight)
+{
+       const float blend = ((weight / 2.0f) + 0.5f);
+
+       if (weight <= 0.25f) {    /* blue->cyan */
+               r_rgb[0] = 0.0f;
+               r_rgb[1] = blend * weight * 4.0f;
+               r_rgb[2] = blend;
+       }
+       else if (weight <= 0.50f) {  /* cyan->green */
+               r_rgb[0] = 0.0f;
+               r_rgb[1] = blend;
+               r_rgb[2] = blend * (1.0f - ((weight - 0.25f) * 4.0f));
+       }
+       else if (weight <= 0.75f) {  /* green->yellow */
+               r_rgb[0] = blend * ((weight - 0.50f) * 4.0f);
+               r_rgb[1] = blend;
+               r_rgb[2] = 0.0f;
+       }
+       else if (weight <= 1.0f) {  /* yellow->red */
+               r_rgb[0] = blend;
+               r_rgb[1] = blend * (1.0f - ((weight - 0.75f) * 4.0f));
+               r_rgb[2] = 0.0f;
+       }
+       else {
+               /* exceptional value, unclamped or nan,
+                * avoid uninitialized memory use */
+               r_rgb[0] = 1.0f;
+               r_rgb[1] = 0.0f;
+               r_rgb[2] = 1.0f;
+       }
+}
+
+/** \} */
index f5e5a37c7d75462226605a3801bc48d235e67404..4c2f513007a92adb9b956342907bc7ba7fbb8ff9 100644 (file)
@@ -49,6 +49,7 @@
 #include "BLI_task.h"
 
 #include "BKE_cdderivedmesh.h"
+#include "BKE_deform.h"
 #include "BKE_mesh.h"
 #include "BKE_editmesh.h"
 #include "BKE_editmesh_bvh.h"
@@ -1082,7 +1083,7 @@ static void statvis_calc_overhang(
        /* fallback max */
        {
                float fcol[3];
-               weight_to_rgb(fcol, 1.0f);
+               BKE_defvert_weight_to_rgb(fcol, 1.0f);
                rgb_float_to_uchar(col_fallback_max, fcol);
        }
 
@@ -1096,7 +1097,7 @@ static void statvis_calc_overhang(
                        fac = (fac - min) * minmax_irange;
                        fac = 1.0f - fac;
                        CLAMP(fac, 0.0f, 1.0f);
-                       weight_to_rgb(fcol, fac);
+                       BKE_defvert_weight_to_rgb(fcol, fac);
                        rgb_float_to_uchar(r_face_colors[index], fcol);
                }
                else {
@@ -1231,7 +1232,7 @@ static void statvis_calc_thickness(
                        fac = (fac - min) * minmax_irange;
                        fac = 1.0f - fac;
                        CLAMP(fac, 0.0f, 1.0f);
-                       weight_to_rgb(fcol, fac);
+                       BKE_defvert_weight_to_rgb(fcol, fac);
                        rgb_float_to_uchar(r_face_colors[i], fcol);
                }
                else {
@@ -1270,7 +1271,7 @@ static void statvis_calc_intersect(
        overlap = BKE_bmbvh_overlap(bmtree, bmtree, &overlap_len);
 
        /* same for all faces */
-       weight_to_rgb(fcol, 1.0f);
+       BKE_defvert_weight_to_rgb(fcol, 1.0f);
        rgb_float_to_uchar(col, fcol);
 
        if (overlap) {
@@ -1357,7 +1358,7 @@ static void statvis_calc_distort(
                        float fcol[3];
                        fac = (fac - min) * minmax_irange;
                        CLAMP(fac, 0.0f, 1.0f);
-                       weight_to_rgb(fcol, fac);
+                       BKE_defvert_weight_to_rgb(fcol, fac);
                        rgb_float_to_uchar(r_face_colors[index], fcol);
                }
                else {
@@ -1407,7 +1408,7 @@ static void statvis_calc_sharp(
                        float fcol[3];
                        fac = (fac - min) * minmax_irange;
                        CLAMP(fac, 0.0f, 1.0f);
-                       weight_to_rgb(fcol, fac);
+                       BKE_defvert_weight_to_rgb(fcol, fac);
                        rgb_float_to_uchar(r_vert_colors[i], fcol);
                }
                else {
index aec4d8b735af00f0ef22e579f6d6f29886ac4127..82514f0c92de55c33683d3d605683a05fe148b26 100644 (file)
@@ -2767,7 +2767,7 @@ static void psys_cache_edit_paths_iter(
                /* selection coloring in edit mode */
                if (use_weight) {
                        if (k == 0) {
-                               weight_to_rgb(ca->col, pind.hkey[1]->weight);
+                               BKE_defvert_weight_to_rgb(ca->col, pind.hkey[1]->weight);
                        }
                        else {
                                /* warning: copied from 'do_particle_interpolation' (without 'mvert' array stepping) */
@@ -2789,8 +2789,8 @@ static void psys_cache_edit_paths_iter(
                                float w1[3], w2[3];
                                keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
 
-                               weight_to_rgb(w1, pind.hkey[0]->weight);
-                               weight_to_rgb(w2, pind.hkey[1]->weight);
+                               BKE_defvert_weight_to_rgb(w1, pind.hkey[0]->weight);
+                               BKE_defvert_weight_to_rgb(w2, pind.hkey[1]->weight);
 
                                interp_v3_v3v3(ca->col, w1, w2, keytime);
                        }
index 8f94c7b3c8dc75d62e704aad6dcb9097fae693d8..35c8761f67126fd2f0b84c1045384f4a61985102 100644 (file)
@@ -70,7 +70,6 @@
 
 #include "BKE_animsys.h"
 #include "BKE_boids.h"
-#include "BKE_cdderivedmesh.h"
 #include "BKE_collision.h"
 #include "BKE_colortools.h"
 #include "BKE_effect.h"
@@ -81,7 +80,6 @@
 #include "BKE_particle.h"
 
 #include "BKE_collection.h"
-#include "BKE_DerivedMesh.h"
 #include "BKE_object.h"
 #include "BKE_material.h"
 #include "BKE_cloth.h"
@@ -328,7 +326,7 @@ void psys_calc_dmcache(Object *ob, Mesh *mesh_final, Mesh *mesh_original, Partic
 
        /* CACHE LOCATIONS */
        if (!mesh_final->runtime.deformed_only) {
-               /* Will use later to speed up subsurf/derivedmesh */
+               /* Will use later to speed up subsurf/evaluated mesh. */
                LinkNode *node, *nodedmelem, **nodearray;
                int totdmelem, totelem, i, *origindex, *origindex_poly = NULL;
 
index 00bb0110e74be0a6e90975c2dd73cf991ec0c274..7e1e1c53a8f04b15156bdee785a0e6cc18acba6c 100644 (file)
@@ -550,7 +550,7 @@ BLI_INLINE void bmesh_quick_edgedraw_flag(MEdge *med, BMEdge *e)
 
 /**
  *
- * \param bmain May be NULL in case \a calc_object_remap parameter option is set.
+ * \param bmain May be NULL in case \a calc_object_remap parameter option is not set.
  */
 void BM_mesh_bm_to_me(
         Main *bmain, BMesh *bm, Mesh *me,
index 2ee8918c5da2d9ff287fe87d47b852a9b48315dd..a511100ff4e56e6c69ce0a71838dcad7bfa6cf6a 100644 (file)
@@ -48,7 +48,7 @@
 
 #include "BLT_translation.h"
 
-#include "BKE_DerivedMesh.h"
+#include "BKE_bvhutils.h"
 #include "BKE_context.h"
 #include "BKE_editmesh.h"
 #include "BKE_editmesh_bvh.h"
index 97445ebc9e0acdc911ccbd5a9d581d434407784a..11606840b429fcd92c9edd7044edade9b22751a5 100644 (file)
@@ -27,6 +27,7 @@
 #include "CLG_log.h"
 
 #include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 #include "DNA_key_types.h"
 #include "DNA_layer_types.h"
@@ -35,7 +36,6 @@
 #include "BLI_array_utils.h"
 #include "BLI_alloca.h"
 
-#include "BKE_DerivedMesh.h"
 #include "BKE_context.h"
 #include "BKE_key.h"
 #include "BKE_layer.h"
index a78617fde8c26900ff15d8b3b9cac0aef5b98ffa..97fd7295a7b059cbc458cd611270d7b428580e8e 100644 (file)
@@ -49,7 +49,6 @@
 #include "BLI_utildefines.h"
 
 #include "BKE_context.h"
-#include "BKE_DerivedMesh.h"
 #include "BKE_icons.h"
 #include "BKE_layer.h"
 #include "BKE_main.h"
index 7fbf7889551730d57f295cf17fe64533506f8e95..4031159451268f03989fded83f9c6ddbefecc351 100644 (file)
@@ -57,7 +57,6 @@
 
 #include "BKE_colortools.h"
 #include "BKE_context.h"
-#include "BKE_DerivedMesh.h"
 #include "BKE_icons.h"
 #include "BKE_image.h"
 #include "BKE_global.h"
index d90f1b16d29d97f4faf262b7cbd5fe55a261eade..c6874a663a56f42923d610272c80c57baaddf6e6 100644 (file)
@@ -40,8 +40,8 @@
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
 
-#include "BKE_DerivedMesh.h"
 #include "BKE_colorband.h"
+#include "BKE_deform.h"
 #include "BKE_particle.h"
 
 #include "smoke_API.h"
@@ -685,7 +685,7 @@ static void add_needle(float (*verts)[3], float (*colors)[3], float center[3],
        float len = len_v3(dir);
 
        float rgb[3];
-       weight_to_rgb(rgb, len);
+       BKE_defvert_weight_to_rgb(rgb, len);
 
        if (len != 0.0f) {
                mul_v3_fl(dir, 1.0f / len);
@@ -725,7 +725,7 @@ static void add_streamline(float (*verts)[3], float(*colors)[3], float center[3]
        const float len = len_v3(dir);
 
        float rgb[3];
-       weight_to_rgb(rgb, len);
+       BKE_defvert_weight_to_rgb(rgb, len);
 
        copy_v3_v3(colors[(*offset)], rgb);
        copy_v3_v3(verts[(*offset)++], center);
index 6acec568bf4396abc3ff876bd7430a0addc73323..06cdba3f5379c80df46c4f96e73781a0798f8246 100644 (file)
@@ -57,7 +57,6 @@
 #include "BKE_camera.h"
 #include "BKE_context.h"
 #include "BKE_customdata.h"
-#include "BKE_DerivedMesh.h"
 #include "BKE_image.h"
 #include "BKE_key.h"
 #include "BKE_layer.h"
index 4eb2a016b949e56ce07862420437d85813f55258..8263d1d892ce7e6a69264a2e691f9fdff428eacd 100644 (file)
@@ -41,7 +41,6 @@ struct Base;
 struct BoundBox;
 struct Gwn_Batch;
 struct Depsgraph;
-struct DerivedMesh;
 struct Object;
 struct SmokeDomainSettings;
 struct bAnimVizSettings;
index 8462004c549c137910523da52dbb2a921892ce0b..c622a50ff11e25dc127cd594c15563a08c6611d5 100644 (file)
@@ -61,7 +61,6 @@
 #include "BLI_bitmap.h"
 #include "BLI_rect.h"
 
-#include "BKE_DerivedMesh.h"
 #include "BKE_action.h"
 #include "BKE_armature.h"
 #include "BKE_constraint.h"
index 08df08dafb44531d9bae12814872dabe9e864c6d..5fb328a922da9f9e8166a52cd81644bf6976c990 100644 (file)
@@ -48,7 +48,7 @@
 #include "BLI_buffer.h"
 #include "BLI_bitmap.h"
 
-#include "BKE_DerivedMesh.h"
+#include "BKE_deform.h"
 #include "BKE_editmesh.h"
 #include "BKE_material.h"
 #include "BKE_layer.h"
@@ -277,7 +277,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
                                                else
                                                        areadiff = 1.0f - (area / uvarea);
 
-                                               weight_to_rgb(col, areadiff);
+                                               BKE_defvert_weight_to_rgb(col, areadiff);
                                                immUniformColor3fv(col);
 
                                                /* TODO: use editmesh tessface */
@@ -357,7 +357,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
                                        BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
                                                luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
                                                a = fabsf(uvang[i] - ang[i]) / (float)M_PI;
-                                               weight_to_rgb(col, 1.0f - pow2f(1.0f - a));
+                                               BKE_defvert_weight_to_rgb(col, 1.0f - pow2f(1.0f - a));
                                                immAttrib3fv(color, col);
                                                immVertex2fv(pos, luv->uv);
                                        }
index 784e44f57581c9e73037112ee64b9ebf8cb932da..2d725a821db87c115c75ad683be20748f65371ea 100644 (file)
@@ -41,7 +41,6 @@
 #include "BLI_utildefines.h"
 
 
-#include "BKE_cdderivedmesh.h"
 #include "BKE_editmesh.h"
 #include "BKE_mesh.h"
 #include "BKE_library.h"
@@ -218,20 +217,24 @@ static void deformVerts(
        }
 }
 
-/* disabled particles in editmode for now, until support for proper derivedmesh
+/* disabled particles in editmode for now, until support for proper evaluated mesh
  * updates is coded */
 #if 0
 static void deformVertsEM(
-        ModifierData *md, Object *ob, EditMesh *editData,
-        DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
+        ModifierData *md, Object *ob, BMEditMesh *editData,
+        Mesh *mesh, float (*vertexCos)[3], int numVerts)
 {
-       DerivedMesh *dm = derivedData;
-
-       if (!derivedData) dm = CDDM_from_editmesh(editData, ob->data);
+       const bool do_temp_mesh = (mesh == NULL);
+       if (do_temp_mesh) {
+               mesh = BKE_id_new_nomain(ID_ME, ((ID *)ob->data)->name);
+               BM_mesh_bm_to_me(NULL, editData->bm, mesh, &((BMeshToMeshParams){0}));
+       }
 
-       deformVerts(md, ob, dm, vertexCos, numVerts);
+       deformVerts(md, ob, mesh, vertexCos, numVerts);
 
-       if (!derivedData) dm->release(dm);
+       if (derivedData) {
+               BKE_id_free(NULL, mesh);
+       }
 }
 #endif