1.8.0 sripted hinge disappear

If you have problems installing or running Algodoo, have found a bug or need in-game help - this is it!

1.8.0 sripted hinge disappear

Postby Kilinich » Fri Oct 15, 2010 10:43 am

1.8.0
I found this trying to build very fast servomotor. Run scene and see how whole arm disappear after a few moments.

No div by 0, no error in code. It juts disappear in some unpredictable moment.
Not happened on slow speed. Weired.

The only thing I've noticed - it happened then motor speed is near zero and switches 0/-0.

[scene]47345[/scene]
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: 1.8.0 sripted hinge disappear

Postby Kilinich » Fri Oct 15, 2010 11:07 am

I've found the reason :mrgreen:
And It's bad.

Shortly - because of algodoo not very precise sometimes, for example e.normal vector length can be 1.0000001

Then I try to calculate angle between current and last e.normals (call it n1 and n2) using formula
http://en.wikipedia.org/wiki/Dot_product

n1(0) * n2(0) + n1(1) * n2(1) = cos (a)
algodoo sometimes calculate it as 1.0000001 :cry: and math.acos() gives NaN.

I don't know how to handle it yet... maybe Emil can fix it somehow? for example change NaN result of arccos to 0 instead of NaN if argument > 1 (and same for other arc-functions) ?
Last edited by Kilinich on Fri Oct 15, 2010 11:22 am, edited 2 times in total.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: 1.8.0 sripted hinge disappear

Postby Kilinich » Fri Oct 15, 2010 11:13 am

even if motor speed set to NaN it's not good to remove script and motor ad everything it connect from scene..
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: 1.8.0 sripted hinge disappear

Postby electronicboy » Fri Oct 15, 2010 6:06 pm

I agree, algodoo should keep a bad object in the scene so it can be fixed by the author easily.
and if it is impossible to use the bad value, make algodoo restore a valid value like it does with the text box's in the script menu.
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: 1.8.0 sripted hinge disappear

Postby emilk » Wed Oct 27, 2010 11:54 am

Clamp = (x, min, max) =>{ x < min ? min : x > max ? max : x };
Acos = (x)=>{ math.acos(Clamp(x, -1, +1)) };
Emil Ernerfeldt, lead developer
emilk
 
Posts: 616
Joined: Mon Aug 31, 2009 11:01 am
Location: Umeå, Sweden

Re: 1.8.0 sripted hinge disappear

Postby Kilinich » Wed Oct 27, 2010 12:15 pm

emilk wrote:Clamp = (x, min, max) =>{ x < min ? min : x > max ? max : x };
Acos = (x)=>{ math.acos(Clamp(x, -1, +1)) };


sure. but my scenes already lags like hell
so i prefer just * 0.999999 :D
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia


Return to Help / Bug reports

Who is online

Users browsing this forum: No registered users and 2 guests