[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57804] trunk/blender/source/blender/ editors/curve/editcurve.c: fix for old bug, select more in a nurbs surface would crash (under allocing).
Campbell Barton
ideasman42 at gmail.com
Thu Jun 27 05:57:59 CEST 2013
Revision: 57804
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57804
Author: campbellbarton
Date: 2013-06-27 03:57:59 +0000 (Thu, 27 Jun 2013)
Log Message:
-----------
fix for old bug, select more in a nurbs surface would crash (under allocing).
Modified Paths:
--------------
trunk/blender/source/blender/editors/curve/editcurve.c
Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c 2013-06-27 03:05:19 UTC (rev 57803)
+++ trunk/blender/source/blender/editors/curve/editcurve.c 2013-06-27 03:57:59 UTC (rev 57804)
@@ -47,6 +47,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_bitmap.h"
#include "BLI_math.h"
#include "BLI_dynstr.h"
#include "BLI_rand.h"
@@ -5143,7 +5144,6 @@
BPoint *bp, *tempbp;
int a;
short sel = 0;
- short *selbpoints;
/* note that NURBS surface is a special case because we mimic */
/* the behavior of "select more" of mesh tools. */
@@ -5151,11 +5151,12 @@
/* may not be optimal always (example: end of NURBS sphere) */
if (obedit->type == OB_SURF) {
for (nu = editnurb->first; nu; nu = nu->next) {
+ BLI_bitmap selbpoints;
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
- selbpoints = MEM_callocN(sizeof(short) * a - nu->pntsu, "selectlist");
+ selbpoints = BLI_BITMAP_NEW(a, "selectlist");
while (a > 0) {
- if ((selbpoints[a] != 1) && (bp->hide == 0) && (bp->f1 & SELECT)) {
+ if ((!BLI_BITMAP_GET(selbpoints, a)) && (bp->hide == 0) && (bp->f1 & SELECT)) {
/* upper control point */
if (a % nu->pntsu != 0) {
tempbp = bp - 1;
@@ -5168,7 +5169,7 @@
tempbp = bp + nu->pntsu;
if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE);
/* make sure selected bpoint is discarded */
- if (sel == 1) selbpoints[a - nu->pntsu] = 1;
+ if (sel == 1) BLI_BITMAP_SET(selbpoints, a - nu->pntsu);
}
/* right control point */
@@ -5233,13 +5234,13 @@
BezTriple *bezt;
int a;
short sel = 0, lastsel = false;
- short *selbpoints;
if (obedit->type == OB_SURF) {
for (nu = editnurb->first; nu; nu = nu->next) {
+ BLI_bitmap selbpoints;
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
- selbpoints = MEM_callocN(sizeof(short) * a, "selectlist");
+ selbpoints = BLI_BITMAP_NEW(a, "selectlist");
while (a--) {
if ((bp->hide == 0) && (bp->f1 & SELECT)) {
sel = 0;
@@ -5251,7 +5252,7 @@
}
else {
bp--;
- if ((selbpoints[a + 1] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
+ if (BLI_BITMAP_GET(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
bp++;
}
@@ -5269,7 +5270,7 @@
}
else {
bp -= nu->pntsu;
- if ((selbpoints[a + nu->pntsu] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
+ if (BLI_BITMAP_GET(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
bp += nu->pntsu;
}
@@ -5284,7 +5285,7 @@
if (sel != 4) {
select_bpoint(bp, DESELECT, 1, VISIBLE);
- selbpoints[a] = 1;
+ BLI_BITMAP_SET(selbpoints, a);
}
}
else {
More information about the Bf-blender-cvs
mailing list