[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28322] branches/render25: Render Branch: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r28313 :28321

Campbell Barton ideasman42 at gmail.com
Wed Apr 21 11:45:11 CEST 2010


Revision: 28322
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28322
Author:   campbellbarton
Date:     2010-04-21 11:45:11 +0200 (Wed, 21 Apr 2010)

Log Message:
-----------
Render Branch: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r28313:28321

Modified Paths:
--------------
    branches/render25/release/scripts/modules/bpy/utils.py
    branches/render25/source/blender/blenlib/intern/path_util.c
    branches/render25/source/blender/editors/mesh/loopcut.c
    branches/render25/source/blender/editors/object/object_edit.c
    branches/render25/source/blender/editors/render/render_internal.c
    branches/render25/source/blender/imbuf/intern/jp2.c

Modified: branches/render25/release/scripts/modules/bpy/utils.py
===================================================================
--- branches/render25/release/scripts/modules/bpy/utils.py	2010-04-21 09:27:36 UTC (rev 28321)
+++ branches/render25/release/scripts/modules/bpy/utils.py	2010-04-21 09:45:11 UTC (rev 28322)
@@ -205,12 +205,30 @@
 
 
 def expandpath(path):
+    """
+    Returns the absolute path relative to the current blend file using the "//" prefix.
+    """
     if path.startswith("//"):
         return _os.path.join(_os.path.dirname(_bpy.data.filename), path[2:])
 
     return path
 
 
+def relpath(path, start=None):
+    """
+    Returns the path relative to the current blend file using the "//" prefix.
+
+    :arg start: Relative to this path, when not set the current filename is used.
+    :type start: string
+    """
+    if not path.startswith("//"):
+        if start is None:
+            start = _os.path.dirname(_bpy.data.filename)
+        return "//" + _os.path.relpath(path, start)
+
+    return path
+
+
 _unclean_chars = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, \
     17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, \
     35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 58, 59, 60, 61, 62, 63, \

Modified: branches/render25/source/blender/blenlib/intern/path_util.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/path_util.c	2010-04-21 09:27:36 UTC (rev 28321)
+++ branches/render25/source/blender/blenlib/intern/path_util.c	2010-04-21 09:45:11 UTC (rev 28322)
@@ -1330,7 +1330,7 @@
 	/* linux uses binreloc since argv[0] is not relyable, call br_init( NULL ) first */
 	path = br_find_exe( NULL );
 	if (path) {
-		strcpy(fullname, path);
+		BLI_strncpy(fullname, path, sizeof(fullname));
 		free(path);
 		return;
 	}

Modified: branches/render25/source/blender/editors/mesh/loopcut.c
===================================================================
--- branches/render25/source/blender/editors/mesh/loopcut.c	2010-04-21 09:27:36 UTC (rev 28321)
+++ branches/render25/source/blender/editors/mesh/loopcut.c	2010-04-21 09:45:11 UTC (rev 28322)
@@ -413,7 +413,7 @@
 
 	switch (event->type) {
 		case LEFTMOUSE: /* confirm */ // XXX hardcoded
-			if (event->val == KM_RELEASE) {
+			if (event->val == KM_PRESS) {
 				/* finish */
 				ED_region_tag_redraw(lcd->ar);
 				

Modified: branches/render25/source/blender/editors/object/object_edit.c
===================================================================
--- branches/render25/source/blender/editors/object/object_edit.c	2010-04-21 09:27:36 UTC (rev 28321)
+++ branches/render25/source/blender/editors/object/object_edit.c	2010-04-21 09:45:11 UTC (rev 28322)
@@ -119,11 +119,15 @@
 static void error_libdata() {}
 
 
-/* find the correct active object per context */
+/* find the correct active object per context
+ * note: context can be NULL when called from a enum with PROP_ENUM_NO_CONTEXT */
 Object *ED_object_active_context(bContext *C)
 {
-	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
-	if (!ob) ob= CTX_data_active_object(C);
+	Object *ob= NULL;
+	if(C) {
+		ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+		if (!ob) ob= CTX_data_active_object(C);
+	}
 	return ob;
 }
 

Modified: branches/render25/source/blender/editors/render/render_internal.c
===================================================================
--- branches/render25/source/blender/editors/render/render_internal.c	2010-04-21 09:27:36 UTC (rev 28321)
+++ branches/render25/source/blender/editors/render/render_internal.c	2010-04-21 09:45:11 UTC (rev 28322)
@@ -33,6 +33,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_threads.h"
+#include "BLI_rand.h"
 
 #include "DNA_scene_types.h"
 
@@ -131,23 +132,25 @@
 
 	if(ibuf->rect==NULL)
 		imb_addrectImBuf(ibuf);
-
+	
 	rectf+= 4*(rr->rectx*ymin + xmin);
 	rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);
-
+	
 	/* XXX make nice consistent functions for this */
 	if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
 		for(y1= 0; y1<ymax; y1++) {
 			float *rf= rectf;
 			float srgb[3];
 			char *rc= rectc;
+			const float dither = ibuf->dither / 255.0;
 
 			/* XXX temp. because crop offset */
 			if( rectc >= (char *)(ibuf->rect)) {
 				for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
-					srgb[0]= linearrgb_to_srgb(rf[0]);
-					srgb[1]= linearrgb_to_srgb(rf[1]);
-					srgb[2]= linearrgb_to_srgb(rf[2]);
+					const float d = (BLI_frand()-0.5)*dither;
+					srgb[0]= d + linearrgb_to_srgb(rf[0]);
+					srgb[1]= d + linearrgb_to_srgb(rf[1]);
+					srgb[2]= d + linearrgb_to_srgb(rf[2]);
 
 					rc[0]= FTOCHAR(srgb[0]);
 					rc[1]= FTOCHAR(srgb[1]);
@@ -162,20 +165,28 @@
 		for(y1= 0; y1<ymax; y1++) {
 			float *rf= rectf;
 			char *rc= rectc;
+			float rgb[3];
+			const float dither = ibuf->dither / 255.0;
 
 			/* XXX temp. because crop offset */
 			if( rectc >= (char *)(ibuf->rect)) {
 				for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
-					rc[0]= FTOCHAR(rf[0]);
-					rc[1]= FTOCHAR(rf[1]);
-					rc[2]= FTOCHAR(rf[2]);
+					const float d = (BLI_frand()-0.5)*dither;
+					
+					rgb[0] = d + rf[0];
+					rgb[1] = d + rf[1];
+					rgb[2] = d + rf[2];
+					
+					rc[0]= FTOCHAR(rgb[0]);
+					rc[1]= FTOCHAR(rgb[1]);
+					rc[2]= FTOCHAR(rgb[2]);
 					rc[3]= FTOCHAR(rf[3]);
 				}
 			}
 			rectf += 4*rr->rectx;
 			rectc += 4*ibuf->x;
 		}
-	}
+	}	
 }
 
 /* new window uses x,y to set position */

