diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-22 20:07:39 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-27 14:18:43 +0300 |
commit | c055d69f83edfaa67eb771cbe87271af60a80221 (patch) | |
tree | 24701a4c8b0609bad69c2ad5fcb777a382cbe43c /source/blender | |
parent | 2efd8099de9c68951ea251fad5b90b5533657fed (diff) |
Cleanup: remove unused partial visibility code, weird indentation
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 148 |
1 files changed, 61 insertions, 87 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 30e7cf476fb..401f0ef6a85 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2066,9 +2066,7 @@ static void write_customdata(WriteData *wd, int count, CustomData *data, CustomDataLayer *layers, - CustomDataMask cddata_mask, - int partial_type, - int partial_count) + CustomDataMask cddata_mask) { int i; @@ -2105,16 +2103,7 @@ static void write_customdata(WriteData *wd, else { CustomData_file_write_info(layer->type, &structname, &structnum); if (structnum) { - /* when using partial visibility, the MEdge and MFace layers - * are smaller than the original, so their type and count is - * passed to make this work */ - if (layer->type != partial_type) { - datasize = structnum * count; - } - else { - datasize = structnum * partial_count; - } - + datasize = structnum * count; writestruct_id(wd, DATA, structname, datasize, layer->data); } else { @@ -2133,85 +2122,70 @@ static void write_customdata(WriteData *wd, static void write_mesh(WriteData *wd, Mesh *mesh) { - CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE]; - CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE]; - CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE]; - CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE]; - CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE]; - if (mesh->id.us > 0 || wd->use_memfile) { - /* write LibData */ - { - /* write a copy of the mesh, don't modify in place because it is - * not thread safe for threaded renders that are reading this */ - Mesh *old_mesh = mesh; - Mesh copy_mesh = *mesh; - mesh = ©_mesh; - - /* cache only - don't write */ - mesh->mface = NULL; - mesh->totface = 0; - memset(&mesh->fdata, 0, sizeof(mesh->fdata)); - - /** - * Those calls: - * - Reduce mesh->xdata.totlayer to number of layers to write. - * - Fill xlayers with those layers to be written. - * Note that mesh->xdata is from now on invalid for Blender, - * but this is why the whole mesh is a temp local copy! - */ - CustomData_file_write_prepare( - &mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); - CustomData_file_write_prepare( - &mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff)); - flayers = flayers_buff; - CustomData_file_write_prepare( - &mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); - CustomData_file_write_prepare( - &mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); - - writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh); - write_iddata(wd, &mesh->id); - - /* direct data */ - if (mesh->adt) { - write_animdata(wd, mesh->adt); - } + /* Write a copy of the mesh with possibly reduced number of data layers. + * Don't edit the original since other threads might be reading it. */ + Mesh *old_mesh = mesh; + Mesh copy_mesh = *mesh; + mesh = ©_mesh; + + /* cache only - don't write */ + mesh->mface = NULL; + mesh->totface = 0; + memset(&mesh->fdata, 0, sizeof(mesh->fdata)); + + /* Reduce xdata layers, fill xlayers with layers to be written. + * This makes xdata invalid for Blender, which is why we made a + * temporary local copy. */ + CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE]; + CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE]; + CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE]; + CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE]; + CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE]; + + CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); + CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff)); + flayers = flayers_buff; + CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff)); + CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff)); + + writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh); + write_iddata(wd, &mesh->id); - writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat); - writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); + /* direct data */ + if (mesh->adt) { + write_animdata(wd, mesh->adt); + } - write_customdata( - wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, CD_MASK_MESH.vmask, -1, 0); - write_customdata( - wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, CD_MASK_MESH.emask, -1, 0); - /* fdata is really a dummy - written so slots align */ - write_customdata( - wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, CD_MASK_MESH.fmask, -1, 0); - write_customdata( - wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, CD_MASK_MESH.lmask, -1, 0); - write_customdata( - wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, CD_MASK_MESH.pmask, -1, 0); + writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat); + writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); - /* restore pointer */ - mesh = old_mesh; - } - } + write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, CD_MASK_MESH.vmask); + write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, CD_MASK_MESH.emask); + /* fdata is really a dummy - written so slots align */ + write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, CD_MASK_MESH.fmask); + write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, CD_MASK_MESH.lmask); + write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, CD_MASK_MESH.pmask); - if (vlayers && vlayers != vlayers_buff) { - MEM_freeN(vlayers); - } - if (elayers && elayers != elayers_buff) { - MEM_freeN(elayers); - } - if (flayers && flayers != flayers_buff) { - MEM_freeN(flayers); - } - if (llayers && llayers != llayers_buff) { - MEM_freeN(llayers); - } - if (players && players != players_buff) { - MEM_freeN(players); + /* restore pointer */ + mesh = old_mesh; + + /* free temporary data */ + if (vlayers && vlayers != vlayers_buff) { + MEM_freeN(vlayers); + } + if (elayers && elayers != elayers_buff) { + MEM_freeN(elayers); + } + if (flayers && flayers != flayers_buff) { + MEM_freeN(flayers); + } + if (llayers && llayers != llayers_buff) { + MEM_freeN(llayers); + } + if (players && players != players_buff) { + MEM_freeN(players); + } } } |