Buoyancy Controller - jumping on surface

Apr 17, 2011 at 1:22 PM

Not sure if this is something I configured wrong with the Buoyancy Controller, but if you look at the sample below - note how the blocks kind of jump up out of the surface of the water, and then sink right to the bottom. This problem seems specific to the smaller block objects - if I drop in something bigger they behave better.

http://www.youtube.com/watch?v=DcPqWMf8tv0

Any ideas?

Thanks!
-Andy

Coordinator
Apr 17, 2011 at 3:12 PM

Is this version 3.3 or back when we had both the wave controller and buoyancy?

Apr 17, 2011 at 3:35 PM

Yeah this is version 3.3... (however I did use the old version that I think Jeff Weber wrote, and I kind of miss the Wave Controller. I would like to port that but not sure I have the time).

But anyway the behavior shown in the link above, if I debug it looks like the ComputeSubmergedArea method is coming back with a value even when those blocks are out of the top of the buoyancy container.

I'll probably have to get you a code sample so you can see, I know it's hard to tell anything from a video but I was wondering if anyone had run into this behavior.

Thanks again
-Andy


Coordinator
Apr 17, 2011 at 3:41 PM

The thing is that I ported the wave controller to the buoyancy controller back in 3.0, but the behavior your are seeing is the same as I was having. The problem originated from the wave controller as it only works in (x,y) > (0,0). I scrapped the implementation as the limitation would give too much trouble.

Try with just the buoyancy controller alone and it should work. (It works in the testbed)

Apr 17, 2011 at 3:49 PM

I'm pretty sure there is no Wave Controller in play here - I am using 3.3 and I don't see any Wave Controller in the FP 3.3.1 source code... But maybe I am missing something.

Thanks,
-Andy

Coordinator
Apr 17, 2011 at 4:05 PM

The 3.3 sources does not include a wave controller, but I'm seeing something disturbing the water surface on the video. is it just graphics?

Apr 17, 2011 at 4:08 PM

Yes - sorry, should have explained. The waves you see are just a Storyboard animation in Silverlight - they're not generated in the physics.

No worries on this, I can probably work around it with some tweaks. Just wondering if some ideas would pop into mind.

 

Coordinator
Apr 17, 2011 at 4:17 PM

I'm not sure what could cause this. If you replicate it in a testbed sample, I would be happy to take a look at it.

By the way Andy, good job on the Physics Helper. Great to see it is being kept up to date.

Sep 15, 2011 at 3:53 PM

After this problem was driving me crazy, I finally found the reason for this behavior (but sadly, no solution as of yet).

The thing is, the testbed uses, for whatever reason, negative forces for the gravity. I'm using positve values. But in both cases (testbed with negative value and my own project with a positive), objects are falling down. Now it seems to be the case, that the buoyancy controller only works in the testbed case. When I negate my own gravity and put the water area to the top of the screen, all objects fall up and also behave like they should on the water surface (that is, the bottom of the area).

And now I need to find a proper solution to put this knowledge into use.

Sep 19, 2011 at 2:24 PM
Edited Sep 19, 2011 at 2:25 PM

In case anybody is still interested in the solution, here is how I've done this:

Two changes were necessary, one in the Buoyancy Controller and one in the PolygonShape class.

Buoyancy Controller, line 66, the Container property ,replace

_offset = _container.UpperBound.Y;

with

_offset = _container.LowerBound.Y;

 

And in PolygonShape, line 446, the ComputeSubmergedArea, replace

bool isSubmerged = depths[i] < -Settings.Epsilon;

with

bool isSubmerged = depths[i] > -Settings.Epsilon;

 

At least, this worked for me anyway. This is kind of a hack and should be handled more properly, but I just wanted to get the controller to work :)

May 23, 2012 at 3:11 PM

You've just saved my life.

I've been staring at my screen all day trying to figure out what I'm doing wrong having this "jump out - jump back in) effect. Changed those 2 lines fixed the problem at the spot.

Jun 17, 2013 at 10:25 AM
It just works like a charm for me tho~! Thank you. But, is it alright to change that things? Does it affect to another part of the engine?