Modified: branches/render25/source/blender/imbuf/intern/jp2.c
===================================================================
--- branches/render25/source/blender/imbuf/intern/jp2.c	2010-04-21 09:27:36 UTC (rev 28321)
+++ branches/render25/source/blender/imbuf/intern/jp2.c	2010-04-21 09:45:11 UTC (rev 28322)
@@ -91,8 +91,6 @@
 {
 	struct ImBuf *ibuf = 0;
 	int use_float = 0; /* for precision higher then 8 use float */
-	unsigned char *rect= NULL;
-	float *rect_float= NULL;
 	
 	long signed_offsets[4] = {0,0,0,0};
 	int float_divs[4];
@@ -158,7 +156,7 @@
 		return NULL;
 	}
 	
-	w = image->comps[0].w;	    
+	w = image->comps[0].w;
 	h = image->comps[0].h;
 	
 	switch (image->numcomps) {
@@ -188,13 +186,7 @@
 		float_divs[i]= (1<<image->comps[i].prec)-1;
 	}
 	
-	if (use_float) {
-		ibuf= IMB_allocImBuf(w, h, depth, IB_rectfloat, 0);
-		rect_float = ibuf->rect_float;
-	} else {
-		ibuf= IMB_allocImBuf(w, h, depth, IB_rect, 0);
-		rect = (unsigned char *) ibuf->rect;
-	}
+	ibuf= IMB_allocImBuf(w, h, depth, use_float ? IB_rectfloat : IB_rect, 0);
 	
 	if (ibuf==NULL) {
 		if(dinfo)
@@ -205,8 +197,8 @@
 	ibuf->ftype = JP2;
 	
 	if (use_float) {
-		rect_float = ibuf->rect_float;
-		
+		float *rect_float= ibuf->rect_float;
+
 		if (image->numcomps < 3) {
 			/* greyscale 12bits+ */
 			for (i = 0; i < w * h; i++, rect_float+=4) {
@@ -236,13 +228,14 @@
 		}
 		
 	} else {
-		
+		unsigned char *rect= (unsigned char *)ibuf->rect;
+
 		if (image->numcomps < 3) {
 			/* greyscale */
 			for (i = 0; i < w * h; i++, rect+=4) {
 				index = w * h - ((i) / (w) + 1) * w + (i) % (w);
 				
-				rect_float[0]= rect_float[1]= rect_float[2]= (image->comps[0].data[index] + signed_offsets[0]);
+				rect[0]= rect[1]= rect[2]= (image->comps[0].data[index] + signed_offsets[0]);
 				
 				if (image->numcomps == 2)
 					rect[3]= image->comps[1].data[index] + signed_offsets[1];





More information about the Bf-blender-cvs mailing list