Quote:Original post by Hybrid
I can't believe you got that up and running so quick? It looks fantastic by the way, the moment is excellent! Will it work fine if the water surface is moving up and down??? I guess it will.
[smile]
It was simply matter of putting equations. It haven't needed any tuning - i selected k=1.5 since the beginning, etc (the only thing i tuned a bit is that restarting code, took less than typing typical long message in English).
Sure. One important point:
you need to do
f-=dh_dt*friction;
and
dh_dt*=min(1.0,prev_em/em);
relatively to water.
That is,
....
double rel_dh_dt=dh_dt-water_dh_dt;
.....
f-=rel_dh_dt*friction;
.....
rel_dh_dt*=min(1.0,prev_em/em);
....
dh_dt=rel_dh_dt+water_dh_dt;
Also to absolutely ultimately increase stability, instead of
f-=rel_dh_dt*friction; // drag force
you can do
rel_dh_dt*=exp(-game_dt*friction/em); // analitical drag results for given timestep
And it probably will work well with densities down to 1E-4 (hydrogen) The only reason it fail to work with extremely small density is that drag.
BTW, friction should depend to type of object, should be roundly proportional to it's cross-section.
BTW2, it looks the best from bottom side of water cube, from where you can see all events( start and impact)...
BTW3, once it'll work you can try to play with drag force direction.
BTW4, you can actually compute your underwater volume, it's very similar to computing volume of arbitrary objects.(say, if you use piramids method, you must just compute underwater volumes of piramids only. If you use prisms method , similarly)