Merge branch 'master' into blender2.8
authormano-wii <germano.costa@ig.com.br>
Fri, 14 Jul 2017 19:56:36 +0000 (16:56 -0300)
committermano-wii <germano.costa@ig.com.br>
Fri, 14 Jul 2017 19:56:36 +0000 (16:56 -0300)
# Conflicts:
# source/blender/editors/transform/transform_snap_object.c

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

index 1d58dd62c7e8f3e9f79dbb2d190927eac4bbd279,61f4914a3f04d99fa9ad6fe430e2e9ff7b1fecb7..39d76c89e4d5de653a2758f3b8d2e10bbb18efd5
@@@ -140,42 -139,55 +140,54 @@@ struct SnapObjectContext 
  * \{ */
  
  
- #define ITER_SNAP_OBJECTS(use_obedit, ob, obmat, sctx, snap_select, obedit, CODE) \
-       Base *base_act = sctx->scene_layer->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_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 &&\
-                       !((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) ||\
-                         (snap_select == SNAP_NOT_ACTIVE && base == base_act)))\
-               {\
-                       Object *ob_iter = base->object;\
-                       if (ob_iter->transflag & OB_DUPLI) {\
-                               DupliObject *dupli_ob;\
-                               ListBase *lb = object_duplilist(sctx->bmain->eval_ctx, sctx->scene, ob_iter);\
-                               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_iter->data == obedit->data;\
-                       ob = use_obedit ? obedit : ob_iter;\
-                       obmat = ob->obmat;\
-                       CODE\
-               }\
-       }\
+ typedef void(*IterSnapObjsCallback)(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data);
+ /**
+  * 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 obedit : Object Edited to use its coordinates of BMesh(if any) to do the snapping.
+  */
+ static void iter_snap_objects(
+         SnapObjectContext *sctx,
+         const SnapSelect snap_select,
+         Object *obedit,
+         IterSnapObjsCallback sob_callback,
+         void *data)
+ {
 -      Base *base_act = sctx->scene->basact;
++      Base *base_act = sctx->scene_layer->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) {
+               sob_callback(sctx, false, base_act->object, base_act->object->obmat, data);
+       }
 -      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))) ||
++      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 &&
++                      !((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) ||
+                         (snap_select == SNAP_NOT_ACTIVE && base == base_act)))
+               {
+                       bool use_obedit;
+                       Object *obj = base->object;
+                       if (obj->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;
+                                       sob_callback(sctx, use_obedit, use_obedit ? obedit : dupli_ob->ob, dupli_ob->mat, data);
+                               }
+                               free_object_duplilist(lb);
+                       }
+                       use_obedit = obedit && obj->data == obedit->data;
+                       sob_callback(sctx, use_obedit, use_obedit ? obedit : obj, obj->obmat, data);
+               }
+       }
+ }
  
  
  /**