Edit Mesh: remove derived-mesh from crazy-space calculation
This commit is contained in:
@@ -541,8 +541,6 @@ DerivedMesh *mesh_create_derived_no_deform_render(
|
||||
struct Object *ob, float (*vertCos)[3],
|
||||
CustomDataMask dataMask);
|
||||
|
||||
DerivedMesh *editbmesh_get_derived_base(
|
||||
struct Object *ob, struct BMEditMesh *em, CustomDataMask data_mask);
|
||||
DerivedMesh *editbmesh_get_derived_cage(
|
||||
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
|
||||
struct BMEditMesh *em, CustomDataMask dataMask);
|
||||
|
||||
@@ -67,6 +67,7 @@ struct CustomData;
|
||||
struct Scene;
|
||||
struct MLoopUV;
|
||||
struct ReportList;
|
||||
struct BMEditMesh;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -91,6 +92,9 @@ struct BMesh *BKE_mesh_to_bmesh(
|
||||
|
||||
struct Mesh *BKE_bmesh_to_mesh_nomain(struct BMesh *bm, const struct BMeshToMeshParams *params);
|
||||
|
||||
struct Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(
|
||||
struct BMEditMesh *em, CustomDataMask data_mask, float (*vertexCos)[3]);
|
||||
|
||||
int poly_find_loop_from_vert(
|
||||
const struct MPoly *poly,
|
||||
const struct MLoop *loopstart, unsigned vert);
|
||||
|
||||
@@ -1914,24 +1914,6 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, bool has_prev
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* TODO(campbell): support mesh with only an edit-mesh which is lazy initialized. */
|
||||
static Mesh *mesh_from_editmesh_with_coords(
|
||||
BMEditMesh *em, CustomDataMask data_mask, float (*vertexCos)[3])
|
||||
{
|
||||
Mesh *me = BKE_bmesh_to_mesh_nomain(
|
||||
em->bm,
|
||||
&(struct BMeshToMeshParams){
|
||||
.cd_mask_extra = data_mask,
|
||||
});
|
||||
if (vertexCos) {
|
||||
/* We will own this array in the future. */
|
||||
BKE_mesh_apply_vert_coords(me, vertexCos);
|
||||
MEM_freeN(vertexCos);
|
||||
}
|
||||
return me;
|
||||
}
|
||||
|
||||
static void editbmesh_calc_modifiers(
|
||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob,
|
||||
BMEditMesh *em, CustomDataMask dataMask,
|
||||
@@ -1962,7 +1944,7 @@ static void editbmesh_calc_modifiers(
|
||||
modifiers_clearErrors(ob);
|
||||
|
||||
if (r_cage && cageIndex == -1) {
|
||||
*r_cage = mesh_from_editmesh_with_coords(em, dataMask, NULL);
|
||||
*r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, dataMask, NULL);
|
||||
}
|
||||
|
||||
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
|
||||
@@ -2116,7 +2098,7 @@ static void editbmesh_calc_modifiers(
|
||||
BKE_mesh_runtime_ensure_edit_data(me_orig);
|
||||
me_orig->runtime.edit_data->vertexCos = MEM_dupallocN(deformedVerts);
|
||||
}
|
||||
*r_cage = mesh_from_editmesh_with_coords(
|
||||
*r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(
|
||||
em, mask,
|
||||
deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
|
||||
}
|
||||
@@ -2160,7 +2142,7 @@ static void editbmesh_calc_modifiers(
|
||||
MEM_freeN((void *)mesh->runtime.edit_data->vertexCos);
|
||||
mesh->runtime.edit_data->vertexCos = MEM_dupallocN(deformedVerts);
|
||||
}
|
||||
*r_final = mesh_from_editmesh_with_coords(em, dataMask, deformedVerts);
|
||||
*r_final = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, dataMask, deformedVerts);
|
||||
deformedVerts = NULL;
|
||||
|
||||
#if 0
|
||||
@@ -2616,11 +2598,6 @@ DerivedMesh *editbmesh_get_derived_cage(
|
||||
return em->derivedCage;
|
||||
}
|
||||
|
||||
DerivedMesh *editbmesh_get_derived_base(Object *obedit, BMEditMesh *em, CustomDataMask data_mask)
|
||||
{
|
||||
return getEditDerivedBMesh(em, obedit, data_mask, NULL);
|
||||
}
|
||||
|
||||
/***/
|
||||
|
||||
/* get derived mesh from an object, using editbmesh if available. */
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "BKE_multires.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_library.h"
|
||||
|
||||
BLI_INLINE void tan_calc_quat_v3(
|
||||
float r_quat[4],
|
||||
@@ -256,7 +257,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
|
||||
float (**deformmats)[3][3], float (**deformcos)[3])
|
||||
{
|
||||
ModifierData *md;
|
||||
DerivedMesh *dm;
|
||||
Mesh *me;
|
||||
int i, a, numleft = 0, numVerts = 0;
|
||||
int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
|
||||
float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL;
|
||||
@@ -265,7 +266,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
|
||||
|
||||
modifiers_clearErrors(ob);
|
||||
|
||||
dm = NULL;
|
||||
me = NULL;
|
||||
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
|
||||
|
||||
/* compute the deformation matrices and coordinates for the first
|
||||
@@ -274,7 +275,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
|
||||
for (i = 0; md && i <= cageIndex; i++, md = md->next) {
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
if (!editbmesh_modifier_is_enabled(scene, md, dm != NULL))
|
||||
if (!editbmesh_modifier_is_enabled(scene, md, me != NULL))
|
||||
continue;
|
||||
|
||||
if (mti->type == eModifierTypeType_OnlyDeform && mti->deformMatricesEM) {
|
||||
@@ -285,26 +286,26 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
|
||||
data_mask = datamasks->mask;
|
||||
BLI_linklist_free((LinkNode *)datamasks, NULL);
|
||||
|
||||
dm = getEditDerivedBMesh(em, ob, data_mask, NULL);
|
||||
me = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, data_mask, NULL);
|
||||
deformedVerts = editbmesh_get_vertex_cos(em, &numVerts);
|
||||
defmats = MEM_mallocN(sizeof(*defmats) * numVerts, "defmats");
|
||||
|
||||
for (a = 0; a < numVerts; a++)
|
||||
unit_m3(defmats[a]);
|
||||
}
|
||||
|
||||
modifier_deformMatricesEM_DM_deprecated(md, &mectx, em, dm, deformedVerts, defmats, numVerts);
|
||||
mti->deformMatricesEM(md, &mectx, em, me, deformedVerts, defmats, numVerts);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for (; md && i <= cageIndex; md = md->next, i++)
|
||||
if (editbmesh_modifier_is_enabled(scene, md, dm != NULL) && modifier_isCorrectableDeformed(md))
|
||||
if (editbmesh_modifier_is_enabled(scene, md, me != NULL) && modifier_isCorrectableDeformed(md))
|
||||
numleft++;
|
||||
|
||||
if (dm)
|
||||
dm->release(dm);
|
||||
if (me) {
|
||||
BKE_id_free(NULL, me);
|
||||
}
|
||||
|
||||
*deformmats = defmats;
|
||||
*deformcos = deformedVerts;
|
||||
|
||||
@@ -756,6 +756,25 @@ Mesh *BKE_bmesh_to_mesh_nomain(BMesh *bm, const struct BMeshToMeshParams *params
|
||||
return mesh;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO(campbell): support mesh with only an edit-mesh which is lazy initialized.
|
||||
*/
|
||||
Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(
|
||||
BMEditMesh *em, CustomDataMask data_mask, float (*vertexCos)[3])
|
||||
{
|
||||
Mesh *me = BKE_bmesh_to_mesh_nomain(
|
||||
em->bm,
|
||||
&(struct BMeshToMeshParams){
|
||||
.cd_mask_extra = data_mask,
|
||||
});
|
||||
if (vertexCos) {
|
||||
/* We will own this array in the future. */
|
||||
BKE_mesh_apply_vert_coords(me, vertexCos);
|
||||
MEM_freeN(vertexCos);
|
||||
}
|
||||
return me;
|
||||
}
|
||||
|
||||
void BKE_mesh_make_local(Main *bmain, Mesh *me, const bool lib_local)
|
||||
{
|
||||
BKE_id_make_local_generic(bmain, &me->id, true, lib_local);
|
||||
|
||||
Reference in New Issue
Block a user