Commit: a300f8004387f8748d403be0e30eacd59dcf8e9d
Author: Luca Rood
Date:   Mon Jan 23 18:43:11 2017 -0200
Branches: surface-deform-modifier
https://developer.blender.org/rBa300f8004387f8748d403be0e30eacd59dcf8e9d

Review: Inline loop indices

Also fixed endian switch sign, and UI Python thingy...

===================================================================

M       release/scripts/startup/bl_ui/properties_data_modifier.py
M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/writefile.c
M       source/blender/modifiers/intern/MOD_surfacedeform.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 74227cedf4..68e1b3b210 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -957,7 +957,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         layout.separator()
 
         col = layout.column()
-        col.enabled = bool(md.target)
+        col.active = md.target is not None
 
         if md.is_bound:
             col.operator("object.surfacedeform_bind", text="Unbind")
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 5be3dcaa32..3bebb3f38a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5304,22 +5304,21 @@ static void direct_link_modifiers(FileData *fd, 
ListBase *lb)
                }
                else if (md->type == eModifierType_SurfaceDeform) {
                        SurfaceDeformModifierData *smd = 
(SurfaceDeformModifierData *)md;
-                       int i, j;
 
                        smd->verts = newdataadr(fd, smd->verts);
 
                        if (smd->verts) {
-                               for (i = 0; i < smd->numverts; i++) {
+                               for (int i = 0; i < smd->numverts; i++) {
                                        smd->verts[i].binds = newdataadr(fd, 
smd->verts[i].binds);
 
                                        if (smd->verts[i].binds) {
-                                               for (j = 0; j < 
smd->verts[i].numbinds; j++) {
+                                               for (int j = 0; j < 
smd->verts[i].numbinds; j++) {
                                                        
smd->verts[i].binds[j].vert_inds = newdataadr(fd, 
smd->verts[i].binds[j].vert_inds);
                                                        
smd->verts[i].binds[j].vert_weights = newdataadr(fd, 
smd->verts[i].binds[j].vert_weights);
 
                                                        if (fd->flags & 
FD_FLAGS_SWITCH_ENDIAN) {
                                                                if 
(smd->verts[i].binds[j].vert_inds)
-                                                                       
BLI_endian_switch_int32_array(smd->verts[i].binds[j].vert_inds, 
smd->verts[i].binds[j].numverts);
+                                                                       
BLI_endian_switch_uint32_array(smd->verts[i].binds[j].vert_inds, 
smd->verts[i].binds[j].numverts);
 
                                                                if 
(smd->verts[i].binds[j].vert_weights) {
                                                                        if 
(smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index 86a7a5a3f3..6066529951 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1832,16 +1832,15 @@ static void write_modifiers(WriteData *wd, ListBase 
*modbase)
                }
                else if (md->type == eModifierType_SurfaceDeform) {
                        SurfaceDeformModifierData *smd = 
(SurfaceDeformModifierData *)md;
-                       int i, j;
 
                        writestruct(wd, DATA, SDefVert, smd->numverts, 
smd->verts);
 
                        if (smd->verts) {
-                               for (i = 0; i < smd->numverts; i++) {
+                               for (int i = 0; i < smd->numverts; i++) {
                                        writestruct(wd, DATA, SDefBind, 
smd->verts[i].numbinds, smd->verts[i].binds);
 
                                        if (smd->verts[i].binds) {
-                                               for (j = 0; j < 
smd->verts[i].numbinds; j++) {
+                                               for (int j = 0; j < 
smd->verts[i].numbinds; j++) {
                                                        writedata(wd, DATA, 
sizeof(int) * smd->verts[i].binds[j].numverts, 
smd->verts[i].binds[j].vert_inds);
 
                                                        if 
(smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c 
b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 067a84de77..487af7d944 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -86,9 +86,9 @@ static void freeData(ModifierData *md)
        SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *) md;
 
        if (smd->verts) {
-               for (unsigned int i = 0; i < smd->numverts; i++) {
+               for (int i = 0; i < smd->numverts; i++) {
                        if (smd->verts[i].binds) {
-                               for (unsigned int j = 0; j < 
smd->verts[i].numbinds; j++) {
+                               for (int j = 0; j < smd->verts[i].numbinds; 
j++) {
                                        if (smd->verts[i].binds[j].vert_inds) {
                                                
MEM_freeN(smd->verts[i].binds[j].vert_inds);
                                        }
@@ -117,11 +117,11 @@ static void copyData(ModifierData *md, ModifierData 
*target)
        if (smd->verts) {
                tsmd->verts = MEM_dupallocN(smd->verts);
 
-               for (unsigned int i = 0; i < smd->numverts; i++) {
+               for (int i = 0; i < smd->numverts; i++) {
                        if (smd->verts[i].binds) {
                                tsmd->verts[i].binds = 
MEM_dupallocN(smd->verts[i].binds);
 
-                               for (unsigned int j = 0; j < 
smd->verts[i].numbinds; j++) {
+                               for (int j = 0; j < smd->verts[i].numbinds; 
j++) {
                                        if (smd->verts[i].binds[j].vert_inds) {
                                                
tsmd->verts[i].binds[j].vert_inds = 
MEM_dupallocN(smd->verts[i].binds[j].vert_inds);
                                        }
@@ -177,7 +177,7 @@ static void freeAdjacencyMap(SDefAdjacency ** const 
vert_edges, SDefEdgePolys *
 
        MEM_freeN(edge_polys);
 
-       for (unsigned int i = 0; i < numverts; i++) {
+       for (int i = 0; i < numverts; i++) {
                for (adj = vert_edges[i]; adj; adj = vert_edges[i]) {
                        vert_edges[i] = adj->next;
 
@@ -193,13 +193,12 @@ static int buildAdjacencyMap(const MPoly *poly, const 
MEdge *edge, const MLoop *
 {
        const MLoop *loop;
        SDefAdjacency *adj;
-       unsigned int i;
 
        /* Fing polygons adjacent to edges */
-       for (i = 0; i < numpoly; i++, poly++) {
+       for (int i = 0; i < numpoly; i++, poly++) {
                loop = &mloop[poly->loopstart];
 
-               for (unsigned int j = 0; j < poly->totloop; j++, loop++) {
+               for (int j = 0; j < poly->totloop; j++, loop++) {
                        if (edge_polys[loop->e].num == 0) {
                                edge_polys[loop->e].polys[0] = i;
                                edge_polys[loop->e].polys[1] = -1;
@@ -217,7 +216,7 @@ static int buildAdjacencyMap(const MPoly *poly, const MEdge 
*edge, const MLoop *
        }
 
        /* Find edges adjacent to vertices */
-       for (i = 0; i < numedges; i++, edge++) {
+       for (int i = 0; i < numedges; i++, edge++) {
                adj = MEM_mallocN(sizeof(*adj), "SDefVertEdge");
                if (adj == NULL) {
                        return 0;
@@ -243,9 +242,8 @@ static int buildAdjacencyMap(const MPoly *poly, const MEdge 
*edge, const MLoop *
 BLI_INLINE void sortPolyVertsEdge(unsigned int *indices, const MLoop * const 
mloop, const unsigned int edge, const unsigned int num)
 {
        bool found = false;
-       unsigned int i;
 
-       for (i = 0; i < num; i++) {
+       for (int i = 0; i < num; i++) {
                if (mloop[i].e == edge) {
                        found = true;
                }
@@ -256,7 +254,7 @@ BLI_INLINE void sortPolyVertsEdge(unsigned int *indices, 
const MLoop * const mlo
        }
 
        /* Fill in remaining vertex indices that occur before the edge */
-       for (i = 0; mloop[i].e != edge; i++) {
+       for (int i = 0; mloop[i].e != edge; i++) {
                *indices = mloop[i].v;
                indices++;
        }
@@ -264,14 +262,12 @@ BLI_INLINE void sortPolyVertsEdge(unsigned int *indices, 
const MLoop * const mlo
 
 BLI_INLINE void sortPolyVertsTri(unsigned int *indices, const MLoop * const 
mloop, const unsigned int loopstart, const unsigned int num)
 {
-       unsigned int i;
-
-       for (i = loopstart; i < num; i++) {
+       for (int i = loopstart; i < num; i++) {
                *indices = mloop[i].v;
                indices++;
        }
 
-       for (i = 0; i < loopstart; i++) {
+       for (int i = 0; i < loopstart; i++) {
                *indices = mloop[i].v;
                indices++;
        }
@@ -286,14 +282,14 @@ BLI_INLINE unsigned int nearestVert(SDefBindCalcData * 
const data, const float p
        const MLoop *loop;
        float max_dist = FLT_MAX;
        float dist;
-       unsigned int index;
+       unsigned int index = 0;
 
        BLI_bvhtree_find_nearest(data->treeData->tree, point_co, &nearest, 
data->treeData->nearest_callback, data->treeData);
 
        poly = &data->mpoly[data->looptri[nearest.index].poly];
        loop = &data->mloop[poly->loopstart];
 
-       for (unsigned int i = 0; i < poly->totloop; i++, loop++) {
+       for (int i = 0; i < poly->totloop; i++, loop++) {
                edge = &data->medge[loop->e];
                dist = dist_squared_to_line_segment_v3(point_co, 
mvert[edge->v1].co, mvert[edge->v2].co);
 
@@ -325,7 +321,7 @@ BLI_INLINE bool isPolyValid(const float coords[][2], const 
unsigned int nr)
        copy_v2_v2(prev_co, coords[nr - 1]);
        sub_v2_v2v2(prev_vec, prev_co, coords[nr - 2]);
 
-       for (unsigned int i = 0; i < nr; i++) {
+       for (int i = 0; i < nr; i++) {
                sub_v2_v2v2(curr_vec, coords[i], prev_co);
 
                if (len_v2(curr_vec) < FLT_EPSILON) {
@@ -384,7 +380,6 @@ BLI_INLINE SDefBindWeightData 
*computeBindWeights(SDefBindCalcData * const data,
        float tot_weight = 0.0f;
        int inf_weight_flags = 0;
        unsigned int numpoly = 0;
-       unsigned int i, j;
 
        bwdata = MEM_callocN(sizeof(*bwdata), "SDefBindWeightData");
        if (bwdata == NULL) {
@@ -396,7 +391,7 @@ BLI_INLINE SDefBindWeightData 
*computeBindWeights(SDefBindCalcData * const data,
        for (vedge = vert_edges; vedge; vedge = vedge->next) {
                unsigned int edge_ind = vedge->index;
 
-               for (i = 0; i < edge_polys[edge_ind].num; i++) {
+               for (int i = 0; i < edge_polys[edge_ind].num; i++) {
                        for (bpoly = bwdata->bind_polys; bpoly; bpoly = 
bpoly->next) {
                                if (bpoly->index == 
edge_polys[edge_ind].polys[i]) {
                                        break;
@@ -446,7 +441,7 @@ BLI_INLINE SDefBindWeightData 
*computeBindWeights(SDefBindCalcData * const data,
                                        return NULL;
                                }
 
-                               for (j = 0; j < poly->totloop; j++, loop++) {
+                               for (int j = 0; j < poly->totloop; j++, loop++) 
{
                                        copy_v3_v3(bpoly->coords[j], 
data->mvert[loop->v].co);
 
                                        /* Find corner and edge indices within 
poly loop array */
@@ -474,7 +469,7 @@ BLI_INLINE SDefBindWeightData 
*computeBindWeights(SDefBindCalcData * const data,
                                
map_to_plane_axis_angle_v2_v3v3fl(bpoly->point_v2, point_co, axis, angle);
 
                                zero_v2(bpoly->centroid_v2);
-                               for (j = 0; j < poly->totloop; j++) {
+                               for (int j = 0; j < poly->totloop; j++) {
                                        
map_to_plane_axis_angle_v2_v3v3fl(bpoly->coords_v2[j], bpoly->coords[j], axis, 
angle);
                                        madd_v2_v2fl(bpoly->centroid_v2, 
bpoly->coords_v2[j], 1.0f / poly->totloop);
                                }
@@ -551,6 +546,7 @@ BLI_INLINE SDefBindWeightData 
*computeBindWeights(SDefBindCalcData * const data,
                        float tmp1, tmp2;
                        unsigned int edge_ind = vedge->index;
                        unsigned int edge_on_poly[2];
+                       int i;
 
                        epolys = &edge_polys[edge_ind];
 
@@ -802,7 +798,7 @@ static void bindVert(void *userdata, void 
*UNUSED(userdata_chunk), const int ind
 
                                /* Reproject vert based on weights and original 
poly verts, to reintroduce poly non-planarity */
                                zero_v3(point_co_proj);
-                               for (unsigned int i = 0; i < bpoly->numverts; 
i++, loop++) {
+                               for (int i = 0; i < bpoly->numverts; i++, 
loop++) {
                                        madd_v3_v3fl(point_co_proj, 
bpoly->coords[i], sdbind->

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to