Possible bug with EvenlyDistributeShapesAlongPath?

Nov 28, 2012 at 9:43 PM
Edited Nov 29, 2012 at 6:39 AM
Howdy,I'm experimenting with different ways to simulate a soft body. In my testing, I'm having issues with generating bodies that are properly distributed around the path. One of the bodies always appears to have the incorrect Y-axis position. Here's an example: here. My code is below. Is this a bug or am I missing something? Thanks! edit: Also, I've noticed it generates 1 less than the number of bodies you specify in the method.
//make rectangular path Path path = new Path(); path.Add(new Vector2(0, 6)); path.Add(new Vector2(6, 6)); path.Add(new Vector2(6f, 0f)); path.Add(new Vector2(0f, 0)); path.Closed = true; //Create shape List<Shape> shapes = new List<Shape>(1); shapes.Add(new CircleShape(2f, 1)); //Distribute shape List<Body> softBodies; softBodies = PathManager.EvenlyDistributeShapesAlongPath(game.fs_world, _path, shapes, BodyType.Dynamic, 21);

edit2: ignore the purple triangle that's lined around the circles, that's my temporary texture.

Developer
Nov 29, 2012 at 10:14 PM

So it is a bug then?

Nov 30, 2012 at 6:36 PM

(^_^;) ok, I'm pretty sure it was a bug on my end. sorry!

Nov 30, 2012 at 8:01 PM

ok... I'm not so sure anymore. I removed my code that was completely misplacing the first body, which fixed it from being grossly off. But it still seems slightly off...

Developer
Nov 30, 2012 at 8:18 PM

Well the code only approximates positions, some shapes have sizes which cannot be perfectly spaced. Can you post another screenshot?

Nov 30, 2012 at 9:19 PM
Edited Nov 30, 2012 at 9:22 PM

My path is the same as above (a 6x6 box). I understand it's just an approximation, and the error becomes less visible as you increase the number of objects (2nd image) but it still seems odd that the error is large enough to be visible. I think the error is only present (or visible) when the path is closed.