[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40118] branches/bmesh/blender: svn merge -r40104:40117 https://svn.blender.org/svnroot/bf-blender/trunk/ blender

Campbell Barton ideasman42 at gmail.com
Sun Sep 11 10:28:17 CEST 2011


Revision: 40118
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40118
Author:   campbellbarton
Date:     2011-09-11 08:28:16 +0000 (Sun, 11 Sep 2011)
Log Message:
-----------
svn merge -r40104:40117 https://svn.blender.org/svnroot/bf-blender/trunk/blender

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

Modified Paths:
--------------
    branches/bmesh/blender/doc/python_api/rst/info_gotcha.rst
    branches/bmesh/blender/source/blender/blenfont/intern/blf_font.c
    branches/bmesh/blender/source/blender/blenfont/intern/blf_internal.h
    branches/bmesh/blender/source/blender/blenfont/intern/blf_util.c
    branches/bmesh/blender/source/blender/blenkernel/BKE_colortools.h
    branches/bmesh/blender/source/blender/blenkernel/intern/brush.c
    branches/bmesh/blender/source/blender/blenkernel/intern/colortools.c
    branches/bmesh/blender/source/blender/blenkernel/intern/curve.c
    branches/bmesh/blender/source/blender/blenkernel/intern/shrinkwrap.c
    branches/bmesh/blender/source/blender/blenlib/intern/BLI_kdopbvh.c
    branches/bmesh/blender/source/blender/editors/animation/anim_channels_defines.c
    branches/bmesh/blender/source/blender/editors/armature/meshlaplacian.c
    branches/bmesh/blender/source/blender/editors/include/UI_interface.h
    branches/bmesh/blender/source/blender/editors/include/UI_resources.h
    branches/bmesh/blender/source/blender/editors/interface/interface_draw.c
    branches/bmesh/blender/source/blender/editors/interface/interface_panel.c
    branches/bmesh/blender/source/blender/editors/interface/interface_widgets.c
    branches/bmesh/blender/source/blender/editors/interface/resources.c
    branches/bmesh/blender/source/blender/editors/object/CMakeLists.txt
    branches/bmesh/blender/source/blender/editors/screen/area.c
    branches/bmesh/blender/source/blender/editors/space_file/file_draw.c
    branches/bmesh/blender/source/blender/editors/space_nla/nla_draw.c
    branches/bmesh/blender/source/blender/editors/space_node/drawnode.c
    branches/bmesh/blender/source/blender/editors/space_node/node_draw.c
    branches/bmesh/blender/source/blender/editors/space_outliner/outliner_draw.c
    branches/bmesh/blender/source/blender/editors/space_sequencer/sequencer_draw.c
    branches/bmesh/blender/source/blender/editors/space_text/text_draw.c
    branches/bmesh/blender/source/blender/editors/space_view3d/drawarmature.c
    branches/bmesh/blender/source/blender/editors/space_view3d/drawobject.c
    branches/bmesh/blender/source/blender/editors/space_view3d/drawvolume.c
    branches/bmesh/blender/source/blender/editors/space_view3d/view3d_draw.c
    branches/bmesh/blender/source/blender/editors/util/CMakeLists.txt
    branches/bmesh/blender/source/blender/modifiers/CMakeLists.txt
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_navmesh.cpp
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_weightvgproximity.c
    branches/bmesh/blender/source/blender/render/intern/include/render_types.h
    branches/bmesh/blender/source/blender/render/intern/include/rendercore.h
    branches/bmesh/blender/source/blender/render/intern/include/renderdatabase.h
    branches/bmesh/blender/source/blender/render/intern/include/shading.h
    branches/bmesh/blender/source/blender/render/intern/include/zbuf.h
    branches/bmesh/blender/source/blender/render/intern/source/convertblender.c
    branches/bmesh/blender/source/blender/render/intern/source/render_texture.c
    branches/bmesh/blender/source/blender/render/intern/source/rendercore.c
    branches/bmesh/blender/source/blender/render/intern/source/renderdatabase.c
    branches/bmesh/blender/source/blender/render/intern/source/shadeinput.c
    branches/bmesh/blender/source/blender/render/intern/source/shadeoutput.c
    branches/bmesh/blender/source/blender/render/intern/source/sss.c
    branches/bmesh/blender/source/blender/render/intern/source/volumetric.c
    branches/bmesh/blender/source/blender/render/intern/source/zbuf.c
    branches/bmesh/blender/source/blender/windowmanager/intern/wm_dragdrop.c
    branches/bmesh/blender/source/blenderplayer/CMakeLists.txt
    branches/bmesh/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
    branches/bmesh/blender/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
    branches/bmesh/blender/source/gameengine/GamePlayer/ghost/GPG_Application.h
    branches/bmesh/blender/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
    branches/bmesh/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
    branches/bmesh/blender/source/gameengine/Ketsji/KX_KetsjiEngine.h
    branches/bmesh/blender/source/gameengine/Ketsji/KX_PythonInit.cpp

