[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30419] branches/soc-2008-mxcurioni: Merged changes in the trunk up to revision 30416.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Fri Jul 16 23:35:49 CEST 2010


Revision: 30419
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30419
Author:   kjym3
Date:     2010-07-16 23:35:48 +0200 (Fri, 16 Jul 2010)

Log Message:
-----------
Merged changes in the trunk up to revision 30416.

Revision Links:
--------------
    http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30416

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/io/netrender/repath.py
    branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/curve.c
    branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/sequencer.c
    branches/soc-2008-mxcurioni/source/blender/blenlib/BLI_path_util.h
    branches/soc-2008-mxcurioni/source/blender/blenlib/intern/path_util.c
    branches/soc-2008-mxcurioni/source/blender/editors/space_file/file_ops.c
    branches/soc-2008-mxcurioni/source/blender/editors/space_file/fsmenu.c
    branches/soc-2008-mxcurioni/source/blender/editors/space_sequencer/sequencer_draw.c
    branches/soc-2008-mxcurioni/source/blender/editors/space_sequencer/sequencer_edit.c
    branches/soc-2008-mxcurioni/source/blender/gpu/GPU_extensions.h
    branches/soc-2008-mxcurioni/source/blender/gpu/intern/gpu_extensions.c
    branches/soc-2008-mxcurioni/source/blender/python/intern/bpy_app.c
    branches/soc-2008-mxcurioni/source/blender/windowmanager/intern/wm_draw.c
    branches/soc-2008-mxcurioni/source/blender/windowmanager/intern/wm_files.c
    branches/soc-2008-mxcurioni/source/blender/windowmanager/intern/wm_init_exit.c
    branches/soc-2008-mxcurioni/source/gameengine/PyDoc/bge.logic.rst
    branches/soc-2008-mxcurioni/source/gameengine/PyDoc/bge.render.rst

Added Paths:
-----------
    branches/soc-2008-mxcurioni/release/freedesktop/blender-thumbnailer.py

