diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-30 13:40:16 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-30 15:29:05 +0300 |
commit | da16cb1511f71b552b5746269544ed595e308c29 (patch) | |
tree | 7e9513cd2397cc840e9830a616a62275a394bdeb /source | |
parent | f03953ae06af7edb1e28f83dc1451b7fb6266924 (diff) |
Eevee: Keep track on whether orco was allocated or not
If it's coming from vertex data, we must not free that pointer.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 5d60b144fd3..188ba6b07f7 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -139,6 +139,7 @@ typedef struct MeshRenderData { MLoop *mloop; MPoly *mpoly; float (*orco)[3]; /* vertex coordinates normalized to bounding box */ + bool is_orco_allocated; MDeformVert *dvert; MLoopUV *mloopuv; MLoopCol *mloopcol; @@ -564,10 +565,12 @@ static MeshRenderData *mesh_render_data_create_ex( #undef CD_VALIDATE_ACTIVE_LAYER + rdata->is_orco_allocated = false; if (cd_vused[CD_ORCO] & 1) { rdata->orco = CustomData_get_layer(cd_vdata, CD_ORCO); /* If orco is not available compute it ourselves */ if (!rdata->orco) { + rdata->is_orco_allocated = true; if (me->edit_btmesh) { BMesh *bm = me->edit_btmesh->bm; rdata->orco = MEM_mallocN(sizeof(*rdata->orco) * rdata->vert_len, "orco mesh"); @@ -814,7 +817,9 @@ static MeshRenderData *mesh_render_data_create_ex( static void mesh_render_data_free(MeshRenderData *rdata) { - MEM_SAFE_FREE(rdata->orco); + if (rdata->is_orco_allocated) { + MEM_SAFE_FREE(rdata->orco); + } MEM_SAFE_FREE(rdata->cd.offset.uv); MEM_SAFE_FREE(rdata->cd.offset.vcol); MEM_SAFE_FREE(rdata->cd.uuid.auto_mix); |