Page 1 of 1

A small Bug in VoronoiFractureDemo

Posted: Wed Oct 02, 2013 7:14 pm
by suejunghuh
In methods,
VoronoiBreakingDemo::voronoiConvexHullShatter
VoronoiBreakingDemo::voronoiBBShatter
j shoud start from i+1 not 1.

:D

-----------

for (i=0; i < numpoints ;i++) {
curVoronoiPoint = points;
btVector3 icp = quatRotate(bbiq, curVoronoiPoint - bbt);
rbb = icp - bbmax;
nrbb = bbmin - icp;
planes.resize(6);
planes[0] = bbvx; planes[0][3] = rbb.x();
planes[1] = bbvy; planes[1][3] = rbb.y();
planes[2] = bbvz; planes[2][3] = rbb.z();
planes[3] = -bbvx; planes[3][3] = nrbb.x();
planes[4] = -bbvy; planes[4][3] = nrbb.y();
planes[5] = -bbvz; planes[5][3] = nrbb.z();
maxDistance = SIMD_INFINITY;
sortedVoronoiPoints.heapSort(pointCmp());
for (j=i+1; j < numpoints; j++) { <<<====================== Here

Re: A small Bug in VoronoiFractureDemo

Posted: Thu Oct 03, 2013 7:40 pm
by Erwin Coumans
Your 'fix' breaks the demo, have you tried it?

Re: A small Bug in VoronoiFractureDemo

Posted: Thu Oct 10, 2013 6:18 pm
by suejunghuh
Oh! :oops:

There should be only one fix in the method,
VoronoiBreakingDemo::voronoiConvexHullShatter
j shoud start from i+1 not 1.

Attached is the file with the comment FIX - UPDATE.

[The code has been updated with the most recent one.]

Re: A small Bug in VoronoiFractureDemo

Posted: Fri Oct 11, 2013 10:18 am
by Flix
Your "new fix" does not break the demo anymore, because in the demo VoronoiBreakingDemo::voronoiConvexHullShatter is never called.

However if I apply your proposed fix to a demo where voronoiConvexHullShatter is used, it still breaks the demo in a similiar way...

Re: A small Bug in VoronoiFractureDemo

Posted: Sun Oct 13, 2013 7:03 am
by suejunghuh
Sorry I was testing this in a different setting
where the convex was only axis-aligned when voronoiConvexHullShatter is called.

Now I have changed my code so it would work on the general setting exactly the same setting like the demo.
It should roughly run 2 times faster than the original demo, by storing the history.

By the way, I know the original code was just for the demo (kindly provided by Alain Ducharme),
so I know it wasn't meant to be as efficient as it could be in the first place.

Thanks.

Re: A small Bug in VoronoiFractureDemo

Posted: Sun Oct 13, 2013 7:04 am
by suejunghuh
Also nor my code is as efficient as it could be...

Re: A small Bug in VoronoiFractureDemo

Posted: Sun Oct 13, 2013 8:15 am
by suejunghuh
By the way, I have added getVerticesInsidePlanes2.
Attached is the updated header.

Re: A small Bug in VoronoiFractureDemo

Posted: Sun Oct 13, 2013 3:48 pm
by suejunghuh
The code is updated to re-use the previously computed/found planes.

Note that now the iteration starts at i+1 at // UPDATE - FIX

Indeed!

Thanks.

Re: A small Bug in VoronoiFractureDemo

Posted: Sun Oct 13, 2013 5:10 pm
by suejunghuh
By the way, the change is reflected only in voronoiConvexHullShatter not in voronoiBBShatter.

Re: A small Bug in VoronoiFractureDemo

Posted: Sat Oct 19, 2013 9:48 am
by suejunghuh
The plane computation was incorrect. Attached is the modified code.
In my rough benchmark, it was around 40% faster than the original.