[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20641] trunk/blender/source/gameengine/ Ketsji/KX_Camera.cpp: getScreenPosition, Ray and Vect fixes:
Dalai Felinto
dfelinto at gmail.com
Fri Jun 5 02:51:36 CEST 2009
Revision: 20641
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20641
Author: dfelinto
Date: 2009-06-05 02:51:36 +0200 (Fri, 05 Jun 2009)
Log Message:
-----------
getScreenPosition, Ray and Vect fixes:
- fix for [#18867] getScreenRay error
... the Vector wasn't been added to KX_Camera origin. Therefore the Ray was always casted to the wrong coordinate when camera wasn't in [0,0,0] (where is obviously was in my tests :)
- making the input parameter compatible with Blender/BGE window coordinate system (Top-Bottom).
... that will break scripts done in 2.49. Since this feature was added only in 2.49 that fix is OK. (and the fix is ridiculous.
Note:
the input parameter is normalized. That means it runs from 0.0 to 1.0. Some users found it confusing, but it allows to make a game compatible with multiple desktop resolutions.a
Modified Paths:
--------------
trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp
Modified: trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp 2009-06-05 00:39:42 UTC (rev 20640)
+++ trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp 2009-06-05 00:51:36 UTC (rev 20641)
@@ -1047,9 +1047,11 @@
gluProject(vect[0], vect[1], vect[2], modelmatrix, projmatrix, viewport, &win[0], &win[1], &win[2]);
- vect[0] = win[0] / (viewport[0] + viewport[2]);
- vect[1] = win[1] / (viewport[1] + viewport[3]);
+ vect[0] = (win[0] - viewport[0]) / viewport[2];
+ vect[1] = (win[1] - viewport[1]) / viewport[3];
+ vect[1] = 1.0 - vect[1]; //to follow Blender window coordinate system (Top-Down)
+
PyObject* ret = PyTuple_New(2);
if(ret){
PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(vect[0]));
@@ -1068,6 +1070,8 @@
if (!PyArg_ParseTuple(args,"dd:getScreenVect",&x,&y))
return NULL;
+ y = 1.0 - y; //to follow Blender window coordinate system (Top-Down)
+
MT_Vector3 vect;
MT_Point3 campos, screenpos;
@@ -1127,7 +1131,8 @@
}
Py_DECREF(argValue);
- dist *= -1.0;
+ dist = -dist;
+ vect += this->GetCameraLocation();
argValue = (propName?PyTuple_New(3):PyTuple_New(2));
if (argValue) {
More information about the Bf-blender-cvs
mailing list