Commit 1ea1bbaa authored by hybrid's avatar hybrid

Fix user clip planes. For D3D only a security measure in case plane3d changes....

Fix user clip planes. For D3D only a security measure in case plane3d changes. For OpenGL we fixed the user clip planes to world coords now. This is coherent with D3D usage and more natural. Bug fix suggested by heda.
I've also removed the clip plane upload from the projection matrix setting. I don't think it's needed there. At least my test cases don't need it. If someone finds a problem with this change, please report in the forum.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4291 dfc29bdd-3216-0410-991c-e03cc46cb475
parent eaeb461d
...@@ -3406,7 +3406,7 @@ bool CD3D9Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enab ...@@ -3406,7 +3406,7 @@ bool CD3D9Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enab
if (index >= MaxUserClipPlanes) if (index >= MaxUserClipPlanes)
return false; return false;
HRESULT ok = pID3DDevice->SetClipPlane(index, (const float*)&plane); HRESULT ok = pID3DDevice->SetClipPlane(index, (const float*)&(plane.Normal.X));
if (D3D_OK == ok) if (D3D_OK == ok)
enableClipPlane(index, enable); enableClipPlane(index, enable);
return true; return true;
......
...@@ -946,21 +946,23 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri ...@@ -946,21 +946,23 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
{ {
// OpenGL only has a model matrix, view and world is not existent. so lets fake these two. // OpenGL only has a model matrix, view and world is not existent. so lets fake these two.
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer());
// first load the viewing transformation for user clip planes
glLoadMatrixf((Matrices[ETS_VIEW]).pointer());
// we have to update the clip planes to the latest view matrix // we have to update the clip planes to the latest view matrix
for (u32 i=0; i<MaxUserClipPlanes; ++i) for (u32 i=0; i<MaxUserClipPlanes; ++i)
if (UserClipPlanes[i].Enabled) if (UserClipPlanes[i].Enabled)
uploadClipPlane(i); uploadClipPlane(i);
// now the real model-view matrix
glMultMatrixf(Matrices[ETS_WORLD].pointer());
} }
break; break;
case ETS_PROJECTION: case ETS_PROJECTION:
{ {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadMatrixf(mat.pointer()); glLoadMatrixf(mat.pointer());
// we have to update the clip planes to the latest view matrix
for (u32 i=0; i<MaxUserClipPlanes; ++i)
if (UserClipPlanes[i].Enabled)
uploadClipPlane(i);
} }
break; break;
case ETS_COUNT: case ETS_COUNT:
...@@ -4614,7 +4616,7 @@ bool COpenGLDriver::setClipPlane(u32 index, const core::plane3df& plane, bool en ...@@ -4614,7 +4616,7 @@ bool COpenGLDriver::setClipPlane(u32 index, const core::plane3df& plane, bool en
void COpenGLDriver::uploadClipPlane(u32 index) void COpenGLDriver::uploadClipPlane(u32 index)
{ {
// opengl needs an array of doubles for the plane equation // opengl needs an array of doubles for the plane equation
double clip_plane[4]; GLdouble clip_plane[4];
clip_plane[0] = UserClipPlanes[index].Plane.Normal.X; clip_plane[0] = UserClipPlanes[index].Plane.Normal.X;
clip_plane[1] = UserClipPlanes[index].Plane.Normal.Y; clip_plane[1] = UserClipPlanes[index].Plane.Normal.Y;
clip_plane[2] = UserClipPlanes[index].Plane.Normal.Z; clip_plane[2] = UserClipPlanes[index].Plane.Normal.Z;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment