[Bf-blender-cvs] [3bc21bc5f79] blender2.8: Cleanup: Moar DM busting, mostly cleaning up MOD_utils.

Bastien Montagne noreply at git.blender.org
Fri Jun 29 19:03:14 CEST 2018


Commit: 3bc21bc5f79aa21a63c6d545327b8e24eb9eb975
Author: Bastien Montagne
Date:   Fri Jun 29 18:58:13 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB3bc21bc5f79aa21a63c6d545327b8e24eb9eb975

Cleanup: Moar DM busting, mostly cleaning up MOD_utils.

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

M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/draw/intern/draw_cache_impl_mesh.c
M	source/blender/modifiers/intern/MOD_util.c
M	source/blender/modifiers/intern/MOD_util.h

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

diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 4a5be9f0f70..3486027e628 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -50,7 +50,6 @@ struct Main;
 struct Object;
 struct Scene;
 struct Depsgraph;
-struct DerivedMesh;
 struct ModifierData;
 struct MTFace;
 struct MCol;
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 91dd1e3dbaa..59847b28785 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -254,7 +254,7 @@ RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob, const int UNUSED(f
 /* ************************************** */
 /* Setup Utilities - Validate Sim Instances */
 
-/* get the appropriate DerivedMesh based on rigid body mesh source */
+/* get the appropriate evaluated mesh based on rigid body mesh source */
 static Mesh *rigidbody_get_mesh(Object *ob)
 {
 	switch (ob->rigidbody_object->mesh_source) {
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 94ebf7e0a14..df91af8123a 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -44,7 +44,6 @@
 
 #include "BKE_customdata.h"
 #include "BKE_deform.h"
-#include "BKE_DerivedMesh.h"
 #include "BKE_editmesh.h"
 #include "BKE_editmesh_tangent.h"
 #include "BKE_mesh.h"
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 29a3745a7e1..ca75f0355ae 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -40,10 +40,10 @@
 #include "DNA_scene_types.h"
 
 #include "BLI_utildefines.h"
+#include "BLI_bitmap.h"
 #include "BLI_math_vector.h"
 #include "BLI_math_matrix.h"
 
-#include "BKE_cdderivedmesh.h"
 #include "BKE_deform.h"
 #include "BKE_editmesh.h"
 #include "BKE_image.h"
@@ -155,79 +155,6 @@ void get_texture_coords_mesh(
 	}
 }
 
-void get_texture_coords(
-        MappingInfoModifierData *dmd, Object *ob,
-        DerivedMesh *dm,
-        float (*co)[3], float (*texco)[3],
-        int numVerts)
-{
-	int i;
-	int texmapping = dmd->texmapping;
-	float mapob_imat[4][4];
-
-	if (texmapping == MOD_DISP_MAP_OBJECT) {
-		if (dmd->map_object)
-			invert_m4_m4(mapob_imat, dmd->map_object->obmat);
-		else /* if there is no map object, default to local */
-			texmapping = MOD_DISP_MAP_LOCAL;
-	}
-
-	/* UVs need special handling, since they come from faces */
-	if (texmapping == MOD_DISP_MAP_UV) {
-		if (CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) {
-			MPoly *mpoly = dm->getPolyArray(dm);
-			MPoly *mp;
-			MLoop *mloop = dm->getLoopArray(dm);
-			char *done = MEM_calloc_arrayN(numVerts, sizeof(*done),
-			                         "get_texture_coords done");
-			int numPolys = dm->getNumPolys(dm);
-			char uvname[MAX_CUSTOMDATA_LAYER_NAME];
-			MLoopUV *mloop_uv;
-
-			CustomData_validate_layer_name(&dm->loopData, CD_MLOOPUV, dmd->uvlayer_name, uvname);
-			mloop_uv = CustomData_get_layer_named(&dm->loopData, CD_MLOOPUV, uvname);
-
-			/* verts are given the UV from the first face that uses them */
-			for (i = 0, mp = mpoly; i < numPolys; ++i, ++mp) {
-				unsigned int fidx = mp->totloop - 1;
-
-				do {
-					unsigned int lidx = mp->loopstart + fidx;
-					unsigned int vidx = mloop[lidx].v;
-
-					if (done[vidx] == 0) {
-						/* remap UVs from [0, 1] to [-1, 1] */
-						texco[vidx][0] = (mloop_uv[lidx].uv[0] * 2.0f) - 1.0f;
-						texco[vidx][1] = (mloop_uv[lidx].uv[1] * 2.0f) - 1.0f;
-						done[vidx] = 1;
-					}
-
-				} while (fidx--);
-			}
-
-			MEM_freeN(done);
-			return;
-		}
-		else /* if there are no UVs, default to local */
-			texmapping = MOD_DISP_MAP_LOCAL;
-	}
-
-	for (i = 0; i < numVerts; ++i, ++co, ++texco) {
-		switch (texmapping) {
-			case MOD_DISP_MAP_LOCAL:
-				copy_v3_v3(*texco, *co);
-				break;
-			case MOD_DISP_MAP_GLOBAL:
-				mul_v3_m4v3(*texco, ob->obmat, *co);
-				break;
-			case MOD_DISP_MAP_OBJECT:
-				mul_v3_m4v3(*texco, ob->obmat, *co);
-				mul_m4_v3(mapob_imat, *texco);
-				break;
-		}
-	}
-}
-
 void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3])
 {
 	while ((md = md->next) && md->type == eModifierType_Armature) {
@@ -240,60 +167,6 @@ void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3])
 	/* lattice/mesh modifier too */
 }
 
