[Bf-blender-cvs] [93c143ecf37] blender2.8: Fix wire-toggle restoring previous shading mode

Campbell Barton noreply at git.blender.org
Fri Nov 23 06:28:09 CET 2018


Commit: 93c143ecf375b57deff612d3e0f4e283369bff3b
Author: Campbell Barton
Date:   Fri Nov 23 16:25:00 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB93c143ecf375b57deff612d3e0f4e283369bff3b

Fix wire-toggle restoring previous shading mode

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

M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/makesdna/DNA_view3d_types.h

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

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 5f0ce77703d..58bf91e5a17 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4872,7 +4872,7 @@ static int toggle_shading_exec(bContext *C, wmOperator *op)
 	ScrArea *sa = CTX_wm_area(C);
 	int type = RNA_enum_get(op->ptr, "type");
 
-	if (ELEM(type, OB_WIRE, OB_SOLID)) {
+	if (type == OB_SOLID) {
 		if (v3d->shading.type != type) {
 			v3d->shading.type = type;
 		}
@@ -4884,12 +4884,18 @@ static int toggle_shading_exec(bContext *C, wmOperator *op)
 		}
 	}
 	else {
-
+		char *prev_type = (
+		        (type == OB_WIRE) ?
+		        &v3d->shading.prev_type_wire :
+		        &v3d->shading.prev_type));
 		if (v3d->shading.type == type) {
-			v3d->shading.type = v3d->shading.prev_type;
+			if (*prev_type == type || !ELEM(*prev_type, OB_WIRE, OB_SOLID, OB_MATERIAL, OB_RENDER)) {
+				*prev_type = OB_SOLID;
+			}
+			v3d->shading.type = *prev_type;
 		}
 		else {
-			v3d->shading.prev_type = v3d->shading.type;
+			*prev_type = v3d->shading.type;
 			v3d->shading.type = type;
 		}
 	}
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 30b3f0ba688..e778edff52e 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -135,12 +135,12 @@ typedef struct View3DCursor {
 
 /* 3D Viewport Shading settings */
 typedef struct View3DShading {
-	short type;        /* Shading type (VIEW3D_SHADE_SOLID, ..) */
-	short prev_type;   /* Runtime, for toggle between rendered viewport. */
+	char type;        /* Shading type (VIEW3D_SHADE_SOLID, ..) */
+	char prev_type;   /* Runtime, for toggle between rendered viewport. */
+	char prev_type_wire;
 
-	short flag;
 	char color_type;
-	char _pad0[7];
+	short flag;
 
 	char light;
 	char background_type;



More information about the Bf-blender-cvs mailing list