Fix T46215: Explode modifier looses textures

This commit is contained in:
Campbell Barton 2015-09-23 22:57:00 +10:00 committed by Sergey Sharybin
parent f6445cd6ae
commit e24ea81d65
Notes: blender-bot 2023-02-14 08:37:01 +01:00
Referenced by issue #46739, Cycles freezes computer after < 10 min of rendering
Referenced by issue #46341, OS X trackpad and magic mouse gestures not working
Referenced by issue #46323, Crash right after BVH build completes when hair particles applied
Referenced by issue #46325, bone rotation
Referenced by issue #46314, German translation
Referenced by issue #46315, Blender 2.76 64 bit crashes on Debian Wheezy when trying to access "User Preferences"
Referenced by issue #46298, Cannot access user preferences Blender crashes
Referenced by issue #46299, File Browser Crash while listing big folders in preview mode (fonts, images...).
Referenced by issue #46305, The viewport artifacts associated with the use of normal maps.
Referenced by issue #46287, 3d cursor unwanted undo when isolate selected
Referenced by issue #46291, File Browser Crash while listing big image folders
Referenced by issue #46296, Rigify: Bone Heat Weighting: failed to find solution for one or more bones
Referenced by issue #46275, IK problem
Referenced by issue #46266, the user preference window will be black after re-open blend files
Referenced by issue #46244, SimpleDeform modifier Deform:Angle only incrementing by thousandths when clicking and dragging
Referenced by issue #46245, File delete error in splash screen
6 changed files with 62 additions and 22 deletions

View File

