Function "btQuantizedBvh::walkStacklessTreeAgainstRay"

fishboy82
Posts: 91
Joined: Wed Jun 10, 2009 4:01 am

Function "btQuantizedBvh::walkStacklessTreeAgainstRay"

Post by fishboy82 »

When I read this function I got my selfconfused in the code line;
bounds[0] = rootNode->m_aabbMinOrg;
bounds[1] = rootNode->m_aabbMaxOrg;
/* Add box cast extents */
bounds[0] += aabbMin;
bounds[1] += aabbMax;
I think it should be like this:
bounds[0] = rootNode->m_aabbMinOrg;
bounds[1] = rootNode->m_aabbMaxOrg;
/* Add box cast extents */
bounds[0] -= aabbMax;
bounds[1] -= aabbMin;
Or did I miss something,
[img]I%20attach%20a%20png%20file%20to%20show%20this:[/img]
You do not have the required permissions to view the files attached to this post.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Function "btQuantizedBvh::walkStacklessTreeAgainstRay"

Post by Erwin Coumans »

Those extends are around the origin, so for a convex cast, aabbMin is a negative value and aabbMax is a positive value, so both need to be added to the current extents.
(for a ray test both values are zero)

Thanks,
Erwin
fishboy82
Posts: 91
Joined: Wed Jun 10, 2009 4:01 am

Re: Function "btQuantizedBvh::walkStacklessTreeAgainstRay"

Post by fishboy82 »

Hi Erwin:
I know we need to add extension to the original node aabb bound ,but take a look at my picture,I think the right formula should be :
bounds[0] -= aabbMax;(left bottom )
bounds[1] -= aabbMin;(right top)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Function "btQuantizedBvh::walkStacklessTreeAgainstRay"

Post by Erwin Coumans »

Say we have a box cast from A to B, see picture, with the green arrow the 'aabbMin' and red arrow 'aabbMax'.
s6iCr-mGulvtVIuJahrRQxw_42.png
We need the AABB that bounds the swept volume, so we have to add the 'green' arrow to the A and red to B.
Thanks,
Erwin
You do not have the required permissions to view the files attached to this post.
fishboy82
Posts: 91
Joined: Wed Jun 10, 2009 4:01 am

Re: Function "btQuantizedBvh::walkStacklessTreeAgainstRay"

Post by fishboy82 »

Thanks a lot Erwin, but ...somehow ,what I mean is not the box bound the swept volumn of the convex , but the Box bound the node in the AABB tree , It seems that before perform a ray-AABB intersect :
rayBoxOverlap = aabbOverlap ? btRayAabb2 (raySource, rayDirectionInverse, sign, bounds, param, 0.0f, lambda_max) : false;
the bullet will expands the AABB Node's bound box using the code
bounds[0] = rootNode->m_aabbMinOrg;
bounds[1] = rootNode->m_aabbMaxOrg;
/* Add box cast extents */
bounds[0] += aabbMin;
bounds[1] += aabbMax;
But I think the code shoud be:
bounds[0] = rootNode->m_aabbMinOrg;
bounds[1] = rootNode->m_aabbMaxOrg;
/* Add box cast extents */
bounds[0] -= aabbMax;
bounds[1] -= aabbMin;
As showed in my picture.
So I agree with the swept volumn box calculation of the convex box ,but I am not agree with the calculation of the box of the AABB Node(which is used to perform a ray test)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Function "btQuantizedBvh::walkStacklessTreeAgainstRay"

Post by Erwin Coumans »

You are right, there seems to be a problem.

I'll look into it further, and filed an issue here: http://code.google.com/p/bullet/issues/detail?id=322

Thanks for the report!
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Function "btQuantizedBvh::walkStacklessTreeAgainstRay"

Post by Erwin Coumans »

Issue has been fixed in latest trunk.

A reproduction case that show previous failure is attached to this closed issue:
http://code.google.com/p/bullet/issues/detail?id=322

Thanks a lot for the report and fix!
Erwin