Commit 9e695384 authored by hybrid's avatar hybrid

Added collision function parameter for restricting check to only parts of the...

Added collision function parameter for restricting check to only parts of the scene, patch by Darktib.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2310 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 443e9884
...@@ -106,7 +106,7 @@ namespace scene ...@@ -106,7 +106,7 @@ namespace scene
//! Gets the scene node, which is currently visible under the given screencoordinates, viewed from the currently active camera. //! Gets the scene node, which is currently visible under the given screencoordinates, viewed from the currently active camera.
/** The collision tests are done using a bounding box for each /** The collision tests are done using a bounding box for each
scene node. scene node. You can limit the recursive search so just all children of the specified root are tested.
\param pos: Position in pixel screen coordinates, under which \param pos: Position in pixel screen coordinates, under which
the returned scene node will be. the returned scene node will be.
\param idBitMask: Only scene nodes with an id with bits set \param idBitMask: Only scene nodes with an id with bits set
...@@ -114,25 +114,28 @@ namespace scene ...@@ -114,25 +114,28 @@ namespace scene
feature is disabled. feature is disabled.
\param bNoDebugObjects: Doesn't take debug objects into account \param bNoDebugObjects: Doesn't take debug objects into account
when true. These are scene nodes with IsDebugObject() = true. when true. These are scene nodes with IsDebugObject() = true.
\param root If different from 0, the search is limited to the children of this node.
\return Visible scene node under screen coordinates with \return Visible scene node under screen coordinates with
matching bits in its id. If there is no scene node under this matching bits in its id. If there is no scene node under this
position, 0 is returned. */ position, 0 is returned. */
virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(const core::position2d<s32> & pos, virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(const core::position2d<s32>& pos,
s32 idBitMask=0, bool bNoDebugObjects = false) = 0; s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0) =0;
//! Returns the nearest scene node which collides with a 3d ray and whose id matches a bitmask. //! Returns the nearest scene node which collides with a 3d ray and whose id matches a bitmask.
/** The collision tests are done using a bounding box for each scene node. /** The collision tests are done using a bounding box for each
\param ray: Line with witch collisions are tested. scene node. The recursive search can be limited be specifying a scene node.
\param idBitMask: Only scene nodes with an id which matches at least one of the \param ray Line with which collisions are tested.
bits contained in this mask will be tested. However, if this parameter is 0, then \param idBitMask Only scene nodes with an id which matches at
all nodes are checked. least one of the bits contained in this mask will be tested.
However, if this parameter is 0, then all nodes are checked.
\param bNoDebugObjects: Doesn't take debug objects into account when true. These \param bNoDebugObjects: Doesn't take debug objects into account when true. These
are scene nodes with IsDebugObject() = true. are scene nodes with IsDebugObject() = true.
\return Returns the scene node nearest to ray.start, which collides with the \param root If different from 0, the search is limited to the children of this node.
ray and matches the idBitMask, if the mask is not null. If no scene \return Scene node nearest to ray.start, which collides with
node is found, 0 is returned. */ the ray and matches the idBitMask, if the mask is not null. If
virtual ISceneNode* getSceneNodeFromRayBB(const core::line3d<f32>& ray, no scene node is found, 0 is returned. */
s32 idBitMask=0, bool bNoDebugObjects = false) =0; virtual ISceneNode* getSceneNodeFromRayBB(const core::line3d<f32>& ray,
s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0) =0;
//! Get the scene node, which the given camera is looking at and whose id matches the bitmask. //! Get the scene node, which the given camera is looking at and whose id matches the bitmask.
/** A ray is simply casted from the position of the camera to /** A ray is simply casted from the position of the camera to
......
...@@ -38,31 +38,31 @@ CSceneCollisionManager::~CSceneCollisionManager() ...@@ -38,31 +38,31 @@ CSceneCollisionManager::~CSceneCollisionManager()
} }
//! Returns the scene node, which is currently visible under the overgiven //! Returns the scene node, which is currently visible at the given
//! screencoordinates, viewed from the currently active camera. //! screen coordinates, viewed from the currently active camera.
ISceneNode* CSceneCollisionManager::getSceneNodeFromScreenCoordinatesBB( ISceneNode* CSceneCollisionManager::getSceneNodeFromScreenCoordinatesBB(
const core::position2d<s32> & pos, s32 idBitMask, bool bNoDebugObjects) const core::position2d<s32>& pos, s32 idBitMask, bool bNoDebugObjects, scene::ISceneNode* root)
{ {
const core::line3d<f32> ln = getRayFromScreenCoordinates(pos, 0); const core::line3d<f32> ln = getRayFromScreenCoordinates(pos, 0);
if ( ln.start == ln.end ) if ( ln.start == ln.end )
return 0; return 0;
return getSceneNodeFromRayBB(ln, idBitMask, bNoDebugObjects); return getSceneNodeFromRayBB(ln, idBitMask, bNoDebugObjects, root);
} }
//! Returns the nearest scene node which collides with a 3d ray and //! Returns the nearest scene node which collides with a 3d ray and
//! which id matches a bitmask. //! which id matches a bitmask.
ISceneNode* CSceneCollisionManager::getSceneNodeFromRayBB(const core::line3d<f32>& ray, ISceneNode* CSceneCollisionManager::getSceneNodeFromRayBB(const core::line3d<f32>& ray,
s32 idBitMask, bool bNoDebugObjects) s32 idBitMask, bool bNoDebugObjects, scene::ISceneNode* root)
{ {
ISceneNode* best = 0; ISceneNode* best = 0;
f32 dist = FLT_MAX; f32 dist = FLT_MAX;
core::line3d<f32> truncatableRay(ray); core::line3d<f32> truncatableRay(ray);
getPickedNodeBB(SceneManager->getRootSceneNode(), truncatableRay, getPickedNodeBB((root==0)?SceneManager->getRootSceneNode():root, truncatableRay,
idBitMask, bNoDebugObjects, dist, best); idBitMask, bNoDebugObjects, dist, best);
return best; return best;
......
...@@ -28,12 +28,13 @@ namespace scene ...@@ -28,12 +28,13 @@ namespace scene
//! Returns the scene node, which is currently visible at the given //! Returns the scene node, which is currently visible at the given
//! screen coordinates, viewed from the currently active camera. //! screen coordinates, viewed from the currently active camera.
virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(const core::position2d<s32>& pos, virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(const core::position2d<s32>& pos,
s32 idBitMask=0, bool bNoDebugObjects = false); s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0);
//! Returns the nearest scene node which collides with a 3d ray and //! Returns the nearest scene node which collides with a 3d ray and
//! which id matches a bitmask. //! whose id matches a bitmask.
virtual ISceneNode* getSceneNodeFromRayBB(const core::line3d<f32>& ray, virtual ISceneNode* getSceneNodeFromRayBB(const core::line3d<f32>& ray,
s32 idBitMask=0, bool bNoDebugObjects = false); s32 idBitMask=0, bool bNoDebugObjects=false,
ISceneNode* root=0);
//! Returns the scene node, at which the overgiven camera is looking at and //! Returns the scene node, at which the overgiven camera is looking at and
//! which id matches the bitmask. //! which id matches the bitmask.
......
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