Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-05-30 15:04:26 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-05-30 15:04:26 +0400
commitb97c77df2bafd7add01ea9dc8bfcad1e82714559 (patch)
treedb7ba1f4290677e22effe5511ecaa3185cc68ab9 /source/gameengine
parent62c333a5629bc5e264fd2740b032cc6ac28311dc (diff)
Check for zero normal vectors in the clip planes (if eg Python has set a strange projection matrix)
Fix the transformation of the frustum bound sphere to world coordinates.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index ffab2c946a9..4ed7b1e62d0 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -232,7 +232,11 @@ void KX_Camera::NormaliseClipPlanes()
return;
for (unsigned int p = 0; p < 6; p++)
- m_planes[p] /= sqrt(m_planes[p][0]*m_planes[p][0] + m_planes[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]);
+ {
+ MT_Scalar factor = sqrt(m_planes[p][0]*m_planes[p][0] + m_planes[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]);
+ if (!MT_fuzzyZero(factor))
+ m_planes[p] /= factor;
+ }
m_normalised = true;
}
@@ -257,11 +261,12 @@ void KX_Camera::ExtractFrustumSphere()
// Compute centre
m_frustum_centre = MT_Point3(0., 0.,
- -(nearpoint.dot(nearpoint) - farpoint.dot(farpoint))/(2.0*(m_camdata.m_clipend - m_camdata.m_clipstart)));
+ (nearpoint.dot(nearpoint) - farpoint.dot(farpoint))/(2.0*(m_camdata.m_clipend - m_camdata.m_clipstart)));
m_frustum_radius = m_frustum_centre.distance(farpoint);
// Transform to world space.
- m_frustum_centre = GetWorldToCamera()(m_frustum_centre);
+ m_frustum_centre = GetCameraToWorld()(m_frustum_centre);
+ m_frustum_radius /= fabs(NodeGetWorldScaling()[NodeGetWorldScaling().closestAxis()]);
m_set_frustum_centre = true;
}