Fix loading external MDisps, BMesh merge bug.

* When converting mfaces to mpolys, load external MDisp data in, add
  CustomDataExternal struct to loopdata if needed.

* Fix multires modifier's filepath RNA functions to use ldata rather
  than fdata.
This commit is contained in:
Nicholas Bishop 2012-04-13 05:39:27 +00:00
parent e9358a3806
commit 60d3b8f27b
3 changed files with 18 additions and 3 deletions

@ -1978,6 +1978,11 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex,
float (*disps)[3] = fd->disps;
int i, tot = mf->v4 ? 4 : 3;
int side, corners;
if (CustomData_external_test(&me->fdata, CD_MDISPS)) {
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS,
me->totloop, me->fdata.external->filename);
}
corners = multires_mdisp_corners(fd);
@ -2042,6 +2047,9 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
CustomData_to_bmeshpoly(&mesh->fdata, &mesh->pdata, &mesh->ldata,
mesh->totloop, mesh->totpoly);
/* ensure external data is transferred */
CustomData_external_read(&mesh->fdata, &mesh->id, CD_MASK_MDISPS, mesh->totface);
eh = BLI_edgehash_new();
/*build edge hash*/

@ -3708,7 +3708,14 @@ static void lib_link_mesh(FileData *fd, Main *main)
/*check if we need to convert mfaces to mpolys*/
if (me->totface && !me->totpoly) {
/* temporarily switch main so that reading from
external CustomData works */
Main *gmain = G.main;
G.main = main;
BKE_mesh_convert_mfaces_to_mpolys(me);
G.main = gmain;
}
/*

@ -490,7 +490,7 @@ static int rna_MultiresModifier_external_get(PointerRNA *ptr)
static void rna_MultiresModifier_filepath_get(PointerRNA *ptr, char *value)
{
Object *ob = (Object*)ptr->id.data;
CustomDataExternal *external = ((Mesh*)ob->data)->fdata.external;
CustomDataExternal *external = ((Mesh*)ob->data)->ldata.external;
BLI_strncpy(value, (external)? external->filename: "", sizeof(external->filename));
}
@ -498,7 +498,7 @@ static void rna_MultiresModifier_filepath_get(PointerRNA *ptr, char *value)
static void rna_MultiresModifier_filepath_set(PointerRNA *ptr, const char *value)
{
Object *ob = (Object*)ptr->id.data;
CustomDataExternal *external = ((Mesh*)ob->data)->fdata.external;
CustomDataExternal *external = ((Mesh*)ob->data)->ldata.external;
if (external && strcmp(external->filename, value)) {
BLI_strncpy(external->filename, value, sizeof(external->filename));
@ -509,7 +509,7 @@ static void rna_MultiresModifier_filepath_set(PointerRNA *ptr, const char *value
static int rna_MultiresModifier_filepath_length(PointerRNA *ptr)
{
Object *ob = (Object*)ptr->id.data;
CustomDataExternal *external = ((Mesh*)ob->data)->fdata.external;
CustomDataExternal *external = ((Mesh*)ob->data)->ldata.external;
return strlen((external)? external->filename: "");
}