[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38552] trunk/blender/source/blender/ editors/space_view3d: fix [#28037] Missing orange selection lines (trivial)

Campbell Barton ideasman42 at gmail.com
Thu Jul 21 03:30:28 CEST 2011


Revision: 38552
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38552
Author:   campbellbarton
Date:     2011-07-21 01:30:26 +0000 (Thu, 21 Jul 2011)
Log Message:
-----------
fix [#28037] Missing orange selection lines (trivial)

>From what I can tell there is no good fix for this bug, calculating the 2d/3d viewborder and then attempting to align them to be pixel perfect fails because of float imprecision.

Added a workaround, so the camera border is always drawn in 2d space,
since this workaround may cause problems later on its kept under the define VIEW3D_CAMERA_BORDER_HACK so we can get old behavior back easily.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/editors/space_view3d/view3d_intern.h

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2011-07-21 00:41:00 UTC (rev 38551)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2011-07-21 01:30:26 UTC (rev 38552)
@@ -1335,6 +1335,11 @@
 	glEnd();
 }
 
+#ifdef VIEW3D_CAMERA_BORDER_HACK
+float view3d_camera_border_hack_col[4];
+short view3d_camera_border_hack_test= FALSE;
+#endif
+
 /* flag similar to draw_object() */
 static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int flag)
 {
@@ -1348,7 +1353,15 @@
 	const float scax= 1.0f / len_v3(ob->obmat[0]);
 	const float scay= 1.0f / len_v3(ob->obmat[1]);
 	const float scaz= 1.0f / len_v3(ob->obmat[2]);
-	
+
+#ifdef VIEW3D_CAMERA_BORDER_HACK
+	if(is_view && !(G.f & G_PICKSEL)) {
+		glGetFloatv(GL_CURRENT_COLOR, view3d_camera_border_hack_col);
+		view3d_camera_border_hack_test= TRUE;
+		return;
+	}
+#endif
+
 	cam= ob->data;
 	aspx= (float) scene->r.xsch*scene->r.xasp;
 	aspy= (float) scene->r.ysch*scene->r.yasp;

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2011-07-21 00:41:00 UTC (rev 38551)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2011-07-21 01:30:26 UTC (rev 38552)
@@ -1007,6 +1007,8 @@
 	/* note: quite un-scientific but without this bit extra
 	 * 0.0001 on the lower left the 2D border sometimes
 	 * obscures the 3D camera border */
+	/* note: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticable
+	 * but keep it here incase we need to remove the workaround */
 	x1i= (int)(x1 - 1.0001f);
 	y1i= (int)(y1 - 1.0001f);
 	x2i= (int)(x2 + (1.0f-0.0001f));
@@ -1039,7 +1041,17 @@
 	setlinestyle(0);
 	UI_ThemeColor(TH_BACK);
 	glRectf(x1i, y1i, x2i, y2i);
-	
+
+#ifdef VIEW3D_CAMERA_BORDER_HACK
+	{
+		if(view3d_camera_border_hack_test == TRUE) {
+			glColor4fv(view3d_camera_border_hack_col);
+			glRectf(x1i+1, y1i+1, x2i-1, y2i-1);
+			view3d_camera_border_hack_test= FALSE;
+		}
+	}
+#endif
+
 	setlinestyle(3);
 	UI_ThemeColor(TH_WIRE);
 	glRectf(x1i, y1i, x2i, y2i);

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_intern.h	2011-07-21 00:41:00 UTC (rev 38551)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_intern.h	2011-07-21 01:30:26 UTC (rev 38552)
@@ -194,6 +194,16 @@
 /* draw_volume.c */
 void draw_volume(struct ARegion *ar, struct GPUTexture *tex, float *min, float *max, int res[3], float dx, struct GPUTexture *tex_shadow);
 
+/* workaround for trivial but noticable camera bug caused by imprecision
+ * between view border calculation in 2D/3D space, workaround for bug [#28037].
+ * without this deifne we get the old behavior which is to try and align them
+ * both which _mostly_ works fine, but when the camera moves beyond ~1000 in
+ * any direction it starts to fail */
+#define VIEW3D_CAMERA_BORDER_HACK
+#ifdef VIEW3D_CAMERA_BORDER_HACK
+extern float view3d_camera_border_hack_col[4];
+extern short view3d_camera_border_hack_test;
+#endif
 
 #endif /* ED_VIEW3D_INTERN_H */
 




More information about the Bf-blender-cvs mailing list