forked from bartvdbraak/blender
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
This commit is contained in:
parent
8154de7045
commit
52b7c157a0
@ -1047,8 +1047,10 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition,
|
||||
|
||||
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){
|
||||
@ -1068,6 +1070,8 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect,
|
||||
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 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenRay,
|
||||
}
|
||||
Py_DECREF(argValue);
|
||||
|
||||
dist *= -1.0;
|
||||
dist = -dist;
|
||||
vect += this->GetCameraLocation();
|
||||
|
||||
argValue = (propName?PyTuple_New(3):PyTuple_New(2));
|
||||
if (argValue) {
|
||||
|
Loading…
Reference in New Issue
Block a user