[Bf-blender-cvs] [df5cbfb] master: Fix T39070: Custom bone shapes appear only one sided

Sergey Sharybin noreply at git.blender.org
Tue Mar 11 08:14:36 CET 2014


Commit: df5cbfb6253b10763375e3c86e827a1a34700231
Author: Sergey Sharybin
Date:   Tue Mar 11 13:08:43 2014 +0600
https://developer.blender.org/rBdf5cbfb6253b10763375e3c86e827a1a34700231

Fix T39070: Custom bone shapes appear only one sided

The idea is simple -- only enable culling for bones if they're not using
custom shape or if culling is enabled in shading panel.

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

M	source/blender/editors/space_view3d/drawarmature.c

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

diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 8aced48..8793dff 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -1667,6 +1667,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 	short do_dashed = 3;
 	bool draw_wire = false;
 	int flag;
+	bool is_cull_enabled;
 	
 	/* being set below */
 	arm->layer_used = 0;
@@ -1714,9 +1715,15 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 	}
 	
 	/* little speedup, also make sure transparent only draws once */
-	glCullFace(GL_BACK); 
-	glEnable(GL_CULL_FACE);
-	
+	glCullFace(GL_BACK);
+	if (v3d->flag2 & V3D_BACKFACE_CULLING) {
+		glEnable(GL_CULL_FACE);
+		is_cull_enabled = true;
+	}
+	else {
+		is_cull_enabled = false;
+	}
+
 	/* if solid we draw that first, with selection codes, but without names, axes etc */
 	if (dt > OB_WIRE) {
 		if (arm->flag & ARM_POSEMODE) 
@@ -1765,26 +1772,38 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 							draw_wire = true;
 						}
 						else {
+							if (is_cull_enabled && (v3d->flag2 & V3D_BACKFACE_CULLING) == 0) {
+								is_cull_enabled = false;
+								glDisable(GL_CULL_FACE);
+							}
+
 							draw_custom_bone(scene, v3d, rv3d, pchan->custom,
 							                 OB_SOLID, arm->flag, flag, index, bone->length);
 						}
 					}
-					else if (arm->drawtype == ARM_LINE) {
-						/* nothing in solid */
-					}
-					else if (arm->drawtype == ARM_WIRE) {
-						/* nothing in solid */
-					}
-					else if (arm->drawtype == ARM_ENVELOPE) {
-						draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, pchan, NULL);
-					}
-					else if (arm->drawtype == ARM_B_BONE) {
-						draw_b_bone(OB_SOLID, arm->flag, flag, 0, index, pchan, NULL);
-					}
 					else {
-						draw_bone(OB_SOLID, arm->flag, flag, 0, index, bone->length);
+						if (is_cull_enabled == false) {
+							is_cull_enabled = true;
+							glEnable(GL_CULL_FACE);
+						}
+
+						if (arm->drawtype == ARM_LINE) {
+							/* nothing in solid */
+						}
+						else if (arm->drawtype == ARM_WIRE) {
+							/* nothing in solid */
+						}
+						else if (arm->drawtype == ARM_ENVELOPE) {
+							draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, pchan, NULL);
+						}
+						else if (arm->drawtype == ARM_B_BONE) {
+							draw_b_bone(OB_SOLID, arm->flag, flag, 0, index, pchan, NULL);
+						}
+						else {
+							draw_bone(OB_SOLID, arm->flag, flag, 0, index, bone->length);
+						}
 					}
-						
+
 					glPopMatrix();
 				}
 			}
@@ -1885,7 +1904,12 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 			if (arm->flag & ARM_POSEMODE) 
 				index = base->selcol;
 		}
-		
+
+		if (is_cull_enabled == false) {
+			is_cull_enabled = true;
+			glEnable(GL_CULL_FACE);
+		}
+
 		for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
 			bone = pchan->bone;
 			arm->layer_used |= bone->layer;
@@ -1990,7 +2014,9 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 	}
 	
 	/* restore */
-	glDisable(GL_CULL_FACE);
+	if (is_cull_enabled) {
+		glDisable(GL_CULL_FACE);
+	}
 	
 	/* draw DoFs */
 	if (arm->flag & ARM_POSEMODE) {




More information about the Bf-blender-cvs mailing list