Merge branch 'master' of git@git.blender.org:blender.git into blender2.8
authormano-wii <germano.costa@ig.com.br>
Thu, 13 Jul 2017 23:12:17 +0000 (20:12 -0300)
committermano-wii <germano.costa@ig.com.br>
Thu, 13 Jul 2017 23:12:17 +0000 (20:12 -0300)
# Conflicts:
# source/blender/editors/transform/transform_snap_object.c

1  2 
source/blender/editors/transform/transform_snap_object.c

index de556d52d25bd41be8bc5ec93423a1276a8bcd73,85833f54da63f8a94a439bcb6cd0ea71770f90be..0d63bae93e98aebcbf61a42f31cf1a2fb71879a8
@@@ -139,87 -138,44 +139,43 @@@ struct SnapObjectContext 
  /** Common utilities
  * \{ */
  
- struct SnapObject {
-       struct SnapObject *next, *prev;
  
-       bool use_obedit;
-       struct Object *ob;
-       float obmat[4][4];
- };
- /**
-  * Walks through all objects in the scene to create the list of objets to snap.
-  *
-  * \param sctx: Snap context to store data.
-  * \param snap_select : from enum SnapSelect.
-  * \param use_object_edit_cage : Uses the coordinates of BMesh(if any) to do the snapping.
-  *
-  */
- static void create_object_list(
-         SnapObjectContext *sctx,
-         const SnapSelect snap_select, const bool use_object_edit_cage, ListBase *r_obj_list)
- {
-       r_obj_list->first = r_obj_list->last = NULL;
-       Object *obedit = use_object_edit_cage ? sctx->scene->obedit : NULL;
-       bool ignore_object_selected = false, ignore_object_active = false;
-       switch (snap_select) {
-               case SNAP_ALL:
-                       break;
-               case SNAP_NOT_SELECTED:
-                       ignore_object_selected = true;
-                       break;
-               case SNAP_NOT_ACTIVE:
-                       ignore_object_active = true;
-                       break;
-       }
-       /* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA
-        * which makes the loop skip it, even the derived mesh will never change
-        *
-        * To solve that problem, we do it first as an exception.
-        * */
-       Base *base_act = sctx->scene_layer->basact;
-       if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) {
-               struct SnapObject *sobj = MEM_mallocN(sizeof(*sobj), __func__);
-               sobj->use_obedit = false;
-               sobj->ob = base_act->object;
-               copy_m4_m4(sobj->obmat, sobj->ob->obmat);
-               BLI_addtail(r_obj_list, sobj);
-       }
-       for (Base *base = sctx->scene_layer->object_bases.first; base != NULL; base = base->next) {
-               if ((BASE_VISIBLE_NEW(base)) && (base->flag_legacy & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
-                       !((ignore_object_selected && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) ||
-                       (ignore_object_active && base == base_act)))
-               {
-                       Object *ob = base->object;
-                       if (ob->transflag & OB_DUPLI) {
-                               DupliObject *dupli_ob;
-                               ListBase *lb = object_duplilist(sctx->bmain->eval_ctx, sctx->scene, ob);
-                               for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
-                                       struct SnapObject *sobj = MEM_mallocN(sizeof(*sobj), __func__);
-                                       sobj->use_obedit = obedit && dupli_ob->ob->data == obedit->data;
-                                       sobj->ob = sobj->use_obedit ? obedit : dupli_ob->ob;;
-                                       copy_m4_m4(sobj->obmat, dupli_ob->mat);
-                                       BLI_addtail(r_obj_list, sobj);
-                               }
-                               free_object_duplilist(lb);
-                       }
-                       struct SnapObject *sobj = MEM_mallocN(sizeof(*sobj), __func__);
-                       sobj->use_obedit = obedit && ob->data == obedit->data;
-                       sobj->ob = sobj->use_obedit ? obedit : ob;
-                       copy_m4_m4(sobj->obmat, sobj->ob->obmat);
-                       BLI_addtail(r_obj_list, sobj);
-               }
-       }
- }
+ #define ITER_SNAP_OBJECTS(use_obedit, ob, obmat, sctx, snap_select, obedit, CODE) \
+       Base *base_act = sctx->scene->basact;\
+       /* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA\
+        * which makes the loop skip it, even the derived mesh will never change\
+        *\
+        * To solve that problem, we do it first as an exception.\
+        * */\
+       if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) {\
+               use_obedit = false;\
+               ob = base_act->object;\
+               obmat = ob->obmat;\
+               CODE\
+       }\
+       for (Base *base = sctx->scene->base.first; base != NULL; base = base->next) {\
 -              if ((BASE_VISIBLE_BGMODE(sctx->v3d_data.v3d, sctx->scene, base)) &&\
 -                  (base->flag & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&\
 -                      !((snap_select == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL))) ||\
++              if ((BASE_VISIBLE_NEW(base)) && (base->flag_legacy & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&\
++                      !((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) ||\
+                         (snap_select == SNAP_NOT_ACTIVE && base == base_act)))\
+               {\
+                       Object *obj = base->object;\
+                       if (ob->transflag & OB_DUPLI) {\
+                               DupliObject *dupli_ob;\
+                               ListBase *lb = object_duplilist(sctx->bmain->eval_ctx, sctx->scene, obj);\
+                               for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {\
+                                       use_obedit = obedit && dupli_ob->ob->data == obedit->data;;\
+                                       ob = use_obedit ? obedit : dupli_ob->ob;\
+                                       obmat = dupli_ob->mat;\
+                                       CODE\
+                               }\
+                               free_object_duplilist(lb);\
+                       }\
+                       use_obedit = obedit && ob->data == obedit->data;\
+                       ob = use_obedit ? obedit : obj;\
+                       obmat = ob->obmat;\
+                       CODE\
+               }\
+       }\
  
  
  /**