BVH question

Post Reply
AlexSilverman
Posts: 141
Joined: Mon Jul 02, 2007 5:12 pm

BVH question

Post by AlexSilverman »

Hello,

I'm not sure if this is a BVH question in general or something specific to Bullets use of them, but here goes. We have a wall with some holes in it and we're using a btBvhTriangleMeshShape to represent it. It's about 9x18x4 (all meters), so it isn't all that large. We added some more detail to the collision mesh, so it's now about 1200 tris, and noticed a slowdown. On a guess, I scaled it up by ten, and now the slowdown is gone. This leads me to believe that the BVH is more optimized the larger the triangles are (probably to a point, as I'm aware of the suggested upper limit on triangle size). Is this true, or is the optimization supposed to be equal regardless of the size of the triangles in the mesh?

If it is true, is there a way to tweak the "works best at" size, so that smaller triangles will be more optimized?

Thanks.

- Alex
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: BVH question

Post by sparkprime »

Where did the slowdown occur? If you throw a box at the wall and it hits 100 triangles then that will surely be 10x slower than if the triangles were 10x bigger so the box only hit 10 of them...
AlexSilverman
Posts: 141
Joined: Mon Jul 02, 2007 5:12 pm

Re: BVH question

Post by AlexSilverman »

sparkprime,

The slowdown was as soon as other objects were added to the scene, not just when collisions happened.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: BVH question

Post by sparkprime »

broadphase or narrowphase?

I can't see how more triangles would affect broadphase as the number of AABB proxies would be the same


but unless the objects are near the wall, it ought not to affect narrowphase, and any affect would be O(log n) in the number of triangles in theory
AlexSilverman
Posts: 141
Joined: Mon Jul 02, 2007 5:12 pm

Re: BVH question

Post by AlexSilverman »

I didn't profile it at the time, as we ended up removing most of the unnecessary triangles (and there were quite a few :) ) from the mesh to save the framerate as quickly as possible. My guess is that they were about 10 meters away. Well outside the AABB of the wall, and the objects themselves were somewhat large hockey pucks, so they wouldn't have very large AABBs themselves. It's my understanding that the AABB's must overlap to add objects to the narrowphase pass. Is this correct? I've never really dug into where that line is in Bullet, and that was always just my assumption.

I'm heading out for the long weekend tomorrow so I'm unable to do anything on this until Tuesday, but at that time I'll drop this scene into a demo and see what turns up. In the meantime, I'd like to redirect the focus back to the conceptual bvh question. In Bullet, do the size of the triangles affect the optimization that the mesh receives? Hopefully it's cut and dry enough to answer :)

Thanks for your help.

- Alex
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: BVH question

Post by Erwin Coumans »

The BVH generation shouldn't be influenced by the size of the triangles. There must be some overlap with more triangles due to some reason. Have you tried visual debug drawing to check overlapping triangles?

Thanks,
Erwin
AlexSilverman
Posts: 141
Joined: Mon Jul 02, 2007 5:12 pm

Re: BVH question

Post by AlexSilverman »

I talked with the guy experiencing this problem about the makeup of the scene and it turns out he was manually holding several boxes in positions where they were penetrating the wall mesh, thus the slowdown and resulting fix when the wall was enlarged. Sorry for the misdirection, but thanks for the help.

- Alex
Post Reply