~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/blender/bmesh/operators/bmo_subdivide_edgering.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "MEM_guardedalloc.h"
41
41
 
42
42
#include "BLI_utildefines.h"
43
 
#include "BLI_array.h"
 
43
#include "BLI_alloca.h"
44
44
#include "BLI_math.h"
45
45
#include "BLI_listbase.h"
46
46
 
47
47
#include "BKE_curve.h"
48
48
 
49
49
#include "bmesh.h"
50
 
#include "tools/bmesh_edgesplit.h"
51
50
 
52
51
#include "intern/bmesh_operators_private.h" /* own include */
53
52
 
204
203
/* -------------------------------------------------------------------- */
205
204
/* Edge Loop Pairs */
206
205
/* key (ordered loop pointers) */
207
 
static GHash *bm_edgering_pair_calc(BMesh *bm, ListBase *eloops_rim)
 
206
static GSet *bm_edgering_pair_calc(BMesh *bm, ListBase *eloops_rim)
208
207
{
209
208
        /**
210
209
         * Method for for finding pairs:
220
219
         * could sort and optimize this but not really so important.
221
220
         */
222
221
 
223
 
        GHash *eloop_pair_gh = BLI_ghash_pair_new(__func__);
 
222
        GSet *eloop_pair_gs = BLI_gset_pair_new(__func__);
224
223
        GHash *vert_eloop_gh = BLI_ghash_ptr_new(__func__);
225
224
 
226
225
        struct BMEdgeLoopStore *el_store;
257
256
                                        if (pair_test.first > pair_test.second)
258
257
                                                SWAP(const void *, pair_test.first, pair_test.second);
259
258
 
260
 
                                        if (!BLI_ghash_haskey(eloop_pair_gh, &pair_test)) {
 
259
                                        if (!BLI_gset_haskey(eloop_pair_gs, &pair_test)) {
261
260
                                                GHashPair *pair = BLI_ghashutil_pairalloc(pair_test.first, pair_test.second);
262
 
                                                BLI_ghash_insert(eloop_pair_gh, pair, NULL);
 
261
                                                BLI_gset_insert(eloop_pair_gs, pair);
263
262
                                        }
264
263
 
265
264
                                }
269
268
 
270
269
        BLI_ghash_free(vert_eloop_gh, NULL, NULL);
271
270
 
272
 
        if (BLI_ghash_size(eloop_pair_gh) == 0) {
273
 
                BLI_ghash_free(eloop_pair_gh, NULL, NULL);
274
 
                eloop_pair_gh = NULL;
 
271
        if (BLI_gset_size(eloop_pair_gs) == 0) {
 
272
                BLI_gset_free(eloop_pair_gs, NULL);
 
273
                eloop_pair_gs = NULL;
275
274
        }
276
275
 
277
 
        return eloop_pair_gh;
 
276
        return eloop_pair_gs;
278
277
}
279
278
 
280
279
 
920
919
                }
921
920
                BLI_assert(node != NULL);
922
921
 
923
 
                BLI_rotatelist(lb_b, node);
 
922
                BLI_rotatelist_first(lb_b, node);
924
923
 
925
924
                /* now check we are winding the same way */
926
925
                if (bm_edgering_pair_order_is_flipped(bm, el_store_a, el_store_b)) {
927
926
                        BM_edgeloop_flip(bm, el_store_b);
928
927
                        /* re-ensure the first node */
929
 
                        BLI_rotatelist(lb_b, node);
 
928
                        BLI_rotatelist_first(lb_b, node);
930
929
                }
931
930
 
932
931
                /* sanity checks that we are aligned & winding now */
1167
1166
                        bm_edgering_pair_ringsubd(bm, lpair, el_store_a, el_store_b,
1168
1167
                                                  interp_mode, cuts, smooth, falloff_cache);
1169
1168
                        bm_edgering_pair_store_free(lpair, interp_mode);
 
1169
                        change = true;