Property Changed:
----------------
    branches/bmesh/blender/
    branches/bmesh/blender/release/
    branches/bmesh/blender/source/blender/editors/space_outliner/


Property changes on: branches/bmesh/blender
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/blender:39992-40104
   + /trunk/blender:39992-40117

Modified: branches/bmesh/blender/doc/python_api/rst/info_gotcha.rst
===================================================================
--- branches/bmesh/blender/doc/python_api/rst/info_gotcha.rst	2011-09-11 08:21:26 UTC (rev 40117)
+++ branches/bmesh/blender/doc/python_api/rst/info_gotcha.rst	2011-09-11 08:28:16 UTC (rev 40118)
@@ -378,6 +378,41 @@
 As suggested above, simply not holding references to data when Blender is used interactively by the user is the only way to ensure the script doesn't become unstable.
 
 
+Edit Mode / Memory Access
+-------------------------
+
+Switching edit-mode ``bpy.ops.object.mode_set(mode='EDIT')`` / ``bpy.ops.object.mode_set(mode='OBJECT')`` will re-allocate objects data, any references to a meshes vertices/faces/uvs, armatures bones, curves points etc cannot be accessed after switching edit-mode.
+
+Only the reference to the data its self can be re-accessed, the following example will crash.
+
+.. code-block:: python
+
+   mesh = bpy.context.active_object.data
+   faces = mesh.faces
+   bpy.ops.object.mode_set(mode='EDIT')
+   bpy.ops.object.mode_set(mode='OBJECT')
+
+   # this will crash
+   print(faces)
+
+
+So after switching edit-mode you need to re-access any object data variables, the following example shows how to avoid the crash above.
+
+.. code-block:: python
+
+   mesh = bpy.context.active_object.data
+   faces = mesh.faces
+   bpy.ops.object.mode_set(mode='EDIT')
+   bpy.ops.object.mode_set(mode='OBJECT')
+
+   # faces have been re-allocated
+   faces = mesh.faces
+   print(faces)
+
+
+These kinds of problems can happen for any functions which re-allocate the object data but are most common when switching edit-mode.
+
+
 Array Re-Allocation
 -------------------
 


Property changes on: branches/bmesh/blender/release
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/blender/release:31524-40104
   + /trunk/blender/release:31524-40117

Modified: branches/bmesh/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- branches/bmesh/blender/source/blender/blenfont/intern/blf_font.c	2011-09-11 08:21:26 UTC (rev 40117)
+++ branches/bmesh/blender/source/blender/blenfont/intern/blf_font.c	2011-09-11 08:28:16 UTC (rev 40118)
@@ -97,14 +97,52 @@
 	}
 }
 
