[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45354] trunk/blender/source/blender/bmesh /intern: fix [#30772] No more than two subdivions give correct result when adding an icosphere

Campbell Barton ideasman42 at gmail.com
Tue Apr 3 04:38:33 CEST 2012


Revision: 45354
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45354
Author:   campbellbarton
Date:     2012-04-03 02:38:27 +0000 (Tue, 03 Apr 2012)
Log Message:
-----------
fix [#30772] No more than two subdivions give correct result when adding an icosphere

bug was introduced in r45297, which inadvertently broke testing for multiple flags at once.

added BM_elem_flag_test_bool() and BMO_elem_flag_test_bool() to get TRUE/FALSE results rather then the flag value.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45297

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_inline.h
    trunk/blender/source/blender/bmesh/intern/bmesh_marking.c
    trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h
    trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
    trunk/blender/source/blender/bmesh/intern/bmesh_operators.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_inline.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_inline.h	2012-04-03 02:16:27 UTC (rev 45353)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_inline.h	2012-04-03 02:38:27 UTC (rev 45354)
@@ -30,18 +30,24 @@
 #define __BMESH_INLINE_H__
 
 /* stuff for dealing with header flags */
-#define BM_elem_flag_test(   ele, hflag)      _bm_elem_flag_test    (&(ele)->head, hflag)
-#define BM_elem_flag_enable( ele, hflag)      _bm_elem_flag_enable  (&(ele)->head, hflag)
-#define BM_elem_flag_disable(ele, hflag)      _bm_elem_flag_disable (&(ele)->head, hflag)
-#define BM_elem_flag_set(    ele, hflag, val) _bm_elem_flag_set     (&(ele)->head, hflag, val)
-#define BM_elem_flag_toggle( ele, hflag)      _bm_elem_flag_toggle  (&(ele)->head, hflag)
-#define BM_elem_flag_merge(  ele_a, ele_b)    _bm_elem_flag_merge   (&(ele_a)->head, &(ele_b)->head)
+#define BM_elem_flag_test(     ele, hflag)      _bm_elem_flag_test     (&(ele)->head, hflag)
+#define BM_elem_flag_test_bool(ele, hflag)      _bm_elem_flag_test_bool(&(ele)->head, hflag)
+#define BM_elem_flag_enable(   ele, hflag)      _bm_elem_flag_enable   (&(ele)->head, hflag)
+#define BM_elem_flag_disable(  ele, hflag)      _bm_elem_flag_disable  (&(ele)->head, hflag)
+#define BM_elem_flag_set(      ele, hflag, val) _bm_elem_flag_set      (&(ele)->head, hflag, val)
+#define BM_elem_flag_toggle(   ele, hflag)      _bm_elem_flag_toggle   (&(ele)->head, hflag)
+#define BM_elem_flag_merge(    ele_a, ele_b)    _bm_elem_flag_merge    (&(ele_a)->head, &(ele_b)->head)
 
 BLI_INLINE char _bm_elem_flag_test(const BMHeader *head, const char hflag)
 {
 	return head->hflag & hflag;
 }
 
+BLI_INLINE short _bm_elem_flag_test_bool(const BMHeader *head, const char hflag)
+{
+	return (head->hflag & hflag) != 0;
+}
+
 BLI_INLINE void _bm_elem_flag_enable(BMHeader *head, const char hflag)
 {
 	head->hflag |= hflag;

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_marking.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_marking.c	2012-04-03 02:16:27 UTC (rev 45353)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_marking.c	2012-04-03 02:38:27 UTC (rev 45354)
@@ -449,29 +449,30 @@
  * counts number of elements with flag enabled/disabled
  */
 static int bm_mesh_flag_count(BMesh *bm, const char htype, const char hflag,
-                              int respecthide, int test_for_enabled)
+                              const short respecthide, const short test_for_enabled)
 {
 	BMElem *ele;
 	BMIter iter;
-	const char hflag_test = (test_for_enabled ? hflag : 0);
 	int tot = 0;
 
+	BLI_assert(ELEM(TRUE, FALSE, test_for_enabled));
+
 	if (htype & BM_VERT) {
 		for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); ele; ele = BM_iter_step(&iter)) {
 			if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue;
-			if (BM_elem_flag_test(ele, hflag) == hflag_test) tot++;
+			if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++;
 		}
 	}
 	if (htype & BM_EDGE) {
 		for (ele = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); ele; ele = BM_iter_step(&iter)) {
 			if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue;
-			if (BM_elem_flag_test(ele, hflag) == hflag_test) tot++;
+			if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++;
 		}
 	}
 	if (htype & BM_FACE) {
 		for (ele = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); ele; ele = BM_iter_step(&iter)) {
 			if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue;
-			if (BM_elem_flag_test(ele, hflag) == hflag_test) tot++;
+			if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++;
 		}
 	}
 

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h	2012-04-03 02:16:27 UTC (rev 45353)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h	2012-04-03 02:38:27 UTC (rev 45354)
@@ -75,17 +75,19 @@
 
 struct GHashIterator;
 