1170
1170
                }
1171
1171
                else {
1172
1172
                        BMO_error_raise(bm, op, BMERR_INVALID_SELECTION,
1175
1175
                }
1176
1176
        }
1177
1177
        else {
1178
 
                GHashIterator gh_iter;
 
1178
                GSetIterator gs_iter;
1179
1179
                int i;
1180
1180
 
1181
 
                GHash *eloop_pairs_gh = bm_edgering_pair_calc(bm, &eloops_rim);
 
1181
                GSet *eloop_pairs_gs = bm_edgering_pair_calc(bm, &eloops_rim);
1182
1182
                LoopPairStore **lpair_arr;
1183
1183
 
1184
 
                if (eloop_pairs_gh == NULL) {
 
1184
                if (eloop_pairs_gs == NULL) {
1185
1185
                        BMO_error_raise(bm, op, BMERR_INVALID_SELECTION,
1186
1186
                                        "Edge-rings are not connected");
1187
1187
                        goto cleanup;
1188
1188
                }
1189
1189
 
1190
 
                lpair_arr = BLI_array_alloca(lpair_arr, BLI_ghash_size(eloop_pairs_gh));
 
1190
                lpair_arr = BLI_array_alloca(lpair_arr, BLI_gset_size(eloop_pairs_gs));
1191
1191
 
1192
1192
                /* first cache pairs */
1193
 
                GHASH_ITER_INDEX (gh_iter, eloop_pairs_gh, i) {
1194
 
                        GHashPair *eloop_pair = BLI_ghashIterator_getKey(&gh_iter);
 
1193
                GSET_ITER_INDEX (gs_iter, eloop_pairs_gs, i) {
 
1194
                        GHashPair *eloop_pair = BLI_gsetIterator_getKey(&gs_iter);
1195
1195
                        struct BMEdgeLoopStore *el_store_a = (void *)eloop_pair->first;
1196
1196
                        struct BMEdgeLoopStore *el_store_b = (void *)eloop_pair->second;
1197
1197
                        LoopPairStore *lpair;
1207
1207
                        BLI_assert(bm_verts_tag_count(bm) == 0);
1208
1208
                }
1209
1209
 
1210
 
                GHASH_ITER_INDEX (gh_iter, eloop_pairs_gh, i) {
1211
 
                        GHashPair *eloop_pair = BLI_ghashIterator_getKey(&gh_iter);
 
1210
                GSET_ITER_INDEX (gs_iter, eloop_pairs_gs, i) {
 
1211
                        GHashPair *eloop_pair = BLI_gsetIterator_getKey(&gs_iter);
1212
1212
                        struct BMEdgeLoopStore *el_store_a = (void *)eloop_pair->first;
1213
1213
                        struct BMEdgeLoopStore *el_store_b = (void *)eloop_pair->second;
1214
1214
                        LoopPairStore *lpair = lpair_arr[i];
1217
1217
                                bm_edgering_pair_ringsubd(bm, lpair, el_store_a, el_store_b,
1218
1218
                                                          interp_mode, cuts, smooth, falloff_cache);
1219
1219
                                bm_edgering_pair_store_free(lpair, interp_mode);
 
1220
                                change = true;
1220
1221
                        }
1221
1222
 
1222
1223
                        BLI_assert(bm_verts_tag_count(bm) == 0);
1223
1224
                }
1224
 
                BLI_ghash_free(eloop_pairs_gh, MEM_freeN, NULL);
 
1225
                BLI_gset_free(eloop_pairs_gs, MEM_freeN);
1225
1226
        }
1226
1227
 
1227
1228
cleanup:
1229
1230
 
1230
1231
        /* flag output */
1231
1232
        if (change) {
1232
 
                BMO_slot_buffer_flag_enable(bm, op->slots_out, "faces.out", BM_FACE, FACE_OUT);
 
1233
                BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_OUT);
1233
1234
        }
1234
1235
}