[Bf-blender-cvs] [8d09eec] master: Fix (unreported) Ocean modifier assuming all its faces are quads.

Bastien Montagne noreply at git.blender.org
Sun Dec 6 21:07:49 CET 2015


Commit: 8d09eecc50480158a916d3e7796a0dc7760de9c5
Author: Bastien Montagne
Date:   Sun Dec 6 21:06:11 2015 +0100
Branches: master
https://developer.blender.org/rB8d09eecc50480158a916d3e7796a0dc7760de9c5

Fix (unreported) Ocean modifier assuming all its faces are quads.

Would be true in most cases (and in particular with own generated geometry),
but in case one would be using original geometry this could have crashed badly.

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

M	source/blender/modifiers/intern/MOD_ocean.c

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

diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index bb18ec5..b82725a 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -479,9 +479,10 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
 	if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
 		if (CustomData_number_of_layers(&dm->loopData, CD_MLOOPCOL) < MAX_MCOL) {
 			const int num_polys = dm->getNumPolys(dm);
+			const int num_loops = dm->getNumLoops(dm);
 			MLoop *mloops = dm->getLoopArray(dm);
 			MLoopCol *mloopcols = CustomData_add_layer_named(
-			                          &dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, num_polys * 4, omd->foamlayername);
+			                          &dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->foamlayername);
 
 			if (mloopcols) { /* unlikely to fail */
 				MPoly *mpolys = dm->getPolyArray(dm);




More information about the Bf-blender-cvs mailing list