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:
authorCampbell Barton <ideasman42@gmail.com>2012-12-12 06:48:03 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-12 06:48:03 +0400
commitc40030a36ce61cd6d4158e129fe8e5a17ac33bc5 (patch)
tree6fe04dab2b3740ec2e2bb8bbd3cd1d0899631fe1
parentb5ce1b1a23a3befbcc4cd3c67a5ec6a76d77aa5a (diff)
replace BLI_array_declare with BLI_array_staticdeclare() and BLI_array_alloca() for smaller arrays.
-rw-r--r--intern/cycles/kernel/shaders/node_mapping.osl3
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c6
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c86
4 files changed, 31 insertions, 66 deletions
diff --git a/intern/cycles/kernel/shaders/node_mapping.osl b/intern/cycles/kernel/shaders/node_mapping.osl
index 92df043b39d..787f65217aa 100644
--- a/intern/cycles/kernel/shaders/node_mapping.osl
+++ b/intern/cycles/kernel/shaders/node_mapping.osl
@@ -28,9 +28,8 @@ shader node_mapping(
{
point p = transform(Matrix, VectorIn);
- if(use_minmax)
+ if (use_minmax)
p = min(max(mapping_min, p), mapping_max);
VectorOut = p;
}
-
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 4442b4eac9c..870d0f3d7dd 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -1879,7 +1879,7 @@ int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target)
int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
{
BMEdge **stack = NULL;
- BLI_array_declare(stack);
+ BLI_array_staticdeclare(stack, BM_DEFAULT_ITER_STACK_SIZE);
BMVert **verts = NULL;
GHash *visithash;
BMIter eiter, liter;
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index fe9b0f21812..e5a398ec66e 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -1135,7 +1135,7 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv)
/* Make center ngon if odd number of segments and fully beveled */
if (ns % 2 == 1 && vm->count == bv->selcount) {
BMVert **vv = NULL;
- BLI_array_declare(vv);
+ BLI_array_staticdeclare(vv, BM_DEFAULT_NGON_STACK_SIZE);
v = vm->boundstart;
do {
@@ -1153,7 +1153,7 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv)
if (vm->count > bv->selcount) {
int j;
BMVert **vv = NULL;
- BLI_array_declare(vv);
+ BLI_array_staticdeclare(vv, BM_DEFAULT_NGON_STACK_SIZE);
v = vm->boundstart;
f = boundvert_rep_face(v);
@@ -1215,7 +1215,7 @@ static BMFace *bevel_build_poly_ex(BMesh *bm, BevVert *bv)
VMesh *vm = bv->vmesh;
BoundVert *v;
BMVert **vv = NULL;
- BLI_array_declare(vv);
+ BLI_array_staticdeclare(vv, BM_DEFAULT_NGON_STACK_SIZE);
v = vm->boundstart;
n = 0;
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 9c2c300c530..c4267358d61 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -169,10 +169,8 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
MTexPoly *tf;
MLoopUV *luv;
Image *ima = sima->image;
- BLI_array_declare(tf_uv);
- BLI_array_declare(tf_uvorig);
- float aspx, aspy, col[4], (*tf_uv)[2] = NULL, (*tf_uvorig)[2] = NULL;
- int i, j, nverts;
+ float aspx, aspy, col[4];
+ int i;
ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
@@ -182,20 +180,14 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
float totarea = 0.0f, totuvarea = 0.0f, areadiff, uvarea, area;
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ const int efa_len = efa->len;
+ float (*tf_uv)[2] = BLI_array_alloca(tf_uv, efa_len);
+ float (*tf_uvorig)[2] = BLI_array_alloca(tf_uvorig, efa_len);
tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY);
-
- BLI_array_empty(tf_uv);
- BLI_array_empty(tf_uvorig);
- BLI_array_grow_items(tf_uv, efa->len);
- BLI_array_grow_items(tf_uvorig, efa->len);
- i = 0;
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
-
copy_v2_v2(tf_uvorig[i], luv->uv);
-
- i++;
}
uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len);
@@ -232,20 +224,15 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
else {
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
- area = BM_face_calc_area(efa) / totarea;
+ const int efa_len = efa->len;
+ float (*tf_uv)[2] = BLI_array_alloca(tf_uv, efa_len);
+ float (*tf_uvorig)[2] = BLI_array_alloca(tf_uvorig, efa_len);
- BLI_array_empty(tf_uv);
- BLI_array_empty(tf_uvorig);
- BLI_array_grow_items(tf_uv, efa->len);
- BLI_array_grow_items(tf_uvorig, efa->len);
+ area = BM_face_calc_area(efa) / totarea;
- i = 0;
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
-
copy_v2_v2(tf_uvorig[i], luv->uv);
-
- i++;
}
uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len);
@@ -276,18 +263,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
}
case SI_UVDT_STRETCH_ANGLE:
{
- float *uvang = NULL;
- float *ang = NULL;
- float (*av)[3] = NULL; /* use for 2d and 3d angle vectors */
- float (*auv)[2] = NULL;
float a;
- BLI_array_declare(uvang);
- BLI_array_declare(ang);
- BLI_array_declare(av);
- BLI_array_declare(auv);
-
- col[3] = 0.5; /* hard coded alpha, not that nice */
+ col[3] = 0.5f; /* hard coded alpha, not that nice */
glShadeModel(GL_SMOOTH);
@@ -295,44 +273,40 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY);
if (uvedit_face_visible_test(scene, ima, efa, tf)) {
- nverts = efa->len;
+ const int efa_len = efa->len;
+ float (*tf_uv)[2] = BLI_array_alloca(tf_uv, efa_len);
+ float (*tf_uvorig)[2] = BLI_array_alloca(tf_uvorig, efa_len);
+ float *uvang = BLI_array_alloca(uvang, efa_len);
+ float *ang = BLI_array_alloca(ang, efa_len);
+ float (*av)[3] = BLI_array_alloca(av, efa_len); /* use for 2d and 3d angle vectors */
+ float (*auv)[2] = BLI_array_alloca(auv, efa_len);
+ int j;
+
BM_elem_flag_enable(efa, BM_ELEM_TAG);
- BLI_array_empty(tf_uv);
- BLI_array_empty(tf_uvorig);
- BLI_array_empty(uvang);
- BLI_array_empty(ang);
- BLI_array_empty(av);
- BLI_array_empty(auv);
- BLI_array_grow_items(tf_uv, nverts);
- BLI_array_grow_items(tf_uvorig, nverts);
- BLI_array_grow_items(uvang, nverts);
- BLI_array_grow_items(ang, nverts);
- BLI_array_grow_items(av, nverts);
- BLI_array_grow_items(auv, nverts);
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
copy_v2_v2(tf_uvorig[i], luv->uv);
}
- uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, nverts);
+ uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa_len);
- j = nverts - 1;
+ j = efa_len - 1;
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
sub_v2_v2v2(auv[i], tf_uv[j], tf_uv[i]); normalize_v2(auv[i]);
sub_v3_v3v3(av[i], l->prev->v->co, l->v->co); normalize_v3(av[i]);
j = i;
}
- for (i = 0; i < nverts; i++) {
+ for (i = 0; i < efa_len; i++) {
#if 0
/* Simple but slow, better reuse normalized vectors
* (Not ported to bmesh, copied for reference) */
uvang1 = RAD2DEG(angle_v2v2v2(tf_uv[3], tf_uv[0], tf_uv[1]));
ang1 = RAD2DEG(angle_v3v3v3(efa->v4->co, efa->v1->co, efa->v2->co));
#endif
- uvang[i] = angle_normalized_v2v2(auv[i], auv[(i + 1) % nverts]);
- ang[i] = angle_normalized_v3v3(av[i], av[(i + 1) % nverts]);
+ uvang[i] = angle_normalized_v2v2(auv[i], auv[(i + 1) % efa_len]);
+ ang[i] = angle_normalized_v3v3(av[i], av[(i + 1) % efa_len]);
}
glBegin(GL_POLYGON);
@@ -354,17 +328,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
glShadeModel(GL_FLAT);
- BLI_array_free(uvang);
- BLI_array_free(ang);
- BLI_array_free(av);
- BLI_array_free(auv);
-
break;
}
}
-
- BLI_array_free(tf_uv);
- BLI_array_free(tf_uvorig);
}
static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage)