Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2007-01-11 18:00:17 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2007-01-11 18:00:17 +0300
commitcedfafc9cd97a8bd2f92fcc8bc9c5336cad8dd9d (patch)
treef3b4ba41eef75750085d69958ed241cebede0507 /source/blender/blenkernel/intern/brush.c
parent35295636839755767c8d4d5cdfe1fe4a10c6523a (diff)
Fix for bug #5666:
Crash texture painting with airbrush and pressure, due to division by zero and resulting nan's. Cause of this crash found by Andrea, thanks!
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 13f84246ded..53fdb2ac115 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -807,7 +807,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
/* compute brush spacing adapted to brush size, spacing may depend
on pressure, so update it */
brush_apply_pressure(painter, brush, painter->lastpressure);
- spacing= MAX2(1.0, brush->size)*brush->spacing*0.01f;
+ spacing= MAX2(1.0f, brush->size)*brush->spacing*0.01f;
/* setup starting distance, direction vector and accumulated distance */
startdistance= painter->accumdistance;
@@ -816,15 +816,15 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
painter->accumdistance += len;
/* do paint op over unpainted distance */
- while (painter->accumdistance >= spacing) {
+ while ((len > 0.0f) && (painter->accumdistance >= spacing)) {
step= spacing - startdistance;
paintpos[0]= painter->lastmousepos[0] + dmousepos[0]*step;
paintpos[1]= painter->lastmousepos[1] + dmousepos[1]*step;
t = step/len;
- press= (1.0-t)*painter->lastpressure + t*pressure;
+ press= (1.0f-t)*painter->lastpressure + t*pressure;
brush_apply_pressure(painter, brush, press);
- spacing= MAX2(1.0, brush->size)*brush->spacing*0.01f;
+ spacing= MAX2(1.0f, brush->size)*brush->spacing*0.01f;
if (painter->cache.enabled)
brush_painter_refresh_cache(painter, paintpos);