Commit 8b71ff58 authored by cutealien's avatar cutealien

The following functions will now use a "ISceneNode *" instead of a "const ISceneNode *":

ITriangleSelector::getSceneNodeForTriangle, ISceneNodeAnimatorCollisionResponse::getCollisionNode, ISceneCollisionManager::getCollisionPoint and ISceneCollisionManager::getCollisionResultPosition.
As collision functions often are followed by changing node positions users where so far forced to using const_casts (found by Greenya).
(This will lead once more to many post about correct getCollisionResultPosition usage, but can't be helped - those consts were too restricitive, sorry)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3442 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 5c3e9500
Changes in 1.8 (??.0?.2010) Changes in 1.8 (??.0?.2010)
- The following functions will now use a "ISceneNode *" instead of a "const ISceneNode *":
ITriangleSelector::getSceneNodeForTriangle, ISceneNodeAnimatorCollisionResponse::getCollisionNode, ISceneCollisionManager::getCollisionPoint and ISceneCollisionManager::getCollisionResultPosition.
As collision functions often are followed by changing node positions users where so far forced to using const_casts (found by Greenya).
- Add vector3d::getAs3Values (patch provided by slavik262) - Add vector3d::getAs3Values (patch provided by slavik262)
- Add function to SViewFrustum to get corners of the near plane (patch provided by Matt Kline, aka slavik262) - Add function to SViewFrustum to get corners of the near plane (patch provided by Matt Kline, aka slavik262)
......
...@@ -1733,7 +1733,7 @@ void CQuake3EventHandler::useItem( Q3Player * player) ...@@ -1733,7 +1733,7 @@ void CQuake3EventHandler::useItem( Q3Player * player)
line3d<f32> line(start, end); line3d<f32> line(start, end);
// get intersection point with map // get intersection point with map
const scene::ISceneNode* hitNode; scene::ISceneNode* hitNode;
if (smgr->getSceneCollisionManager()->getCollisionPoint( if (smgr->getSceneCollisionManager()->getCollisionPoint(
line, Meta, end, triangle,hitNode)) line, Meta, end, triangle,hitNode))
{ {
......
...@@ -620,7 +620,7 @@ void CDemo::shoot() ...@@ -620,7 +620,7 @@ void CDemo::shoot()
core::line3d<f32> line(start, end); core::line3d<f32> line(start, end);
// get intersection point with map // get intersection point with map
const scene::ISceneNode* hitNode; scene::ISceneNode* hitNode;
if (sm->getSceneCollisionManager()->getCollisionPoint( if (sm->getSceneCollisionManager()->getCollisionPoint(
line, mapSelector, end, triangle, hitNode)) line, mapSelector, end, triangle, hitNode))
{ {
......
...@@ -40,7 +40,7 @@ namespace scene ...@@ -40,7 +40,7 @@ namespace scene
\return True if a collision was detected and false if not. */ \return True if a collision was detected and false if not. */
virtual bool getCollisionPoint(const core::line3d<f32>& ray, virtual bool getCollisionPoint(const core::line3d<f32>& ray,
ITriangleSelector* selector, core::vector3df& outCollisionPoint, ITriangleSelector* selector, core::vector3df& outCollisionPoint,
core::triangle3df& outTriangle, const ISceneNode*& outNode) =0; core::triangle3df& outTriangle, ISceneNode*& outNode) =0;
//! Collides a moving ellipsoid with a 3d world with gravity and returns the resulting new position of the ellipsoid. //! Collides a moving ellipsoid with a 3d world with gravity and returns the resulting new position of the ellipsoid.
/** This can be used for moving a character in a 3d world: The /** This can be used for moving a character in a 3d world: The
...@@ -73,7 +73,7 @@ namespace scene ...@@ -73,7 +73,7 @@ namespace scene
core::triangle3df& triout, core::triangle3df& triout,
core::vector3df& hitPosition, core::vector3df& hitPosition,
bool& outFalling, bool& outFalling,
const ISceneNode*& outNode, ISceneNode*& outNode,
f32 slidingSpeed = 0.0005f, f32 slidingSpeed = 0.0005f,
const core::vector3df& gravityDirectionAndSpeed const core::vector3df& gravityDirectionAndSpeed
= core::vector3df(0.0f, 0.0f, 0.0f)) = 0; = core::vector3df(0.0f, 0.0f, 0.0f)) = 0;
......
...@@ -153,7 +153,7 @@ namespace scene ...@@ -153,7 +153,7 @@ namespace scene
virtual const core::vector3df & getCollisionResultPosition(void) const = 0; virtual const core::vector3df & getCollisionResultPosition(void) const = 0;
//! Returns the node that was collided with. //! Returns the node that was collided with.
virtual const ISceneNode* getCollisionNode(void) const = 0; virtual ISceneNode* getCollisionNode(void) const = 0;
//! Sets a callback interface which will be called if a collision occurs. //! Sets a callback interface which will be called if a collision occurs.
/** \param callback: collision callback handler that will be called when a collision /** \param callback: collision callback handler that will be called when a collision
......
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
selector. If there is more than one scene node associated (e.g. for selector. If there is more than one scene node associated (e.g. for
an IMetaTriangleSelector) this this function may be called multiple an IMetaTriangleSelector) this this function may be called multiple
times to retrieve all triangles. times to retrieve all triangles.
Please note that unoptimized triangle selectors also may return Please note that unoptimized triangle selectors also may return
triangles which are not in contact at all with the 3d line. triangles which are not in contact at all with the 3d line.
\param triangles: Array where the resulting triangles will be written \param triangles: Array where the resulting triangles will be written
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
the associated scene node. the associated scene node.
\return The scene node associated with that triangle. \return The scene node associated with that triangle.
*/ */
virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const = 0; virtual ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const = 0;
}; };
......
...@@ -135,7 +135,7 @@ void CMetaTriangleSelector::removeAllTriangleSelectors() ...@@ -135,7 +135,7 @@ void CMetaTriangleSelector::removeAllTriangleSelectors()
//! Return the scene node associated with a given triangle. //! Return the scene node associated with a given triangle.
const ISceneNode* CMetaTriangleSelector::getSceneNodeForTriangle(u32 triangleIndex) const ISceneNode* CMetaTriangleSelector::getSceneNodeForTriangle(u32 triangleIndex) const
{ {
u32 totalTriangles = 0; u32 totalTriangles = 0;
......
...@@ -33,17 +33,17 @@ public: ...@@ -33,17 +33,17 @@ public:
//! Gets all triangles which lie within a specific bounding box. //! Gets all triangles which lie within a specific bounding box.
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::aabbox3d<f32>& box, s32& outTriangleCount, const core::aabbox3d<f32>& box,
const core::matrix4* transform=0) const; const core::matrix4* transform=0) const;
//! Gets all triangles which have or may have contact with a 3d line. //! Gets all triangles which have or may have contact with a 3d line.
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::line3d<f32>& line, s32& outTriangleCount, const core::line3d<f32>& line,
const core::matrix4* transform=0) const; const core::matrix4* transform=0) const;
//! Adds a triangle selector to the collection of triangle selectors //! Adds a triangle selector to the collection of triangle selectors
//! in this metaTriangleSelector. //! in this metaTriangleSelector.
virtual void addTriangleSelector(ITriangleSelector* toAdd); virtual void addTriangleSelector(ITriangleSelector* toAdd);
//! Removes a specific triangle selector which was added before from the collection. //! Removes a specific triangle selector which was added before from the collection.
virtual bool removeTriangleSelector(ITriangleSelector* toRemove); virtual bool removeTriangleSelector(ITriangleSelector* toRemove);
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
virtual void removeAllTriangleSelectors(); virtual void removeAllTriangleSelectors();
//! Return the scene node associated with a given triangle. //! Return the scene node associated with a given triangle.
virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const; virtual ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const;
private: private:
......
...@@ -14,7 +14,7 @@ namespace scene ...@@ -14,7 +14,7 @@ namespace scene
//! constructor //! constructor
COctreeTriangleSelector::COctreeTriangleSelector(const IMesh* mesh, COctreeTriangleSelector::COctreeTriangleSelector(const IMesh* mesh,
const ISceneNode* node, s32 minimalPolysPerNode) ISceneNode* node, s32 minimalPolysPerNode)
: CTriangleSelector(mesh, node), Root(0), NodeCount(0), : CTriangleSelector(mesh, node), Root(0), NodeCount(0),
MinimalPolysPerNode(minimalPolysPerNode) MinimalPolysPerNode(minimalPolysPerNode)
{ {
......
...@@ -20,7 +20,7 @@ class COctreeTriangleSelector : public CTriangleSelector ...@@ -20,7 +20,7 @@ class COctreeTriangleSelector : public CTriangleSelector
public: public:
//! Constructs a selector based on a mesh //! Constructs a selector based on a mesh
COctreeTriangleSelector(const IMesh* mesh, const ISceneNode* node, s32 minimalPolysPerNode); COctreeTriangleSelector(const IMesh* mesh, ISceneNode* node, s32 minimalPolysPerNode);
virtual ~COctreeTriangleSelector(); virtual ~COctreeTriangleSelector();
......
...@@ -303,7 +303,7 @@ void CSceneCollisionManager::getPickedNodeFromBBAndSelector( ...@@ -303,7 +303,7 @@ void CSceneCollisionManager::getPickedNodeFromBBAndSelector(
core::triangle3df candidateTriangle; core::triangle3df candidateTriangle;
// do intersection test in object space // do intersection test in object space
const ISceneNode * hitNode = 0; ISceneNode * hitNode = 0;
if (box.intersectsWithLine(line) && if (box.intersectsWithLine(line) &&
getCollisionPoint(ray, selector, candidateCollisionPoint, candidateTriangle, hitNode)) getCollisionPoint(ray, selector, candidateCollisionPoint, candidateTriangle, hitNode))
{ {
...@@ -349,7 +349,7 @@ ISceneNode* CSceneCollisionManager::getSceneNodeFromCameraBB( ...@@ -349,7 +349,7 @@ ISceneNode* CSceneCollisionManager::getSceneNodeFromCameraBB(
bool CSceneCollisionManager::getCollisionPoint(const core::line3d<f32>& ray, bool CSceneCollisionManager::getCollisionPoint(const core::line3d<f32>& ray,
ITriangleSelector* selector, core::vector3df& outIntersection, ITriangleSelector* selector, core::vector3df& outIntersection,
core::triangle3df& outTriangle, core::triangle3df& outTriangle,
const ISceneNode*& outNode) ISceneNode*& outNode)
{ {
if (!selector) if (!selector)
{ {
...@@ -423,7 +423,7 @@ core::vector3df CSceneCollisionManager::getCollisionResultPosition( ...@@ -423,7 +423,7 @@ core::vector3df CSceneCollisionManager::getCollisionResultPosition(
core::triangle3df& triout, core::triangle3df& triout,
core::vector3df& hitPosition, core::vector3df& hitPosition,
bool& outFalling, bool& outFalling,
const ISceneNode*& outNode, ISceneNode*& outNode,
f32 slidingSpeed, f32 slidingSpeed,
const core::vector3df& gravity) const core::vector3df& gravity)
{ {
...@@ -691,7 +691,7 @@ core::vector3df CSceneCollisionManager::collideEllipsoidWithWorld( ...@@ -691,7 +691,7 @@ core::vector3df CSceneCollisionManager::collideEllipsoidWithWorld(
core::triangle3df& triout, core::triangle3df& triout,
core::vector3df& hitPosition, core::vector3df& hitPosition,
bool& outFalling, bool& outFalling,
const ISceneNode*& outNode) ISceneNode*& outNode)
{ {
if (!selector || radius.X == 0.0f || radius.Y == 0.0f || radius.Z == 0.0f) if (!selector || radius.X == 0.0f || radius.Y == 0.0f || radius.Z == 0.0f)
return position; return position;
......
...@@ -45,7 +45,7 @@ namespace scene ...@@ -45,7 +45,7 @@ namespace scene
virtual bool getCollisionPoint(const core::line3d<f32>& ray, virtual bool getCollisionPoint(const core::line3d<f32>& ray,
ITriangleSelector* selector, core::vector3df& outCollisionPoint, ITriangleSelector* selector, core::vector3df& outCollisionPoint,
core::triangle3df& outTriangle, core::triangle3df& outTriangle,
const ISceneNode* & outNode); ISceneNode* & outNode);
//! Collides a moving ellipsoid with a 3d world with gravity and returns //! Collides a moving ellipsoid with a 3d world with gravity and returns
//! the resulting new position of the ellipsoid. //! the resulting new position of the ellipsoid.
...@@ -57,7 +57,7 @@ namespace scene ...@@ -57,7 +57,7 @@ namespace scene
core::triangle3df& triout, core::triangle3df& triout,
core::vector3df& hitPosition, core::vector3df& hitPosition,
bool& outFalling, bool& outFalling,
const ISceneNode*& outNode, ISceneNode*& outNode,
f32 slidingSpeed, f32 slidingSpeed,
const core::vector3df& gravityDirectionAndSpeed); const core::vector3df& gravityDirectionAndSpeed);
...@@ -138,7 +138,7 @@ namespace scene ...@@ -138,7 +138,7 @@ namespace scene
const core::vector3df& gravity, core::triangle3df& triout, const core::vector3df& gravity, core::triangle3df& triout,
core::vector3df& hitPosition, core::vector3df& hitPosition,
bool& outFalling, bool& outFalling,
const ISceneNode*& outNode); ISceneNode*& outNode);
core::vector3df collideWithWorld(s32 recursionDepth, SCollisionData &colData, core::vector3df collideWithWorld(s32 recursionDepth, SCollisionData &colData,
core::vector3df pos, core::vector3df vel); core::vector3df pos, core::vector3df vel);
......
...@@ -23,7 +23,7 @@ CSceneNodeAnimatorCollisionResponse::CSceneNodeAnimatorCollisionResponse( ...@@ -23,7 +23,7 @@ CSceneNodeAnimatorCollisionResponse::CSceneNodeAnimatorCollisionResponse(
f32 slidingSpeed) f32 slidingSpeed)
: Radius(ellipsoidRadius), Gravity(gravityPerSecond), Translation(ellipsoidTranslation), : Radius(ellipsoidRadius), Gravity(gravityPerSecond), Translation(ellipsoidTranslation),
World(world), Object(object), SceneManager(scenemanager), LastTime(0), World(world), Object(object), SceneManager(scenemanager), LastTime(0),
SlidingSpeed(slidingSpeed), CollisionCallback(0), SlidingSpeed(slidingSpeed), CollisionNode(0), CollisionCallback(0),
Falling(false), IsCamera(false), AnimateCameraTarget(true), CollisionOccurred(false), Falling(false), IsCamera(false), AnimateCameraTarget(true), CollisionOccurred(false),
FirstUpdate(true) FirstUpdate(true)
{ {
......
...@@ -110,7 +110,7 @@ namespace scene ...@@ -110,7 +110,7 @@ namespace scene
virtual const core::vector3df & getCollisionResultPosition(void) const { return CollisionResultPosition; } virtual const core::vector3df & getCollisionResultPosition(void) const { return CollisionResultPosition; }
virtual const ISceneNode* getCollisionNode(void) const { return CollisionNode; } virtual ISceneNode* getCollisionNode(void) const { return CollisionNode; }
//! Sets a callback interface which will be called if a collision occurs. //! Sets a callback interface which will be called if a collision occurs.
...@@ -140,7 +140,7 @@ namespace scene ...@@ -140,7 +140,7 @@ namespace scene
core::vector3df CollisionPoint; core::vector3df CollisionPoint;
core::triangle3df CollisionTriangle; core::triangle3df CollisionTriangle;
core::vector3df CollisionResultPosition; core::vector3df CollisionResultPosition;
const ISceneNode * CollisionNode; ISceneNode * CollisionNode;
ICollisionCallback* CollisionCallback; ICollisionCallback* CollisionCallback;
bool Falling; bool Falling;
......
...@@ -186,6 +186,11 @@ s32 CTerrainTriangleSelector::getTriangleCount() const ...@@ -186,6 +186,11 @@ s32 CTerrainTriangleSelector::getTriangleCount() const
return TrianglePatches.TotalTriangles; return TrianglePatches.TotalTriangles;
} }
ISceneNode* CTerrainTriangleSelector::getSceneNodeForTriangle(u32 triangleIndex) const
{
return SceneNode;
}
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
// The code for the TerrainTriangleSelector is based on the GeoMipMapSelector // The code for the TerrainTriangleSelector is based on the GeoMipMapSelector
// developed by Spintz. He made it available for Irrlicht and allowed it to be // developed by Spintz. He made it available for Irrlicht and allowed it to be
// distributed under this licence. I only modified some parts. A lot of thanks go to him. // distributed under this licence. I only modified some parts. A lot of thanks go to him.
#ifndef __C_TERRAIN_TRIANGLE_SELECTOR_H__ #ifndef __C_TERRAIN_TRIANGLE_SELECTOR_H__
#define __C_TERRAIN_TRIANGLE_SELECTOR_H__ #define __C_TERRAIN_TRIANGLE_SELECTOR_H__
...@@ -21,8 +21,8 @@ class ITerrainSceneNode; ...@@ -21,8 +21,8 @@ class ITerrainSceneNode;
//! Triangle Selector for the TerrainSceneNode //! Triangle Selector for the TerrainSceneNode
//! The code for the TerrainTriangleSelector is based on the GeoMipMapSelector //! The code for the TerrainTriangleSelector is based on the GeoMipMapSelector
//! developed by Spintz. He made it available for Irrlicht and allowed it to be //! developed by Spintz. He made it available for Irrlicht and allowed it to be
//! distributed under this licence. I only modified some parts. A lot of thanks go to him. //! distributed under this licence. I only modified some parts. A lot of thanks go to him.
class CTerrainTriangleSelector : public ITriangleSelector class CTerrainTriangleSelector : public ITriangleSelector
{ {
public: public:
...@@ -46,16 +46,14 @@ public: ...@@ -46,16 +46,14 @@ public:
//! Gets all triangles which have or may have contact with a 3d line. //! Gets all triangles which have or may have contact with a 3d line.
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::line3d<f32>& line, s32& outTriangleCount, const core::line3d<f32>& line,
const core::matrix4* transform=0) const; const core::matrix4* transform=0) const;
//! Returns amount of all available triangles in this selector //! Returns amount of all available triangles in this selector
virtual s32 getTriangleCount() const; virtual s32 getTriangleCount() const;
//! Return the scene node associated with a given triangle. //! Return the scene node associated with a given triangle.
/** ITerrainSceneNode is an ISceneNode, we just don't know it yet. */ virtual ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const;
virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const
{ return (ISceneNode*)SceneNode; }
private: private:
......
...@@ -11,7 +11,7 @@ namespace scene ...@@ -11,7 +11,7 @@ namespace scene
{ {
//! constructor //! constructor
CTriangleBBSelector::CTriangleBBSelector(const ISceneNode* node) CTriangleBBSelector::CTriangleBBSelector(ISceneNode* node)
: CTriangleSelector(node) : CTriangleSelector(node)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -25,7 +25,7 @@ CTriangleBBSelector::CTriangleBBSelector(const ISceneNode* node) ...@@ -25,7 +25,7 @@ CTriangleBBSelector::CTriangleBBSelector(const ISceneNode* node)
//! Gets all triangles. //! Gets all triangles.
void CTriangleBBSelector::getTriangles(core::triangle3df* triangles, void CTriangleBBSelector::getTriangles(core::triangle3df* triangles,
s32 arraySize, s32& outTriangleCount, s32 arraySize, s32& outTriangleCount,
const core::matrix4* transform) const const core::matrix4* transform) const
{ {
if (!SceneNode) if (!SceneNode)
......
...@@ -18,10 +18,10 @@ class CTriangleBBSelector : public CTriangleSelector ...@@ -18,10 +18,10 @@ class CTriangleBBSelector : public CTriangleSelector
public: public:
//! Constructs a selector based on a mesh //! Constructs a selector based on a mesh
CTriangleBBSelector(const ISceneNode* node); CTriangleBBSelector(ISceneNode* node);
//! Gets all triangles. //! Gets all triangles.
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
const core::matrix4* transform=0) const; const core::matrix4* transform=0) const;
}; };
......
...@@ -13,7 +13,7 @@ namespace scene ...@@ -13,7 +13,7 @@ namespace scene
{ {
//! constructor //! constructor
CTriangleSelector::CTriangleSelector(const ISceneNode* node) CTriangleSelector::CTriangleSelector(ISceneNode* node)
: SceneNode(node), AnimatedNode(0), LastMeshFrame(-1) : SceneNode(node), AnimatedNode(0), LastMeshFrame(-1)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -23,7 +23,7 @@ CTriangleSelector::CTriangleSelector(const ISceneNode* node) ...@@ -23,7 +23,7 @@ CTriangleSelector::CTriangleSelector(const ISceneNode* node)
//! constructor //! constructor
CTriangleSelector::CTriangleSelector(const IMesh* mesh, const ISceneNode* node) CTriangleSelector::CTriangleSelector(const IMesh* mesh, ISceneNode* node)
: SceneNode(node), AnimatedNode(0) : SceneNode(node), AnimatedNode(0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -137,7 +137,7 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const ...@@ -137,7 +137,7 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const
//! constructor //! constructor
CTriangleSelector::CTriangleSelector(const core::aabbox3d<f32>& box, const ISceneNode* node) CTriangleSelector::CTriangleSelector(const core::aabbox3d<f32>& box, ISceneNode* node)
: SceneNode(node) : SceneNode(node)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -172,7 +172,7 @@ void CTriangleSelector::update(void) const ...@@ -172,7 +172,7 @@ void CTriangleSelector::update(void) const
//! Gets all triangles. //! Gets all triangles.
void CTriangleSelector::getTriangles(core::triangle3df* triangles, void CTriangleSelector::getTriangles(core::triangle3df* triangles,
s32 arraySize, s32& outTriangleCount, s32 arraySize, s32& outTriangleCount,
const core::matrix4* transform) const const core::matrix4* transform) const
{ {
// Update my triangles if necessary // Update my triangles if necessary
...@@ -203,8 +203,8 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles, ...@@ -203,8 +203,8 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles,
//! Gets all triangles which lie within a specific bounding box. //! Gets all triangles which lie within a specific bounding box.
void CTriangleSelector::getTriangles(core::triangle3df* triangles, void CTriangleSelector::getTriangles(core::triangle3df* triangles,
s32 arraySize, s32& outTriangleCount, s32 arraySize, s32& outTriangleCount,
const core::aabbox3d<f32>& box, const core::aabbox3d<f32>& box,
const core::matrix4* transform) const const core::matrix4* transform) const
{ {
......
...@@ -23,51 +23,51 @@ class CTriangleSelector : public ITriangleSelector ...@@ -23,51 +23,51 @@ class CTriangleSelector : public ITriangleSelector
public: public:
//! Constructs a selector based on a mesh //! Constructs a selector based on a mesh
CTriangleSelector(const ISceneNode* node); CTriangleSelector(ISceneNode* node);
//! Constructs a selector based on a mesh //! Constructs a selector based on a mesh
CTriangleSelector(const IMesh* mesh, const ISceneNode* node); CTriangleSelector(const IMesh* mesh, ISceneNode* node);
//! Constructs a selector based on an animated mesh scene node //! Constructs a selector based on an animated mesh scene node
//!\param node An animated mesh scene node, which must have a valid mesh //!\param node An animated mesh scene node, which must have a valid mesh
CTriangleSelector(IAnimatedMeshSceneNode* node); CTriangleSelector(IAnimatedMeshSceneNode* node);
//! Constructs a selector based on a bounding box //! Constructs a selector based on a bounding box
CTriangleSelector(const core::aabbox3d<f32>& box, const ISceneNode* node); CTriangleSelector(const core::aabbox3d<f32>& box, ISceneNode* node);
//! Gets all triangles. //! Gets all triangles.
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
const core::matrix4* transform=0) const; const core::matrix4* transform=0) const;
//! Gets all triangles which lie within a specific bounding box. //! Gets all triangles which lie within a specific bounding box.
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount, void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const; const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const;
//! Gets all triangles which have or may have contact with a 3d line. //! Gets all triangles which have or may have contact with a 3d line.
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::line3d<f32>& line, s32& outTriangleCount, const core::line3d<f32>& line,
const core::matrix4* transform=0) const; const core::matrix4* transform=0) const;
//! Returns amount of all available triangles in this selector //! Returns amount of all available triangles in this selector
virtual s32 getTriangleCount() const; virtual s32 getTriangleCount() const;
//! Return the scene node associated with a given triangle. //! Return the scene node associated with a given triangle.
virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const { return SceneNode; } virtual ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const { return SceneNode; }
protected: protected:
//! Create from a mesh //! Create from a mesh
virtual void createFromMesh(const IMesh* mesh); virtual void createFromMesh(const IMesh* mesh);
//! Update when the mesh has changed //! Update when the mesh has changed
virtual void updateFromMesh(const IMesh* mesh) const; virtual void updateFromMesh(const IMesh* mesh) const;
//! Update the triangle selector, which will only have an effect if it //! Update the triangle selector, which will only have an effect if it
//! was built from an animated mesh and that mesh's frame has changed //! was built from an animated mesh and that mesh's frame has changed
//! since the last time it was updated. //! since the last time it was updated.
virtual void update(void) const; virtual void update(void) const;
const ISceneNode* SceneNode; ISceneNode* SceneNode;
mutable core::array<core::triangle3df> Triangles; mutable core::array<core::triangle3df> Triangles; // (mutable for CTriangleBBSelector)
IAnimatedMeshSceneNode* AnimatedNode; IAnimatedMeshSceneNode* AnimatedNode;
mutable s32 LastMeshFrame; mutable s32 LastMeshFrame;
......
...@@ -18,7 +18,7 @@ static bool testGetCollisionResultPosition(IrrlichtDevice * device, ...@@ -18,7 +18,7 @@ static bool testGetCollisionResultPosition(IrrlichtDevice * device,
triangle3df triOut; triangle3df triOut;
vector3df hitPosition; vector3df hitPosition;
bool falling; bool falling;
const ISceneNode* hitNode; ISceneNode* hitNode;
vector3df resultPosition = vector3df resultPosition =
collMgr->getCollisionResultPosition(cubeSelector, collMgr->getCollisionResultPosition(cubeSelector,
...@@ -112,7 +112,7 @@ static bool getCollisionPoint_ignoreTriangleVertices(IrrlichtDevice * device, ...@@ -112,7 +112,7 @@ static bool getCollisionPoint_ignoreTriangleVertices(IrrlichtDevice * device,
line3df ray(0, 0, -5, 0, 0, 100); line3df ray(0, 0, -5, 0, 0, 100);
vector3df hitPosition; vector3df hitPosition;
triangle3df hitTriangle; triangle3df hitTriangle;
const ISceneNode* hitNode; ISceneNode* hitNode;
bool collision = collMgr->getCollisionPoint(ray, meta, hitPosition, hitTriangle, hitNode); bool collision = collMgr->getCollisionPoint(ray, meta, hitPosition, hitTriangle, hitNode);
......
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