Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2018-05-08 12:33:31 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-05-08 12:46:28 +0300
commit1c0be0e90fb17775ca4fdbe91cc0fb377dd446d7 (patch)
tree45c933937aa284b01a82a3af73fac8bf0cedea05 /source/blender/modifiers/intern/MOD_util.c
parentabb58eec5393820ee990926915c176664e205bab (diff)
Ported Mesh Deform modifier
This modifier still has issues that are not related to this port: - While editing the deformation mesh, the deformed mesh doesn't update. This update only happens after exiting edit mode, making editing cumbersome. - Binding doesn't work yet. It works fine when binding in master and loading pre-bound in 2.8. This was also an issue before this port, and will be investigated separately.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_util.c')
-rw-r--r--source/blender/modifiers/intern/MOD_util.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index a5e4a33b791..fd3f9e91b9e 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -46,8 +46,10 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
+#include "BKE_editmesh.h"
#include "BKE_image.h"
#include "BKE_lattice.h"
+#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
@@ -57,6 +59,8 @@
#include "MEM_guardedalloc.h"
+#include "bmesh.h"
+
void modifier_init_texture(const Scene *scene, Tex *tex)
{
if (!tex)
@@ -281,6 +285,47 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *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,
+ float (*vertexCos)[3], bool use_normals, bool use_orco)
+{
+ if (mesh) {
+ /* pass */
+ }
+ else if (ob->type == OB_MESH) {
+ struct BMeshToMeshParams bmtmp = {0};
+ if (em) mesh = BKE_bmesh_to_mesh_nomain(em->bm, &bmtmp);
+ else {
+ BKE_id_copy_ex(NULL, ob->data, (ID **)&mesh,
+ LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_CREATE_NO_DEG_TAG,
+ false);
+ }
+
+ if (vertexCos) {
+ BKE_mesh_apply_vert_coords(mesh, vertexCos);
+ mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+ }
+
+ if (use_orco) {
+ CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob), mesh->totvert);
+ }
+ }
+ else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
+ /* TODO(sybren): get evaluated mesh from depsgraph once that's properly generated for curves. */
+ mesh = BKE_new_mesh_nomain_from_curve(ob);
+ }
+
+ if (use_normals) {
+ if (LIKELY(mesh)) {
+ BKE_mesh_ensure_normals(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.
*/