Reproducible crash

Report problems here (or use the built-in feedback dialog in the editor)
Post Reply
rokus
Posts: 4
Joined: Mon Apr 06, 2015 1:11 pm

Reproducible crash

Post by rokus »

Hi,

when i open the attached rube-file and try to delete the points marked red, RUBE crashes (version 1.7.2, Linux Mint, 64bit).

Regards!
Attachments
crashable.rube
(10.91 KiB) Downloaded 1094 times
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Reproducible crash

Post by iforce2d »

Thanks for the report. Unfortunately this crash seems be an issue with the poly2tri library which is not yet resolved. I'm hoping to add support for another polygon decomposition lib in future which does not have this issue, but in the meantime we'll need to work around it.

I notice that you have a lot of colinear vertices, and also some coincident vertices, both of which play havoc with Box2D and are meaningless when creating a physics body. My recommendation would be simply to delete them. However, since deleting them a few at a time can trigger the crash, we need to get rid of them all at once before letting the polygon decomposition run. You can use this script to select all colinear vertices:

Code: Select all

vertex[] vs = sf()[0].getVertices();
for (uint i = 2; i < vs.length; i++) {
	vertex v0 = vs[i-2];
	vertex v1 = vs[i-1];
	vertex v2 = vs[i];
	vec2 d0 = v1.pos - v0.pos;
	vec2 d1 = v2.pos - v1.pos;
	d0.normalize();
	d1.normalize();
	if ( d0.dot(d1) > 0.999 )
		v1.select();
}
To use this, open your scene, paste that into the script panel, select the fixture and run the script. You should then see all the offending vertices selected, and you can delete them in one go. After that you should be able to delete the points marked in red without triggering the crash.

It looks like you may have been drawing this shape to use for some kind of artistic layout rather than for physics, because some vertices are in exactly the same place. This will cause problems for polygon decomposition, so you might want to use 'loop' shapes instead for that type of thing.
rokus
Posts: 4
Joined: Mon Apr 06, 2015 1:11 pm

Re: Reproducible crash

Post by rokus »

Thank you for your answer. I imported the vertices with a script, thank you for your script to select the problematic vertices all at once.
Post Reply