+static void blf_font_ensure_ascii_table(FontBLF *font)
+{
+	/* build ascii on demand */
+	if(font->glyph_ascii_table['0']==NULL) {
+		GlyphBLF *g;
+		unsigned int i;
+		for(i=0; i<256; i++) {
+			g= blf_glyph_search(font->glyph_cache, i);
+			if (!g) {
+				FT_UInt glyph_index= FT_Get_Char_Index(font->face, i);
+				g= blf_glyph_add(font, glyph_index, i);
+			}
+			font->glyph_ascii_table[i]= g;
+		}
+	}
+}
+
+/* Fast path for runs of ASCII characters. Given that common UTF-8
+ * input will consist of an overwhelming majority of ASCII
+ * characters.
+ */
+
+/* Note,
+ * blf_font_ensure_ascii_table(font); must be called before this macro */
+
+#define BLF_UTF8_NEXT_FAST(font, g, str, i, c)                                \
+	if(((c)= (str)[i]) < 0x80) {                                              \
+		g= (font)->glyph_ascii_table[c];                                      \
+		i++;                                                                  \
+	}                                                                         \
+	else if ((c= blf_utf8_next((unsigned char *)(str), &(i)))) {              \
+		if ((g= blf_glyph_search((font)->glyph_cache, c)) == NULL) {          \
+			g= blf_glyph_add(font, FT_Get_Char_Index((font)->face, c), c);    \
+		}                                                                     \
+	}                                                                         \
+
+
+
 void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
 {
 	unsigned int c;
 	GlyphBLF *g, *g_prev;
 	FT_Vector delta;
-	FT_UInt glyph_index;
 	int pen_x, pen_y;
-	int i, has_kerning, st;
+	int has_kerning, st;
+	unsigned int i;
 
 	if (!font->glyph_cache)
 		return;
@@ -115,17 +153,15 @@
 	has_kerning= FT_HAS_KERNING(font->face);
 	g_prev= NULL;
 
+	blf_font_ensure_ascii_table(font);
+
 	while (str[i] && i < len) {
-		c= blf_utf8_next((unsigned char *)str, &i);
+
+		BLF_UTF8_NEXT_FAST(font, g, str, i, c);
+
 		if (c == 0)
 			break;
 
-		g= blf_glyph_search(font->glyph_cache, c);
-		if (!g) {
-			glyph_index= FT_Get_Char_Index(font->face, c);
-			g= blf_glyph_add(font, glyph_index, c);
-		}
-
 		/* if we don't found a glyph, skip it. */
 		if (!g)
 			continue;
@@ -157,9 +193,8 @@
 	char c;
 	GlyphBLF *g, *g_prev;
 	FT_Vector delta;
-	FT_UInt glyph_index;
 	int pen_x, pen_y;
-	int i, has_kerning, st;
+	int has_kerning, st;
 
 	if (!font->glyph_cache)
 		return;
@@ -169,18 +204,8 @@
 	has_kerning= FT_HAS_KERNING(font->face);
 	g_prev= NULL;
 
-	/* build ascii on demand */
-	if(font->glyph_ascii_table['0']==NULL) {
-		for(i=0; i<256; i++) {
-			g= blf_glyph_search(font->glyph_cache, i);
-			if (!g) {
-				glyph_index= FT_Get_Char_Index(font->face, i);
-				g= blf_glyph_add(font, glyph_index, i);
-			}
-			font->glyph_ascii_table[i]= g;
-		}
-	}
-	
+	blf_font_ensure_ascii_table(font);
+
 	while ((c= *(str++)) && len--) {
 		g= font->glyph_ascii_table[c];
 
@@ -216,10 +241,10 @@
 	unsigned char b_col_char[4];
 	GlyphBLF *g, *g_prev;
 	FT_Vector delta;
-	FT_UInt glyph_index;
 	float a, *fbuf;
 	int pen_x, y, x;
-	int i, has_kerning, st, chx, chy;
+	int has_kerning, st, chx, chy;
+	unsigned int i;
 
 	if (!font->glyph_cache || (!font->b_fbuf && !font->b_cbuf))
 		return;
@@ -234,18 +259,16 @@
 	b_col_char[2]= font->b_col[2] * 255;
 	b_col_char[3]= font->b_col[3] * 255;
 
+	blf_font_ensure_ascii_table(font);
+
 	while (str[i]) {
 		int pen_y;
-		c= blf_utf8_next((unsigned char *)str, &i);
+
+		BLF_UTF8_NEXT_FAST(font, g, str, i, c);
+
 		if (c == 0)
 			break;
 
-		g= blf_glyph_search(font->glyph_cache, c);
-		if (!g) {
-			glyph_index= FT_Get_Char_Index(font->face, c);
-			g= blf_glyph_add(font, glyph_index, c);
-		}
-
 		/* if we don't found a glyph, skip it. */
 		if (!g)
 			continue;
@@ -363,10 +386,10 @@
 	unsigned int c;
 	GlyphBLF *g, *g_prev;
 	FT_Vector delta;
-	FT_UInt glyph_index;
 	rctf gbox;
 	int pen_x, pen_y;
-	int i, has_kerning, st;
+	int has_kerning, st;
+	unsigned int i;
 
 	if (!font->glyph_cache)
 		return;
@@ -382,17 +405,15 @@
 	has_kerning= FT_HAS_KERNING(font->face);
 	g_prev= NULL;
 
+	blf_font_ensure_ascii_table(font);
+
 	while (str[i]) {
-		c= blf_utf8_next((unsigned char *)str, &i);
+
+		BLF_UTF8_NEXT_FAST(font, g, str, i, c);
+
 		if (c == 0)
 			break;
 
-		g= blf_glyph_search(font->glyph_cache, c);
-		if (!g) {
-			glyph_index= FT_Get_Char_Index(font->face, c);
-			g= blf_glyph_add(font, glyph_index, c);
-		}
-
 		/* if we don't found a glyph, skip it. */
 		if (!g)
 			continue;
@@ -534,7 +555,7 @@
 
 static void blf_font_fill(FontBLF *font)
 {
-	int i;
+	unsigned int i;
 
 	font->aspect[0]= 1.0f;
 	font->aspect[1]= 1.0f;

Modified: branches/bmesh/blender/source/blender/blenfont/intern/blf_internal.h
===================================================================
--- branches/bmesh/blender/source/blender/blenfont/intern/blf_internal.h	2011-09-11 08:21:26 UTC (rev 40117)
+++ branches/bmesh/blender/source/blender/blenfont/intern/blf_internal.h	2011-09-11 08:28:16 UTC (rev 40118)
@@ -40,7 +40,7 @@
 
 unsigned int blf_next_p2(unsigned int x);
 unsigned int blf_hash(unsigned int val);
-int blf_utf8_next(unsigned char *buf, int *iindex);
+int blf_utf8_next(unsigned char *buf, unsigned int *iindex);
 
 char *blf_dir_search(const char *file);
 char *blf_dir_metrics_search(const char *filename);

Modified: branches/bmesh/blender/source/blender/blenfont/intern/blf_util.c
===================================================================
--- branches/bmesh/blender/source/blender/blenfont/intern/blf_util.c	2011-09-11 08:21:26 UTC (rev 40117)
+++ branches/bmesh/blender/source/blender/blenfont/intern/blf_util.c	2011-09-11 08:28:16 UTC (rev 40118)
@@ -72,7 +72,7 @@
  * The original name: imlib_font_utf8_get_next
  * more info here: http://docs.enlightenment.org/api/imlib2/html/
  */
-int blf_utf8_next(unsigned char *buf, int *iindex)
+int blf_utf8_next(unsigned char *buf, unsigned int *iindex)
 {
 	/* Reads UTF8 bytes from 'buf', starting at 'index' and
 	 * returns the code point of the next valid code point.

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_colortools.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_colortools.h	2011-09-11 08:21:26 UTC (rev 40117)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_colortools.h	2011-09-11 08:28:16 UTC (rev 40118)
@@ -55,7 +55,7 @@
 struct CurveMapping	*curvemapping_add(int tot, float minx, float miny, float maxx, float maxy);
 void				curvemapping_free(struct CurveMapping *cumap);
 struct CurveMapping	*curvemapping_copy(struct CurveMapping *cumap);
-void				curvemapping_set_black_white(struct CurveMapping *cumap, float *black, float *white);
+void				curvemapping_set_black_white(struct CurveMapping *cumap, const float black[3], const float white[3]);
 
 #define CURVEMAP_SLOPE_NEGATIVE	0
 #define CURVEMAP_SLOPE_POSITIVE	1
@@ -70,9 +70,9 @@
 float				curvemap_evaluateF(struct CurveMap *cuma, float value);
 					/* single curve, with table check */
 float				curvemapping_evaluateF(struct CurveMapping *cumap, int cur, float value);
-void				curvemapping_evaluate3F(struct CurveMapping *cumap, float *vecout, const float *vecin);
-void				curvemapping_evaluateRGBF(struct CurveMapping *cumap, float *vecout, const float *vecin);
-void				curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float *vecout, const float *vecin);
+void				curvemapping_evaluate3F(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
+void				curvemapping_evaluateRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
+void				curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
 void				curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBuf *ibuf);
 void				curvemapping_premultiply(struct CurveMapping *cumap, int restore);
 int					curvemapping_RGBA_does_something(struct CurveMapping *cumap);


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list