diff options
author | Ton Roosendaal <ton@blender.org> | 2006-02-03 00:52:35 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-02-03 00:52:35 +0300 |
commit | b43ddb4dec8abe9b891b69cd89eb139422881638 (patch) | |
tree | 0eabc0b869e9982b147bab350f2249f14cb1b9c0 /source | |
parent | 4249bce1bfbe5ecbd18af8fc5eb211fa97ae9a16 (diff) |
Added better safety in vertex/weight paint, so it survives painting outside
the window edge. Also did a paranoia larger memory allocation... weird
reports I got.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/src/vpaint.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c index 498fd4195f8..749f45d772e 100644 --- a/source/blender/src/vpaint.c +++ b/source/blender/src/vpaint.c @@ -606,16 +606,19 @@ static int sample_backbuf_area(int x, int y, float size) x1= x-size; x2= x+size; - CLAMP(x1, 0, curarea->winx); - CLAMP(x2, 0, curarea->winx); + CLAMP(x1, 0, curarea->winx-1); + CLAMP(x2, 0, curarea->winx-1); y1= y-size; y2= y+size; - CLAMP(y1, 0, curarea->winy); - CLAMP(y2, 0, curarea->winy); + CLAMP(y1, 0, curarea->winy-1); + CLAMP(y2, 0, curarea->winy-1); #ifdef __APPLE__ glReadBuffer(GL_AUX0); #endif - ibuf = IMB_allocImBuf(2*size + 1, 2*size + 1, 32, IB_rect, 0); + + if(x1>=x2 || y1>=y2) return 0; + + ibuf = IMB_allocImBuf(2*size + 4, 2*size + 4, 32, IB_rect, 0); glReadPixels(x1+curarea->winrct.xmin, y1+curarea->winrct.ymin, x2-x1+1, y2-y1+1, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); glReadBuffer(GL_BACK); |