A small Bug in VoronoiFractureDemo

Post Reply
suejunghuh
Posts: 9
Joined: Wed Oct 02, 2013 7:08 pm

A small Bug in VoronoiFractureDemo

Post 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
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: A small Bug in VoronoiFractureDemo

Post by Erwin Coumans »

Your 'fix' breaks the demo, have you tried it?
suejunghuh
Posts: 9
Joined: Wed Oct 02, 2013 7:08 pm

Re: A small Bug in VoronoiFractureDemo

Post 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.]
Attachments
VoronoiFractureDemo.cpp
(28.03 KiB) Downloaded 297 times
Last edited by suejunghuh on Mon Oct 21, 2013 7:30 am, edited 2 times in total.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: A small Bug in VoronoiFractureDemo

Post 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...
suejunghuh
Posts: 9
Joined: Wed Oct 02, 2013 7:08 pm

Re: A small Bug in VoronoiFractureDemo

Post 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.
Last edited by suejunghuh on Mon Oct 21, 2013 7:25 am, edited 1 time in total.
suejunghuh
Posts: 9
Joined: Wed Oct 02, 2013 7:08 pm

Re: A small Bug in VoronoiFractureDemo

Post by suejunghuh »

Also nor my code is as efficient as it could be...
suejunghuh
Posts: 9
Joined: Wed Oct 02, 2013 7:08 pm

Re: A small Bug in VoronoiFractureDemo

Post by suejunghuh »

By the way, I have added getVerticesInsidePlanes2.
Attached is the updated header.
Attachments
VoronoiFractureDemo.h
(3.33 KiB) Downloaded 320 times
suejunghuh
Posts: 9
Joined: Wed Oct 02, 2013 7:08 pm

Re: A small Bug in VoronoiFractureDemo

Post 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.
Last edited by suejunghuh on Mon Oct 21, 2013 7:25 am, edited 1 time in total.
suejunghuh
Posts: 9
Joined: Wed Oct 02, 2013 7:08 pm

Re: A small Bug in VoronoiFractureDemo

Post by suejunghuh »

By the way, the change is reflected only in voronoiConvexHullShatter not in voronoiBBShatter.
suejunghuh
Posts: 9
Joined: Wed Oct 02, 2013 7:08 pm

Re: A small Bug in VoronoiFractureDemo

Post by suejunghuh »

The plane computation was incorrect. Attached is the modified code.
In my rough benchmark, it was around 40% faster than the original.
Attachments
VoronoiFractureDemo.cpp
(28.03 KiB) Downloaded 306 times
Post Reply