Revert my previous ITriangleSelector patch and implement garritg's great idea about retrieving an ISceneNode by index. Add an out parameter to ISceneCollisionManager::getCollisionPoint() to return the hit scene node. This is an API breaking change; the test and example apps have been updated. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2125 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
74658ced68
commit
81671c23b2
|
@ -1,5 +1,7 @@
|
|||
Changes in version 1.6
|
||||
|
||||
- Add an outNode to getCollisionPoint() that returns the scene node that was hit, as well as the triangle.
|
||||
|
||||
- Initial support for Alpha To Coverage, needs some more fixing until it works on all supported platforms.
|
||||
|
||||
- Added support for Anti-Aliasing modes per material
|
||||
|
|
|
@ -123,10 +123,10 @@ int main()
|
|||
*/
|
||||
IrrlichtDevice *device =
|
||||
#ifdef _IRR_OSX_PLATFORM_
|
||||
createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
|
||||
createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
|
||||
false, false, false, 0);
|
||||
#else
|
||||
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
|
||||
createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
|
||||
false, false, false, 0);
|
||||
#endif
|
||||
if (!device)
|
||||
|
|
|
@ -251,9 +251,10 @@ int main()
|
|||
|
||||
core::vector3df intersection;
|
||||
core::triangle3df tri;
|
||||
const scene::ISceneNode* hitNode;
|
||||
|
||||
if (smgr->getSceneCollisionManager()->getCollisionPoint(
|
||||
line, selector, intersection, tri))
|
||||
line, selector, intersection, tri, hitNode))
|
||||
{
|
||||
bill->setPosition(intersection);
|
||||
|
||||
|
|
|
@ -635,9 +635,9 @@ void CDemo::shoot()
|
|||
core::line3d<f32> line(start, end);
|
||||
|
||||
// get intersection point with map
|
||||
|
||||
const scene::ISceneNode* hitNode;
|
||||
if (sm->getSceneCollisionManager()->getCollisionPoint(
|
||||
line, mapSelector, end, triangle))
|
||||
line, mapSelector, end, triangle, hitNode))
|
||||
{
|
||||
// collides with wall
|
||||
core::vector3df out = triangle.getNormal();
|
||||
|
|
|
@ -38,10 +38,13 @@ namespace scene
|
|||
contain the position of the nearest collision.
|
||||
\param outTriangle: If a collision is detected, this will
|
||||
contain the triangle with which the ray collided.
|
||||
\param outNode: If a collision is detected, this will contain
|
||||
the scene node associated with the triangle that was hit.
|
||||
\return True if a collision was detected and false if not. */
|
||||
virtual bool getCollisionPoint(const core::line3d<f32>& ray,
|
||||
ITriangleSelector* selector, core::vector3df& outCollisionPoint,
|
||||
core::triangle3df& outTriangle) = 0;
|
||||
core::triangle3df& outTriangle,
|
||||
const ISceneNode*& outNode) = 0;
|
||||
|
||||
//! 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
|
||||
|
|
|
@ -49,23 +49,9 @@ public:
|
|||
\param transform: Pointer to matrix for transforming the triangles
|
||||
before they are returned. Useful for example to scale all triangles
|
||||
down into an ellipsoid space. If this pointer is null, no
|
||||
transformation will be done.
|
||||
\param node: On input, if this is 0 then all triangles for all nodes
|
||||
will be returned. If *node is 0, or a node that is not associated
|
||||
with any of the triangles in this selector, then the selector will return
|
||||
the triangles for its first (or only) associated node. If you pass in
|
||||
a node for which the selector holds triangles, then it will return
|
||||
the triangles for the *next* node. On output, *node will return the node
|
||||
that is associated with the triangles being returned.
|
||||
\return false if the triangles and node for the last (or only) node
|
||||
are being returned. true if there are more nodes and triangles to
|
||||
return; on true, you may call this method again, passing in the same
|
||||
node that was just returned in order to retrieve the triangles for the
|
||||
next node.
|
||||
*/
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const = 0;
|
||||
transformation will be done. */
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::matrix4* transform=0) const = 0;
|
||||
|
||||
//! Gets the triangles for one associated node which lie or may lie within a specific bounding box.
|
||||
/**
|
||||
|
@ -86,24 +72,10 @@ public:
|
|||
\param transform: Pointer to matrix for transforming the triangles
|
||||
before they are returned. Useful for example to scale all triangles
|
||||
down into an ellipsoid space. If this pointer is null, no
|
||||
transformation will be done.
|
||||
\param node: On input, if this is 0 then all triangles for all nodes
|
||||
will be returned. If *node is 0, or a node that is not associated
|
||||
with any of the triangles in this selector, then the selector will return
|
||||
the triangles for its first (or only) associated node. If you pass in
|
||||
a node for which the selector holds triangles, then it will return
|
||||
the triangles for the *next* node. On output, *node will return the node
|
||||
that is associated with the triangles being returned.
|
||||
\return false if the triangles and node for the last (or only) node
|
||||
are being returned. true if there are more nodes and triangles to
|
||||
return; on true, you may call this method again, passing in the same
|
||||
node that was just returned in order to retrieve the triangles for the
|
||||
next node.
|
||||
*/
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
transformation will be done. */
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::aabbox3d<f32>& box,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const = 0;
|
||||
const core::matrix4* transform=0) const = 0;
|
||||
|
||||
//! Gets the triangles for one associated node which have or may have contact with a 3d line.
|
||||
/**
|
||||
|
@ -124,27 +96,22 @@ public:
|
|||
\param transform: Pointer to matrix for transforming the triangles
|
||||
before they are returned. Useful for example to scale all triangles
|
||||
down into an ellipsoid space. If this pointer is null, no
|
||||
transformation will be done.
|
||||
\param node: On input, if this is 0 then all triangles for all nodes
|
||||
will be returned. If *node is 0, or a node that is not associated
|
||||
with any of the triangles in this selector, then the selector will return
|
||||
the triangles for its first (or only) associated node. If you pass in
|
||||
a node for which the selector holds triangles, then it will return
|
||||
the triangles for the *next* node. On output, *node will return the node
|
||||
that is associated with the triangles being returned.
|
||||
\return false if the triangles and node for the last (or only) node
|
||||
are being returned. true if there are more nodes and triangles to
|
||||
return; on true, you may call this method again, passing in the same
|
||||
node that was just returned in order to retrieve the triangles for the
|
||||
next node.
|
||||
*/
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
transformation will be done. */
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::line3d<f32>& line,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const = 0;
|
||||
const core::matrix4* transform=0) const = 0;
|
||||
|
||||
//! Return the scene node associated with a given triangle.
|
||||
/**
|
||||
This allows you to find which scene node (potentially of several) is
|
||||
associated with a specific triangle.
|
||||
|
||||
\param triangleIndex: the index of the triangle for which you want to find
|
||||
the associated scene node.
|
||||
\return The scene node associated with that triangle.
|
||||
*/
|
||||
virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const = 0;
|
||||
|
||||
//! Gets the scene node to which this selector is associated.
|
||||
virtual const ISceneNode* getSceneNode(void) const = 0;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
|
@ -37,42 +37,10 @@ s32 CMetaTriangleSelector::getTriangleCount() const
|
|||
|
||||
|
||||
//! Gets all triangles.
|
||||
bool CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::matrix4* transform) const
|
||||
{
|
||||
s32 outWritten = 0;
|
||||
|
||||
if(node)
|
||||
{
|
||||
if(TriangleSelectors.size() == 0)
|
||||
{
|
||||
*node = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 selector = 0;
|
||||
|
||||
for (u32 i=0; i<TriangleSelectors.size(); ++i)
|
||||
if(*node == TriangleSelectors[i]->getSceneNode())
|
||||
{
|
||||
selector = i;
|
||||
break;
|
||||
}
|
||||
|
||||
s32 t = 0;
|
||||
TriangleSelectors[selector]->getTriangles(triangles + outWritten,
|
||||
arraySize - outWritten, t,
|
||||
transform);
|
||||
outWritten += t;
|
||||
|
||||
*node = TriangleSelectors[selector]->getSceneNode();
|
||||
|
||||
if(selector < TriangleSelectors.size() - 1)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i=0; i<TriangleSelectors.size(); ++i)
|
||||
{
|
||||
s32 t = 0;
|
||||
|
@ -82,51 +50,16 @@ bool CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
|
|||
outWritten += t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
outTriangleCount = outWritten;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Gets all triangles which lie within a specific bounding box.
|
||||
bool CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::aabbox3d<f32>& box,
|
||||
const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
s32 outWritten = 0;
|
||||
|
||||
if(node)
|
||||
{
|
||||
if(TriangleSelectors.size() == 0)
|
||||
{
|
||||
*node = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 selector = 0;
|
||||
|
||||
for (u32 i=0; i<TriangleSelectors.size(); ++i)
|
||||
if(*node == TriangleSelectors[i]->getSceneNode())
|
||||
{
|
||||
selector = i;
|
||||
break;
|
||||
}
|
||||
|
||||
s32 t = 0;
|
||||
TriangleSelectors[selector]->getTriangles(triangles + outWritten,
|
||||
arraySize - outWritten, t,
|
||||
box, transform);
|
||||
outWritten += t;
|
||||
|
||||
*node = TriangleSelectors[selector]->getSceneNode();
|
||||
|
||||
if(selector < TriangleSelectors.size() - 1)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i=0; i<TriangleSelectors.size(); ++i)
|
||||
{
|
||||
s32 t = 0;
|
||||
|
@ -136,51 +69,16 @@ bool CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
|
|||
outWritten += t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
outTriangleCount = outWritten;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Gets all triangles which have or may have contact with a 3d line.
|
||||
bool CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::line3d<f32>& line,
|
||||
const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
s32 outWritten = 0;
|
||||
|
||||
if(node)
|
||||
{
|
||||
if(TriangleSelectors.size() == 0)
|
||||
{
|
||||
*node = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 selector = 0;
|
||||
|
||||
for (u32 i=0; i<TriangleSelectors.size(); ++i)
|
||||
if(*node == TriangleSelectors[i]->getSceneNode())
|
||||
{
|
||||
selector = i;
|
||||
break;
|
||||
}
|
||||
|
||||
s32 t = 0;
|
||||
TriangleSelectors[selector]->getTriangles(triangles + outWritten,
|
||||
arraySize - outWritten, t,
|
||||
line, transform);
|
||||
outWritten += t;
|
||||
|
||||
*node = TriangleSelectors[selector]->getSceneNode();
|
||||
|
||||
if(selector < TriangleSelectors.size() - 1)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i=0; i<TriangleSelectors.size(); ++i)
|
||||
{
|
||||
s32 t = 0;
|
||||
|
@ -190,10 +88,7 @@ bool CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
|
|||
outWritten += t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
outTriangleCount = outWritten;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -235,6 +130,24 @@ void CMetaTriangleSelector::removeAllTriangleSelectors()
|
|||
TriangleSelectors.clear();
|
||||
}
|
||||
|
||||
//! Return the scene node associated with a given triangle.
|
||||
const ISceneNode* CMetaTriangleSelector::getSceneNodeForTriangle(u32 triangleIndex) const
|
||||
{
|
||||
u32 totalTriangles = 0;
|
||||
|
||||
for (u32 i=0; i<TriangleSelectors.size(); ++i)
|
||||
{
|
||||
totalTriangles += TriangleSelectors[i]->getTriangleCount();
|
||||
|
||||
if(totalTriangles > triangleIndex)
|
||||
return TriangleSelectors[i]->getSceneNodeForTriangle(0);
|
||||
}
|
||||
|
||||
// For lack of anything more sensible, return the first selector.
|
||||
return TriangleSelectors[0]->getSceneNodeForTriangle(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
|
|
@ -28,21 +28,18 @@ public:
|
|||
virtual s32 getTriangleCount() const;
|
||||
|
||||
//! Gets all triangles.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::matrix4* transform=0) const;
|
||||
|
||||
//! Gets all triangles which lie within a specific bounding box.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::aabbox3d<f32>& box,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
const core::matrix4* transform=0) const;
|
||||
|
||||
//! Gets all triangles which have or may have contact with a 3d line.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::line3d<f32>& line,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
const core::matrix4* transform=0) const;
|
||||
|
||||
//! Adds a triangle selector to the collection of triangle selectors
|
||||
//! in this metaTriangleSelector.
|
||||
|
@ -54,8 +51,8 @@ public:
|
|||
//! Removes all triangle selectors from the collection.
|
||||
virtual void removeAllTriangleSelectors();
|
||||
|
||||
//! *This* selector isn't associated with any specific node
|
||||
virtual const ISceneNode* getSceneNode(void) const { return 0; }
|
||||
//! Return the scene node associated with a given triangle.
|
||||
virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -109,11 +109,10 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node)
|
|||
|
||||
|
||||
//! Gets all triangles which lie within a specific bounding box.
|
||||
bool COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
s32 arraySize, s32& outTriangleCount,
|
||||
const core::aabbox3d<f32>& box,
|
||||
const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
core::matrix4 mat;
|
||||
core::aabbox3d<f32> invbox = box;
|
||||
|
@ -140,10 +139,6 @@ bool COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles,
|
|||
arraySize, invbox, &mat, triangles);
|
||||
|
||||
outTriangleCount = trianglesWritten;
|
||||
|
||||
if(node)
|
||||
*node = SceneNode;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,10 +173,9 @@ void COctTreeTriangleSelector::getTrianglesFromOctTree(
|
|||
|
||||
|
||||
//! Gets all triangles which have or may have contact with a 3d line.
|
||||
bool COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
void COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::line3d<f32>& line,
|
||||
const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
core::aabbox3d<f32> box(line.start);
|
||||
box.addInternalPoint(line.end);
|
||||
|
@ -189,10 +183,6 @@ bool COctTreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 ar
|
|||
// TODO: Could be optimized for line a little bit more.
|
||||
COctTreeTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount,
|
||||
box, transform);
|
||||
|
||||
if(node)
|
||||
*node = SceneNode;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,15 +25,13 @@ public:
|
|||
virtual ~COctTreeTriangleSelector();
|
||||
|
||||
//! Gets all triangles which lie within a specific bounding box.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::aabbox3d<f32>& box, const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const;
|
||||
|
||||
//! Gets all triangles which have or may have contact with a 3d line.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::line3d<f32>& line,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
const core::matrix4* transform=0) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -237,7 +237,8 @@ ISceneNode* CSceneCollisionManager::getSceneNodeFromCameraBB(
|
|||
//! Finds the collision point of a line and lots of triangles, if there is one.
|
||||
bool CSceneCollisionManager::getCollisionPoint(const core::line3d<f32>& ray,
|
||||
ITriangleSelector* selector, core::vector3df& outIntersection,
|
||||
core::triangle3df& outTriangle)
|
||||
core::triangle3df& outTriangle,
|
||||
const ISceneNode*& outNode)
|
||||
{
|
||||
if (!selector)
|
||||
{
|
||||
|
@ -291,6 +292,7 @@ bool CSceneCollisionManager::getCollisionPoint(const core::line3d<f32>& ray,
|
|||
nearest = tmp;
|
||||
outTriangle = triangle;
|
||||
outIntersection = intersection;
|
||||
outNode = selector->getSceneNodeForTriangle(i);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ namespace scene
|
|||
//! Finds the collision point of a line and lots of triangles, if there is one.
|
||||
virtual bool getCollisionPoint(const core::line3d<f32>& ray,
|
||||
ITriangleSelector* selector, core::vector3df& outCollisionPoint,
|
||||
core::triangle3df& outTriangle);
|
||||
core::triangle3df& outTriangle,
|
||||
const ISceneNode* & outNode);
|
||||
|
||||
//! Collides a moving ellipsoid with a 3d world with gravity and returns
|
||||
//! the resulting new position of the ellipsoid.
|
||||
|
|
|
@ -75,8 +75,8 @@ void CTerrainTriangleSelector::setTriangleData(ITerrainSceneNode* node, s32 LOD)
|
|||
}
|
||||
|
||||
//! Gets all triangles.
|
||||
bool CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::matrix4* transform, const ISceneNode * * node) const
|
||||
void CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::matrix4* transform) const
|
||||
{
|
||||
s32 count = TrianglePatches.TotalTriangles;
|
||||
|
||||
|
@ -106,17 +106,13 @@ bool CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32
|
|||
}
|
||||
|
||||
outTriangleCount = tIndex;
|
||||
|
||||
if(node)
|
||||
*node = SceneNode;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Gets all triangles which lie within a specific bounding box.
|
||||
bool CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32 arraySize,
|
||||
void CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::aabbox3d<f32>& box,
|
||||
const core::matrix4* transform, const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
s32 count = TrianglePatches.TotalTriangles;
|
||||
|
||||
|
@ -147,16 +143,12 @@ bool CTerrainTriangleSelector::getTriangles ( core::triangle3df* triangles, s32
|
|||
}
|
||||
|
||||
outTriangleCount = tIndex;
|
||||
|
||||
if(node)
|
||||
*node = SceneNode;
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Gets all triangles which have or may have contact with a 3d line.
|
||||
bool CTerrainTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
void CTerrainTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::line3d<f32>& line,
|
||||
const core::matrix4* transform, const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
const s32 count = core::min_((s32)TrianglePatches.TotalTriangles, arraySize);
|
||||
|
||||
|
@ -186,10 +178,6 @@ bool CTerrainTriangleSelector::getTriangles(core::triangle3df* triangles, s32 ar
|
|||
}
|
||||
|
||||
outTriangleCount = tIndex;
|
||||
|
||||
if(node)
|
||||
*node = SceneNode;
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Returns amount of all available triangles in this selector
|
||||
|
|
|
@ -37,26 +37,25 @@ public:
|
|||
virtual void setTriangleData (ITerrainSceneNode* node, s32 LOD);
|
||||
|
||||
//! Gets all triangles.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::matrix4* transform=0) const;
|
||||
|
||||
//! Gets all triangles which lie within a specific bounding box.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::aabbox3d<f32>& box, const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const;
|
||||
|
||||
//! Gets all triangles which have or may have contact with a 3d line.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::line3d<f32>& line,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
const core::matrix4* transform=0) const;
|
||||
|
||||
//! Returns amount of all available triangles in this selector
|
||||
virtual s32 getTriangleCount() const;
|
||||
|
||||
//! ITerrainSceneNode is an ISceneNode, we just don't know it yet.
|
||||
virtual const ISceneNode* getSceneNode(void) const { return (ISceneNode*)SceneNode; }
|
||||
//! Return the scene node associated with a given triangle.
|
||||
/** ITerrainSceneNode is an ISceneNode, we just don't know it yet. */
|
||||
virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const
|
||||
{ return (ISceneNode*)SceneNode; }
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -24,13 +24,12 @@ CTriangleBBSelector::CTriangleBBSelector(const ISceneNode* node)
|
|||
|
||||
|
||||
//! Gets all triangles.
|
||||
bool CTriangleBBSelector::getTriangles(core::triangle3df* triangles,
|
||||
void CTriangleBBSelector::getTriangles(core::triangle3df* triangles,
|
||||
s32 arraySize, s32& outTriangleCount,
|
||||
const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
if (!SceneNode)
|
||||
return false;
|
||||
return;
|
||||
|
||||
// construct triangles
|
||||
const core::aabbox3d<f32>& box = SceneNode->getBoundingBox();
|
||||
|
@ -57,10 +56,6 @@ bool CTriangleBBSelector::getTriangles(core::triangle3df* triangles,
|
|||
|
||||
// call parent
|
||||
CTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, transform);
|
||||
|
||||
if(node)
|
||||
*node = SceneNode;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ public:
|
|||
CTriangleBBSelector(const ISceneNode* node);
|
||||
|
||||
//! Gets all triangles.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::matrix4* transform=0, const ISceneNode * * node = 0) const;
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::matrix4* transform=0) const;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
|
@ -67,10 +67,9 @@ CTriangleSelector::CTriangleSelector(const core::aabbox3d<f32>& box, const IScen
|
|||
|
||||
|
||||
//! Gets all triangles.
|
||||
bool CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
void CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
s32 arraySize, s32& outTriangleCount,
|
||||
const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
s32 cnt = Triangles.size();
|
||||
if (cnt > arraySize)
|
||||
|
@ -93,36 +92,29 @@ bool CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
|||
}
|
||||
|
||||
outTriangleCount = cnt;
|
||||
|
||||
if(node)
|
||||
*node = SceneNode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Gets all triangles which lie within a specific bounding box.
|
||||
bool CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
void CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
s32 arraySize, s32& outTriangleCount,
|
||||
const core::aabbox3d<f32>& box,
|
||||
const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
// return all triangles
|
||||
return getTriangles(triangles, arraySize, outTriangleCount, transform, node);
|
||||
return getTriangles(triangles, arraySize, outTriangleCount, transform);
|
||||
}
|
||||
|
||||
|
||||
//! Gets all triangles which have or may have contact with a 3d line.
|
||||
bool CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
void CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
s32 arraySize, s32& outTriangleCount,
|
||||
const core::line3d<f32>& line,
|
||||
const core::matrix4* transform,
|
||||
const ISceneNode * * node) const
|
||||
const core::matrix4* transform) const
|
||||
{
|
||||
// return all triangles
|
||||
return getTriangles(triangles, arraySize, outTriangleCount, transform, node);
|
||||
return getTriangles(triangles, arraySize, outTriangleCount, transform);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,26 +31,23 @@ public:
|
|||
CTriangleSelector(const core::aabbox3d<f32>& box, const ISceneNode* node);
|
||||
|
||||
//! Gets all triangles.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::matrix4* transform=0) const;
|
||||
|
||||
//! Gets all triangles which lie within a specific bounding box.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::aabbox3d<f32>& box, const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
|
||||
const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const;
|
||||
|
||||
//! Gets all triangles which have or may have contact with a 3d line.
|
||||
virtual bool getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
|
||||
s32& outTriangleCount, const core::line3d<f32>& line,
|
||||
const core::matrix4* transform=0,
|
||||
const ISceneNode * * node = 0) const;
|
||||
const core::matrix4* transform=0) const;
|
||||
|
||||
//! Returns amount of all available triangles in this selector
|
||||
virtual s32 getTriangleCount() const;
|
||||
|
||||
//! Gets the scene node to which this selector is associated.
|
||||
virtual const ISceneNode* getSceneNode(void) const { return SceneNode; }
|
||||
//! Return the scene node associated with a given triangle.
|
||||
virtual const ISceneNode* getSceneNodeForTriangle(u32 triangleIndex) const { return SceneNode; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -99,11 +99,18 @@ static bool getCollisionPoint_ignoreTriangleVertices(IrrlichtDevice * device,
|
|||
line3df ray(0, 0, -5, 0, 0, 100);
|
||||
vector3df hitPosition;
|
||||
triangle3df hitTriangle;
|
||||
const ISceneNode* hitNode;
|
||||
|
||||
bool collision = collMgr->getCollisionPoint(ray, meta, hitPosition, hitTriangle);
|
||||
bool collision = collMgr->getCollisionPoint(ray, meta, hitPosition, hitTriangle, hitNode);
|
||||
|
||||
meta->drop();
|
||||
|
||||
if(hitNode != nearBigCube)
|
||||
{
|
||||
logTestString("getCollisionPoint_ignoreTriangleVertices: hit the wrong node.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!collision)
|
||||
{
|
||||
logTestString("getCollisionPoint_ignoreTriangleVertices: didn't get a hit.\n");
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Test suite pass at GMT Thu Jan 22 14:10:54 2009
|
||||
Test suite pass at GMT Thu Jan 22 15:48:42 2009
|
||||
|
||||
|
|
Loading…
Reference in New Issue