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:
authorBenoit Bolsee <benoit.bolsee@online.be>2015-10-13 00:18:18 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2015-10-13 00:18:18 +0300
commit9d18fd1188e1a3e2d5a58fada0a26ae4107dcfe7 (patch)
tree92fa891b35de3f0c9b3797ad6027d12855fe4c46 /source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
parentc36f08d573a4c867cf196ac56fa3949ddaecd880 (diff)
BGE: support camera scale, can be negative.
Camera scale was previously ignored in the BGE. It is now injected in the modelview matrix as a scale of the scene coordinates in the camera local reference. This is equivalent to a zoom: A scale of 2 multiplies the coordinates by 2 => only the points with coordinates less then 0.5 before the scale will fall in the frustrum => equivalent to a zoom. Anisotropic scale is supported (different scale in x, y, z) Negative scale is also supported. As an odd number of negative scale flips the normals of the objects, the OGL front face setting is also flipped to compensate. A Y negative scale of -1 produces a vertical flip at OGL level.
Diffstat (limited to 'source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp')
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index bef36b52956..6dff495cbc7 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -91,6 +91,7 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage)
m_time(0.0),
m_campos(0.0f, 0.0f, 0.0f),
m_camortho(false),
+ m_camnegscale(false),
m_stereomode(RAS_STEREO_NOSTEREO),
m_curreye(RAS_STEREO_LEFTEYE),
m_eyeseparation(0.0),
@@ -866,6 +867,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
const MT_Matrix3x3 & camOrientMat3x3,
const MT_Point3 & pos,
+ const MT_Vector3 &scale,
bool perspective)
{
m_viewmatrix = mat;
@@ -908,6 +910,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
}
}
+ m_viewmatrix.tscale(scale[0], scale[1], scale[2], 1.0);
m_viewinvmatrix = m_viewmatrix;
m_viewinvmatrix.invert();
@@ -918,6 +921,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(glviewmat);
m_campos = pos;
+ m_camnegscale = ((scale[0] < 0.0) ^ (scale[1] < 0.0) ^ (scale[2] < 0.0)) ? true : false;
}
@@ -1050,6 +1054,9 @@ void RAS_OpenGLRasterizer::SetAlphaBlend(int alphablend)
void RAS_OpenGLRasterizer::SetFrontFace(bool ccw)
{
+ if (m_camnegscale)
+ ccw = !ccw;
+
if (m_last_frontface == ccw)
return;