meiyunyang / chipmunk-physics

Automatically exported from code.google.com/p/chipmunk-physics
MIT License
0 stars 0 forks source link

handleQueryRehashHelper() in infinite loop #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

What steps will reproduce the problem?
1. Download cocos2d develop branch.

$ git clone git://github.com/cocos2d/cocos2d-iphone.git
$ git checkout develop

2. Open the Xcode project
   Select "ChipmunkTestBed" target

3. Edit external/Chipmunk/Demo/cocos2dChipmunkDemo.m

And replace "demos" with this one:
static chipmunkDemo *demos[] = {
//  &MagnetsElectric,
    &LogoSmash,
    &Simple,
    &PyramidStack,
    &Plink,
    &Tumble,
    &PyramidTopple,
    &Bounce,
    &Planet,
    &Springies,
    &Pump,
    &TheoJansen,
    &MagnetsElectric,
    &UnsafeOps,
    &Query,
    &OneWay,
    &Player,
    &Sensors,
    &Joints,
    &Tank,
};

 4. Tap the screen until you reach the Theo Jansen Demo.

5. Tap again... you should see the Magnets Electric Demo. Instead, code is 
doing an infinite loop handleQueryRehashHelper()

If I comment the    "MagnetsElectric" Demo it works Ok.
And sometimes it works OK even with the MagnetsElectric uncommented.
Also, if "MagnetsElectric" is the 1st demo, the bug is not reproducible.

"cocos2d develop" includes Chipmunk 5.3 + 2 little fixes to prevent a compile 
warning.
The demos were modified to prevent compile warnings.
drawShapes was modified to draw the shapes in the cocos2d environment.

Original issue reported on code.google.com by ricardoq...@gmail.com on 10 Aug 2010 at 5:29

GoogleCodeExporter commented 8 years ago
I've had this problem before as well with that demo. I think it is a floating 
point precision problem. The forces calculated for the bodies cause them to fly 
off to ininity or NaN and then the spatial hash has to add the body to a nearly 
infinite number of hash cells. It doesn't seem to happen when using doubles.

The demo was contributed by a forum member that was using Chipmunk as a 
platform for physics research actually. It was a cool demo which is why I 
included it, but it doesn't really show off any Chipmunk features. It is also 
extremely slow as calculating the interaction forces is O(n^2). I would just 
say to drop that demo from the list.

Original comment by slemb...@gmail.com on 10 Aug 2010 at 5:39