Copied: branches/soc-2008-mxcurioni/release/freedesktop/blender-thumbnailer.py (from rev 30416, trunk/blender/release/freedesktop/blender-thumbnailer.py)
===================================================================
--- branches/soc-2008-mxcurioni/release/freedesktop/blender-thumbnailer.py	                        (rev 0)
+++ branches/soc-2008-mxcurioni/release/freedesktop/blender-thumbnailer.py	2010-07-16 21:35:48 UTC (rev 30419)
@@ -0,0 +1,132 @@
+#!/usr/bin/python
+
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+"""
+Thumbnailer runs with python 2.6 and 3.x.
+To run automatically with nautilus:
+   gconftool --type boolean --set /desktop/gnome/thumbnailers/application at x-blender/enable true
+   gconftool --type string --set /desktop/gnome/thumbnailers/application at x-blender/command "blender-thumbnailer.py %i %o"
+"""
+
+import os
+import struct
+import sys
+
+def blend_extract_thumb(path):
+    # def MAKE_ID(tag): ord(tag[0])<<24 | ord(tag[1])<<16 | ord(tag[2])<<8 | ord(tag[3])
+    REND = 1145980242 # MAKE_ID(b'REND')
+    TEST = 1414743380 # MAKE_ID(b'TEST')
+
+    blendfile = open(path, 'rb')
+
+    head = blendfile.read(7)
+
+    if head[0:2] == b'\x1f\x8b': # gzip magic
+        import gzip
+        blendfile.close()
+        blendfile = gzip.open(path, 'rb')
+        head = blendfile.read(7)
+
+    if head != b'BLENDER':
+        blendfile.close()
+        return None, 0, 0
+
+    is_64_bit = (blendfile.read(1) == b'-')
+
+    # true for PPC, false for X86
+    is_big_endian = (blendfile.read(1) == b'V')
+
+    # Now read the bhead chunk!!!
+    blendfile.read(3) # skip the version
+
+    sizeof_pointer = 8 if is_64_bit else 4
+
+    sizeof_bhead = 24 if is_64_bit else 20
+    
+    int_endian = '>i' if is_big_endian else '<i'
+    int_endian_pair = '>ii' if is_big_endian else '<ii'
+    
+    while True:
+        try:
+            code, length = struct.unpack(int_endian_pair, blendfile.read(8)) # 8 == sizeof(int) * 2
+        except IOError:
+            return None, 0, 0
+        
+        # finally read the rest of the bhead struct, pointer and 2 ints
+        blendfile.seek(sizeof_bhead - 8, os.SEEK_CUR)
+
+        if code == REND:
+            blendfile.seek(length, os.SEEK_CUR)
+        else:
+            break
+    
+    if code != TEST:
+        return None, 0, 0
+
+    try:
+        x, y = struct.unpack(int_endian_pair, blendfile.read(8)) # 8 == sizeof(int) * 2
+    except struct.error:
+        return None, 0, 0
+
+    length -= 8 # sizeof(int) * 2
+    
+    if length != x * y * 4:
+        return None, 0, 0
+    
+    image_buffer = blendfile.read(length)
+    
+    if len(image_buffer) != length:
+        return None, 0, 0
+
+    return image_buffer, x, y
+
+
+def write_png(buf, width, height):
+    import zlib
+
+    # reverse the vertical line order and add null bytes at the start
+    width_byte_4 = width * 4
+    raw_data = b"".join([b'\x00' + buf[span:span + width_byte_4] for span in range((height - 1) * width * 4, -1, - width_byte_4)])
+    
+    def png_pack(png_tag, data):
+        chunk_head = png_tag + data
+        return struct.pack("!I", len(data)) + chunk_head + struct.pack("!I", 0xFFFFFFFF & zlib.crc32(chunk_head))
+
+    return b"".join([
+        b'\x89PNG\r\n\x1a\n',
+        png_pack(b'IHDR', struct.pack("!2I5B", width, height, 8, 6, 0, 0, 0)),
+        png_pack(b'IDAT', zlib.compress(raw_data, 9)),
+        png_pack(b'IEND', b'')])
+
+
+if __name__ == '__main__':
+    if len(sys.argv) < 2:
+        print("Expected 2 arguments <input.blend> <output.png>")
+    else:
+        file_in = sys.argv[-2]
+
+        buf, width, height = blend_extract_thumb(file_in)
+        
+        if buf:
+            file_out = sys.argv[-1]
+
+            f = open(file_out, "wb")
+            f.write(write_png(buf, width, height))
+            f.close()

Modified: branches/soc-2008-mxcurioni/release/scripts/io/netrender/repath.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/io/netrender/repath.py	2010-07-16 17:43:08 UTC (rev 30418)
+++ branches/soc-2008-mxcurioni/release/scripts/io/netrender/repath.py	2010-07-16 21:35:48 UTC (rev 30419)
@@ -144,4 +144,4 @@
         
         process(args)
         
-        bpy.ops.wm.save_as_mainfile(path=new_path, check_existing=False)
+        bpy.ops.wm.save_as_mainfile(filepath=new_path, check_existing=False)

Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/curve.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/curve.c	2010-07-16 17:43:08 UTC (rev 30418)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/curve.c	2010-07-16 21:35:48 UTC (rev 30419)
@@ -3078,7 +3078,7 @@
 		nu->orderu= nu->pntsu;
 		change= 1;
 	}
