[Bf-blender-cvs] [da16cb1511f] blender2.8: Eevee: Keep track on whether orco was allocated or not

Sergey Sharybin noreply at git.blender.org
Wed May 30 14:39:22 CEST 2018


Commit: da16cb1511f71b552b5746269544ed595e308c29
Author: Sergey Sharybin
Date:   Wed May 30 12:40:16 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBda16cb1511f71b552b5746269544ed595e308c29

Eevee: Keep track on whether orco was allocated or not

If it's coming from vertex data, we must not free that pointer.

===================================================================

M	source/blender/draw/intern/draw_cache_impl_mesh.c

===================================================================

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);



More information about the Bf-blender-cvs mailing list