@ -498,6 +498,11 @@ void DM_init(
DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
int numFaces, int numLoops, int numPolys);
void DM_from_template_ex(
DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type,
int numVerts, int numEdges, int numTessFaces,
int numLoops, int numPolys,
CustomDataMask mask);
void DM_from_template(
DerivedMesh *dm, DerivedMesh *source,
DerivedMeshType type,

View File

@ -84,9 +84,15 @@ struct DerivedMesh *CDDM_copy_from_tessface(struct DerivedMesh *dm);
* given DerivedMesh and containing the requested numbers of elements.
* elements are initialized to all zeros
*/
struct DerivedMesh *CDDM_from_template(struct DerivedMesh *source,
int numVerts, int numEdges, int numFaces,
int numLoops, int numPolys);
struct DerivedMesh *CDDM_from_template_ex(
struct DerivedMesh *source,
int numVerts, int numEdges, int numFaces,
int numLoops, int numPolys,
CustomDataMask mask);
struct DerivedMesh *CDDM_from_template(
struct DerivedMesh *source,
int numVerts, int numEdges, int numFaces,
int numLoops, int numPolys);
/* converts mfaces to mpolys. note things may break if there are not valid
* medges surrounding each mface.

View File

@ -328,21 +328,17 @@ void DM_init(
* Utility function to initialize a DerivedMesh for the desired number
* of vertices, edges and faces, with a layer setup copied from source
*/
void DM_from_template(
void DM_from_template_ex(
DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type,
int numVerts, int numEdges, int numTessFaces,
int numLoops, int numPolys)
int numLoops, int numPolys,
CustomDataMask mask)
{
CustomData_copy(&source->vertData, &dm->vertData, CD_MASK_DERIVEDMESH,
CD_CALLOC, numVerts);
CustomData_copy(&source->edgeData, &dm->edgeData, CD_MASK_DERIVEDMESH,
CD_CALLOC, numEdges);
CustomData_copy(&source->faceData, &dm->faceData, CD_MASK_DERIVEDMESH,
CD_CALLOC, numTessFaces);
CustomData_copy(&source->loopData, &dm->loopData, CD_MASK_DERIVEDMESH,
CD_CALLOC, numLoops);
CustomData_copy(&source->polyData, &dm->polyData, CD_MASK_DERIVEDMESH,
CD_CALLOC, numPolys);
CustomData_copy(&source->vertData, &dm->vertData, mask, CD_CALLOC, numVerts);
CustomData_copy(&source->edgeData, &dm->edgeData, mask, CD_CALLOC, numEdges);
CustomData_copy(&source->faceData, &dm->faceData, mask, CD_CALLOC, numTessFaces);
CustomData_copy(&source->loopData, &dm->loopData, mask, CD_CALLOC, numLoops);
CustomData_copy(&source->polyData, &dm->polyData, mask, CD_CALLOC, numPolys);
dm->cd_flag = source->cd_flag;
@ -358,6 +354,17 @@ void DM_from_template(
dm->needsFree = 1;
dm->dirty = 0;
}
void DM_from_template(
DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type,
int numVerts, int numEdges, int numTessFaces,
int numLoops, int numPolys)
{
DM_from_template_ex(
dm, source, type,
numVerts, numEdges, numTessFaces,
numLoops, numPolys,
CD_MASK_DERIVEDMESH);
}
int DM_release(DerivedMesh *dm)
{

View File

@ -2423,10 +2423,11 @@ DerivedMesh *CDDM_copy_from_tessface(DerivedMesh *source)
/* note, the CD_ORIGINDEX layers are all 0, so if there is a direct
* relationship between mesh data this needs to be set by the caller. */
DerivedMesh *CDDM_from_template(
DerivedMesh *CDDM_from_template_ex(
DerivedMesh *source,
int numVerts, int numEdges, int numTessFaces,
int numLoops, int numPolys)
int numLoops, int numPolys,
CustomDataMask mask)
{
CDDerivedMesh *cddm = cdDM_create("CDDM_from_template dest");
DerivedMesh *dm = &cddm->dm;
@ -2438,7 +2439,11 @@ DerivedMesh *CDDM_from_template(
source->getPolyDataArray(source, CD_ORIGINDEX);
/* this does a copy of all non mvert/medge/mface layers */
DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces, numLoops, numPolys);
DM_from_template_ex(
dm, source, DM_TYPE_CDDM,
numVerts, numEdges, numTessFaces,
numLoops, numPolys,
mask);
/* now add mvert/medge/mface layers */
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_CALLOC, NULL, numVerts);
@ -2462,6 +2467,16 @@ DerivedMesh *CDDM_from_template(
return dm;
}
DerivedMesh *CDDM_from_template(
DerivedMesh *source,
int numVerts, int numEdges, int numTessFaces,
int numLoops, int numPolys)
{
return CDDM_from_template_ex(
source, numVerts, numEdges, numTessFaces,
numLoops, numPolys,
CD_MASK_DERIVEDMESH);
}
void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
{

View File

@ -1361,9 +1361,16 @@ const CustomDataMask CD_MASK_BMESH =
CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
CD_MASK_CUSTOMLOOPNORMAL;
const CustomDataMask CD_MASK_FACECORNERS = /* XXX Not used anywhere! */
CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
CD_MASK_MLOOPCOL | CD_MASK_NORMAL | CD_MASK_MLOOPTANGENT;
/**
* cover values copied by #BKE_mesh_loops_to_tessdata
*/
const CustomDataMask CD_MASK_FACECORNERS =
CD_MASK_MTFACE | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
CD_MASK_MCOL | CD_MASK_MLOOPCOL |
CD_MASK_PREVIEW_MCOL | CD_MASK_PREVIEW_MLOOPCOL |
CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP |
CD_MASK_TESSLOOPNORMAL | CD_MASK_NORMAL |
CD_MASK_TANGENT | CD_MASK_MLOOPTANGENT;
const CustomDataMask CD_MASK_EVERYTHING =
CD_MASK_MVERT | CD_MASK_MDEFORMVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_NORMAL /* | CD_MASK_POLYINDEX */ | CD_MASK_PROP_FLT |

View File

@ -861,7 +861,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
BLI_edgehashIterator_free(ehi);
/* the final duplicated vertices */
explode = CDDM_from_template(dm, totdup, 0, totface - delface, 0, 0);
explode = CDDM_from_template_ex(dm, totdup, 0, totface - delface, 0, 0, CD_MASK_DERIVEDMESH | CD_MASK_FACECORNERS);
mtface = CustomData_get_layer_named(&explode->faceData, CD_MTFACE, emd->uvname);
/*dupvert = CDDM_get_verts(explode);*/