Fix multires modifier using too much memory outside of sculpt mode
This reduce memory usage by about 25% in object mode for multires meshes.
This commit is contained in:
parent
c5b8d3b6d7
commit
490f966af5
|
@ -121,6 +121,13 @@ struct Mesh *BKE_mesh_new_nomain_from_template(const struct Mesh *me_src,
|
|||
int tessface_len,
|
||||
int loops_len,
|
||||
int polys_len);
|
||||
struct Mesh *BKE_mesh_new_nomain_from_template_ex(const struct Mesh *me_src,
|
||||
int verts_len,
|
||||
int edges_len,
|
||||
int tessface_len,
|
||||
int loops_len,
|
||||
int polys_len,
|
||||
CustomData_MeshMasks mask);
|
||||
|
||||
void BKE_mesh_eval_delete(struct Mesh *me_eval);
|
||||
|
||||
|
|
|
@ -661,13 +661,13 @@ Mesh *BKE_mesh_new_nomain(
|
|||
return mesh;
|
||||
}
|
||||
|
||||
static Mesh *mesh_new_nomain_from_template_ex(const Mesh *me_src,
|
||||
int verts_len,
|
||||
int edges_len,
|
||||
int tessface_len,
|
||||
int loops_len,
|
||||
int polys_len,
|
||||
CustomData_MeshMasks mask)
|
||||
Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
|
||||
int verts_len,
|
||||
int edges_len,
|
||||
int tessface_len,
|
||||
int loops_len,
|
||||
int polys_len,
|
||||
CustomData_MeshMasks mask)
|
||||
{
|
||||
/* Only do tessface if we are creating tessfaces or copying from mesh with only tessfaces. */
|
||||
const bool do_tessface = (tessface_len || ((me_src->totface != 0) && (me_src->totpoly == 0)));
|
||||
|
@ -713,7 +713,7 @@ Mesh *BKE_mesh_new_nomain_from_template(const Mesh *me_src,
|
|||
int loops_len,
|
||||
int polys_len)
|
||||
{
|
||||
return mesh_new_nomain_from_template_ex(
|
||||
return BKE_mesh_new_nomain_from_template_ex(
|
||||
me_src, verts_len, edges_len, tessface_len, loops_len, polys_len, CD_MASK_EVERYTHING);
|
||||
}
|
||||
|
||||
|
|
|
@ -498,9 +498,14 @@ static bool subdiv_mesh_topology_info(const SubdivForeachContext *foreach_contex
|
|||
const int num_loops,
|
||||
const int num_polygons)
|
||||
{
|
||||
/* Multires grid data will be applied or become invalid after subdivision,
|
||||
* so don't try to preserve it and use memory. */
|
||||
CustomData_MeshMasks mask = CD_MASK_EVERYTHING;
|
||||
mask.lmask &= ~CD_MASK_MULTIRES_GRIDS;
|
||||
|
||||
SubdivMeshContext *subdiv_context = foreach_context->user_data;
|
||||
subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template(
|
||||
subdiv_context->coarse_mesh, num_vertices, num_edges, 0, num_loops, num_polygons);
|
||||
subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template_ex(
|
||||
subdiv_context->coarse_mesh, num_vertices, num_edges, 0, num_loops, num_polygons, mask);
|
||||
subdiv_mesh_ctx_cache_custom_data_layers(subdiv_context);
|
||||
subdiv_mesh_prepare_accumulator(subdiv_context, num_vertices);
|
||||
return true;
|
||||
|
|
|
@ -197,6 +197,9 @@ typedef enum CustomDataType {
|
|||
/** Data types that may be defined for all mesh elements types. */
|
||||
#define CD_MASK_GENERIC_DATA (CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR)
|
||||
|
||||
/** Multires loop data. */
|
||||
#define CD_MASK_MULTIRES_GRIDS (CD_MASK_MDISPS | CD_GRID_PAINT_MASK)
|
||||
|
||||
typedef struct CustomData_MeshMasks {
|
||||
uint64_t vmask;
|
||||
uint64_t emask;
|
||||
|
|
Loading…
Reference in New Issue