Cause:
getCollisionPoint() uses the optimized getTriangles() that only returns triangles near the supplied ray. But, passes the raw loop counter to MetaTriangleSelector.getSceneNodeForTriangle(). The problem with this is that the optimized getTriangles() returns a subset of triangles so the indexes do not represent the true indexes.
Solution:
Instead of getSceneNodeForTriangle() accepting an integer index, it accepts a triangle, which is then used to compare against all triangles in all sub-selectors. the problem with this is that is slow and costly in computations. So rather write up a patch myself I figured i'd let one of you guys think of how to do it.
Another possible solution, would would be most cost effective, would be to make getTirangles() accept another paramter for and outbound int array. Which you store the boundaries in.
Example:
Code: Select all
void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::aabbox3d<f32>& box,
const core::matrix4* transform, core::u32 *boundaries) const
{
s32 outWritten = 0;
for (u32 i=0; i<TriangleSelectors.size(); ++i)
{
s32 t = 0;
TriangleSelectors[i]->getTriangles(triangles + outWritten,
arraySize - outWritten, t,
box, transform);
outWritten += t;
boundaries[i] = outWritten;
}
outTriangleCount = outWritten;
}
getSelectorCount() would be used to initialize the array you send to getTriangles()
Code: Select all
for(u32 i = 0; i < selector.getSelectorCount(); i++){
if(boundaries[i] >= triangle_index) {
node = selector.getTriangleSelector(i).getSceneNode();
}
}
I am bad at considering optimizations so take a look and please tell me what you think.
Because I got tired of waiting, {ya I know im impatient}
I decided to implement the method using Boundaries and SelectorCounts
I posted the patch file here against SVN rev2295
PasteBin.com - [2295]getCollisionPoint Fix LexManos Apply to /trunk/
this modifies 12 files so its kinda important it gets added ASAP if its going to be added at all. As to have less of a chance to conflict with anything. Also please tell me if this breaks anything, it shouldnt as all I did was add a single optional parameter to getTriangles(line)