Not logged inOpenClonk Forum
Up Topic General / Help and Questions / Clonk Terrain / Fluid Engine
- - By zorry [de] Date 2011-05-22 14:05
Hi
Im a indie developer and i am planning a project with destructable terrain and fluid.
I was wondering how it is possible in Clonk to process such giant landscapes with water and earth with such a perfect framerate.
Coul somebody of you explain me how it works? I would look the Code up by myself, but I am not familliar with C++ (Im C#-Coder)

Thanks
zorry
Parent - - By Zapper [de] Date 2011-05-22 14:10
The whole landscape is stored as a huge two dimensional array where you can quickly get and set single pixels (to change the material from earth to tunnel, for example).

I can not say much about the drawing or the liquids, though - maybe someone else can explain that :)

(Our ultimate goal is to have polygon-based landscapes by the way. Those work a lot better with zooming and certain stuff (for physics))
Parent - - By zorry [de] Date 2011-05-22 14:20
I also thought about polygon based landscape, but i will have a lot of liquid, so this would lag very much ;)
Yea what i really need to know is how the "moving" materials work. like water and sand.
Parent - By B_E [de] Date 2011-05-22 15:57 Edited 2011-05-22 16:05
I think a main part of that (especially liquids) is done by the so-called "MassMover". I remember there was some kind of article or documentation about it somewhere, I'll see if I can find it.

[Edit]
Can't find it anymore, the best thing is probably to ask one of the engine-devs about the massmover and PXS.
Parent - - By Sven2 [de] Date 2011-05-22 16:19 Edited 2011-05-22 16:22
This is handled by the "MassMover". Whenever solid material is blast or shoveled away, the engine checks whether one of the new sky/tunnel pixels lies adjacent to liquid pixels. Any such liquid pixels that reach downwards or sidewards into air or tunnel materials are added to the MassMover list. Each frame, the MassMover checks for each of these border pixels, traverses upwards through the liquid body until it finds a "top" border pixel and moves that pixel directly to the bottom. If the moved pixel lies adjacent to sky or tunnel, it is again added to the MassMover to be processed next frame.

This method grows linearly in the number of border pixels. that's why flooding a small tunnel below an ocean is not a big issue. When huge oceans flood into huge caves, however, the framerate goes down.

PXS are loose, single pixels like rain or snow. They are not written into the landscape memory while they're moving (falling or sliding), but calculated and drawn from a separate list. When they reach the surface, they are converted into regular landscape pixels.

This means you cannot "swim" in rain pixels or be blocked by snow pixels, even if the precipitation is very dense.
Parent - By zorry [de] Date 2011-05-22 16:43
Thank you very much!
I think this is what i was looking for.
I will try it and respond after
Parent - By Caesar [de] Date 2011-05-22 17:40

>This means you cannot "swim" in rain pixels or be blocked by snow pixels, even if the precipitation is very dense.


And you can have dozens of PXS in one pixel which can cause liquid to appear magically.
Up Topic General / Help and Questions / Clonk Terrain / Fluid Engine

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill