[Bf-blender-cvs] [cd590fe] bake-cycles: Cycles-Bake: [review] style cleanup

Dalai Felinto noreply at git.blender.org
Wed Apr 23 02:47:44 CEST 2014


Commit: cd590fe2cd0f54388b80fac18b98339c33223729
Author: Dalai Felinto
Date:   Tue Mar 25 17:33:17 2014 -0300
https://developer.blender.org/rBcd590fe2cd0f54388b80fac18b98339c33223729

Cycles-Bake: [review] style cleanup

===================================================================

M	source/blender/editors/object/object_bake_new.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_render.c
M	source/blender/render/extern/include/RE_bake.h
M	source/blender/render/extern/include/RE_engine.h
M	source/blender/render/intern/source/bake_new.c
M	source/blender/render/intern/source/external_engine.c

===================================================================

diff --git a/source/blender/editors/object/object_bake_new.c b/source/blender/editors/object/object_bake_new.c
index a36bf96..9c9924a 100644
--- a/source/blender/editors/object/object_bake_new.c
+++ b/source/blender/editors/object/object_bake_new.c
@@ -125,7 +125,7 @@ static bool write_external_bake_pixels(
     char imtype, char exr_codec, char quality, char compression, char color_mode, char color_depth)
 {
 	ImBuf *ibuf = NULL;
-	short ok = FALSE;
+	bool ok = false;
 	ImageFormatData imf;
 	bool is_float;
 
@@ -161,7 +161,7 @@ static bool write_external_bake_pixels(
 	/* margins */
 	RE_bake_margin(pixel_array, ibuf, margin, width, height);
 
-	if ((ok=BKE_imbuf_write(ibuf, filepath, &imf))) {
+	if ((ok = BKE_imbuf_write(ibuf, filepath, &imf))) {
 #ifndef WIN32
 		chmod(filepath, S_IRUSR | S_IWUSR);
 #endif
@@ -283,40 +283,37 @@ static int bake_exec(bContext *C, wmOperator *op)
 	pixel_array_low = MEM_callocN(sizeof(BakePixel) * num_pixels, "bake pixels low poly");
 	result = MEM_callocN(sizeof(float) * depth * num_pixels, "bake return pixels");
 
-	/**
-	 // PSEUDO-CODE TIME
-
-	 // for now ignore the 'bakemap' references below
-	 // this is just to help thinking how this will fit
-	 // in the overall design and future changes
-	 // for the current bake structure just consider
-	 // that there is one bakemap made with the current
-	 // render selected options
+#if 0
+	/* PSEUDO-CODE TIME
+	 *
+	 * for now ignore the 'bakemap' references below
+	 * this is just to help thinking how this will fit
+	 * in the overall design and future changes
+	 * for the current bake structure just consider
+	 * that there is one bakemap made with the current
+	 * render selected options */
 
-	 for object in selected_objects:
- 		BakePixels *pixel_array[];
+	for object in selected_objects:
+		BakePixels *pixel_array[];
 
-	 	// doing this at this point means a bakemap won't have
-		// a unique UVMap, which may be fine
+		/* doing this at this point means a bakemap won't have
+		 * a unique UVMap, which may be fine */
 
-	 	populate_bake_pixels(object, pixel_array);
+		populate_bake_pixels(object, pixel_array);
 
-	 	for bakemap in object.bakemaps:
-	 		float *ret[]
+		for bakemap in object.bakemaps:
+			float *ret[]
 
-	 		if bakemap.type in (A):
-	 			extern_bake(object, pixel_array, len(bp), bakemap.type, ret);
-	 		else:
-	 			intern_bake(object, pixel_array, len(bp), bakemap.type, ret);
+			extern_bake(object, pixel_array, len(bp), bakemap.type, ret);
 
-	 		if bakemap.save_external:
-	 			write_image(bakemap.filepath, ret);
+			if bakemap.save_external:
+				write_image(bakemap.filepath, ret);
 
-	 		elif bakemap.save_internal:
-	 			bakemap.image(bakemap.image, ret);
+			elif bakemap.save_internal:
+				bakemap.image(bakemap.image, ret);
 
-	 		elif ... (vertex color?)
-	 */
+			elif ... (vertex color?)
+#endif
 
 	is_cage = ob_high && (ob_high->type == OB_MESH);
 	is_tangent = pass_type == SCE_PASS_NORMAL && normal_space == R_BAKE_SPACE_TANGENT;
@@ -340,7 +337,11 @@ static int bake_exec(bContext *C, wmOperator *op)
 
 			for (md = ob_low->modifiers.first; md; md = md->next) {
 				/* Edge Split cannot be applied in the cage,
-				 otherwise we loose interpolated normals */
+				 * the cage is supposed to have interpolated normals
+				 * between the faces unless the geometry is physically
+				 * split. So we create a copy of the low poly mesh without
+				 * the eventual edge split.*/
+
 				if (md->type == eModifierType_EdgeSplit)
 					continue;
 
@@ -436,11 +437,14 @@ static int bake_exec(bContext *C, wmOperator *op)
 			{
 				/* Cycles internal format */
 				if (normal_swizzle[0] == OB_NEGX &&
-					normal_swizzle[1] == OB_NEGY &&
-					normal_swizzle[2] == OB_NEGZ)
+				    normal_swizzle[1] == OB_NEGY &&
+				    normal_swizzle[2] == OB_NEGZ)
+				{
 					break;
-				else
+				}
+				else {
 					RE_normal_world_to_world(pixel_array_low, num_pixels,  depth, result, normal_swizzle);
+				}
 				break;
 			}
 			case R_BAKE_SPACE_OBJECT:
@@ -477,19 +481,11 @@ static int bake_exec(bContext *C, wmOperator *op)
 			ok = write_external_bake_pixels(name, pixel_array_render, result, width, height, is_linear, margin, imtype, exr_codec, quality, compression, color_mode, color_depth);
 
 			if (!ok) {
-				char *error = NULL;
-				error = BLI_sprintfN("Problem saving baked map in \"%s\".", name);
-
-				BKE_report(op->reports, RPT_ERROR, error);
-				MEM_freeN(error);
+				BKE_reportf(op->reports, RPT_ERROR, "Problem saving baked map in \"%s\".", name);
 				op_result = OPERATOR_CANCELLED;
 			}
 			else {
-				char *msg = NULL;
-				msg = BLI_sprintfN("Baking map written to \"%s\".", name);
-
-				BKE_report(op->reports, RPT_INFO, msg);
-				MEM_freeN(msg);
+				BKE_reportf(op->reports, RPT_INFO, "Baking map written to \"%s\".", name);
 				op_result = OPERATOR_FINISHED;
 			}
 		}
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 34ca827..f90d946 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -210,38 +210,38 @@ typedef struct SceneRenderLayer {
 #define SCE_LAY_NEG_ZMASK	0x80000
 
 /* srl->passflag */
-typedef enum ScenePassType{
-	SCE_PASS_COMBINED                 = (1<<0),
-	SCE_PASS_Z                        = (1<<1),
-	SCE_PASS_RGBA                     = (1<<2),
-	SCE_PASS_DIFFUSE                  = (1<<3),
-	SCE_PASS_SPEC                     = (1<<4),
-	SCE_PASS_SHADOW                   = (1<<5),
-	SCE_PASS_AO                       = (1<<6),
-	SCE_PASS_REFLECT                  = (1<<7),
-	SCE_PASS_NORMAL                   = (1<<8),
-	SCE_PASS_VECTOR                   = (1<<9),
-	SCE_PASS_REFRACT                  = (1<<10),
-	SCE_PASS_INDEXOB                  = (1<<11),
-	SCE_PASS_UV                       = (1<<12),
-	SCE_PASS_INDIRECT                 = (1<<13),
-	SCE_PASS_MIST                     = (1<<14),
-	SCE_PASS_RAYHITS                  = (1<<15),
-	SCE_PASS_EMIT                     = (1<<16),
-	SCE_PASS_ENVIRONMENT              = (1<<17),
-	SCE_PASS_INDEXMA                  = (1<<18),
-	SCE_PASS_DIFFUSE_DIRECT           = (1<<19),
-	SCE_PASS_DIFFUSE_INDIRECT         = (1<<20),
-	SCE_PASS_DIFFUSE_COLOR            = (1<<21),
-	SCE_PASS_GLOSSY_DIRECT            = (1<<22),
-	SCE_PASS_GLOSSY_INDIRECT          = (1<<23),
-	SCE_PASS_GLOSSY_COLOR             = (1<<24),
-	SCE_PASS_TRANSM_DIRECT            = (1<<25),
-	SCE_PASS_TRANSM_INDIRECT          = (1<<26),
-	SCE_PASS_TRANSM_COLOR             = (1<<27),
-	SCE_PASS_SUBSURFACE_DIRECT        = (1<<28),
-	SCE_PASS_SUBSURFACE_INDIRECT      = (1<<29),
-	SCE_PASS_SUBSURFACE_COLOR         = (1<<30),
+typedef enum ScenePassType {
+	SCE_PASS_COMBINED                 = (1 << 0),
+	SCE_PASS_Z                        = (1 << 1),
+	SCE_PASS_RGBA                     = (1 << 2),
+	SCE_PASS_DIFFUSE                  = (1 << 3),
+	SCE_PASS_SPEC                     = (1 << 4),
+	SCE_PASS_SHADOW                   = (1 << 5),
+	SCE_PASS_AO                       = (1 << 6),
+	SCE_PASS_REFLECT                  = (1 << 7),
+	SCE_PASS_NORMAL                   = (1 << 8),
+	SCE_PASS_VECTOR                   = (1 << 9),
+	SCE_PASS_REFRACT                  = (1 << 10),
+	SCE_PASS_INDEXOB                  = (1 << 11),
+	SCE_PASS_UV                       = (1 << 12),
+	SCE_PASS_INDIRECT                 = (1 << 13),
+	SCE_PASS_MIST                     = (1 << 14),
+	SCE_PASS_RAYHITS                  = (1 << 15),
+	SCE_PASS_EMIT                     = (1 << 16),
+	SCE_PASS_ENVIRONMENT              = (1 << 17),
+	SCE_PASS_INDEXMA                  = (1 << 18),
+	SCE_PASS_DIFFUSE_DIRECT           = (1 << 19),
+	SCE_PASS_DIFFUSE_INDIRECT         = (1 << 20),
+	SCE_PASS_DIFFUSE_COLOR            = (1 << 21),
+	SCE_PASS_GLOSSY_DIRECT            = (1 << 22),
+	SCE_PASS_GLOSSY_INDIRECT          = (1 << 23),
+	SCE_PASS_GLOSSY_COLOR             = (1 << 24),
+	SCE_PASS_TRANSM_DIRECT            = (1 << 25),
+	SCE_PASS_TRANSM_INDIRECT          = (1 << 26),
+	SCE_PASS_TRANSM_COLOR             = (1 << 27),
+	SCE_PASS_SUBSURFACE_DIRECT        = (1 << 28),
+	SCE_PASS_SUBSURFACE_INDIRECT      = (1 << 29),
+	SCE_PASS_SUBSURFACE_COLOR         = (1 << 30),
 } ScenePassType;
 
 /* note, srl->passflag is treestore element 'nr' in outliner, short still... */
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index cab0a19..81ce1e9 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -726,19 +726,19 @@ static void rna_def_render_bake_pixel(BlenderRNA *brna)
 	RNA_def_property_float_sdna(prop, NULL, "v");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
-	prop = RNA_def_property(srna, "dudx", PROP_FLOAT, PROP_NONE);
+	prop = RNA_def_property(srna, "du_dx", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "dudx");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
-	prop = RNA_def_property(srna, "dudy", PROP_FLOAT, PROP_NONE);
+	prop = RNA_def_property(srna, "du_dy", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "dudy");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
-	prop = RNA_def_property(srna, "dvdx", PROP_FLOAT, PROP_NONE);
+	prop = RNA_def_property(srna, "dv_dx", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "dvdx");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
-	prop = RNA_def_property(srna, "dvdy", PROP_FLOAT, PROP_NONE);
+	prop = RNA_def_property(srna, "dv_dy", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "dvdy");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
diff --git a/source/blender/render/extern/include/RE_bake.h b/source/blender/render/extern/include/RE_bake.h
index b972021..d93a72b 100644
--- a/source/blender/render/extern/include/RE_bake.h
+++ b/source/blender/render/extern/include/RE_bake.h
@@ -45,28 +45,27 @@ typedef struct BakePixel {
 /* external_engine.c */
 bool RE_engine_has_bake(struct Render *re);
 
-bool RE_engine_bake(struct Render *re, struct Object *object, struct BakePixel pixel_array[], int num_pixels, int depth, ScenePassType pass_type, float result[]);
+bool RE_engine_bake(struct Render *re, str

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list