hecht-software / box2dweb

Automatically exported from code.google.com/p/box2dweb
308 stars 94 forks source link

Static/Kinematic bodies moving on Android 4 #35

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Spend months developing a large and complex game that relies on Box2dWeb
2. Test it to death, and not see any problem
3. Release it, then test it to death on Android 4 :)

What is the expected output? What do you see instead?
I don't expect static and kinematic bodies to move. They move.

What version of the product are you using? On what operating system?
Box2dWeb-2.1.a.3.js on Android 4

Please provide any additional information below.
Description of the problem, with screenshots of debug, here: 
http://coding.tinternet.info/friction-pool-serious-android-4-problem

If anyone has any insight, I'd be glad to hear it. If anyone has a fix, I'd be 
even gladder! Maybe this is another floating point problem somehow (like issue 
29: http://code.google.com/p/box2dweb/issues/detail?id=29)?

Original issue reported on code.google.com by threegar...@gmail.com on 26 Oct 2012 at 9:38

GoogleCodeExporter commented 8 years ago
I can confirm this issue. Is someone working on it?

Original comment by daniele....@gmail.com on 9 Nov 2012 at 3:01

GoogleCodeExporter commented 8 years ago
I too confirm this issue. 

I found a work-around for this issue but I am not sure how far it would help 
you out. But this worked-out for me :) 

WORK-AROUND: 
Set the value to the "restitution" property for fixture definition of all the 
body in the box2d world to "0". 
For e.g.: 
        var fixDef = new Box2D.Dynamics.b2FixtureDef(); 
        fixDef.restitution = 0; 

However, I don't believe that this is the apt solution. 

Please try out this and let me know whether the work-around was helpful for 
you. 

Original comment by rahulvlu...@gmail.com on 6 Feb 2013 at 7:13

GoogleCodeExporter commented 8 years ago
This is an issue with Math.sin and Math.cos in the Android browser.
See this: https://code.google.com/p/v8/issues/detail?id=2234

Hack-ish workaround:

var mathSin = Math.sin;
Math.sin = function(a){
    if (a === 0) return 0;
    else return mathSin(a);
};
var mathCos = Math.cos;
Math.cos = function(a){
    if (a === 0) return 1;
    else return mathCos(a);
};

Original comment by lazarv1...@gmail.com on 4 Aug 2013 at 9:34