[Bf-blender-cvs] [ad5497b] master: Code cleanup: style and use switch () for (un)pack

Campbell Barton noreply at git.blender.org
Wed Apr 23 11:23:05 CEST 2014


Commit: ad5497b6dfffb97bcc55bce1097a1d80728b331a
Author: Campbell Barton
Date:   Wed Apr 23 19:22:03 2014 +1000
https://developer.blender.org/rBad5497b6dfffb97bcc55bce1097a1d80728b331a

Code cleanup: style and use switch () for (un)pack

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

M	source/blender/blenkernel/intern/material.c
M	source/blender/blenkernel/intern/packedFile.c
M	source/blender/editors/physics/rigidbody_world.c

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

diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 1ee84fb..f9af77b 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1039,7 +1039,7 @@ static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode
 				basemat->mode_l |= ma->mode & ~(MA_MODE_PIPELINE | MA_SHLESS);
 				basemat->mode2_l |= ma->mode2 & ~MA_MODE2_PIPELINE;
 				/* basemat only considered shadeless if all node materials are too */
-				if(!(ma->mode & MA_SHLESS))
+				if (!(ma->mode & MA_SHLESS))
 					basemat->mode_l &= ~MA_SHLESS;
 
 				if (ma->strand_surfnor > 0.0f)
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index fc8a23a..6c86554 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -627,21 +627,27 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
 /* ID should be not NULL, return 1 if there's a packed file */
 bool BKE_pack_check(ID *id)
 {
-	if (GS(id->name) == ID_IM) {
-		Image *ima = (Image *)id;
-		return ima->packedfile != NULL;
-	}
-	if (GS(id->name) == ID_VF) {
-		VFont *vf = (VFont *)id;
-		return vf->packedfile != NULL;
-	}
-	if (GS(id->name) == ID_SO) {
-		bSound *snd = (bSound *)id;
-		return snd->packedfile != NULL;
-	}
-	if (GS(id->name) == ID_LI) {
-		Library *li = (Library *)id;
-		return li->packedfile != NULL;
+	switch (GS(id->name)) {
+		case ID_IM:
+		{
+			Image *ima = (Image *)id;
+			return ima->packedfile != NULL;
+		}
+		case ID_VF:
+		{
+			VFont *vf = (VFont *)id;
+			return vf->packedfile != NULL;
+		}
+		case ID_SO:
+		{
+			bSound *snd = (bSound *)id;
+			return snd->packedfile != NULL;
+		}
+		case ID_LI:
+		{
+			Library *li = (Library *)id;
+			return li->packedfile != NULL;
+		}
 	}
 	return false;
 }
@@ -649,23 +655,36 @@ bool BKE_pack_check(ID *id)
 /* ID should be not NULL */
 void BKE_unpack_id(Main *bmain, ID *id, ReportList *reports, int how)
 {
-	if (GS(id->name) == ID_IM) {
-		Image *ima = (Image *)id;
-		if (ima->packedfile)
-			unpackImage(reports, ima, how);
-	}
-	if (GS(id->name) == ID_VF) {
-		VFont *vf = (VFont *)id;
-		if (vf->packedfile)
-			unpackVFont(reports, vf, how);
-	}
-	if (GS(id->name) == ID_SO) {
-		bSound *snd = (bSound *)id;
-		if (snd->packedfile)
-			unpackSound(bmain, reports, snd, how);
-	}
-	if (GS(id->name) == ID_LI) {
-		Library *li = (Library *)id;
-		BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);
+	switch (GS(id->name)) {
+		case ID_IM:
+		{
+			Image *ima = (Image *)id;
+			if (ima->packedfile) {
+				unpackImage(reports, ima, how);
+			}
+			break;
+		}
+		case ID_VF:
+		{
+			VFont *vf = (VFont *)id;
+			if (vf->packedfile) {
+				unpackVFont(reports, vf, how);
+			}
+			break;
+		}
+		case ID_SO:
+		{
+			bSound *snd = (bSound *)id;
+			if (snd->packedfile) {
+				unpackSound(bmain, reports, snd, how);
+			}
+			break;
+		}
+		case ID_LI:
+		{
+			Library *li = (Library *)id;
+			BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);
+			break;
+		}
 	}
 }
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index b7430cb..d5056d5 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -159,7 +159,7 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
 	char path[FILE_MAX];
 
 	/* sanity checks */
-	if ELEM(NULL, scene, rbw) {
+	if (ELEM(NULL, scene, rbw)) {
 		BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to export");
 		return OPERATOR_CANCELLED;
 	}




More information about the Bf-blender-cvs mailing list