-	if(((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) {
+	if(((nu->flagu & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) {
 		CLAMP(nu->orderu, 3,4);
 		change= 1;
 	}
@@ -3092,7 +3092,7 @@
 		nu->orderv= nu->pntsv;
 		change= 1;
 	}
-	if(((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) {
+	if(((nu->flagv & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) {
 		CLAMP(nu->orderv, 3,4);
 		change= 1;
 	}

Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/sequencer.c	2010-07-16 17:43:08 UTC (rev 30418)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/sequencer.c	2010-07-16 21:35:48 UTC (rev 30419)
@@ -1800,6 +1800,10 @@
 	if(seq->flag & SEQ_FLIPX) {
 		IMB_flipx(se->ibuf);
 	}
+	
+	if(seq->flag & SEQ_FLIPY) {
+		IMB_flipy(se->ibuf);
+	}
 
 	if(seq->sat != 1.0f) {
 		/* inline for now, could become an imbuf function */
@@ -2279,6 +2283,13 @@
 						addzbuffloatImBuf(se->ibuf);
 						memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty);
 					}
+
+					/* {
+						ImBuf *imb= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0);
+						IMB_saveiff(imb, "/tmp/foo.image", IB_rect | IB_metadata);
+						IMB_freeImBuf(imb);
+					} */
+
 				} else if (rres.rect32) {
 					se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0);
 					memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty);

Modified: branches/soc-2008-mxcurioni/source/blender/blenlib/BLI_path_util.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenlib/BLI_path_util.h	2010-07-16 17:43:08 UTC (rev 30418)
+++ branches/soc-2008-mxcurioni/source/blender/blenlib/BLI_path_util.h	2010-07-16 21:35:48 UTC (rev 30419)
@@ -40,14 +40,14 @@
 struct ListBase;
 struct direntry;
 
-char *BLI_gethome(void);
+char *BLI_getDefaultDocumentFolder(void);
 
 char *BLI_get_folder(int folder_id, char *subfolder);
 char *BLI_get_folder_create(int folder_id, char *subfolder);
 
 /* folder_id */
 
-/* general, will find baserd on user/local/system priority */
+/* general, will find based on user/local/system priority */
 #define BLENDER_CONFIG				1
 #define BLENDER_DATAFILES			2
 #define BLENDER_SCRIPTS				3
@@ -59,6 +59,7 @@
 #define BLENDER_USER_DATAFILES		32
 #define BLENDER_USER_SCRIPTS		33
 #define BLENDER_USER_PLUGINS		34
+#define BLENDER_USER_AUTOSAVE		35
 
 /* system */
 #define BLENDER_SYSTEM_CONFIG		51	/* optional */

Modified: branches/soc-2008-mxcurioni/source/blender/blenlib/intern/path_util.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenlib/intern/path_util.c	2010-07-16 17:43:08 UTC (rev 30418)
+++ branches/soc-2008-mxcurioni/source/blender/blenlib/intern/path_util.c	2010-07-16 21:35:48 UTC (rev 30419)
@@ -732,66 +732,38 @@
 	}
 }
 
-char *BLI_gethome(void) {
+/* This is now only used to really get the user's default document folder */
+/* On Windows I chose the 'Users/<MyUserName>/Documents' since it's used
+   as default location to save documents */
+char *BLI_getDefaultDocumentFolder(void) {
 	#if !defined(WIN32)
 		return getenv("HOME");
 
 	#else /* Windows */
 		char * ret;
-		static char dir[512];
-		static char appdatapath[MAXPATHLEN];
+		static char documentfolder[MAXPATHLEN];
 		HRESULT hResult;
 
 		/* Check for %HOME% env var */
 
 		ret = getenv("HOME");
 		if(ret) {
-			sprintf(dir, "%s\\%s", ret, blender_version_decimal());
-			if (BLI_is_dir(dir)) return dir;
+			if (BLI_is_dir(ret)) return ret;
 		}
-
-		/* else, check install dir (path containing blender.exe) */
-
-		if(BLI_getInstallationDir(dir))
-		{
-			sprintf(dir, "%s", dir, blender_version_decimal());
-			if (BLI_is_dir(dir)) return(dir);
-		}
-
 				
 		/* add user profile support for WIN 2K / NT.
 		 * This is %APPDATA%, which translates to either
 		 * %USERPROFILE%\Application Data or since Vista
 		 * to %USERPROFILE%\AppData\Roaming
 		 */
-		hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath);
+		hResult = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, documentfolder);
 		
 		if (hResult == S_OK)
 		{
-			if (BLI_is_dir(appdatapath)) { /* from fop, also below... */
-				sprintf(dir, "%s\\Blender Foundation\\Blender", appdatapath);
-				BLI_recurdir_fileops(dir);
-				if (BLI_is_dir(dir)) {
-					sprintf(dir,"%s\\%s", dir, blender_version_decimal());
-					if(BLI_is_dir(dir)) return(dir);
-				}
-			}
-			hResult = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath);
-			if (hResult == S_OK)
-			{
-				if (BLI_is_dir(appdatapath)) 
-				{ /* from fop, also below... */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list