cenkguzelis / jbox2d

Automatically exported from code.google.com/p/jbox2d
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Create stretchable edge shape or polygon #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When creating any sort of deformable object like a blob, rope, or bridge, it 
would be very useful to have some sort of deformable shape (or body?) so that 
it's more difficult for things to penetrate inside the object (see the blob 
test for an example, the idea would be to have a shape that could connect the 
vertices and keep things out, which is tricky to do with rigid bodies).

While fully deformable objects are very messy to implement, it might be 
feasible to add something like a stretchable edge shape, which is free to 
stretch along its perimeter if pulled apart or pushed together by joints.

This is low priority, as it's a feature that doesn't exist in Box2d proper, but 
I'll take a look at it and see if it would be too difficult to implement.  The 
main concern I have is that all of the bits of the solver assume that the 
anchor points are fixed, and this would not be the case; this would also 
probably need to be implemented by sub-typing Body rather than Shape, because 
most of the places where impulses are applied don't actually touch the shapes, 
but work purely with bodies after determining where on the body the impulses 
are going to be applied.

On the bright side, the refactorings necessary to make this possible *might* 
simplify parts of the engine a good bit - there's still a lot of stuff that's 
directly inlined in the code, when it really could be factored out (for 
instance, tons of code in most of the joint subclasses is repeated all over the 
place, and really boils down to simple things like "apply an impulse at this 
point" or "find the relative velocity of two local points").

Will see, though, this could be pretty tough...

Original issue reported on code.google.com by ewjor...@gmail.com on 19 Jul 2011 at 8:55

GoogleCodeExporter commented 9 years ago
What do you mean by stretching along it's perimeter?  Would a circle body with 
a dynamic radius fall into this catagory?

Original comment by toucansa...@gmail.com on 19 Jul 2011 at 11:22

GoogleCodeExporter commented 9 years ago
Thinking about it some more, what I'm really thinking is a body that is able to 
stretch along one axis but is rigid along the other.  But that leads to some 
tricky questions when applied to general bodies, and starts getting into things 
like elastic constants and other not-so-fun factors.  It would also cause 
problems with circles, because those can't be deformed in any simple way since 
we don't have ellipse shapes.

A perfect concrete example of what I'd like to enable is the swinging rope 
example in the testbed, but allow the rope to be stretchy and not have gaps no 
matter how far it's pulled.  That's not possible to do with rigid bodies as the 
rope elements.

Maybe this is more trouble than it's worth...I'll have to think about it some 
more, see if I can come up with any possible way to implement it.  I'm pretty 
sure Erin has denied this sort of feature request many times, and I'm sure he's 
thought about it.  Then again, Bullet has deformables, so it's definitely 
possible, but Bullet is a much more highly abstracted engine than Box2d, so 
that's an apples to oranges comparison.

Original comment by ewjor...@gmail.com on 20 Jul 2011 at 6:50

GoogleCodeExporter commented 9 years ago
Hm... well we'd need to start by deciding exactly what we want here, and how to 
define it.

probably not accurate brainstorming:

If our rope segments are stretching, does that mean they're exerting force 
back?  If we do this on an axis-basis, we'll have to have a function for each 
body (fixture? what's stretching?) to determine the 'unstretch' force...

so that means we'll be dealing with a spring situation, which isn't too bad, 
except when we use circles.  with polygons, we could 'stretch' all of the 
points away from the 'center of outward force' along the given axis, but we're 
a bit more screwed with circles, as we'd have to completely redo the algorithms 
to deal with elipses instead of circles.  which probably = performance loss.

So maybe we could restrict this to polygons (or edge/loop shapes)?

Back to the springy polygons, we'd have to define how that would work.  Would 
we treat all 'pulls' with the same linear displacement force?  Does this apply 
with only one 'pull/push' source?  then we'd have to somehow take the density 
of the shape into the equation.  Otherwise, if we only have this work when 
there are two sources of push/pull, we could just compute the center between 
them and do linear spring displacement from that....

Maintainability-wise, could we keep this up to date with the engine?

Original comment by toucansa...@gmail.com on 21 Jul 2011 at 3:58