[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28119] trunk/blender/source/gameengine: BGE fix #20456 - 2.5: mouse position problem (offseted by 1 vertically)

Dalai Felinto dfelinto at gmail.com
Sun Apr 11 03:53:22 CEST 2010


Revision: 28119
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28119
Author:   dfelinto
Date:     2010-04-11 03:53:21 +0200 (Sun, 11 Apr 2010)

Log Message:
-----------
BGE fix #20456 - 2.5: mouse position problem (offseted by 1 vertically)

In Blender 2.49 the win width and height were been calculated including an extra pixel (e.g. a fullscreen editor would be (width + 1) by (height + 1) )
In opposite to that, Blender 2.5 window/editor code were fixed to have the exact width,height size.
So although the BGE canvas code was still the same as 2.49 it was producing a wrong result.

I'm also adding some commentaries in the setViewport code. BGE is setting the viewports 1 pixel larger.
the setViewport command is been used as if one should pass (minx, miny, width, height), while it should be (minx, miny, maxx, maxy). I will take care of that later, if any one has extra comments on that, please let me know.

Modified Paths:
--------------
    trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
    trunk/blender/source/gameengine/GamePlayer/common/GPC_Canvas.cpp

Modified: trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
===================================================================
--- trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp	2010-04-11 00:59:39 UTC (rev 28118)
+++ trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp	2010-04-11 01:53:21 UTC (rev 28119)
@@ -117,6 +117,11 @@
 	int x1, int y1,
 	int x2, int y2
 ){
+	/*	x1 and y1 are the min pixel coordinate (e.g. 0)
+		x2 and y2 are the max pixel coordinate
+		the width,height is calculated including both pixels
+		therefore: max - min + 1
+	*/
 	int vp_width = (x2 - x1) + 1;
 	int vp_height = (y2 - y1) + 1;
 	int minx = m_frame_rect.GetLeft();
@@ -166,7 +171,7 @@
 	int winY = m_frame_rect.GetBottom();
 	int winH = m_frame_rect.GetHeight();
 	
-	BL_warp_pointer(m_win, winX + x, winY + (winH-y-1));
+	BL_warp_pointer(m_win, winX + x, winY + (winH-y));
 }
 
 

Modified: trunk/blender/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
===================================================================
--- trunk/blender/source/gameengine/GamePlayer/common/GPC_Canvas.cpp	2010-04-11 00:59:39 UTC (rev 28118)
+++ trunk/blender/source/gameengine/GamePlayer/common/GPC_Canvas.cpp	2010-04-11 01:53:21 UTC (rev 28119)
@@ -100,6 +100,12 @@
 
 void GPC_Canvas::SetViewPort(int x1, int y1, int x2, int y2)
 {
+		/*	x1 and y1 are the min pixel coordinate (e.g. 0)
+			x2 and y2 are the max pixel coordinate
+			the width,height is calculated including both pixels
+			therefore: max - min + 1
+		*/
+		
 		/* XXX, nasty, this needs to go somewhere else,
 		 * but where... definitly need to clean up this
 		 * whole canvas/rendertools mess.





More information about the Bf-blender-cvs mailing list