-/* returns a cdderivedmesh if dm == NULL or is another type of derivedmesh */
-DerivedMesh *get_cddm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (*vertexCos)[3], bool use_normals)
-{
-	if (dm) {
-		if (dm->type != DM_TYPE_CDDM) {
-			dm = CDDM_copy(dm);
-		}
-		CDDM_apply_vert_coords(dm, vertexCos);
-
-		if (use_normals) {
-			DM_ensure_normals(dm);
-		}
-	}
-	else {
-		dm = get_dm(ob, em, dm, vertexCos, use_normals, false);
-	}
-
-	return dm;
-}
-
-/* returns a derived mesh if dm == NULL, for deforming modifiers that need it */
-DerivedMesh *get_dm(
-        Object *ob, struct BMEditMesh *em, DerivedMesh *dm,
-        float (*vertexCos)[3], bool use_normals, bool use_orco)
-{
-	if (dm) {
-		/* pass */
-	}
-	else if (ob->type == OB_MESH) {
-		if (em) dm = CDDM_from_editbmesh(em, false, false);
-		else dm = CDDM_from_mesh((struct Mesh *)(ob->data));
-
-		if (vertexCos) {
-			CDDM_apply_vert_coords(dm, vertexCos);
-			dm->dirty |= DM_DIRTY_NORMALS;
-		}
-
-		if (use_orco) {
-			DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob));
-		}
-	}
-	else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
-		dm = CDDM_from_curve(ob);
-	}
-
-	if (use_normals) {
-		if (LIKELY(dm)) {
-			DM_ensure_normals(dm);
-		}
-	}
-
-	return dm;
-}
-
 /* returns a mesh if mesh == NULL, for deforming modifiers that need it */
 Mesh *get_mesh(
         Object *ob, struct BMEditMesh *em, Mesh *mesh,
@@ -345,33 +218,6 @@ Mesh *get_mesh(
 	return mesh;
 }
 
-/* Get derived mesh for other object, which is used as an operand for the modifier,
- * i.e. second operand for boolean modifier.
- */
-DerivedMesh *get_dm_for_modifier(Object *ob, ModifierApplyFlag flag)
-{
-	if (flag & MOD_APPLY_RENDER) {
-		/* TODO(sergey): Use proper derived render in the future. */
-		return ob->derivedFinal;
-	}
-	else {
-		return ob->derivedFinal;
-	}
-}
-
-void modifier_get_vgroup(Object *ob, DerivedMesh *dm, const char *name, MDeformVert **dvert, int *defgrp_index)
-{
-	*defgrp_index = defgroup_name_index(ob, name);
-	*dvert = NULL;
-
-	if (*defgrp_index != -1) {
-		if (ob->type == OB_LATTICE)
-			*dvert = BKE_lattice_deform_verts_get(ob);
-		else if (dm)
-			*dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
-	}
-}
-
 /* TODO(sybren): replace the above function with this one, once we got rid of DerivedMesh for modifiers. */
 void modifier_get_vgroup_mesh(Object *ob, struct Mesh *mesh, const char *name, MDeformVert **dvert, int *defgrp_index)
 {
diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h
index 0b3452b22b8..85f74616e14 100644
--- a/source/blender/modifiers/intern/MOD_util.h
+++ b/source/blender/modifiers/intern/MOD_util.h
@@ -33,7 +33,6 @@
 
 #include "DEG_depsgraph_build.h"
 
-struct DerivedMesh;
 struct Depsgraph;
 struct MDeformVert;
 struct Mesh;
@@ -43,9 +42,6 @@ struct Scene;
 struct Tex;
 
 void modifier_init_texture(const struct Depsgraph *depsgraph, struct Tex *texture);
-void get_texture_coords(
-        struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm,
-        float (*co)[3], float (*texco)[3], int numVerts);
 void get_texture_coords_mesh(
         struct MappingInfoModifierData *dmd,
         struct Object *ob,
@@ -53,20 +49,10 @@ void get_texture_coords_mesh(
         float (*cos)[3],
         float (*r_texco)[3]);
 void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]);
-struct DerivedMesh *get_cddm(
-        struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm,
-        float (*vertexCos)[3], bool use_normals);
-struct DerivedMesh *get_dm(
-        struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm,
-        float (*vertexCos)[3], bool use_normals, bool use_orco);
 struct Mesh *get_mesh(
         struct Object *ob, struct BMEditMesh *em, struct Mesh *mesh,
         float (*vertexCos)[3], bool use_normals, bool use_orco);
-struct DerivedMesh *get_dm_for_modifier(struct Object *ob, ModifierApplyFlag flag);
 
-void modifier_get_vgroup(
-        struct Object *ob, struct DerivedMesh *dm,
-        const char *name, struct MDeformVert **dvert, int *defgrp_index);
 void modifier_get_vgroup_mesh(
         struct Object *ob, struct Mesh *mesh,
         const char *name, struct MDeformVert **dvert, int *defgrp_index);



More information about the Bf-blender-cvs mailing list