-#define BMO_elem_flag_test(   bm, ele, oflag)      _bmo_elem_flag_test    (bm, (ele)->oflags, oflag)
-#define BMO_elem_flag_enable( bm, ele, oflag)      _bmo_elem_flag_enable  (bm, (ele)->oflags, oflag)
-#define BMO_elem_flag_disable(bm, ele, oflag)      _bmo_elem_flag_disable (bm, (ele)->oflags, oflag)
-#define BMO_elem_flag_set(    bm, ele, oflag, val) _bmo_elem_flag_set     (bm, (ele)->oflags, oflag, val)
-#define BMO_elem_flag_toggle( bm, ele, oflag)      _bmo_elem_flag_toggle  (bm, (ele)->oflags, oflag)
+#define BMO_elem_flag_test(     bm, ele, oflag)      _bmo_elem_flag_test     (bm, (ele)->oflags, oflag)
+#define BMO_elem_flag_test_bool(bm, ele, oflag)      _bmo_elem_flag_test_bool(bm, (ele)->oflags, oflag)
+#define BMO_elem_flag_enable(   bm, ele, oflag)      _bmo_elem_flag_enable   (bm, (ele)->oflags, oflag)
+#define BMO_elem_flag_disable(  bm, ele, oflag)      _bmo_elem_flag_disable  (bm, (ele)->oflags, oflag)
+#define BMO_elem_flag_set(      bm, ele, oflag, val) _bmo_elem_flag_set      (bm, (ele)->oflags, oflag, val)
+#define BMO_elem_flag_toggle(   bm, ele, oflag)      _bmo_elem_flag_toggle   (bm, (ele)->oflags, oflag)
 
-BLI_INLINE short _bmo_elem_flag_test(BMesh *bm, BMFlagLayer *oflags, const short oflag);
-BLI_INLINE void  _bmo_elem_flag_enable(BMesh *bm, BMFlagLayer *oflags, const short oflag);
-BLI_INLINE void  _bmo_elem_flag_disable(BMesh *bm, BMFlagLayer *oflags, const short oflag);
-BLI_INLINE void  _bmo_elem_flag_set(BMesh *bm, BMFlagLayer *oflags, const short oflag, int val);
-BLI_INLINE void  _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const short oflag);
+BLI_INLINE short _bmo_elem_flag_test(     BMesh *bm, BMFlagLayer *oflags, const short oflag);
+BLI_INLINE short _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag);
+BLI_INLINE void  _bmo_elem_flag_enable(   BMesh *bm, BMFlagLayer *oflags, const short oflag);
+BLI_INLINE void  _bmo_elem_flag_disable(  BMesh *bm, BMFlagLayer *oflags, const short oflag);
+BLI_INLINE void  _bmo_elem_flag_set(      BMesh *bm, BMFlagLayer *oflags, const short oflag, int val);
+BLI_INLINE void  _bmo_elem_flag_toggle(   BMesh *bm, BMFlagLayer *oflags, const short oflag);
 
 /* slot type arrays are terminated by the last member
  * having a slot type of 0.*/
@@ -297,17 +299,17 @@
 
 /* copies the values from another slot to the end of the output slot */
 void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot,
-							BMOperator *other_op, const char *other_op_slot);
+                            BMOperator *other_op, const char *other_op_slot);
 
 /* puts every element of type 'type' (which is a bitmask) with tool
  * flag 'flag', into a slot. */
 void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname,
-									   const char htype, const short oflag);
+                                       const char htype, const short oflag);
 
 /* puts every element of type 'type' (which is a bitmask) without tool
  * flag 'flag', into a slot. */
 void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname,
-										const char htype, const short oflag);
+                                        const char htype, const short oflag);
 
 /* tool-flags all elements inside an element slot array with flag flag. */
 void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname,
@@ -327,15 +329,15 @@
  * flag 'flag', into a slot.  note: ignores hidden elements
  * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/
 void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op,
-										const char *slotname,
-										const char htype, const char hflag);
+                                        const char *slotname,
+                                        const char htype, const char hflag);
 
 /* puts every element of type 'type' (which is a bitmask) without
  * header flag 'flag', into a slot.  note: ignores hidden elements
  * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/
 void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op,
-										 const char *slotname,
-										 const char htype, const char hflag);
+                                         const char *slotname,
+                                         const char htype, const char hflag);
 
 /* counts number of elements inside a slot array. */
 int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slotname);

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h	2012-04-03 02:16:27 UTC (rev 45353)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h	2012-04-03 02:38:27 UTC (rev 45354)
@@ -40,9 +40,14 @@
 /* flags 15 and 16 (1 << 14 and 1 << 15) are reserved for bmesh api use */
 BLI_INLINE short _bmo_elem_flag_test(BMesh *bm, BMFlagLayer *oflags, const short oflag)
 {
-    return oflags[bm->stackdepth - 1].f & oflag;
+	return oflags[bm->stackdepth - 1].f & oflag;
 }
 
+BLI_INLINE short _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag)
+{
+	return (oflags[bm->stackdepth - 1].f & oflag) != 0;
+}
+
 BLI_INLINE void _bmo_elem_flag_enable(BMesh *bm, BMFlagLayer *oflags, const short oflag)
 {
 	oflags[bm->stackdepth - 1].f |= oflag;
@@ -65,13 +70,13 @@
 }
 
 BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname,
-                                       void *element, int val)
+                                        void *element, int val)
 {
 	BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int));
 }
 
 BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname,
-                                         void *element, float val)
+                                          void *element, float val)
 {
 	BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float));
 }
@@ -83,7 +88,7 @@
  * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list