Commit 24552f90 authored by bitplane's avatar bitplane

added SViewFrustum::clipLine

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2212 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 7ddbd4f8
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "plane3d.h" #include "plane3d.h"
#include "vector3d.h" #include "vector3d.h"
#include "line3d.h"
#include "aabbox3d.h" #include "aabbox3d.h"
#include "matrix4.h" #include "matrix4.h"
#include "IVideoDriver.h" #include "IVideoDriver.h"
...@@ -83,6 +84,10 @@ namespace scene ...@@ -83,6 +84,10 @@ namespace scene
//! get the given state's matrix based on frustum E_TRANSFORMATION_STATE_FRUSTUM //! get the given state's matrix based on frustum E_TRANSFORMATION_STATE_FRUSTUM
const core::matrix4& getTransform( video::E_TRANSFORMATION_STATE state) const; const core::matrix4& getTransform( video::E_TRANSFORMATION_STATE state) const;
//! clips a line to the view frustum.
//! \Return: Returns true if the line was clipped, false if not
bool clipLine(core::line3d<f32>& line) const;
//! the position of the camera //! the position of the camera
core::vector3df cameraPosition; core::vector3df cameraPosition;
...@@ -283,6 +288,28 @@ namespace scene ...@@ -283,6 +288,28 @@ namespace scene
return Matrices [ index ]; return Matrices [ index ];
} }
//! Clips a line to the frustum
inline bool SViewFrustum::clipLine(core::line3d<f32>& line) const
{
bool wasClipped = false;
for (u32 i=0; i < VF_PLANE_COUNT; ++i)
{
if (planes[i].classifyPointRelation(line.start) == core::ISREL3D_FRONT)
{
line.start = line.start.getInterpolated(line.end,
planes[i].getKnownIntersectionWithLine(line.start, line.end));
wasClipped = true;
}
if (planes[i].classifyPointRelation(line.end) == core::ISREL3D_FRONT)
{
line.end = line.start.getInterpolated(line.end,
planes[i].getKnownIntersectionWithLine(line.start, line.end));
wasClipped = true;
}
}
return wasClipped;
}
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
......
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