[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59937] trunk/blender/source/blender: enable strict flags for mesh_evaluate.c
Campbell Barton
ideasman42 at gmail.com
Mon Sep 9 05:12:25 CEST 2013
Revision: 59937
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59937
Author: campbellbarton
Date: 2013-09-09 03:12:23 +0000 (Mon, 09 Sep 2013)
Log Message:
-----------
enable strict flags for mesh_evaluate.c
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
trunk/blender/source/blender/blenkernel/intern/mesh_evaluate.c
trunk/blender/source/blender/blenlib/BLI_bitmap.h
Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2013-09-09 02:16:22 UTC (rev 59936)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2013-09-09 03:12:23 UTC (rev 59937)
@@ -438,9 +438,9 @@
int *polyindex = CustomData_get_layer(fdata, CD_ORIGINDEX);
- int mf_idx,
- totface = dm->getNumTessFaces(dm),
- ml_idx[4];
+ const int totface = dm->getNumTessFaces(dm);
+ int mf_idx;
+ int ml_idx[4];
/* Should never occure, but better abort than segfault! */
if (!polyindex)
Modified: trunk/blender/source/blender/blenkernel/intern/mesh_evaluate.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mesh_evaluate.c 2013-09-09 02:16:22 UTC (rev 59936)
+++ trunk/blender/source/blender/blenkernel/intern/mesh_evaluate.c 2013-09-09 03:12:23 UTC (rev 59937)
@@ -48,6 +48,8 @@
#include "BKE_multires.h"
+#include "BLI_strict_flags.h"
+
/* -------------------------------------------------------------------- */
/** \name Mesh Normal Calculation
@@ -105,7 +107,7 @@
return;
}
- if (!pnors) pnors = MEM_callocN(sizeof(float) * 3 * numPolys, "poly_nors mesh.c");
+ if (!pnors) pnors = MEM_callocN(sizeof(float) * 3 * (size_t)numPolys, __func__);
/* if (!fnors) fnors = MEM_callocN(sizeof(float) * 3 * numFaces, "face nors mesh.c"); */ /* NO NEED TO ALLOC YET */
@@ -150,7 +152,7 @@
MVert *mvert, float polyno[3], float (*tnorms)[3])
{
const int nverts = mp->totloop;
- float (*edgevecbuf)[3] = BLI_array_alloca(edgevecbuf, nverts);
+ float (*edgevecbuf)[3] = BLI_array_alloca(edgevecbuf, (size_t)nverts);
int i;
/* Polygon Normal and edge-vector */
@@ -218,7 +220,7 @@
}
/* first go through and calculate normals for all the polys */
- tnorms = MEM_callocN(sizeof(*tnorms) * numVerts, __func__);
+ tnorms = MEM_callocN(sizeof(*tnorms) * (size_t)numVerts, __func__);
if (pnors) {
mp = mpolys;
@@ -258,8 +260,8 @@
void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3])
{
- float (*tnorms)[3] = MEM_callocN(numVerts * sizeof(*tnorms), "tnorms");
- float (*fnors)[3] = (faceNors_r) ? faceNors_r : MEM_callocN(sizeof(*fnors) * numFaces, "meshnormals");
+ float (*tnorms)[3] = MEM_callocN(sizeof(*tnorms) * (size_t)numVerts, "tnorms");
+ float (*fnors)[3] = (faceNors_r) ? faceNors_r : MEM_callocN(sizeof(*fnors) * (size_t)numFaces, "meshnormals");
int i;
for (i = 0; i < numFaces; i++) {
@@ -467,7 +469,7 @@
int i;
MLoop *l_iter = loopstart;
float area, polynorm_local[3];
- float (*vertexcos)[3] = BLI_array_alloca(vertexcos, mpoly->totloop);
+ float (*vertexcos)[3] = BLI_array_alloca(vertexcos, (size_t)mpoly->totloop);
const float *no = polynormal ? polynormal : polynorm_local;
/* pack vertex cos into an array for area_poly_v3 */
@@ -697,7 +699,7 @@
return NULL;
vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*");
- buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, "UvMapVert");
+ buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * (size_t)totuv, "UvMapVert");
if (!vmap->vert || !vmap->buf) {
BKE_mesh_uv_vert_map_free(vmap);
@@ -710,7 +712,7 @@
nverts = mp->totloop;
for (i = 0; i < nverts; i++) {
- buf->tfindex = i;
+ buf->tfindex = (unsigned char)i;
buf->f = a;
buf->separate = 0;
buf->next = vmap->vert[mloop[mp->loopstart + i].v];
@@ -785,11 +787,11 @@
const MPoly *mpoly, const MLoop *mloop,
int totvert, int totpoly, int totloop)
{
- MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert poly map");
+ MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, "vert poly map");
int *indices, *index_iter;
int i, j;
- indices = index_iter = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
+ indices = index_iter = MEM_mallocN(sizeof(int) * (size_t)totloop, "vert poly map mem");
/* Count number of polys for each vertex */
for (i = 0; i < totpoly; i++) {
@@ -813,7 +815,7 @@
const MPoly *p = &mpoly[i];
for (j = 0; j < p->totloop; j++) {
- int v = mloop[p->loopstart + j].v;
+ unsigned int v = mloop[p->loopstart + j].v;
map[v].indices[map[v].count] = i;
map[v].count++;
@@ -830,8 +832,8 @@
void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
const MEdge *medge, int totvert, int totedge)
{
- MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert-edge map");
- int *indices = MEM_mallocN(sizeof(int) * totedge * 2, "vert-edge map mem");
+ MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, "vert-edge map");
+ int *indices = MEM_mallocN(sizeof(int) * (size_t)totedge * 2, "vert-edge map mem");
int *i_pt = indices;
int i;
@@ -853,7 +855,7 @@
/* Find the users */
for (i = 0; i < totedge; i++) {
- const int v[2] = {medge[i].v1, medge[i].v2};
+ const unsigned int v[2] = {medge[i].v1, medge[i].v2};
map[v[0]].indices[map[v[0]].count] = i;
map[v[1]].indices[map[v[1]].count] = i;
@@ -871,8 +873,8 @@
const MPoly *mpoly, const int totpoly,
const MLoop *mloop, const int totloop)
{
- MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totedge, "edge-poly map");
- int *indices = MEM_mallocN(sizeof(int) * totloop, "edge-poly map mem");
+ MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totedge, "edge-poly map");
+ int *indices = MEM_mallocN(sizeof(int) * (size_t)totloop, "edge-poly map mem");
int *index_step;
const MPoly *mp;
int i;
@@ -1039,12 +1041,13 @@
/* allocate the length of totfaces, avoid many small reallocs,
* if all faces are tri's it will be correct, quads == 2x allocs */
/* take care. we are _not_ calloc'ing so be sure to initialize each field */
- mface_to_poly_map = MEM_mallocN(sizeof(*mface_to_poly_map) * looptris_tot, __func__);
- mface = MEM_mallocN(sizeof(*mface) * looptris_tot, __func__);
+ mface_to_poly_map = MEM_mallocN(sizeof(*mface_to_poly_map) * (size_t)looptris_tot, __func__);
+ mface = MEM_mallocN(sizeof(*mface) * (size_t)looptris_tot, __func__);
mface_index = 0;
mp = mpoly;
for (poly_index = 0; poly_index < totpoly; poly_index++, mp++) {
+ const unsigned int mp_loopstart = (unsigned int)mp->loopstart;
if (mp->totloop < 3) {
/* do nothing */
}
@@ -1055,9 +1058,9 @@
mface_to_poly_map[mface_index] = poly_index; \
mf = &mface[mface_index]; \
/* set loop indices, transformed to vert indices later */ \
- mf->v1 = mp->loopstart + i1; \
- mf->v2 = mp->loopstart + i2; \
- mf->v3 = mp->loopstart + i3; \
+ mf->v1 = mp_loopstart + i1; \
+ mf->v2 = mp_loopstart + i2; \
+ mf->v3 = mp_loopstart + i3; \
mf->v4 = 0; \
mf->mat_nr = mp->mat_nr; \
mf->flag = mp->flag; \
@@ -1069,10 +1072,10 @@
mface_to_poly_map[mface_index] = poly_index; \
mf = &mface[mface_index]; \
/* set loop indices, transformed to vert indices later */ \
- mf->v1 = mp->loopstart + 0; /* EXCEPTION */ \
- mf->v2 = mp->loopstart + 1; /* EXCEPTION */ \
- mf->v3 = mp->loopstart + 2; /* EXCEPTION */ \
- mf->v4 = mp->loopstart + 3; /* EXCEPTION */ \
+ mf->v1 = mp_loopstart + 0; /* EXCEPTION */ \
+ mf->v2 = mp_loopstart + 1; /* EXCEPTION */ \
+ mf->v3 = mp_loopstart + 2; /* EXCEPTION */ \
+ mf->v4 = mp_loopstart + 3; /* EXCEPTION */ \
mf->mat_nr = mp->mat_nr; \
mf->flag = mp->flag; \
mf->edcode = TESSFACE_IS_QUAD; /* EXCEPTION */ \
@@ -1098,7 +1101,7 @@
else {
#define USE_TESSFACE_CALCNORMAL
- int totfilltri;
+ unsigned int totfilltri;
#ifdef USE_TESSFACE_CALCNORMAL
float normal[3];
@@ -1116,7 +1119,7 @@
for (j = 0; j < mp->totloop; j++, ml++) {
sf_vert = BLI_scanfill_vert_add(&sf_ctx, mvert[ml->v].co);
- sf_vert->keyindex = mp->loopstart + j;
+ sf_vert->keyindex = (unsigned int)(mp->loopstart + j);
if (sf_vert_last) {
BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
@@ -1139,7 +1142,7 @@
#else
totfilltri = BLI_scanfill_calc(&sf_ctx, 0);
#endif
- BLI_assert(totfilltri <= mp->totloop - 2);
+ BLI_assert(totfilltri <= (unsigned int)(mp->totloop - 2));
(void)totfilltri;
for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next, mf++) {
@@ -1180,8 +1183,8 @@
/* not essential but without this we store over-alloc'd memory in the CustomData layers */
if (LIKELY(looptris_tot != totface)) {
- mface = MEM_reallocN(mface, sizeof(*mface) * totface);
- mface_to_poly_map = MEM_reallocN(mface_to_poly_map, sizeof(*mface_to_poly_map) * totface);
+ mface = MEM_reallocN(mface, sizeof(*mface) * (size_t)totface);
+ mface_to_poly_map = MEM_reallocN(mface_to_poly_map, sizeof(*mface_to_poly_map) * (size_t)totface);
}
CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface);
@@ -1231,11 +1234,11 @@
#endif
- lindex[0] = mf->v1;
- lindex[1] = mf->v2;
- lindex[2] = mf->v3;
+ lindex[0] = (int)mf->v1;
+ lindex[1] = (int)mf->v2;
+ lindex[2] = (int)mf->v3;
#ifdef USE_TESSFACE_QUADS
- if (mf_len == 4) lindex[3] = mf->v4;
+ if (mf_len == 4) lindex[3] = (int)mf->v4;
#endif
/*transform loop indices to vert indices*/
@@ -1304,15 +1307,16 @@
k = 0;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list