Shapes drawn on other shapes are not properly affected by physics mode

Issue #14 new
Muhsin King created an issue

When you draw a shape on another shape in a physics-enabled window, it doesn't properly append to either the shape or the window--it reacts to gravity and other objects exactly as the shape it was drawn on does, not using its own properties or borders (it's weight and edges are not accounted for). Not sure if this is fixable, or if we should just tell people to not draw object on other objects when using physics.

Comments (5)

  1. Doug Blank

    We should fix this. I guess that when a shape is moved, we should recursively traverse the shapes drawn on it, and move their physics accordingly. Also, I guess the mass of a shape that has other shapes drawn on it should increase, the center of mass should change, etc. Maybe there is support for all of this in the Farseer Physics library that we use. See https://farseerphysics.codeplex.com/ for more information.

  2. Doug Blank

    Hannah says: "I checked out the python code and I see that the red ball is copying the blue ball's movements. Is the problem that it is using the blue ball's gravity/momentum instead of its own? I was thinking that since it was drawn on the other it was supposed to be pretending that it is somehow attached by an invisible bar to the other. Or is the reason for drawing it onto the blue ball just so that it can use the center of the blue ball as its x==0 position?"

    The "draw shape on shape" was originally just a visual device to be able to have one shape in the reference frame of the other (for example, see the Solar System code in Python animation simulation examples where objects move when the host shape is rotated). But no thought was given to what this means when in Physics mode. So, maybe when in Physics mode, we "physically" attach to the other shape, but when in another mode we do what we do now. Needs to be investigated...

  3. Muhsin King reporter

    Indeed, what seems to be the problem is that when you draw a shape on another shape, the "Window" for the new shape is it's parent shape. This means the overarching Window, which is what is actually processing the physics of the simulation, has no effect on the child shape. If at all possible, it would be good to let the child shapes inherit the Window from their parent somehow, or just to correctly alter the parent shape to reflect the changes of the addition (so, instead of just drawing a new shape in the "Window" of the original, actually change the new shape to include to child).

  4. Natan Organick

    So in the red and blue ball example, if we went with option 2 where the parent shape is correctly altered, would this mean that when the red ball is drawn the parent shape is modified to be the red and blue ball together with a new mass? And then they fall as if they are one shape (even though they are not touching each other)?

    It might be good to have this option and then if someone wanted the red and blue balls to act as separate objects they could draw them both on the main Window.

  5. Doug Blank

    It would be good if we didn't have to handle the details when in Physics mode, just let the Physics engine do it. So, we should look at the Farseer docs to see how to attach the two with a fixed bar. (It seems that I tried that, but it didn't work. We may have to upgrade the Farseer engine to the latest to make this work.)

  6. Log in to comment