Fix T55146: hair + subsurf modifier not positioning hair correctly.
ORIGSPACE data was not being preserved correctly through subsurf.
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#define __BKE_CDDERIVEDMESH_H__
|
||||
|
||||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_customdata.h"
|
||||
|
||||
struct DerivedMesh;
|
||||
struct BMEditMesh;
|
||||
@@ -54,7 +55,7 @@ struct DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces,
|
||||
struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh);
|
||||
|
||||
/* creates a CDDerivedMesh from the given Mesh with custom allocation type. */
|
||||
struct DerivedMesh *CDDM_from_mesh_ex(struct Mesh *mesh, int alloctype);
|
||||
struct DerivedMesh *CDDM_from_mesh_ex(struct Mesh *mesh, int alloctype, CustomDataMask mask);
|
||||
|
||||
|
||||
struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, const bool use_mdisps);
|
||||
|
||||
@@ -1849,7 +1849,7 @@ static void mesh_update_weight_mcol(
|
||||
}
|
||||
MEM_freeN(wtcol_v);
|
||||
|
||||
//dm->dirty |= DM_DIRTY_TESS_CDLAYERS; // XXX: Does Mesh need this?
|
||||
BKE_mesh_tessface_clear(mesh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2464,13 +2464,13 @@ static void mesh_calc_modifiers(
|
||||
if (do_loop_normals) {
|
||||
/* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */
|
||||
BKE_mesh_calc_normals_split(final_mesh);
|
||||
// dm->dirty |= DM_DIRTY_TESS_CDLAYERS; XXX
|
||||
BKE_mesh_tessface_clear(mesh);
|
||||
}
|
||||
|
||||
if (sculpt_dyntopo == false) {
|
||||
/* watch this! after 2.75a we move to from tessface to looptri (by default) */
|
||||
if (dataMask & CD_MASK_MFACE) {
|
||||
// DM_ensure_tessface(final_mesh); // XXX: port?
|
||||
BKE_mesh_tessface_ensure(final_mesh);
|
||||
}
|
||||
|
||||
/* without this, drawing ngon tri's faces will show ugly tessellated face
|
||||
@@ -2525,11 +2525,11 @@ static void mesh_calc_modifiers_dm(
|
||||
(r_deformdm ? &deform_mesh : NULL), &final_mesh);
|
||||
|
||||
if (deform_mesh) {
|
||||
*r_deformdm = CDDM_from_mesh_ex(deform_mesh, CD_DUPLICATE);
|
||||
*r_deformdm = CDDM_from_mesh_ex(deform_mesh, CD_DUPLICATE, CD_MASK_MESH);
|
||||
BKE_id_free(NULL, deform_mesh);
|
||||
}
|
||||
|
||||
*r_finaldm = CDDM_from_mesh_ex(final_mesh, CD_DUPLICATE);
|
||||
*r_finaldm = CDDM_from_mesh_ex(final_mesh, CD_DUPLICATE, CD_MASK_MESH);
|
||||
BKE_id_free(NULL, final_mesh);
|
||||
}
|
||||
|
||||
@@ -3503,7 +3503,7 @@ static void mesh_init_origspace(Mesh *mesh)
|
||||
}
|
||||
}
|
||||
|
||||
//mesh->dirty |= DM_DIRTY_TESS_CDLAYERS; // XXX: Needed for Mesh?
|
||||
BKE_mesh_tessface_clear(mesh);
|
||||
BLI_array_free(vcos_2d);
|
||||
}
|
||||
|
||||
|
||||
@@ -594,14 +594,15 @@ DerivedMesh *CDDM_new(int numVerts, int numEdges, int numTessFaces, int numLoops
|
||||
|
||||
DerivedMesh *CDDM_from_mesh(Mesh *mesh)
|
||||
{
|
||||
return CDDM_from_mesh_ex(mesh, CD_REFERENCE);
|
||||
return CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_MESH);
|
||||
}
|
||||
|
||||
DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh, int alloctype)
|
||||
DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh, int alloctype, CustomDataMask mask)
|
||||
{
|
||||
CDDerivedMesh *cddm = cdDM_create(__func__);
|
||||
DerivedMesh *dm = &cddm->dm;
|
||||
CustomDataMask mask = CD_MASK_MESH & (~CD_MASK_MDISPS);
|
||||
|
||||
mask &= ~CD_MASK_MDISPS;
|
||||
|
||||
/* this does a referenced copy, with an exception for fluidsim */
|
||||
|
||||
|
||||
@@ -890,7 +890,7 @@ void modifier_deformVerts(struct ModifierData *md, const ModifierEvalContext *ct
|
||||
else {
|
||||
DerivedMesh *dm = NULL;
|
||||
if (mesh) {
|
||||
dm = CDDM_from_mesh(mesh);
|
||||
dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING);
|
||||
}
|
||||
|
||||
mti->deformVerts_DM(md, ctx, dm, vertexCos, numVerts);
|
||||
@@ -926,7 +926,7 @@ void modifier_deformMatrices(struct ModifierData *md, const ModifierEvalContext
|
||||
else {
|
||||
DerivedMesh *dm = NULL;
|
||||
if (mesh) {
|
||||
dm = CDDM_from_mesh(mesh);
|
||||
dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING);
|
||||
}
|
||||
|
||||
mti->deformMatrices_DM(md, ctx, dm, vertexCos, defMats, numVerts);
|
||||
@@ -949,7 +949,7 @@ void modifier_deformVertsEM(struct ModifierData *md, const ModifierEvalContext *
|
||||
else {
|
||||
DerivedMesh *dm = NULL;
|
||||
if (mesh) {
|
||||
dm = CDDM_from_mesh(mesh);
|
||||
dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING);
|
||||
}
|
||||
|
||||
mti->deformVertsEM_DM(md, ctx, editData, dm, vertexCos, numVerts);
|
||||
@@ -972,7 +972,7 @@ void modifier_deformMatricesEM(struct ModifierData *md, const ModifierEvalContex
|
||||
else {
|
||||
DerivedMesh *dm = NULL;
|
||||
if (mesh) {
|
||||
dm = CDDM_from_mesh(mesh);
|
||||
dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING);
|
||||
}
|
||||
|
||||
mti->deformMatricesEM_DM(md, ctx, editData, dm, vertexCos, defMats, numVerts);
|
||||
@@ -992,7 +992,7 @@ struct Mesh *modifier_applyModifier(struct ModifierData *md, const ModifierEvalC
|
||||
return mti->applyModifier(md, ctx, mesh);
|
||||
}
|
||||
else {
|
||||
DerivedMesh *dm = CDDM_from_mesh(mesh);
|
||||
DerivedMesh *dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING);
|
||||
|
||||
DerivedMesh *ndm = mti->applyModifier_DM(md, ctx, dm);
|
||||
|
||||
@@ -1028,7 +1028,7 @@ struct Mesh *modifier_applyModifierEM(struct ModifierData *md, const ModifierEva
|
||||
return mti->applyModifierEM(md, ctx, editData, mesh);
|
||||
}
|
||||
else {
|
||||
DerivedMesh *dm = CDDM_from_mesh(mesh);
|
||||
DerivedMesh *dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING);
|
||||
|
||||
DerivedMesh *ndm = mti->applyModifierEM_DM(md, ctx, editData, dm);
|
||||
|
||||
@@ -1164,7 +1164,7 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md
|
||||
struct Mesh *new_mesh = mti->applyModifier(md, ctx, mesh);
|
||||
|
||||
/* Make a DM that doesn't reference new_mesh so we can free the latter. */
|
||||
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE);
|
||||
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, CD_MASK_EVERYTHING);
|
||||
|
||||
if (new_mesh != mesh) {
|
||||
BKE_id_free(NULL, new_mesh);
|
||||
@@ -1197,7 +1197,7 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *
|
||||
struct Mesh *new_mesh = mti->applyModifierEM(md, ctx, editData, mesh);
|
||||
|
||||
/* Make a DM that doesn't reference new_mesh so we can free the latter. */
|
||||
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE);
|
||||
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, CD_MASK_EVERYTHING);
|
||||
|
||||
if (new_mesh != mesh) {
|
||||
BKE_id_free(NULL, new_mesh);
|
||||
|
||||
Reference in New Issue
Block a user