Commit: 813a6568aa2a638df13fb4529798764fcc57b28e
Author: Lukas Tönne
Date: Wed Jul 13 18:38:35 2016 +0200
Branches: strand_gpu
https://developer.blender.org/rB813a6568aa2a638df13fb4529798764fcc57b28e
Fix crashes when generating fibers without any control curves present.
===================================================================
M source/blender/blenkernel/intern/strands.c
M source/blender/gpu/intern/gpu_buffers.c
===================================================================
diff --git a/source/blender/blenkernel/intern/strands.c
b/source/blender/blenkernel/intern/strands.c
index 543f0d9..9a8c603 100644
--- a/source/blender/blenkernel/intern/strands.c
+++ b/source/blender/blenkernel/intern/strands.c
@@ -488,6 +488,9 @@ static void strand_calc_root_distance(StrandFiber *fiber,
const float loc[3], co
static void strands_calc_weights(const Strands *strands, struct DerivedMesh
*scalp, StrandFiber *fibers, int num_fibers)
{
+ if (strands->totcurves == 0)
+ return;
+
float (*strandloc)[3] = MEM_mallocN(sizeof(float) * 3 *
strands->totcurves, "strand locations");
KDTree *tree = BLI_kdtree_new(strands->totcurves);
diff --git a/source/blender/gpu/intern/gpu_buffers.c
b/source/blender/gpu/intern/gpu_buffers.c
index 5f52e55..279fcd1 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -2421,7 +2421,7 @@ static int strands_fiber_length(StrandFiber *fiber,
StrandCurve *curves, unsigne
fnumverts += fiber->control_weight[k] *
(float)curves[index].num_verts;
}
UNUSED_VARS(totcurves);
- int orig_num_verts = (int)ceil(fnumverts);
+ int orig_num_verts = max_ii((int)ceil(fnumverts), 2);
return BKE_strand_curve_cache_size(orig_num_verts, subdiv);
}
@@ -2454,7 +2454,7 @@ static int editstrands_fiber_length(StrandFiber *fiber,
BMStrandCurve *curves, i
fnumverts += fiber->control_weight[k] *
(float)curves[index].num_verts;
}
UNUSED_VARS(totcurves);
- int orig_num_verts = (int)ceil(fnumverts);
+ int orig_num_verts = max_ii((int)ceil(fnumverts), 2);
return BKE_strand_curve_cache_size(orig_num_verts, subdiv);
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs