From 415f35d1dc916edcb9b050f25ae406c6eee2b63d Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 20 Oct 2011 06:38:45 +0000 Subject: =?UTF-8?q?bge=20bugfix:=20patch=20#28893=20"Fix=20for=20#28753=20?= =?UTF-8?q?and=20some=20other=20changes=20for=20BGE=20projection=20code"?= =?UTF-8?q?=20by=20Juha=20M=C3=A4ki-Kanto=20(kanttori)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 9 ++++++++- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 10 ++++++++-- source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 18 +++++++----------- source/gameengine/Rasterizer/RAS_FramingManager.cpp | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) (limited to 'source') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index ce542671425..af4df5035bb 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -360,7 +360,14 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c ketsjiengine->SetCameraOverrideUseOrtho((rv3d->persp == RV3D_ORTHO)); ketsjiengine->SetCameraOverrideProjectionMatrix(MT_CmMatrix4x4(rv3d->winmat)); ketsjiengine->SetCameraOverrideViewMatrix(MT_CmMatrix4x4(rv3d->viewmat)); - ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far); + if(rv3d->persp == RV3D_ORTHO) + { + ketsjiengine->SetCameraOverrideClipping(-v3d->far, v3d->far); + } + else + { + ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far); + } ketsjiengine->SetCameraOverrideLens(v3d->lens); } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 8e6126bb173..afc3bf2b53d 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1400,8 +1400,14 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene) KX_Camera* activecam = NULL; RAS_CameraData camdata = RAS_CameraData(); - if (override_camera) camdata.m_lens = m_overrideCamLens; - + if (override_camera) + { + camdata.m_lens = m_overrideCamLens; + camdata.m_clipstart = m_overrideCamNear; + camdata.m_clipend = m_overrideCamFar; + + camdata.m_perspective= !m_overrideCamUseOrtho; + } activecam = new KX_Camera(scene,KX_Scene::m_callbacks,camdata); activecam->SetName("__default__cam__"); diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 34f5c26415d..e1978263a12 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -240,29 +240,23 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) /* build the from and to point in normalized device coordinates - * Looks like normailized device coordinates are [-1,1] in x [-1,1] in y - * [0,-1] in z + * Normalized device coordinates are [-1,1] in x, y, z * * The actual z coordinates used don't have to be exact just infront and * behind of the near and far clip planes. */ frompoint.setValue( (2 * (m_x-x_lb) / width) - 1.0, 1.0 - (2 * (m_y_inv - y_lb) / height), - /*cam->GetCameraData()->m_perspective ? 0.0:cdata->m_clipstart,*/ /* real clipstart is scaled in ortho for some reason, zero is ok */ - 0.0, /* nearclip, see above comments */ + -1.0, 1.0 ); topoint.setValue( (2 * (m_x-x_lb) / width) - 1.0, 1.0 - (2 * (m_y_inv-y_lb) / height), - cam->GetCameraData()->m_perspective ? 1.0:cam->GetCameraData()->m_clipend, /* farclip, see above comments */ + 1.0, 1.0 ); - - /* camera to world */ - MT_Transform wcs_camcs_tranform = cam->GetWorldToCamera(); - MT_Transform cams_wcs_transform; - cams_wcs_transform.invert(wcs_camcs_tranform); - MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cams_wcs_transform); + /* camera to world */ + MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cam->GetCameraToWorld()); /* badly defined, the first time round.... I wonder why... I might * want to guard against floating point errors here.*/ @@ -272,6 +266,8 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) /* shoot-points: clip to cam to wcs . win to clip was already done.*/ frompoint = clip_camcs_matrix * frompoint; topoint = clip_camcs_matrix * topoint; + /* clipstart = - (frompoint[2] / frompoint[3]) + * clipend = - (topoint[2] / topoint[3]) */ frompoint = camcs_wcs_matrix * frompoint; topoint = camcs_wcs_matrix * topoint; diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp index edacd1dd0f1..6ca402691cb 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp +++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp @@ -99,7 +99,7 @@ ComputeDefaultOrtho( frustum.x1 = -frustum.x2; frustum.y2 = sizeY; frustum.y1 = -frustum.y2; - frustum.camnear = -camfar; + frustum.camnear = camnear; frustum.camfar = camfar; } -- cgit v1.2.3