├── bin ├── .placeholder ├── assets │ ├── icon.png │ ├── lava.png │ └── water.png ├── liquidsim.gdns ├── LiquidNode.tscn ├── plugin.cfg ├── liquidsim_plugin.gd └── liquidsim.gdnlib ├── demo-project ├── .import │ ├── .gdignore │ ├── 1.png-28d6e3d31e46c95f0dea1abf906c0f74.md5 │ ├── 10.png-1d22c7e2b2e0643046bfdea7d4f193b8.md5 │ ├── 11.png-b27bcfeed349865be1f4ad06a93be9b0.md5 │ ├── 12.png-7f42f1bf501e4812a8129d1b858f62b4.md5 │ ├── 13.png-d73d8fba20d4261afdb088213c9a5653.md5 │ ├── 14.png-7431a7bfacae5d226efddb57c12f2846.md5 │ ├── 15.png-77b65e261375c09ef3a6916a885179ff.md5 │ ├── 16.png-b15baa9c8ddc56dc991eac50f5a7bf8d.md5 │ ├── 17.png-e7bbb645ca8eb3ff88f23d3693cc8e19.md5 │ ├── 18.png-e1b039837f46990f006f4023cb722144.md5 │ ├── 2.png-3b4d648e04c4a84e8b8f6c622069553c.md5 │ ├── 3.png-ff3babb0d8b4fdc49e4a4961a679d180.md5 │ ├── 4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.md5 │ ├── 5.png-b386ff019a5e522d985ab44e8f6c88d9.md5 │ ├── 6.png-198374c974b513ba63a3c3a04767d57f.md5 │ ├── 7.png-c05a3ae5d4773ec299ac829d3b573b0d.md5 │ ├── 8.png-6620fba2fdcba673f1916598e67e05b7.md5 │ ├── 9.png-38c9f484173107bbcba945acc5851b07.md5 │ ├── blue.jpg-b041f2b9ef6fd8f55b9b617bc88bf2be.md5 │ ├── icon.png-3e675f6e897d9f0cc6068dd284a5ac25.md5 │ ├── icon.png-487276ed1e3a0c39cad0279d744ee560.md5 │ ├── lava.png-c12d1742681d6ba6e5032e92ea1568e8.md5 │ ├── stone.png-8c1f7be2f21757cdaab7a85691789596.md5 │ ├── texture.jpg-90af301ed61788c92151a600dcebc457.md5 │ ├── texture.jpg-f76fa60f15b8bb51d76fb02d6f6b72ba.md5 │ ├── water.png-06658c94651cac19ac58a28fd847c3b8.md5 │ ├── bricksx64.png-f83b655fa9715e27e885c0609d510d88.md5 │ ├── lightblue.png-091064026f714ddaebd010e3d6a5456f.md5 │ ├── stone_wall02.png-b4b81e3a898f65a459965e7b2fec40bc.md5 │ ├── 1.png-28d6e3d31e46c95f0dea1abf906c0f74.stex │ ├── 2.png-3b4d648e04c4a84e8b8f6c622069553c.stex │ ├── 3.png-ff3babb0d8b4fdc49e4a4961a679d180.stex │ ├── 4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.stex │ ├── 5.png-b386ff019a5e522d985ab44e8f6c88d9.stex │ ├── 6.png-198374c974b513ba63a3c3a04767d57f.stex │ ├── 7.png-c05a3ae5d4773ec299ac829d3b573b0d.stex │ ├── 8.png-6620fba2fdcba673f1916598e67e05b7.stex │ ├── 9.png-38c9f484173107bbcba945acc5851b07.stex │ ├── 10.png-1d22c7e2b2e0643046bfdea7d4f193b8.stex │ ├── 11.png-b27bcfeed349865be1f4ad06a93be9b0.stex │ ├── 12.png-7f42f1bf501e4812a8129d1b858f62b4.stex │ ├── 13.png-d73d8fba20d4261afdb088213c9a5653.stex │ ├── 14.png-7431a7bfacae5d226efddb57c12f2846.stex │ ├── 15.png-77b65e261375c09ef3a6916a885179ff.stex │ ├── 16.png-b15baa9c8ddc56dc991eac50f5a7bf8d.stex │ ├── 17.png-e7bbb645ca8eb3ff88f23d3693cc8e19.stex │ ├── 18.png-e1b039837f46990f006f4023cb722144.stex │ ├── blue.jpg-b041f2b9ef6fd8f55b9b617bc88bf2be.stex │ ├── icon.png-3e675f6e897d9f0cc6068dd284a5ac25.stex │ ├── icon.png-487276ed1e3a0c39cad0279d744ee560.stex │ ├── lava.png-c12d1742681d6ba6e5032e92ea1568e8.stex │ ├── stone.png-8c1f7be2f21757cdaab7a85691789596.stex │ ├── water.png-06658c94651cac19ac58a28fd847c3b8.stex │ ├── bricksx64.png-f83b655fa9715e27e885c0609d510d88.stex │ ├── lightblue.png-091064026f714ddaebd010e3d6a5456f.stex │ ├── texture.jpg-90af301ed61788c92151a600dcebc457.stex │ ├── texture.jpg-f76fa60f15b8bb51d76fb02d6f6b72ba.stex │ └── stone_wall02.png-b4b81e3a898f65a459965e7b2fec40bc.stex ├── addons │ └── liquidsim │ │ ├── .placeholder │ │ ├── assets │ │ ├── icon.png │ │ ├── lava.png │ │ ├── water.png │ │ ├── icon.png.import │ │ ├── lava.png.import │ │ └── water.png.import │ │ ├── liquidsim.gdns │ │ ├── LiquidNode.tscn │ │ ├── plugin.cfg │ │ ├── liquidsim_plugin.gd │ │ └── liquidsim.gdnlib ├── icon.png ├── textures │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 14.png │ ├── 15.png │ ├── 16.png │ ├── 17.png │ ├── 18.png │ ├── blue.jpg │ ├── stone.png │ ├── bricksx64.png │ ├── lightblue.png │ ├── stone_wall02.png │ ├── 1.png.import │ ├── 2.png.import │ ├── 3.png.import │ ├── 4.png.import │ ├── 5.png.import │ ├── 6.png.import │ ├── 7.png.import │ ├── 8.png.import │ ├── 9.png.import │ ├── 10.png.import │ ├── 11.png.import │ ├── 12.png.import │ ├── 13.png.import │ ├── 14.png.import │ ├── 15.png.import │ ├── 16.png.import │ ├── 17.png.import │ ├── 18.png.import │ ├── blue.jpg.import │ ├── stone.png.import │ ├── bricksx64.png.import │ ├── lightblue.png.import │ └── stone_wall02.png.import ├── default_env.tres ├── scripts │ └── TileMap.gd ├── icon.png.import ├── project.godot ├── export_presets.cfg └── scenes │ └── Node2D.tscn ├── docs ├── assets │ ├── icon.png │ ├── screen.png │ ├── activate_plugin.png │ ├── adjust_cell_size.png │ ├── add_plugin_to_tilemap.png │ └── added_liquidsim_node.png ├── .vuepress │ ├── public │ │ └── img │ │ │ ├── hero.png │ │ │ ├── icon.png │ │ │ └── icon1.png │ ├── styles │ │ ├── palette.styl │ │ └── index.styl │ └── config.js ├── game │ └── README.md ├── fr │ ├── game │ │ └── README.md │ ├── README.md │ └── guide │ │ └── README.md ├── es │ ├── game │ │ └── README.md │ ├── README.md │ └── guide │ │ └── README.md ├── README.md └── guide │ └── README.md ├── .gitmodules ├── .clang-format ├── src ├── utils.hpp ├── utils.cpp ├── entry.cpp ├── cell.hpp ├── liquidsim.hpp └── liquidsim.cpp ├── .gitignore ├── package.json ├── LICENSE ├── README.md └── SConstruct /bin/.placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo-project/.import/.gdignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/.placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/bin/assets/icon.png -------------------------------------------------------------------------------- /bin/assets/lava.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/bin/assets/lava.png -------------------------------------------------------------------------------- /bin/assets/water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/bin/assets/water.png -------------------------------------------------------------------------------- /demo-project/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/icon.png -------------------------------------------------------------------------------- /docs/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/assets/icon.png -------------------------------------------------------------------------------- /docs/assets/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/assets/screen.png -------------------------------------------------------------------------------- /demo-project/textures/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/1.png -------------------------------------------------------------------------------- /demo-project/textures/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/2.png -------------------------------------------------------------------------------- /demo-project/textures/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/3.png -------------------------------------------------------------------------------- /demo-project/textures/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/4.png -------------------------------------------------------------------------------- /demo-project/textures/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/5.png -------------------------------------------------------------------------------- /demo-project/textures/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/6.png -------------------------------------------------------------------------------- /demo-project/textures/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/7.png -------------------------------------------------------------------------------- /demo-project/textures/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/8.png -------------------------------------------------------------------------------- /demo-project/textures/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/9.png -------------------------------------------------------------------------------- /demo-project/textures/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/10.png -------------------------------------------------------------------------------- /demo-project/textures/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/11.png -------------------------------------------------------------------------------- /demo-project/textures/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/12.png -------------------------------------------------------------------------------- /demo-project/textures/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/13.png -------------------------------------------------------------------------------- /demo-project/textures/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/14.png -------------------------------------------------------------------------------- /demo-project/textures/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/15.png -------------------------------------------------------------------------------- /demo-project/textures/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/16.png -------------------------------------------------------------------------------- /demo-project/textures/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/17.png -------------------------------------------------------------------------------- /demo-project/textures/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/18.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "godot-cpp"] 2 | path = godot-cpp 3 | url = https://github.com/godotengine/godot-cpp 4 | branch = 3.x 5 | -------------------------------------------------------------------------------- /demo-project/textures/blue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/blue.jpg -------------------------------------------------------------------------------- /demo-project/textures/stone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/stone.png -------------------------------------------------------------------------------- /docs/assets/activate_plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/assets/activate_plugin.png -------------------------------------------------------------------------------- /docs/assets/adjust_cell_size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/assets/adjust_cell_size.png -------------------------------------------------------------------------------- /docs/.vuepress/public/img/hero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/.vuepress/public/img/hero.png -------------------------------------------------------------------------------- /docs/.vuepress/public/img/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/.vuepress/public/img/icon.png -------------------------------------------------------------------------------- /demo-project/textures/bricksx64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/bricksx64.png -------------------------------------------------------------------------------- /demo-project/textures/lightblue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/lightblue.png -------------------------------------------------------------------------------- /docs/.vuepress/public/img/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/.vuepress/public/img/icon1.png -------------------------------------------------------------------------------- /docs/assets/add_plugin_to_tilemap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/assets/add_plugin_to_tilemap.png -------------------------------------------------------------------------------- /docs/assets/added_liquidsim_node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/docs/assets/added_liquidsim_node.png -------------------------------------------------------------------------------- /demo-project/textures/stone_wall02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/textures/stone_wall02.png -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # We'll use defaults from the LLVM style, but with 4 columns indentation. 2 | BasedOnStyle: LLVM 3 | IndentWidth: 4 4 | UseTab: Never 5 | 6 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/addons/liquidsim/assets/icon.png -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/assets/lava.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/addons/liquidsim/assets/lava.png -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/assets/water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/addons/liquidsim/assets/water.png -------------------------------------------------------------------------------- /demo-project/.import/1.png-28d6e3d31e46c95f0dea1abf906c0f74.md5: -------------------------------------------------------------------------------- 1 | source_md5="161c16bbd3d0476365c6202637fc5505" 2 | dest_md5="15a177abb1ff433eb33a574dc132f960" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/10.png-1d22c7e2b2e0643046bfdea7d4f193b8.md5: -------------------------------------------------------------------------------- 1 | source_md5="24db44ddd98bd715022e21064c2e6c16" 2 | dest_md5="c67e2e50de4b2b1faac1bcc2f19e5a99" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/11.png-b27bcfeed349865be1f4ad06a93be9b0.md5: -------------------------------------------------------------------------------- 1 | source_md5="7927e0960514216187da597e40ef4409" 2 | dest_md5="37fc71705bccd6ce5c864823dd62d137" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/12.png-7f42f1bf501e4812a8129d1b858f62b4.md5: -------------------------------------------------------------------------------- 1 | source_md5="054aeddb085745f783a811ba5f443bef" 2 | dest_md5="e8b66b5c04d69d18004c533fd842d50a" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/13.png-d73d8fba20d4261afdb088213c9a5653.md5: -------------------------------------------------------------------------------- 1 | source_md5="34f835d66aaf961f40e11493693bd9c5" 2 | dest_md5="98ea991d753963d05998f657ccb1c1f5" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/14.png-7431a7bfacae5d226efddb57c12f2846.md5: -------------------------------------------------------------------------------- 1 | source_md5="01056e22a46b9c4fa07f82f2ee5f4bd4" 2 | dest_md5="ef7a566f25b404beed61eba6f8124b38" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/15.png-77b65e261375c09ef3a6916a885179ff.md5: -------------------------------------------------------------------------------- 1 | source_md5="34aa3d846637407f4e4f38ace7d83b5b" 2 | dest_md5="3951c1d1acf616656767714b64d5cfab" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/16.png-b15baa9c8ddc56dc991eac50f5a7bf8d.md5: -------------------------------------------------------------------------------- 1 | source_md5="fc4164107d062c56438df96f76b248ef" 2 | dest_md5="037cac9c7a28ead45c912bd3856eb01e" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/17.png-e7bbb645ca8eb3ff88f23d3693cc8e19.md5: -------------------------------------------------------------------------------- 1 | source_md5="2d6d3f3982c23c1baa2d7b3e79291c14" 2 | dest_md5="b0372680ce5c66977d0c5301fb393c43" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/18.png-e1b039837f46990f006f4023cb722144.md5: -------------------------------------------------------------------------------- 1 | source_md5="ee8e9debac2c68cb3fa4089ce5a949d3" 2 | dest_md5="08ceec8f939d76fb48355f57255d6b9a" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/2.png-3b4d648e04c4a84e8b8f6c622069553c.md5: -------------------------------------------------------------------------------- 1 | source_md5="e97a05500ad3d3570575d69e1694d516" 2 | dest_md5="a626bb7d5f34847767931d0c350b3611" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/3.png-ff3babb0d8b4fdc49e4a4961a679d180.md5: -------------------------------------------------------------------------------- 1 | source_md5="0b6a5f114535e33d7edc5dc9d4bb6a4a" 2 | dest_md5="a68d1ee2f643a8bc9323a1fc44d155e9" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.md5: -------------------------------------------------------------------------------- 1 | source_md5="312928664b91d0527a0da58faef73f3e" 2 | dest_md5="c90462587aac2e6ce01006af4bd779fc" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/5.png-b386ff019a5e522d985ab44e8f6c88d9.md5: -------------------------------------------------------------------------------- 1 | source_md5="9ff57f1bd177dee47f156b0c70c9f699" 2 | dest_md5="88402d94a45250cb064aa1b932c0c954" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/6.png-198374c974b513ba63a3c3a04767d57f.md5: -------------------------------------------------------------------------------- 1 | source_md5="3b015d293047d1f2260c3eb3ce711bec" 2 | dest_md5="bfe5bcd078d9bbd430f0b18211bb42f6" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/7.png-c05a3ae5d4773ec299ac829d3b573b0d.md5: -------------------------------------------------------------------------------- 1 | source_md5="ddf413abda902206ba4a8bb89b1875cd" 2 | dest_md5="9ba7ed852acab3087303cf08e9ad1c2d" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/8.png-6620fba2fdcba673f1916598e67e05b7.md5: -------------------------------------------------------------------------------- 1 | source_md5="5d8fe2deeb05f6f4ea7cb047282939bf" 2 | dest_md5="62e94524415a16f5c3900c402921b1f2" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/9.png-38c9f484173107bbcba945acc5851b07.md5: -------------------------------------------------------------------------------- 1 | source_md5="c6677ec0586251cc7a580b9231f44ae3" 2 | dest_md5="8cdbd4f76f4411fa0cb5b1450fb604e2" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/blue.jpg-b041f2b9ef6fd8f55b9b617bc88bf2be.md5: -------------------------------------------------------------------------------- 1 | source_md5="c8cd439da29c886f9da95ae15932acc8" 2 | dest_md5="307953f96bd32ba52a331136e81a95ab" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/icon.png-3e675f6e897d9f0cc6068dd284a5ac25.md5: -------------------------------------------------------------------------------- 1 | source_md5="deae384bcc1c344fda521063b8bc495c" 2 | dest_md5="d654e79778112fc455cb817dad6a73a6" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5: -------------------------------------------------------------------------------- 1 | source_md5="76751b5d37363785613ca50643268987" 2 | dest_md5="785291c6bf3c7cec5fccf42d7efeaaf9" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/lava.png-c12d1742681d6ba6e5032e92ea1568e8.md5: -------------------------------------------------------------------------------- 1 | source_md5="6cd1288882fc7b212781141f6249da3f" 2 | dest_md5="fc2f83e962dca2532281c5c6de00f6f9" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/stone.png-8c1f7be2f21757cdaab7a85691789596.md5: -------------------------------------------------------------------------------- 1 | source_md5="8be4dc864ae9529abe627966f6db7d5b" 2 | dest_md5="ad534a269bf802e2bed3fcaf04e24c11" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/texture.jpg-90af301ed61788c92151a600dcebc457.md5: -------------------------------------------------------------------------------- 1 | source_md5="c8cd439da29c886f9da95ae15932acc8" 2 | dest_md5="1789b6d215cf5d96c4b74385cf4406bb" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/texture.jpg-f76fa60f15b8bb51d76fb02d6f6b72ba.md5: -------------------------------------------------------------------------------- 1 | source_md5="c8cd439da29c886f9da95ae15932acc8" 2 | dest_md5="307953f96bd32ba52a331136e81a95ab" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/water.png-06658c94651cac19ac58a28fd847c3b8.md5: -------------------------------------------------------------------------------- 1 | source_md5="3ae62d48669f5acc86fcd0c5aba529fe" 2 | dest_md5="323a32c3ea0a84a621609deb95c32845" 3 | 4 | -------------------------------------------------------------------------------- /src/utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LIQUIDSIM_UTILS_H 2 | #define LIQUIDSIM_UTILS_H 3 | 4 | float lerp(float a, float b, float f); 5 | int hash_position(int x, int y); 6 | 7 | #endif -------------------------------------------------------------------------------- /demo-project/.import/bricksx64.png-f83b655fa9715e27e885c0609d510d88.md5: -------------------------------------------------------------------------------- 1 | source_md5="9f48372af45811ece4e96970a15d8c82" 2 | dest_md5="c979ad59f6e55804a945a85ec35e1649" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/lightblue.png-091064026f714ddaebd010e3d6a5456f.md5: -------------------------------------------------------------------------------- 1 | source_md5="cd781a0387ca6f6bd3c53a26ff99a36a" 2 | dest_md5="1c7f9237224b4afda2e76da1ca258085" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/stone_wall02.png-b4b81e3a898f65a459965e7b2fec40bc.md5: -------------------------------------------------------------------------------- 1 | source_md5="66674ddfba9b5e3a0e81d8b9015b44ff" 2 | dest_md5="88acf819341f73ec61a9b39f965017ea" 3 | 4 | -------------------------------------------------------------------------------- /demo-project/.import/1.png-28d6e3d31e46c95f0dea1abf906c0f74.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/1.png-28d6e3d31e46c95f0dea1abf906c0f74.stex -------------------------------------------------------------------------------- /demo-project/.import/2.png-3b4d648e04c4a84e8b8f6c622069553c.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/2.png-3b4d648e04c4a84e8b8f6c622069553c.stex -------------------------------------------------------------------------------- /demo-project/.import/3.png-ff3babb0d8b4fdc49e4a4961a679d180.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/3.png-ff3babb0d8b4fdc49e4a4961a679d180.stex -------------------------------------------------------------------------------- /demo-project/.import/4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.stex -------------------------------------------------------------------------------- /demo-project/.import/5.png-b386ff019a5e522d985ab44e8f6c88d9.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/5.png-b386ff019a5e522d985ab44e8f6c88d9.stex -------------------------------------------------------------------------------- /demo-project/.import/6.png-198374c974b513ba63a3c3a04767d57f.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/6.png-198374c974b513ba63a3c3a04767d57f.stex -------------------------------------------------------------------------------- /demo-project/.import/7.png-c05a3ae5d4773ec299ac829d3b573b0d.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/7.png-c05a3ae5d4773ec299ac829d3b573b0d.stex -------------------------------------------------------------------------------- /demo-project/.import/8.png-6620fba2fdcba673f1916598e67e05b7.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/8.png-6620fba2fdcba673f1916598e67e05b7.stex -------------------------------------------------------------------------------- /demo-project/.import/9.png-38c9f484173107bbcba945acc5851b07.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/9.png-38c9f484173107bbcba945acc5851b07.stex -------------------------------------------------------------------------------- /demo-project/.import/10.png-1d22c7e2b2e0643046bfdea7d4f193b8.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/10.png-1d22c7e2b2e0643046bfdea7d4f193b8.stex -------------------------------------------------------------------------------- /demo-project/.import/11.png-b27bcfeed349865be1f4ad06a93be9b0.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/11.png-b27bcfeed349865be1f4ad06a93be9b0.stex -------------------------------------------------------------------------------- /demo-project/.import/12.png-7f42f1bf501e4812a8129d1b858f62b4.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/12.png-7f42f1bf501e4812a8129d1b858f62b4.stex -------------------------------------------------------------------------------- /demo-project/.import/13.png-d73d8fba20d4261afdb088213c9a5653.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/13.png-d73d8fba20d4261afdb088213c9a5653.stex -------------------------------------------------------------------------------- /demo-project/.import/14.png-7431a7bfacae5d226efddb57c12f2846.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/14.png-7431a7bfacae5d226efddb57c12f2846.stex -------------------------------------------------------------------------------- /demo-project/.import/15.png-77b65e261375c09ef3a6916a885179ff.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/15.png-77b65e261375c09ef3a6916a885179ff.stex -------------------------------------------------------------------------------- /demo-project/.import/16.png-b15baa9c8ddc56dc991eac50f5a7bf8d.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/16.png-b15baa9c8ddc56dc991eac50f5a7bf8d.stex -------------------------------------------------------------------------------- /demo-project/.import/17.png-e7bbb645ca8eb3ff88f23d3693cc8e19.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/17.png-e7bbb645ca8eb3ff88f23d3693cc8e19.stex -------------------------------------------------------------------------------- /demo-project/.import/18.png-e1b039837f46990f006f4023cb722144.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/18.png-e1b039837f46990f006f4023cb722144.stex -------------------------------------------------------------------------------- /demo-project/.import/blue.jpg-b041f2b9ef6fd8f55b9b617bc88bf2be.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/blue.jpg-b041f2b9ef6fd8f55b9b617bc88bf2be.stex -------------------------------------------------------------------------------- /demo-project/.import/icon.png-3e675f6e897d9f0cc6068dd284a5ac25.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/icon.png-3e675f6e897d9f0cc6068dd284a5ac25.stex -------------------------------------------------------------------------------- /demo-project/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex -------------------------------------------------------------------------------- /demo-project/.import/lava.png-c12d1742681d6ba6e5032e92ea1568e8.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/lava.png-c12d1742681d6ba6e5032e92ea1568e8.stex -------------------------------------------------------------------------------- /demo-project/.import/stone.png-8c1f7be2f21757cdaab7a85691789596.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/stone.png-8c1f7be2f21757cdaab7a85691789596.stex -------------------------------------------------------------------------------- /demo-project/.import/water.png-06658c94651cac19ac58a28fd847c3b8.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/water.png-06658c94651cac19ac58a28fd847c3b8.stex -------------------------------------------------------------------------------- /demo-project/.import/bricksx64.png-f83b655fa9715e27e885c0609d510d88.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/bricksx64.png-f83b655fa9715e27e885c0609d510d88.stex -------------------------------------------------------------------------------- /demo-project/.import/lightblue.png-091064026f714ddaebd010e3d6a5456f.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/lightblue.png-091064026f714ddaebd010e3d6a5456f.stex -------------------------------------------------------------------------------- /demo-project/.import/texture.jpg-90af301ed61788c92151a600dcebc457.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/texture.jpg-90af301ed61788c92151a600dcebc457.stex -------------------------------------------------------------------------------- /demo-project/.import/texture.jpg-f76fa60f15b8bb51d76fb02d6f6b72ba.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/texture.jpg-f76fa60f15b8bb51d76fb02d6f6b72ba.stex -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | src/*.os 2 | demo-project/addons/liquidsim/lib 3 | *.dylib 4 | *.so 5 | *.bc 6 | *.dll 7 | *.wasm 8 | .sconsign.dblite 9 | .vscode 10 | node_modules 11 | .temp 12 | dist 13 | yarn-error.log 14 | bin_game -------------------------------------------------------------------------------- /demo-project/.import/stone_wall02.png-b4b81e3a898f65a459965e7b2fec40bc.stex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tterrasson/liquid-simulator-godot/HEAD/demo-project/.import/stone_wall02.png-b4b81e3a898f65a459965e7b2fec40bc.stex -------------------------------------------------------------------------------- /demo-project/default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | [resource] 6 | background_mode = 2 7 | background_sky = SubResource( 1 ) 8 | -------------------------------------------------------------------------------- /bin/liquidsim.gdns: -------------------------------------------------------------------------------- 1 | [gd_resource type="NativeScript" load_steps=2 format=2] 2 | 3 | [ext_resource path="res://addons/liquidsim/liquidsim.gdnlib" type="GDNativeLibrary" id=1] 4 | 5 | [resource] 6 | class_name = "LiquidSim" 7 | library = ExtResource( 1 ) 8 | -------------------------------------------------------------------------------- /docs/game/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: false 3 | --- 4 | 5 | # Demo Liquid Simulator Godot "LiquidSim". 6 | 7 | 8 | -------------------------------------------------------------------------------- /bin/LiquidNode.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://addons/liquidsim/assets/water.png" type="Texture" id=1] 4 | 5 | [node name="Node2D" type="Node2D"] 6 | 7 | [node name="Sprite" type="Sprite" parent="."] 8 | texture = ExtResource( 1 ) 9 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/liquidsim.gdns: -------------------------------------------------------------------------------- 1 | [gd_resource type="NativeScript" load_steps=2 format=2] 2 | 3 | [ext_resource path="res://addons/liquidsim/liquidsim.gdnlib" type="GDNativeLibrary" id=1] 4 | 5 | [resource] 6 | class_name = "LiquidSim" 7 | library = ExtResource( 1 ) 8 | -------------------------------------------------------------------------------- /docs/fr/game/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: false 3 | --- 4 | 5 | # Démo de Liquid Simulator pour Godot "LiquidSim". 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/es/game/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: false 3 | --- 4 | 5 | # Demo de Simulador de Liquidos para Godot "LiquidSim". 6 | 7 | 8 | -------------------------------------------------------------------------------- /bin/plugin.cfg: -------------------------------------------------------------------------------- 1 | [plugin] 2 | 3 | name = "LiquidSim" 4 | description = "2D Liquid simulator with cellular automaton in Godot Engine (GDNative / C++) - NativeScript 1.1" 5 | author = "Thibault Terrasson with the collaboration of wladimir perez" 6 | version = "1.0" 7 | script = "liquidsim_plugin.gd" 8 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/LiquidNode.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://addons/liquidsim/assets/water.png" type="Texture" id=1] 4 | 5 | [node name="Node2D" type="Node2D"] 6 | 7 | [node name="Sprite" type="Sprite" parent="."] 8 | texture = ExtResource( 1 ) 9 | -------------------------------------------------------------------------------- /bin/liquidsim_plugin.gd: -------------------------------------------------------------------------------- 1 | 2 | tool 3 | extends EditorPlugin 4 | 5 | func _enter_tree(): 6 | add_custom_type("LiquidSim", "Node", preload("res://addons/liquidsim/liquidsim.gdns"), preload("res://addons/liquidsim/assets/icon.png")) 7 | 8 | func _exit_tree(): 9 | remove_custom_type("LiquidSim") 10 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/plugin.cfg: -------------------------------------------------------------------------------- 1 | [plugin] 2 | 3 | name = "LiquidSim" 4 | description = "2D Liquid simulator with cellular automaton in Godot Engine (GDNative / C++) - NativeScript 1.1" 5 | author = "Thibault Terrasson with the collaboration of wladimir perez" 6 | version = "1.0" 7 | script = "liquidsim_plugin.gd" 8 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/liquidsim_plugin.gd: -------------------------------------------------------------------------------- 1 | 2 | tool 3 | extends EditorPlugin 4 | 5 | func _enter_tree(): 6 | add_custom_type("LiquidSim", "Node", preload("res://addons/liquidsim/liquidsim.gdns"), preload("res://addons/liquidsim/assets/icon.png")) 7 | 8 | func _exit_tree(): 9 | remove_custom_type("LiquidSim") 10 | -------------------------------------------------------------------------------- /docs/.vuepress/styles/palette.styl: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom palette here. 3 | * 4 | * ref:https://v1.vuepress.vuejs.org/zh/config/#palette-styl 5 | */ 6 | 7 | $bgColor = #192229 8 | $navbarColor = #212e36 9 | $accentColor = #007bdf 10 | $textColor = #b7c1c8 11 | $textColor2 = #5f6d77 12 | $borderColor = #273b49 13 | $codeBgColor = #282c34 14 | $themeColor = #007bdf 15 | $tipColor = #485158 16 | $warningColor = #e7c000 17 | -------------------------------------------------------------------------------- /src/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.hpp" 2 | 3 | // Linear interpolation 4 | // Not provided by GDNative 5 | float lerp(float a, float b, float f) { return a + f * (b - a); } 6 | 7 | // Create a unique integer from x/y positions 8 | int hash_position(int x, int y) { 9 | int xx = x >= 0 ? x * 2 : x * -2 - 1; 10 | int yy = y >= 0 ? y * 2 : y * -2 - 1; 11 | return (xx >= yy) ? (xx * xx + xx + yy) : (yy * yy + xx); 12 | } -------------------------------------------------------------------------------- /src/entry.cpp: -------------------------------------------------------------------------------- 1 | #include "liquidsim.hpp" 2 | 3 | extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { 4 | godot::Godot::gdnative_init(o); 5 | } 6 | 7 | extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) { 8 | godot::Godot::gdnative_terminate(o); 9 | } 10 | 11 | extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) { 12 | godot::Godot::nativescript_init(handle); 13 | godot::register_class(); 14 | } 15 | -------------------------------------------------------------------------------- /bin/liquidsim.gdnlib: -------------------------------------------------------------------------------- 1 | [general] 2 | 3 | singleton=false 4 | load_once=true 5 | symbol_prefix="godot_" 6 | reloadable=false 7 | 8 | [entry] 9 | 10 | Android.armeabi-v7a="res://addons/liquidsim/lib/libliquidsim.so" 11 | HTML5.wasm32="res://addons/liquidsim/lib/libliquidsim.wasm" 12 | OSX.64="res://addons/liquidsim/lib/libliquidsim.dylib" 13 | Windows.64="res://addons/liquidsim/lib/libliquidsim.dll" 14 | X11.64="res://addons/liquidsim/lib/libliquidsim.so" 15 | 16 | [dependencies] 17 | 18 | Android.armeabi-v7a=[ ] 19 | HTML5.wasm32=[ ] 20 | OSX.64=[ ] 21 | Windows.64=[ ] 22 | X11.64=[ ] -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/liquidsim.gdnlib: -------------------------------------------------------------------------------- 1 | [general] 2 | 3 | singleton=false 4 | load_once=true 5 | symbol_prefix="godot_" 6 | reloadable=false 7 | 8 | [entry] 9 | 10 | Android.armeabi-v7a="res://addons/liquidsim/lib/libliquidsim.so" 11 | HTML5.wasm32="res://addons/liquidsim/lib/libliquidsim.wasm" 12 | OSX.64="res://addons/liquidsim/lib/libliquidsim.dylib" 13 | Windows.64="res://addons/liquidsim/lib/libliquidsim.dll" 14 | X11.64="res://addons/liquidsim/lib/libliquidsim.so" 15 | 16 | [dependencies] 17 | 18 | Android.armeabi-v7a=[ ] 19 | HTML5.wasm32=[ ] 20 | OSX.64=[ ] 21 | Windows.64=[ ] 22 | X11.64=[ ] 23 | -------------------------------------------------------------------------------- /docs/.vuepress/styles/index.styl: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom Styles here. 3 | * 4 | * ref:https://v1.vuepress.vuejs.org/config/#index-styl 5 | */ 6 | 7 | html, body 8 | background-color: $bgColor 9 | 10 | .navbar 11 | background-color: $navbarColor 12 | .links 13 | background-color: $navbarColor!important 14 | 15 | .search-box input 16 | color: $textColor2!important 17 | 18 | .sidebar 19 | background-color: $bgColor 20 | 21 | .home .hero img 22 | max-width: 300px!important 23 | 24 | .custom-block.tip 25 | color: $tipColor!important 26 | 27 | .custom-block.warning 28 | color: $warningColor!important 29 | -------------------------------------------------------------------------------- /demo-project/scripts/TileMap.gd: -------------------------------------------------------------------------------- 1 | extends TileMap 2 | 3 | 4 | # Declare member variables here. Examples: 5 | # var a = 2 6 | # var b = "text" 7 | 8 | 9 | # Called when the node enters the scene tree for the first time. 10 | func _ready(): 11 | $LiquidSim.set_liquid(15, -1, 5.0) 12 | 13 | 14 | # Called every frame. 'delta' is the elapsed time since the previous frame. 15 | #func _process(delta): 16 | # pass 17 | 18 | 19 | func _input(event): 20 | # Mouse in viewport coordinates 21 | if event is InputEventMouseButton: 22 | var wpos = world_to_map(get_global_mouse_position()) 23 | $LiquidSim.add_liquid(wpos.x, wpos.y, 5.0) 24 | -------------------------------------------------------------------------------- /demo-project/textures/1.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/1.png-28d6e3d31e46c95f0dea1abf906c0f74.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/1.png" 13 | dest_files=[ "res://.import/1.png-28d6e3d31e46c95f0dea1abf906c0f74.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/2.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/2.png-3b4d648e04c4a84e8b8f6c622069553c.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/2.png" 13 | dest_files=[ "res://.import/2.png-3b4d648e04c4a84e8b8f6c622069553c.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/3.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/3.png-ff3babb0d8b4fdc49e4a4961a679d180.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/3.png" 13 | dest_files=[ "res://.import/3.png-ff3babb0d8b4fdc49e4a4961a679d180.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/4.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/4.png" 13 | dest_files=[ "res://.import/4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/5.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/5.png-b386ff019a5e522d985ab44e8f6c88d9.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/5.png" 13 | dest_files=[ "res://.import/5.png-b386ff019a5e522d985ab44e8f6c88d9.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/6.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/6.png-198374c974b513ba63a3c3a04767d57f.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/6.png" 13 | dest_files=[ "res://.import/6.png-198374c974b513ba63a3c3a04767d57f.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/7.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/7.png-c05a3ae5d4773ec299ac829d3b573b0d.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/7.png" 13 | dest_files=[ "res://.import/7.png-c05a3ae5d4773ec299ac829d3b573b0d.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/8.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/8.png-6620fba2fdcba673f1916598e67e05b7.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/8.png" 13 | dest_files=[ "res://.import/8.png-6620fba2fdcba673f1916598e67e05b7.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/9.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/9.png-38c9f484173107bbcba945acc5851b07.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/9.png" 13 | dest_files=[ "res://.import/9.png-38c9f484173107bbcba945acc5851b07.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/10.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/10.png-1d22c7e2b2e0643046bfdea7d4f193b8.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/10.png" 13 | dest_files=[ "res://.import/10.png-1d22c7e2b2e0643046bfdea7d4f193b8.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/11.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/11.png-b27bcfeed349865be1f4ad06a93be9b0.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/11.png" 13 | dest_files=[ "res://.import/11.png-b27bcfeed349865be1f4ad06a93be9b0.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/12.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/12.png-7f42f1bf501e4812a8129d1b858f62b4.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/12.png" 13 | dest_files=[ "res://.import/12.png-7f42f1bf501e4812a8129d1b858f62b4.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/13.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/13.png-d73d8fba20d4261afdb088213c9a5653.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/13.png" 13 | dest_files=[ "res://.import/13.png-d73d8fba20d4261afdb088213c9a5653.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/14.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/14.png-7431a7bfacae5d226efddb57c12f2846.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/14.png" 13 | dest_files=[ "res://.import/14.png-7431a7bfacae5d226efddb57c12f2846.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/15.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/15.png-77b65e261375c09ef3a6916a885179ff.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/15.png" 13 | dest_files=[ "res://.import/15.png-77b65e261375c09ef3a6916a885179ff.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/16.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/16.png-b15baa9c8ddc56dc991eac50f5a7bf8d.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/16.png" 13 | dest_files=[ "res://.import/16.png-b15baa9c8ddc56dc991eac50f5a7bf8d.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/17.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/17.png-e7bbb645ca8eb3ff88f23d3693cc8e19.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/17.png" 13 | dest_files=[ "res://.import/17.png-e7bbb645ca8eb3ff88f23d3693cc8e19.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/18.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/18.png-e1b039837f46990f006f4023cb722144.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/18.png" 13 | dest_files=[ "res://.import/18.png-e1b039837f46990f006f4023cb722144.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/blue.jpg.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/blue.jpg-b041f2b9ef6fd8f55b9b617bc88bf2be.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/blue.jpg" 13 | dest_files=[ "res://.import/blue.jpg-b041f2b9ef6fd8f55b9b617bc88bf2be.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/stone.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/stone.png-8c1f7be2f21757cdaab7a85691789596.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/stone.png" 13 | dest_files=[ "res://.import/stone.png-8c1f7be2f21757cdaab7a85691789596.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | process/normal_map_invert_y=false 32 | stream=false 33 | size_limit=0 34 | detect_3d=true 35 | svg/scale=1.0 36 | -------------------------------------------------------------------------------- /demo-project/textures/bricksx64.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/bricksx64.png-f83b655fa9715e27e885c0609d510d88.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/bricksx64.png" 13 | dest_files=[ "res://.import/bricksx64.png-f83b655fa9715e27e885c0609d510d88.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/textures/lightblue.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/lightblue.png-091064026f714ddaebd010e3d6a5456f.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/lightblue.png" 13 | dest_files=[ "res://.import/lightblue.png-091064026f714ddaebd010e3d6a5456f.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | _global_script_classes=[ ] 12 | _global_script_class_icons={ 13 | } 14 | 15 | [application] 16 | 17 | config/name="Liquid Demo Project" 18 | run/main_scene="res://scenes/Node2D.tscn" 19 | boot_splash/image="res://icon.png" 20 | boot_splash/fullsize=false 21 | config/icon="res://icon.png" 22 | 23 | [display] 24 | 25 | window/stretch/mode="viewport" 26 | 27 | [editor_plugins] 28 | 29 | enabled=PoolStringArray( "res://addons/liquidsim/plugin.cfg" ) 30 | 31 | [rendering] 32 | 33 | environment/default_environment="res://default_env.tres" 34 | -------------------------------------------------------------------------------- /demo-project/textures/stone_wall02.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/stone_wall02.png-b4b81e3a898f65a459965e7b2fec40bc.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://textures/stone_wall02.png" 13 | dest_files=[ "res://.import/stone_wall02.png-b4b81e3a898f65a459965e7b2fec40bc.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/assets/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-3e675f6e897d9f0cc6068dd284a5ac25.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/liquidsim/assets/icon.png" 13 | dest_files=[ "res://.import/icon.png-3e675f6e897d9f0cc6068dd284a5ac25.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | process/normal_map_invert_y=false 32 | stream=false 33 | size_limit=0 34 | detect_3d=true 35 | svg/scale=1.0 36 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/assets/lava.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/lava.png-c12d1742681d6ba6e5032e92ea1568e8.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/liquidsim/assets/lava.png" 13 | dest_files=[ "res://.import/lava.png-c12d1742681d6ba6e5032e92ea1568e8.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | process/normal_map_invert_y=false 32 | stream=false 33 | size_limit=0 34 | detect_3d=true 35 | svg/scale=1.0 36 | -------------------------------------------------------------------------------- /demo-project/addons/liquidsim/assets/water.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/water.png-06658c94651cac19ac58a28fd847c3b8.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/liquidsim/assets/water.png" 13 | dest_files=[ "res://.import/water.png-06658c94651cac19ac58a28fd847c3b8.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | process/normal_map_invert_y=false 32 | stream=false 33 | size_limit=0 34 | detect_3d=true 35 | svg/scale=1.0 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "liquidsim", 3 | "version": "1.0.0", 4 | "description": "2D Liquid simulator with cellular automaton in Godot Engine (GDNative / C++) - NativeScript 1.1", 5 | "descriptionES": "Simulador 2D de Liquido con autómata celular en Godot Engine (GDNative / C++) - NativeScript 1.1", 6 | "descriptionFR": "Simulateur 2D de liquide avec automate cellulaire dans Godot Engine (GDNative / C++) - NativeScript 1.1", 7 | "repository": { 8 | "type": "git", 9 | "url": "aj-wi/liquid-simulator-godot" 10 | }, 11 | "license": "MIT", 12 | "author": "AJ-Wi", 13 | "scripts": { 14 | "build": "vuepress build docs", 15 | "dev": "vuepress dev docs", 16 | "deploy": "gh-pages -d docs/.vuepress/dist", 17 | "godot": "../Godot/Godot_v3.4.4-stable_x11.64 -e --path ./demo-project" 18 | }, 19 | "keywords": [ 20 | "liquidsim" 21 | ], 22 | "devDependencies": { 23 | "gh-pages": "^4.0.0", 24 | "vuepress": "^1.9.7" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | home: true 3 | heroImage: img/hero.png 4 | actionText: how to install → 5 | actionLink: /guide/ 6 | --- 7 | 8 |
9 |
10 |

Simplicity First

11 |

Simple installation, minimal configuration, ideal for you to only focus on the development of your game.

12 |
13 |
14 |

Demonstration

15 | 16 |
17 |
18 |

Performant

19 |

Developed in (GDNative / C++) - NativeScript 1.1, resulting in better plugin performance when running your game.

20 |
21 |
22 | 23 | ::: slot footer 24 | MIT Licensed | Copyright © 2022-present [AJ-Wi](https://github.com/AJ-Wi) | [tterrasson](https://github.com/tterrasson) 25 | ::: 26 | -------------------------------------------------------------------------------- /docs/es/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | home: true 3 | heroImage: ../img/hero.png 4 | actionText: Cómo instalar → 5 | actionLink: /guide/ 6 | --- 7 | 8 |
9 |
10 |

Simplicidad.

11 |

Instalación sencilla, configuración mínima, ideal para que solo te centres en el desarrollo de tu juego.

12 |
13 |
14 |

Demonstración

15 | 16 |
17 |
18 |

Performant

19 |

Desarrollado en (GDNative / C ++) - NativeScript 1.1, lo que resulta en un mejor rendimiento del complemento cuando ejecuta su juego.

20 |
21 |
22 | 23 | ::: slot footer 24 | Licencia MIT | Copyright © 2022-presente [AJ-Wi](https://github.com/AJ-Wi) | [tterrasson](https://github.com/tterrasson) 25 | ::: 26 | -------------------------------------------------------------------------------- /docs/fr/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | home: true 3 | heroImage: ../img/hero.png 4 | actionText: Comment installer → 5 | actionLink: /guide/ 6 | --- 7 | 8 |
9 |
10 |

simplicité.

11 |

Installation simple, configuration minimale, idéal pour vous concentrer uniquement sur le développement de votre jeu.

12 |
13 |
14 |

Manifestation

15 | 16 |
17 |
18 |

Performant

19 |

Développé en (GDNative/C++) - NativeScript 1.1, ce qui améliore les performances du plug-in lors de l'exécution de votre jeu.

20 |
21 |
22 | 23 | ::: slot footer 24 | Licence MIT | Copyright © 2022-Cadeau [AJ-Wi](https://github.com/AJ-Wi) | [tterrasson](https://github.com/tterrasson) 25 | ::: 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2020 Thibault Terrasson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/cell.hpp: -------------------------------------------------------------------------------- 1 | /* Cell */ 2 | 3 | #ifndef LIQUIDSIM_CELL_H 4 | #define LIQUIDSIM_CELL_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "utils.hpp" 12 | 13 | class Cell { 14 | public: 15 | int uid; 16 | int x; 17 | int y; 18 | float liquid_amount; 19 | float new_liquid_amount; // Used during computation 20 | godot::Node2D *node; 21 | godot::Sprite *sprite_node; 22 | bool dir_bottom; 23 | int iteration_since_last_change; 24 | 25 | Cell(godot::Node2D *node_ptr, int pos_x, int pos_y, float amount, float width, float height) { 26 | x = pos_x; 27 | y = pos_y; 28 | node = node_ptr; 29 | liquid_amount = amount; 30 | new_liquid_amount = amount; 31 | sprite_node = 32 | godot::Object::cast_to(node->get_node("Sprite")); 33 | // get the width and height of the texture 34 | float texture_width = sprite_node->get_texture()->get_width(); 35 | float texture_height = sprite_node->get_texture()->get_height(); 36 | // we scale the texture to the size of the tilemap cells 37 | sprite_node->set_scale(godot::Vector2(width / texture_width, height / texture_height)); 38 | // we position the sprite in the center of each cell of the tilemap 39 | sprite_node->set_position(godot::Vector2(width / 2.0f, height / 2.0f)); 40 | dir_bottom = false; 41 | uid = hash_position(pos_x, pos_y); 42 | iteration_since_last_change = 0; 43 | } 44 | }; 45 | 46 | #endif -------------------------------------------------------------------------------- /demo-project/export_presets.cfg: -------------------------------------------------------------------------------- 1 | [preset.0] 2 | 3 | name="HTML5" 4 | platform="HTML5" 5 | runnable=true 6 | custom_features="" 7 | export_filter="all_resources" 8 | include_filter="" 9 | exclude_filter="" 10 | export_path="../bin_game/html5/index.html" 11 | script_export_mode=1 12 | script_encryption_key="" 13 | 14 | [preset.0.options] 15 | 16 | custom_template/debug="" 17 | custom_template/release="" 18 | variant/export_type=2 19 | vram_texture_compression/for_desktop=true 20 | vram_texture_compression/for_mobile=false 21 | html/export_icon=true 22 | html/custom_html_shell="" 23 | html/head_include="" 24 | html/canvas_resize_policy=2 25 | html/focus_canvas_on_start=true 26 | html/experimental_virtual_keyboard=false 27 | progressive_web_app/enabled=false 28 | progressive_web_app/offline_page="" 29 | progressive_web_app/display=1 30 | progressive_web_app/orientation=0 31 | progressive_web_app/icon_144x144="" 32 | progressive_web_app/icon_180x180="" 33 | progressive_web_app/icon_512x512="" 34 | progressive_web_app/background_color=Color( 0, 0, 0, 1 ) 35 | 36 | [preset.1] 37 | 38 | name="Linux/X11" 39 | platform="Linux/X11" 40 | runnable=true 41 | custom_features="" 42 | export_filter="all_resources" 43 | include_filter="" 44 | exclude_filter="" 45 | export_path="../bin_game/linux/demo_project.x86_64" 46 | script_export_mode=1 47 | script_encryption_key="" 48 | 49 | [preset.1.options] 50 | 51 | custom_template/debug="" 52 | custom_template/release="" 53 | binary_format/64_bits=true 54 | binary_format/embed_pck=false 55 | texture_format/bptc=false 56 | texture_format/s3tc=true 57 | texture_format/etc=false 58 | texture_format/etc2=false 59 | texture_format/no_bptc_fallbacks=true 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Hello, welcome to AJ-Wi the space where we learn together** 2 | 3 |
4 | 5 | # LiquidSim 6 | 7 |
8 | 9 | 10 | 11 | ## 2D Liquid simulator with cellular automaton in Godot Engine (GDNative / C++) - NativeScript 1.1 12 | 13 | ## prerequisites 14 | 15 | - Godot 3.x executable 16 | 17 | - C++ compiler 18 | 19 | - SCons as a build tool 20 | 21 | - emcc compiler 22 |
23 | 24 | ## API 25 | 26 | `$LiquidSim.start()` : Start the simulation (started by default) 27 | 28 | `$LiquidSim.stop()` : Stop the simulation 29 | 30 | `$LiquidSim.update_simulation()` : Force an update 31 | 32 | `$LiquidSim.cleanup_empty_cells()` : Cleanup all empty cell (automatic) 33 | 34 | `$LiquidSim.add_liquid(int x, int y, float amount)` : Add some liquid to the cell 35 | 36 | `$LiquidSim.del_liquid(int x, int y)` : Empty a cell 37 | 38 | `$LiquidSim.set_liquid(int x, int y, float amount)` : Set a fixed amount of liquid to the cell 39 | 40 | `$LiquidSim.get_liquid(int x, int y) float` : Return the amount of liquid for the cell 41 | 42 |
43 | 44 |
45 | 46 | 47 | 48 | 49 | 50 |
51 | 52 | ### Original repository 53 | 54 | ```sh 55 | $ git clone --recurse-submodules https://github.com/tterrasson/liquid-simulator-godot 56 | ``` 57 | 58 | ## **For more details, see ["Using the Guide"](https://aj-wi.github.io/liquid-simulator-godot/)** 59 | 60 |
61 |
62 | 63 | **Remember We can all code, but together we can learn** 64 | -------------------------------------------------------------------------------- /src/liquidsim.hpp: -------------------------------------------------------------------------------- 1 | /* Liquid Simulation */ 2 | 3 | #ifndef LIQUIDSIM_H 4 | #define LIQUIDSIM_H 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "cell.hpp" 17 | 18 | namespace godot { 19 | class LiquidSim : public Node2D { 20 | GODOT_CLASS(LiquidSim, Node2D) 21 | 22 | private: 23 | int iteration; 24 | float time_passed; 25 | float refresh_rate; 26 | float max_liquid_value; 27 | float min_liquid_value; 28 | float max_liquid_compression; 29 | float max_flow_value; 30 | float min_flow_value; 31 | float flow_speed; 32 | float sprite_width; // we declare the variables to obtain 33 | float sprite_height; // the width and height of the tilemap cells 34 | 35 | float total_liquid_amount; 36 | 37 | TileMap *world; 38 | std::vector cells; 39 | std::unordered_map cells_positions; 40 | 41 | Ref liquid_scene; 42 | int hash_cell_position(int x, int y); 43 | Cell *get_cell_by_position(int x, int y); 44 | Cell *create_cell(int x, int y, float amount); 45 | float get_vertical_flow_value(float src_liquid_amount, 46 | float dst_liquid_amount); 47 | void refresh_cell_sprite(Cell *cell); 48 | void refresh_all(); 49 | 50 | public: 51 | bool started = false; 52 | static void _register_methods(); 53 | 54 | LiquidSim(); 55 | ~LiquidSim(); 56 | 57 | void _init(); // our initializer called by Godot 58 | 59 | void _ready(); 60 | void _process(float delta); 61 | 62 | void start(); 63 | void stop(); 64 | void clear(); 65 | void update_simulation(); 66 | int cleanup_empty_cells(int limit); 67 | float add_liquid(int x, int y, float amount); 68 | void del_liquid(int x, int y); 69 | void set_liquid(int x, int y, float amount); 70 | float get_liquid(int x, int y); 71 | }; 72 | 73 | } // namespace godot 74 | 75 | #endif -------------------------------------------------------------------------------- /docs/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | const { description, descriptionES, descriptionFR } = require("../../package"); 2 | 3 | module.exports = { 4 | base: "/liquid-simulator-godot/", 5 | title: "LiquidSim", 6 | description: description, 7 | /** 8 | * Extra tags to be injected to the page HTML `` 9 | * 10 | * ref:https://v1.vuepress.vuejs.org/config/#head 11 | */ 12 | head: [ 13 | ["meta", { name: "theme-color", content: "#3eaf7c" }], 14 | ["meta", { name: "apple-mobile-web-app-capable", content: "yes" }], 15 | [ 16 | "meta", 17 | { name: "apple-mobile-web-app-status-bar-style", content: "black" }, 18 | ], 19 | ["link", { rel: "icon", href: "/img/icon.png" }], 20 | ], 21 | alias: { 22 | "@assets": "../assets/", 23 | "@assets2": "../../assets", 24 | }, 25 | themeConfig: { 26 | logo: "/img/icon.png", 27 | repo: "aj-wi/liquid-simulator-godot", 28 | docsDir: "docs", 29 | editLinks: true, 30 | editLinkText: "Edit this page on GitHub", 31 | nav: [ 32 | { text: "Guide", link: "/guide/" }, 33 | { text: "Demo", link: "/game/" }, 34 | ], 35 | sidebarDepth: 3, 36 | sidebar: { 37 | "/guide/": [""], 38 | }, 39 | smoothScroll: true, 40 | locales: { 41 | "/es/": { 42 | selectText: "Idiomas", 43 | editLinkText: "Editar esta página en GitHub", 44 | nav: [ 45 | { text: "Guia", link: "/es/guide/" }, 46 | { text: "Demo", link: "/es/game/" }, 47 | ], 48 | algolia: {}, 49 | }, 50 | "/fr/": { 51 | selectText: "langues", 52 | editLinkText: "Modifier cette page sur GitHub", 53 | nav: [ 54 | { text: "Guide", link: "/fr/guide/" }, 55 | { text: "Démo", link: "/fr/game/" }, 56 | ], 57 | algolia: {}, 58 | }, 59 | }, 60 | }, 61 | /** 62 | * Apply plugins,ref:https://v1.vuepress.vuejs.org/zh/plugin/ 63 | */ 64 | plugins: ["@vuepress/plugin-back-to-top", "@vuepress/plugin-medium-zoom"], 65 | locales: { 66 | // The key is the path for the locale to be nested under. 67 | // As a special case, the default locale can use '/' as its path. 68 | "/": { 69 | lang: "English", 70 | }, 71 | "/es/": { 72 | lang: "Spanish", 73 | description: descriptionES, 74 | }, 75 | "/fr/": { 76 | lang: "French", 77 | description: descriptionFR, 78 | }, 79 | }, 80 | }; 81 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | #!python 2 | import os, subprocess 3 | 4 | opts = Variables([], ARGUMENTS) 5 | 6 | # Gets the standard flags CC, CCX, etc. 7 | env = DefaultEnvironment() 8 | 9 | # Define our options 10 | opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release'])) 11 | opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx', 'javascript'])) 12 | opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx', 'javascript'])) 13 | opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no')) 14 | opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'bin/lib/')) 15 | opts.Add(PathVariable('target_name', 'The library name.', 'libliquidsim', PathVariable.PathAccept)) 16 | opts.Add(PathVariable('emscripten', "The path where the emscripten is installed", '/home/wladimir/emsdk/upstream/emscripten/')) 17 | 18 | # Local dependency paths, adapt them to your setup 19 | godot_headers_path = "godot-cpp/godot-headers/" 20 | cpp_bindings_path = "godot-cpp/" 21 | cpp_library = "libgodot-cpp" 22 | 23 | # only support 64 at this time.. 24 | bits = 64 25 | 26 | # Updates the environment with the option variables. 27 | opts.Update(env) 28 | 29 | # Process some arguments 30 | if env['use_llvm']: 31 | env['CC'] = 'clang' 32 | env['CXX'] = 'clang++' 33 | 34 | if env['p'] != '': 35 | env['platform'] = env['p'] 36 | 37 | if env['platform'] == '': 38 | print("No valid target platform selected.") 39 | quit(); 40 | 41 | # For the reference: 42 | # - CCFLAGS are compilation flags shared between C and C++ 43 | # - CFLAGS are for C-specific compilation flags 44 | # - CXXFLAGS are for C++-specific compilation flags 45 | # - CPPFLAGS are for pre-processor flags 46 | # - CPPDEFINES are for pre-processor defines 47 | # - LINKFLAGS are for linking flags 48 | 49 | # Check our platform specifics 50 | if env['platform'] == "osx": 51 | cpp_library += '.osx' 52 | if env['target'] in ('debug', 'd'): 53 | env.Append(CCFLAGS=['-g', '-O2', '-arch', 'x86_64']) 54 | env.Append(LINKFLAGS=['-arch', 'x86_64']) 55 | env.Append(CXXFLAGS=['-std=c++17']) 56 | else: 57 | env.Append(CCFLAGS=['-g', '-O3', '-arch', 'x86_64']) 58 | env.Append(LINKFLAGS=['-arch', 'x86_64']) 59 | env.Append(CXXFLAGS=['-std=c++17']) 60 | 61 | elif env['platform'] in ('x11', 'linux'): 62 | cpp_library += '.linux' 63 | if env['target'] in ('debug', 'd'): 64 | env.Append(CCFLAGS=['-fPIC', '-g3', '-Og']) 65 | env.Append(CXXFLAGS=['-std=c++17']) 66 | else: 67 | env.Append(CCFLAGS=['-fPIC', '-g', '-O3']) 68 | env.Append(CXXFLAGS=['-std=c++17']) 69 | 70 | elif env['platform'] == "windows": 71 | cpp_library += '.windows' 72 | # This makes sure to keep the session environment variables on windows, 73 | # that way you can run scons in a vs 2017 prompt and it will find all the required tools 74 | env.Append(ENV=os.environ) 75 | 76 | env.Append(CPPDEFINES=['WIN32', '_WIN32', '_WINDOWS', '_CRT_SECURE_NO_WARNINGS']) 77 | env.Append(CCFLAGS=['-W3', '-GR']) 78 | if env['target'] in ('debug', 'd'): 79 | env.Append(CPPDEFINES=['_DEBUG']) 80 | env.Append(CCFLAGS=['-EHsc', '-MDd', '-ZI']) 81 | env.Append(LINKFLAGS=['-DEBUG']) 82 | else: 83 | env.Append(CPPDEFINES=['NDEBUG']) 84 | env.Append(CCFLAGS=['-O2', '-EHsc', '-MD']) 85 | 86 | elif env['platform'] == "javascript": 87 | cpp_library += '.javascript' 88 | js = "true" 89 | bits = "wasm" 90 | if env['target'] in ('debug', 'd'): 91 | env.Append(CCFLAGS=["-O0", "-g"]) 92 | else: 93 | env.Append(CCFLAGS=["-O3"]) 94 | env["ENV"] = os.environ 95 | env["CC"] = env['emscripten'] + "emcc" 96 | env["CXX"] = env['emscripten'] + "em++" 97 | env.Append(CPPFLAGS=["-s", "SIDE_MODULE=1"]) 98 | env.Append(LINKFLAGS=["-s", "SIDE_MODULE=1"]) 99 | env["SHOBJSUFFIX"] = ".bc" 100 | env["SHLIBSUFFIX"] = ".wasm" 101 | 102 | if env['target'] in ('debug', 'd'): 103 | cpp_library += '.debug.' + str(bits) + ".a" 104 | else: 105 | cpp_library += '.release.' + str(bits) + ".a" 106 | 107 | # make sure our binding library is properly includes 108 | env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/']) 109 | env.Append(LIBPATH=[cpp_bindings_path + 'bin/']) 110 | env.Append(LIBS=[cpp_library]) 111 | 112 | # tweak this if you want to use different folders, or more folders, to store your source code in. 113 | env.Append(CPPPATH=['src/']) 114 | sources = Glob('src/*.cpp') 115 | 116 | library = env.SharedLibrary(target=env['target_path'] + env['target_name'] , source=sources) 117 | 118 | Default(library) 119 | 120 | # Generates help for the -h scons option. 121 | Help(opts.GenerateHelpText(env)) 122 | -------------------------------------------------------------------------------- /docs/guide/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | --- 4 | 5 | 6 | 7 | # Guide 8 | 9 | This guide will teach you how to compile and add the plugin to a new **Godot engine** project . 10 | 11 | ::: tip 12 | Try a demo of the plugin [here](../game/) 13 | ::: 14 | 15 | ## Prerequisites. 16 | 17 | For the development of this guide, we must have the following installed in our system: 18 | 19 | ::: tip 20 | 21 | - Godot engine 3.x 22 | - Compilador C++ 23 | - Scones build tool 24 | - Emscripten 2.0.17 build tool (In case of building for web **"wasm"**). 25 | 26 | ::: 27 | 28 | ## Clone Repository. 29 | 30 | ::: warning 31 | It is likely that you will find differences between the original repository and this repository, if you are going to use the original **"tterrasson"** repository , I recommend that you follow the instructions you will find there, since there may be differences in how the plugin is installed. 32 | ::: 33 | 34 | Original Repository. 35 | 36 | ```sh 37 | $ git clone --recurse-submodules https://github.com/tterrasson/liquid-simulator-godot 38 | ``` 39 | 40 | This repository. 41 | 42 | ```sh 43 | $ git clone --recurse-submodules https://github.com/AJ-Wi/liquid-simulator-godot 44 | ``` 45 | 46 | ## Compile binary. 47 | 48 | In this section we will see how to compile both the godot-cpp binary and our plugin. 49 | 50 | ::: tip 51 | In the following commands we must replace **"\"** with the platform on which we want to run our game: 52 | 53 | - windows 54 | - linux 55 | - osx 56 | - javascript 57 | - andorid 58 | ::: 59 | 60 | ### godot-cpp binary. 61 | 62 | We need to compile the godot-cpp binary according to the platform on which we want to run our game, for this we must be positioned inside the godot-cpp folder in our terminal. 63 | 64 | ```sh 65 | $ cd liquid-simulator-godot/godot-cpp 66 | $ scons platform= generate_bindings=yes 67 | ``` 68 | 69 | ### plugin binary. 70 | 71 | Once the godot-cpp binary is compiled, we return to the root folder of the project and compile the plugin. 72 | 73 | ```sh 74 | $ cd .. 75 | $ scons platform= 76 | ``` 77 | 78 | ## Copy the plugin to your project. 79 | 80 | At this point you will find the compiled plugin in the **"bin"** folder of the project, you just need to copy this folder to the **"addons"** folder of your project, and rename the plugin folder as **"liquidsim"** , you can also execute the following command. 81 | 82 | ```sh 83 | $ cp -r bin/* /ruta/a/tuproyecto/addons/liquidsim 84 | ``` 85 | 86 | You should be left with the following file structure in your project. 87 | 88 | ``` 89 | . 90 | tuproyecto 91 | ├── addons 92 | | └── liquidsim 93 | | ├── assets 94 | | | ├── icon.png 95 | | | ├── lava.png 96 | | | └── water.png 97 | | ├── lib 98 | | | └── `libliquidsim.so` (according to the one you have compiled.) 99 | | ├── LiquidSim.tscn 100 | | ├── liquidsim_plugin.gd 101 | | ├── liquidsim.gdnlib 102 | | ├── liquuidsim.gdns 103 | | └── plugin.cfg 104 | ├── default_env.tres 105 | ├── icon.png 106 | ├── project.godot 107 | ``` 108 | 109 | ## Activate the plugin. 110 | 111 | To do this, you access the configuration of your project and **"LiquidSim"** will appear in the plugin section, you just have to activate it. 112 | 113 | ![alt img](~@assets/activate_plugin.png) 114 | 115 | ## Add Node. 116 | 117 | Once activated, the plugin already appears in the list of nodes in the editor. 118 | 119 | ![alt img](~@assets/add_plugin_to_tilemap.png) 120 | 121 | For our new node or plugin to work, we must add it as a child node of a **"TileMap"**. 122 | 123 | ![alt img](~@assets/added_liquidsim_node.png) 124 | 125 | ## Plugin setting. 126 | 127 | Adjust the size of the plugin cells according to the cell size of your **"TileMap"**. 128 | 129 | ![alt img](~@assets/adjust_cell_size.png) 130 | 131 | ## Try the plugin. 132 | 133 | Attach a gdscript to the **"TileMap"** to test the plugin, you can use the following sample code. 134 | 135 | ```py 136 | extends TileMap 137 | 138 | func _ready(): 139 | pass # Replace with function body. 140 | 141 | func _input(event): 142 | if event is InputEventMouseButton: 143 | # Mouse in viewport coordinates 144 | var wpos = world_to_map(get_global_mouse_position()) 145 | $LiquidSim.add_liquid(wpos.x, wpos.y, 10.0) 146 | ``` 147 | 148 | ## API. 149 | 150 | ```py 151 | $LiquidSim.start() : Starts the simulation (Started by default) 152 | $LiquidSim.stop() : Stops the simulation 153 | $LiquidSim.update_simulation() : Force simulation update 154 | $LiquidSim.cleanup_empty_cells() : Clean all empty cells (automatic) 155 | $LiquidSim.add_liquid(int x, int y, float amount) : Adds some liquid to the cell. 156 | $LiquidSim.del_liquid(int x, int y) : empty a cell 157 | $LiquidSim.set_liquid(int x, int y, float amount) : Set a fixed amount of liquid to the cell 158 | $LiquidSim.get_liquid(int x, int y) float : Returns the amount of liquid the cell has. 159 | ``` 160 | 161 | ## Compiling problems. 162 | 163 | As mentioned at the beginning, if you are working with the ["original"](https://github.com/tterrasson/liquid-simulator-godot) version of the plugin, follow the instructions in that repository. 164 | 165 | In case you continue working with the version of this repository, I will leave you with a tip or solution to a problem that I encountered along the way and my experience will probably help you. 166 | 167 | ::: tip 168 | At the time of compiling the plugin for the web version, I found that the **"SConstruct"** script did not contain the necessary code fragment for this task, I got a bash script from the **"godot-cpp"** repositories to compile to the version html5, however, this compilation gave me many problems, and even with little information to solve it, the recommendation of the **"godot"** documentation , as for the version of **"Emscripten"** is 1.39.9, after so many attempts and research I was able to conclude that for the compilation of this plugin the version of **"Emscripten"** that we should use is 2.0.17, and for convenience add the missing code snippet for this operation in the **"SConstruct"** file , so that we can directly execute the **"scons"** command with the addition that we should use the **"emscripten"** attribute to provide the path to our build tool, here is an example: 169 | 170 | ```sh 171 | $ scons platform=javascript emscripten=/usr/bin/emscriptem/ 172 | ``` 173 | 174 | ::: 175 | 176 | For more details, see ["Using GDNative Module"](https://docs.godotengine.org/en/3.2/tutorials/plugins/gdnative/gdnative-cpp-example.html#using-the-gdnative-module) 177 | -------------------------------------------------------------------------------- /docs/es/guide/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | --- 4 | 5 | 6 | 7 | # Guía 8 | 9 | Esta guía, te enseñará cómo compilar y agregar el plugin a un nuevo proyecto de **Godot engine**. 10 | 11 | ::: tip 12 | Prueba una demostración del plugin [aqui](../game/) 13 | ::: 14 | 15 | ## Prerrequisitos. 16 | 17 | Para el desenvolvimiento de esta guía, debemos tener instalado en nuestro sistema lo siguiente: 18 | 19 | ::: tip 20 | 21 | - Godot engine 3.x 22 | - Compilador C++ 23 | - Herramienta de compilación Scons 24 | - Herramienta de compilación Emscripten 2.0.17 (En caso de compilar para web **"wasm"**). 25 | 26 | ::: 27 | 28 | ## Clonar Repositorio. 29 | 30 | ::: warning 31 | Es probable que encuentres diferencias entre el repositorio original y este repositorio, si vas a usar el repositorio original de **"tterrasson"**, te recomiendo que sigas las instrucciones que encontraras en él, ya que puede haber diferencias en como se instala el plugin. 32 | ::: 33 | 34 | Repositorio Original. 35 | 36 | ```sh 37 | $ git clone --recurse-submodules https://github.com/tterrasson/liquid-simulator-godot 38 | ``` 39 | 40 | Este Repositorio. 41 | 42 | ```sh 43 | $ git clone --recurse-submodules https://github.com/AJ-Wi/liquid-simulator-godot 44 | ``` 45 | 46 | ## Compilar binario. 47 | 48 | En esta sección veremos como compilar, tanto el binario de godot-cpp como nuestro plugin. 49 | 50 | ::: tip 51 | En los siguientes comandos debemos sustituir **"\"** por la plataforma en la que queremos ejecutar nuestro juego: 52 | 53 | - windows 54 | - linux 55 | - osx 56 | - javascript 57 | - andorid 58 | ::: 59 | 60 | ### binario godot-cpp. 61 | 62 | Necesitamos compilar el binario de godot-cpp acorde a la plataforma en la que queremos ejecutar nuestro juego, para ello debemos estar posicionados dentro de la carpeta godot-cpp en nuestro terminal. 63 | 64 | ```sh 65 | $ cd liquid-simulator-godot/godot-cpp 66 | $ scons platform= generate_bindings=yes 67 | ``` 68 | 69 | ### binario plugin. 70 | 71 | Una vez compilado el binario de godot-cpp volvemos a la carpeta raíz del proyecto y compilamos el plugin. 72 | 73 | ```sh 74 | $ cd .. 75 | $ scons platform= 76 | ``` 77 | 78 | ## Copia el plugin a tu proyecto. 79 | 80 | En este punto encontrarás el plugin compilado en la carpeta **"bin"** del proyecto, solo debes copiar esta carpeta a la carpeta **"addons"** de tu proyecto, y renombrar la carpeta del plugin como **"liquidsim"**, también puedes ejecutar el siguiente comando. 81 | 82 | ```sh 83 | $ cp -r bin/* /ruta/a/tuproyecto/addons/liquidsim 84 | ``` 85 | 86 | Deberías quedar con la siguiente estructura de archivos en tu proyecto. 87 | 88 | ``` 89 | . 90 | tuproyecto 91 | ├── addons 92 | | └── liquidsim 93 | | ├── assets 94 | | | ├── icon.png 95 | | | ├── lava.png 96 | | | └── water.png 97 | | ├── lib 98 | | | └── `libliquidsim.so` (segun el que hayas compilado.) 99 | | ├── LiquidSim.tscn 100 | | ├── liquidsim_plugin.gd 101 | | ├── liquidsim.gdnlib 102 | | ├── liquuidsim.gdns 103 | | └── plugin.cfg 104 | ├── default_env.tres 105 | ├── icon.png 106 | ├── project.godot 107 | ``` 108 | 109 | ## Activa el plugin. 110 | 111 | Para ello accedes a la configuración de tu proyecto y en la sección de plugin te aparecerá **"LiquidSim"**, solo debes activarlo. 112 | 113 | ![alt img](~@assets2/activate_plugin.png) 114 | 115 | ## Agregar Nodo. 116 | 117 | Una vez activado, ya nos aparece el plugin en la lista de nodos del editor. 118 | 119 | ![alt img](~@assets2/add_plugin_to_tilemap.png) 120 | 121 | Para que funcione nuestro nuevo nodo o plugin, debemos agregarlo como nodo hijo de un **"TileMap"**. 122 | 123 | ![alt img](~@assets2/added_liquidsim_node.png) 124 | 125 | ## Ajuste del plugin. 126 | 127 | Ajusta el tamaño de las celdas del plugin según el tamaño de celdas de tu **"TileMap"**. 128 | 129 | ![alt img](~@assets2/adjust_cell_size.png) 130 | 131 | ## Probar el plugin. 132 | 133 | Adjunte un gdscript al **"TileMap"** para probar el complemento, puede usar el siguiente código de muestra. 134 | 135 | ```py 136 | extends TileMap 137 | 138 | func _ready(): 139 | pass # Replace with function body. 140 | 141 | func _input(event): 142 | if event is InputEventMouseButton: 143 | # Mouse in viewport coordinates 144 | var wpos = world_to_map(get_global_mouse_position()) 145 | $LiquidSim.add_liquid(wpos.x, wpos.y, 10.0) 146 | ``` 147 | 148 | ## API. 149 | 150 | ```py 151 | $LiquidSim.start() : Inicia la simulación (Iniciado por defecto) 152 | $LiquidSim.stop() : Detiene la simulación 153 | $LiquidSim.update_simulation() : Fuerza la actualización de la simulación 154 | $LiquidSim.cleanup_empty_cells() : Limpiar todas las celdas vacías (automático) 155 | $LiquidSim.add_liquid(int x, int y, float amount) : Añade un poco de líquido a la celda. 156 | $LiquidSim.del_liquid(int x, int y) : vaciar una celda 157 | $LiquidSim.set_liquid(int x, int y, float amount) : Establecer una cantidad fija de líquido a la celda 158 | $LiquidSim.get_liquid(int x, int y) float : Retorna la cantidad de líquido que tiene la celda. 159 | ``` 160 | 161 | ## Problemas al compilar. 162 | 163 | Como se mencionó al comienzo, si estás trabajando con la versión ["original"](https://github.com/tterrasson/liquid-simulator-godot) del plugin, sigue las instrucciones de ese repositorio. 164 | 165 | En caso de continuar trabajando con la versión de este repositorio, te dejo un tip o solución a un problema que yo me encontré en el camino y probablemente a ti te sirva mi experiencia. 166 | 167 | ::: tip 168 | Al momento de compilar el plugin para la versión web, me encontré con que el script **"SConstruct"** no contenía el fragmento de código necesario para dicha tarea, conseguí en los repositorios de **"godot-cpp"** un script de bash para compilar a la versión html5, sin embargo, dicha compilación me produjo muchos problemas, e incluso con poca información para poder solucionarlo, la recomendación de la documentación de **"godot"**, en cuanto a la versión de **"Emscripten"** es la 1.39.9, después de tantos intentos e investigar pude concluir que para la compilación de este plugin la versión de **"Emscripten"** que debemos usar es la 2.0.17, y para mayor comodidad agregue el fragmento de código faltante para esta operación en el archivo **"SConstruct"**, de manera que podemos ejecutar directamente el comando **"scons"** con el agregado que debemos usar el atributo **"emscripten"** para proporcionar la ruta de nuestra herramienta de compilación, aquí les dejo un ejemplo: 169 | 170 | ```sh 171 | $ scons platform=javascript emscripten=/usr/bin/emscriptem/ 172 | ``` 173 | 174 | ::: 175 | 176 | Para obtener más detalles, consulte ["Uso de módulo GDNative"](https://docs.godotengine.org/en/3.2/tutorials/plugins/gdnative/gdnative-cpp-example.html#using-the-gdnative-module) 177 | -------------------------------------------------------------------------------- /docs/fr/guide/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | --- 4 | 5 | 6 | 7 | # Guide 8 | 9 | Ce guide vous apprendra comment compiler et ajouter le plugin à un nouveau projet de **Godot engine**. 10 | 11 | ::: tip 12 | Essayez une démo du plugin [ici](../game/) 13 | ::: 14 | 15 | ## Conditions préalables. 16 | 17 | Pour le développement de ce guide, nous devons avoir les éléments suivants installés dans notre système : 18 | 19 | ::: tip 20 | 21 | - Godot engine 3.x 22 | - Compilateur C++ 23 | - Outil de construction de Scons 24 | - Outil de construction Emscripten 2.0.17 (En cas de construction pour le web **"wasm"**). 25 | 26 | ::: 27 | 28 | ## Dépôt de clones. 29 | 30 | ::: warning 31 | Il est probable que vous trouviez des différences entre le référentiel d'origine et ce référentiel, si vous allez utiliser le référentiel **"tterrasson"** d' origine , je vous recommande de suivre les instructions que vous y trouverez, car il peut y avoir des différences dans la façon dont le plugin est installé. 32 | ::: 33 | 34 | Dépôt d'origine. 35 | 36 | ```sh 37 | $ git clone --recurse-submodules https://github.com/tterrasson/liquid-simulator-godot 38 | ``` 39 | 40 | Ce référentiel. 41 | 42 | ```sh 43 | $ git clone --recurse-submodules https://github.com/AJ-Wi/liquid-simulator-godot 44 | ``` 45 | 46 | ## Compiler le binaire. 47 | 48 | Dans cette section, nous verrons comment compiler à la fois le binaire godot-cpp et notre plugin. 49 | 50 | ::: tip 51 | Dans les commandes suivantes, nous devons remplacer **"\"** par la plate-forme sur laquelle nous voulons exécuter notre jeu : 52 | 53 | - windows 54 | - linux 55 | - osx 56 | - javascript 57 | - andorid 58 | ::: 59 | 60 | ### binaire godot-cpp. 61 | 62 | Nous devons compiler le binaire godot-cpp en fonction de la plate-forme sur laquelle nous voulons exécuter notre jeu, pour cela nous devons être positionnés dans le dossier godot-cpp de notre terminal. 63 | 64 | ```sh 65 | $ cd liquid-simulator-godot/godot-cpp 66 | $ scons platform= generate_bindings=yes 67 | ``` 68 | 69 | ### binaire du plugin. 70 | 71 | Une fois le binaire godot-cpp compilé, nous retournons au dossier racine du projet et compilons le plugin. 72 | 73 | ```sh 74 | $ cd .. 75 | $ scons platform= 76 | ``` 77 | 78 | ## Copiez le plugin dans votre projet. 79 | 80 | À ce stade, vous trouverez le plugin compilé dans le dossier **"bin"** du projet, il vous suffit de copier ce dossier dans le dossier **"addons"** de votre projet, et de renommer le dossier du plugin en **"liquidsim"**, vous pouvez également exécuter la commande suivante. 81 | 82 | ```sh 83 | $ cp -r bin/* /ruta/a/tuproyecto/addons/liquidsim 84 | ``` 85 | 86 | Vous devriez vous retrouver avec la structure de fichiers suivante dans votre projet. 87 | 88 | ``` 89 | . 90 | tuproyecto 91 | ├── addons 92 | | └── liquidsim 93 | | ├── assets 94 | | | ├── icon.png 95 | | | ├── lava.png 96 | | | └── water.png 97 | | ├── lib 98 | | | └── `libliquidsim.so` (segun el que hayas compilado.) 99 | | ├── LiquidSim.tscn 100 | | ├── liquidsim_plugin.gd 101 | | ├── liquidsim.gdnlib 102 | | ├── liquuidsim.gdns 103 | | └── plugin.cfg 104 | ├── default_env.tres 105 | ├── icon.png 106 | ├── project.godot 107 | ``` 108 | 109 | ## Activez le plugin. 110 | 111 | Pour cela, vous accédez à la configuration de votre projet et **"LiquidSim"** apparaîtra dans la section plugin, vous n'aurez plus qu'à l'activer. 112 | 113 | ![alt img](~@assets2/activate_plugin.png) 114 | 115 | ## Ajouter un nœud. 116 | 117 | Une fois activé, le plugin apparaît déjà dans la liste des nœuds de l'éditeur. 118 | 119 | ![alt img](~@assets2/add_plugin_to_tilemap.png) 120 | 121 | Pour que notre nouveau nœud ou plugin fonctionne, nous devons l'ajouter en tant que nœud enfant d'un **"TileMap"**. 122 | 123 | ![alt img](~@assets2/added_liquidsim_node.png) 124 | 125 | ## Paramètre de plug-in. 126 | 127 | Ajustez la taille des cellules du plugin en fonction de la taille des cellules de votre **"TileMap"**. 128 | 129 | ![alt img](~@assets2/adjust_cell_size.png) 130 | 131 | ## Essayez le plugin. 132 | 133 | Attachez un gdscript au **"TileMap"** pour tester le plugin, vous pouvez utiliser l'exemple de code suivant. 134 | 135 | ```py 136 | extends TileMap 137 | 138 | func _ready(): 139 | pass # Replace with function body. 140 | 141 | func _input(event): 142 | if event is InputEventMouseButton: 143 | # Mouse in viewport coordinates 144 | var wpos = world_to_map(get_global_mouse_position()) 145 | $LiquidSim.add_liquid(wpos.x, wpos.y, 10.0) 146 | ``` 147 | 148 | ## API. 149 | 150 | ```py 151 | $LiquidSim.start() : Démarre la simulation (Démarré par défaut) 152 | $LiquidSim.stop() : Arrête la simulation 153 | $LiquidSim.update_simulation() : Force la mise à jour de la simulation 154 | $LiquidSim.cleanup_empty_cells() : Nettoyer toutes les cellules vides (automatique) 155 | $LiquidSim.add_liquid(int x, int y, float amount) : Ajoute du liquide à la cellule. 156 | $LiquidSim.del_liquid(int x, int y) : vide une cellule 157 | $LiquidSim.set_liquid(int x, int y, float amount) : définit une quantité fixe de liquide dans la cellule 158 | $LiquidSim.get_liquid(int x, int y) float : Renvoie la quantité de liquide contenue dans la cellule. 159 | ``` 160 | 161 | ## Problèmes de compilation. 162 | 163 | Comme mentionné au début, si vous travaillez avec la version ["originale"](https://github.com/tterrasson/liquid-simulator-godot) du plugin, suivez les instructions de ce référentiel. 164 | 165 | Si vous continuez à travailler avec la version de ce référentiel, je vous laisserai une astuce ou une solution à un problème que j'ai rencontré en cours de route et mon expérience vous aidera probablement. 166 | 167 | ::: tip 168 | Au moment de compiler le plugin pour la version web, j'ai trouvé que le script **"SConstruct"** ne contenait pas le fragment de code nécessaire pour cette tâche, j'ai récupéré un script bash des dépôts **"godot-cpp"** pour compiler vers la version html5 , cependant, cette compilation m'a posé de nombreux problèmes, et même avec peu d'informations pour la résoudre, la recommandation de la documentation **"godot"** , quant à la version de **"Emscripten"** est 1.39.9, après tant de tentatives et de recherches j'ai pu pour conclure que pour la compilation de ce plugin la version de **"Emscripten"** que nous devrions utiliser est 2.0.17, et pour plus de commodité, ajoutez l'extrait de code manquant pour cette opération dans le fichier **"SConstruct"** , afin que nous puissions directement exécuter la commande **"scons"** avec en plus que nous devrions utiliser l' attribut **"emscripten"** pour fournir le chemin vers notre outil de compilation, voici un exemple : 169 | 170 | ```sh 171 | $ scons platform=javascript emscripten=/usr/bin/emscriptem/ 172 | ``` 173 | 174 | ::: 175 | 176 | Pour plus de détails, voir ["Utiliser le module GDNative"](https://docs.godotengine.org/en/3.2/tutorials/plugins/gdnative/gdnative-cpp-example.html#using-the-gdnative-module) 177 | -------------------------------------------------------------------------------- /demo-project/scenes/Node2D.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=22 format=2] 2 | 3 | [ext_resource path="res://scripts/TileMap.gd" type="Script" id=1] 4 | [ext_resource path="res://addons/liquidsim/liquidsim.gdns" type="Script" id=2] 5 | [ext_resource path="res://textures/6.png" type="Texture" id=3] 6 | [ext_resource path="res://textures/12.png" type="Texture" id=4] 7 | [ext_resource path="res://textures/5.png" type="Texture" id=5] 8 | [ext_resource path="res://textures/bricksx64.png" type="Texture" id=6] 9 | [ext_resource path="res://textures/16.png" type="Texture" id=7] 10 | [ext_resource path="res://textures/1.png" type="Texture" id=8] 11 | [ext_resource path="res://textures/7.png" type="Texture" id=9] 12 | [ext_resource path="res://textures/14.png" type="Texture" id=10] 13 | [ext_resource path="res://textures/13.png" type="Texture" id=11] 14 | [ext_resource path="res://textures/15.png" type="Texture" id=12] 15 | [ext_resource path="res://textures/2.png" type="Texture" id=13] 16 | [ext_resource path="res://textures/8.png" type="Texture" id=14] 17 | [ext_resource path="res://textures/9.png" type="Texture" id=15] 18 | [ext_resource path="res://textures/4.png" type="Texture" id=16] 19 | [ext_resource path="res://textures/11.png" type="Texture" id=17] 20 | [ext_resource path="res://textures/10.png" type="Texture" id=18] 21 | [ext_resource path="res://textures/stone.png" type="Texture" id=19] 22 | [ext_resource path="res://textures/3.png" type="Texture" id=20] 23 | 24 | [sub_resource type="TileSet" id=1] 25 | 0/name = "1.png 0" 26 | 0/texture = ExtResource( 8 ) 27 | 0/tex_offset = Vector2( 0, 0 ) 28 | 0/modulate = Color( 1, 1, 1, 1 ) 29 | 0/region = Rect2( 0, 0, 64, 64 ) 30 | 0/tile_mode = 0 31 | 0/occluder_offset = Vector2( 0, 0 ) 32 | 0/navigation_offset = Vector2( 0, 0 ) 33 | 0/shape_offset = Vector2( 0, 0 ) 34 | 0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 35 | 0/shape_one_way = false 36 | 0/shape_one_way_margin = 0.0 37 | 0/shapes = [ ] 38 | 0/z_index = 0 39 | 1/name = "2.png 1" 40 | 1/texture = ExtResource( 13 ) 41 | 1/tex_offset = Vector2( 0, 0 ) 42 | 1/modulate = Color( 1, 1, 1, 1 ) 43 | 1/region = Rect2( 0, 0, 64, 64 ) 44 | 1/tile_mode = 0 45 | 1/occluder_offset = Vector2( 0, 0 ) 46 | 1/navigation_offset = Vector2( 0, 0 ) 47 | 1/shape_offset = Vector2( 0, 0 ) 48 | 1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 49 | 1/shape_one_way = false 50 | 1/shape_one_way_margin = 0.0 51 | 1/shapes = [ ] 52 | 1/z_index = 0 53 | 2/name = "3.png 2" 54 | 2/texture = ExtResource( 20 ) 55 | 2/tex_offset = Vector2( 0, 0 ) 56 | 2/modulate = Color( 1, 1, 1, 1 ) 57 | 2/region = Rect2( 0, 0, 64, 64 ) 58 | 2/tile_mode = 0 59 | 2/occluder_offset = Vector2( 0, 0 ) 60 | 2/navigation_offset = Vector2( 0, 0 ) 61 | 2/shape_offset = Vector2( 0, 0 ) 62 | 2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 63 | 2/shape_one_way = false 64 | 2/shape_one_way_margin = 0.0 65 | 2/shapes = [ ] 66 | 2/z_index = 0 67 | 3/name = "4.png 3" 68 | 3/texture = ExtResource( 16 ) 69 | 3/tex_offset = Vector2( 0, 0 ) 70 | 3/modulate = Color( 1, 1, 1, 1 ) 71 | 3/region = Rect2( 0, 0, 64, 64 ) 72 | 3/tile_mode = 0 73 | 3/occluder_offset = Vector2( 0, 0 ) 74 | 3/navigation_offset = Vector2( 0, 0 ) 75 | 3/shape_offset = Vector2( 0, 0 ) 76 | 3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 77 | 3/shape_one_way = false 78 | 3/shape_one_way_margin = 0.0 79 | 3/shapes = [ ] 80 | 3/z_index = 0 81 | 4/name = "5.png 4" 82 | 4/texture = ExtResource( 5 ) 83 | 4/tex_offset = Vector2( 0, 0 ) 84 | 4/modulate = Color( 1, 1, 1, 1 ) 85 | 4/region = Rect2( 0, 0, 64, 64 ) 86 | 4/tile_mode = 0 87 | 4/occluder_offset = Vector2( 0, 0 ) 88 | 4/navigation_offset = Vector2( 0, 0 ) 89 | 4/shape_offset = Vector2( 0, 0 ) 90 | 4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 91 | 4/shape_one_way = false 92 | 4/shape_one_way_margin = 0.0 93 | 4/shapes = [ ] 94 | 4/z_index = 0 95 | 5/name = "6.png 5" 96 | 5/texture = ExtResource( 3 ) 97 | 5/tex_offset = Vector2( 0, 0 ) 98 | 5/modulate = Color( 1, 1, 1, 1 ) 99 | 5/region = Rect2( 0, 0, 64, 64 ) 100 | 5/tile_mode = 0 101 | 5/occluder_offset = Vector2( 0, 0 ) 102 | 5/navigation_offset = Vector2( 0, 0 ) 103 | 5/shape_offset = Vector2( 0, 0 ) 104 | 5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 105 | 5/shape_one_way = false 106 | 5/shape_one_way_margin = 0.0 107 | 5/shapes = [ ] 108 | 5/z_index = 0 109 | 6/name = "7.png 6" 110 | 6/texture = ExtResource( 9 ) 111 | 6/tex_offset = Vector2( 0, 0 ) 112 | 6/modulate = Color( 1, 1, 1, 1 ) 113 | 6/region = Rect2( 0, 0, 64, 64 ) 114 | 6/tile_mode = 0 115 | 6/occluder_offset = Vector2( 0, 0 ) 116 | 6/navigation_offset = Vector2( 0, 0 ) 117 | 6/shape_offset = Vector2( 0, 0 ) 118 | 6/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 119 | 6/shape_one_way = false 120 | 6/shape_one_way_margin = 0.0 121 | 6/shapes = [ ] 122 | 6/z_index = 0 123 | 7/name = "8.png 7" 124 | 7/texture = ExtResource( 14 ) 125 | 7/tex_offset = Vector2( 0, 0 ) 126 | 7/modulate = Color( 1, 1, 1, 1 ) 127 | 7/region = Rect2( 0, 0, 64, 64 ) 128 | 7/tile_mode = 0 129 | 7/occluder_offset = Vector2( 0, 0 ) 130 | 7/navigation_offset = Vector2( 0, 0 ) 131 | 7/shape_offset = Vector2( 0, 0 ) 132 | 7/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 133 | 7/shape_one_way = false 134 | 7/shape_one_way_margin = 0.0 135 | 7/shapes = [ ] 136 | 7/z_index = 0 137 | 8/name = "9.png 8" 138 | 8/texture = ExtResource( 15 ) 139 | 8/tex_offset = Vector2( 0, 0 ) 140 | 8/modulate = Color( 1, 1, 1, 1 ) 141 | 8/region = Rect2( 0, 0, 64, 64 ) 142 | 8/tile_mode = 0 143 | 8/occluder_offset = Vector2( 0, 0 ) 144 | 8/navigation_offset = Vector2( 0, 0 ) 145 | 8/shape_offset = Vector2( 0, 0 ) 146 | 8/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 147 | 8/shape_one_way = false 148 | 8/shape_one_way_margin = 0.0 149 | 8/shapes = [ ] 150 | 8/z_index = 0 151 | 9/name = "10.png 9" 152 | 9/texture = ExtResource( 18 ) 153 | 9/tex_offset = Vector2( 0, 0 ) 154 | 9/modulate = Color( 1, 1, 1, 1 ) 155 | 9/region = Rect2( 0, 0, 64, 64 ) 156 | 9/tile_mode = 0 157 | 9/occluder_offset = Vector2( 0, 0 ) 158 | 9/navigation_offset = Vector2( 0, 0 ) 159 | 9/shape_offset = Vector2( 0, 0 ) 160 | 9/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 161 | 9/shape_one_way = false 162 | 9/shape_one_way_margin = 0.0 163 | 9/shapes = [ ] 164 | 9/z_index = 0 165 | 10/name = "11.png 10" 166 | 10/texture = ExtResource( 17 ) 167 | 10/tex_offset = Vector2( 0, 0 ) 168 | 10/modulate = Color( 1, 1, 1, 1 ) 169 | 10/region = Rect2( 0, 0, 64, 64 ) 170 | 10/tile_mode = 0 171 | 10/occluder_offset = Vector2( 0, 0 ) 172 | 10/navigation_offset = Vector2( 0, 0 ) 173 | 10/shape_offset = Vector2( 0, 0 ) 174 | 10/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 175 | 10/shape_one_way = false 176 | 10/shape_one_way_margin = 0.0 177 | 10/shapes = [ ] 178 | 10/z_index = 0 179 | 11/name = "12.png 11" 180 | 11/texture = ExtResource( 4 ) 181 | 11/tex_offset = Vector2( 0, 0 ) 182 | 11/modulate = Color( 1, 1, 1, 1 ) 183 | 11/region = Rect2( 0, 0, 64, 64 ) 184 | 11/tile_mode = 0 185 | 11/occluder_offset = Vector2( 0, 0 ) 186 | 11/navigation_offset = Vector2( 0, 0 ) 187 | 11/shape_offset = Vector2( 0, 0 ) 188 | 11/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 189 | 11/shape_one_way = false 190 | 11/shape_one_way_margin = 0.0 191 | 11/shapes = [ ] 192 | 11/z_index = 0 193 | 12/name = "13.png 12" 194 | 12/texture = ExtResource( 11 ) 195 | 12/tex_offset = Vector2( 0, 0 ) 196 | 12/modulate = Color( 1, 1, 1, 1 ) 197 | 12/region = Rect2( 0, 0, 64, 64 ) 198 | 12/tile_mode = 0 199 | 12/occluder_offset = Vector2( 0, 0 ) 200 | 12/navigation_offset = Vector2( 0, 0 ) 201 | 12/shape_offset = Vector2( 0, 0 ) 202 | 12/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 203 | 12/shape_one_way = false 204 | 12/shape_one_way_margin = 0.0 205 | 12/shapes = [ ] 206 | 12/z_index = 0 207 | 13/name = "14.png 13" 208 | 13/texture = ExtResource( 10 ) 209 | 13/tex_offset = Vector2( 0, 0 ) 210 | 13/modulate = Color( 1, 1, 1, 1 ) 211 | 13/region = Rect2( 0, 0, 64, 64 ) 212 | 13/tile_mode = 0 213 | 13/occluder_offset = Vector2( 0, 0 ) 214 | 13/navigation_offset = Vector2( 0, 0 ) 215 | 13/shape_offset = Vector2( 0, 0 ) 216 | 13/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 217 | 13/shape_one_way = false 218 | 13/shape_one_way_margin = 0.0 219 | 13/shapes = [ ] 220 | 13/z_index = 0 221 | 14/name = "15.png 14" 222 | 14/texture = ExtResource( 12 ) 223 | 14/tex_offset = Vector2( 0, 0 ) 224 | 14/modulate = Color( 1, 1, 1, 1 ) 225 | 14/region = Rect2( 0, 0, 64, 64 ) 226 | 14/tile_mode = 0 227 | 14/occluder_offset = Vector2( 0, 0 ) 228 | 14/navigation_offset = Vector2( 0, 0 ) 229 | 14/shape_offset = Vector2( 0, 0 ) 230 | 14/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 231 | 14/shape_one_way = false 232 | 14/shape_one_way_margin = 0.0 233 | 14/shapes = [ ] 234 | 14/z_index = 0 235 | 15/name = "16.png 15" 236 | 15/texture = ExtResource( 7 ) 237 | 15/tex_offset = Vector2( 0, 0 ) 238 | 15/modulate = Color( 1, 1, 1, 1 ) 239 | 15/region = Rect2( 0, 0, 64, 64 ) 240 | 15/tile_mode = 0 241 | 15/occluder_offset = Vector2( 0, 0 ) 242 | 15/navigation_offset = Vector2( 0, 0 ) 243 | 15/shape_offset = Vector2( 0, 0 ) 244 | 15/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 245 | 15/shape_one_way = false 246 | 15/shape_one_way_margin = 0.0 247 | 15/shapes = [ ] 248 | 15/z_index = 0 249 | 16/name = "bricksx64.png 16" 250 | 16/texture = ExtResource( 6 ) 251 | 16/tex_offset = Vector2( 0, 0 ) 252 | 16/modulate = Color( 1, 1, 1, 1 ) 253 | 16/region = Rect2( 0, 0, 64, 64 ) 254 | 16/tile_mode = 0 255 | 16/occluder_offset = Vector2( 0, 0 ) 256 | 16/navigation_offset = Vector2( 0, 0 ) 257 | 16/shape_offset = Vector2( 0, 0 ) 258 | 16/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 259 | 16/shape_one_way = false 260 | 16/shape_one_way_margin = 0.0 261 | 16/shapes = [ ] 262 | 16/z_index = 0 263 | 17/name = "stone.png 17" 264 | 17/texture = ExtResource( 19 ) 265 | 17/tex_offset = Vector2( 0, 0 ) 266 | 17/modulate = Color( 1, 1, 1, 1 ) 267 | 17/region = Rect2( 0, 0, 64, 64 ) 268 | 17/tile_mode = 0 269 | 17/occluder_offset = Vector2( 0, 0 ) 270 | 17/navigation_offset = Vector2( 0, 0 ) 271 | 17/shape_offset = Vector2( 0, 0 ) 272 | 17/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 273 | 17/shape_one_way = false 274 | 17/shape_one_way_margin = 0.0 275 | 17/shapes = [ ] 276 | 17/z_index = 0 277 | 278 | [node name="Node2D" type="Node2D"] 279 | 280 | [node name="TileMap" type="TileMap" parent="."] 281 | tile_set = SubResource( 1 ) 282 | format = 1 283 | tile_data = PoolIntArray( -196610, 16, 0, -196609, 16, 0, -262144, 16, 0, -262143, 16, 0, -262142, 16, 0, -262141, 16, 0, -262140, 16, 0, -262139, 16, 0, -262138, 16, 0, -262137, 16, 0, -262136, 16, 0, -262135, 16, 0, -262134, 16, 0, -262133, 16, 0, -262132, 16, 0, -262131, 16, 0, -262130, 16, 0, -262129, 16, 0, -262128, 16, 0, -262127, 16, 0, -262126, 16, 0, -262125, 16, 0, -262124, 16, 0, -262123, 16, 0, -262122, 16, 0, -131074, 16, 0, -196586, 16, 0, -65538, 16, 0, -131050, 16, 0, -2, 16, 0, -65514, 16, 0, 65534, 3, 0, 8, 16, 0, 9, 16, 0, 10, 16, 0, 11, 16, 0, 12, 16, 0, 13, 16, 0, 21, 16, 0, 22, 5, 0, 131070, 3, 0, 65550, 16, 0, 65556, 16, 0, 65558, 5, 0, 196606, 3, 0, 131074, 17, 0, 131077, 17, 0, 131087, 16, 0, 131091, 16, 0, 131094, 5, 0, 262142, 3, 0, 196610, 17, 0, 196613, 17, 0, 196614, 17, 0, 196624, 16, 0, 196626, 16, 0, 196630, 5, 0, 327678, 3, 0, 262146, 17, 0, 262149, 17, 0, 262151, 17, 0, 262161, 16, 0, 262166, 5, 0, 393214, 3, 0, 327682, 17, 0, 327685, 17, 0, 327688, 17, 0, 327702, 5, 0, 458745, 16, 0, 458750, 3, 0, 393218, 17, 0, 393221, 17, 0, 393225, 17, 0, 393231, 8, 0, 393234, 8, 0, 393238, 5, 0, 393244, 16, 0, 524281, 16, 0, 524286, 3, 0, 458754, 17, 0, 458755, 17, 0, 458756, 17, 0, 458757, 17, 0, 458767, 8, 0, 458768, 8, 0, 458769, 8, 0, 458770, 8, 0, 458774, 5, 0, 458780, 16, 0, 589817, 16, 0, 589822, 3, 0, 524296, 16, 0, 524297, 16, 0, 524298, 16, 0, 524299, 16, 0, 524300, 16, 0, 524301, 16, 0, 524310, 5, 0, 524316, 16, 0, 655353, 16, 0, 655358, 3, 0, 589832, 16, 0, 589837, 16, 0, 589846, 5, 0, 589852, 16, 0, 720889, 16, 0, 720894, 3, 0, 655382, 5, 0, 655388, 16, 0, 786425, 16, 0, 786430, 3, 0, 720897, 12, 0, 720898, 1, 0, 720899, 1, 0, 720900, 1, 0, 720901, 1, 0, 720902, 1, 0, 720903, 1, 0, 720904, 1, 0, 720905, 1, 0, 720906, 1, 0, 720907, 1, 0, 720908, 1, 0, 720909, 1, 0, 720910, 1, 0, 720911, 1, 0, 720912, 1, 0, 720913, 1, 0, 720914, 1, 0, 720915, 14, 0, 720918, 5, 0, 720924, 16, 0, 851961, 16, 0, 851966, 3, 0, 786454, 5, 0, 786460, 16, 0, 917497, 16, 0, 917502, 3, 0, 917503, 8, 0, 851968, 8, 0, 851969, 8, 0, 851970, 8, 0, 851971, 8, 0, 851972, 8, 0, 851973, 8, 0, 851974, 8, 0, 851975, 8, 0, 851976, 8, 0, 851977, 8, 0, 851978, 8, 0, 851979, 8, 0, 851980, 8, 0, 851981, 8, 0, 851982, 8, 0, 851983, 8, 0, 851984, 8, 0, 851985, 8, 0, 851986, 8, 0, 851987, 8, 0, 851988, 8, 0, 851989, 8, 0, 851990, 5, 0, 851996, 16, 0, 983033, 16, 0, 917532, 16, 0, 1048569, 16, 0, 983068, 16, 0, 1114105, 16, 0, 1114106, 16, 0, 1114107, 16, 0, 1114108, 16, 0, 1114109, 16, 0, 1114110, 16, 0, 1114111, 16, 0, 1048576, 16, 0, 1048577, 16, 0, 1048578, 16, 0, 1048579, 16, 0, 1048580, 16, 0, 1048581, 16, 0, 1048582, 16, 0, 1048583, 16, 0, 1048584, 16, 0, 1048585, 16, 0, 1048586, 16, 0, 1048587, 16, 0, 1048588, 16, 0, 1048589, 16, 0, 1048590, 16, 0, 1048591, 16, 0, 1048592, 16, 0, 1048593, 16, 0, 1048594, 16, 0, 1048595, 16, 0, 1048596, 16, 0, 1048597, 16, 0, 1048598, 16, 0, 1048599, 16, 0, 1048600, 16, 0, 1048601, 16, 0, 1048602, 16, 0, 1048603, 16, 0, 1048604, 16, 0 ) 284 | script = ExtResource( 1 ) 285 | 286 | [node name="LiquidSim" type="Node" parent="TileMap"] 287 | script = ExtResource( 2 ) 288 | 289 | [node name="Camera2D" type="Camera2D" parent="."] 290 | offset = Vector2( 680, 300 ) 291 | current = true 292 | zoom = Vector2( 1.7, 2 ) 293 | -------------------------------------------------------------------------------- /src/liquidsim.cpp: -------------------------------------------------------------------------------- 1 | #include "liquidsim.hpp" 2 | 3 | #include "utils.hpp" 4 | 5 | using namespace godot; 6 | 7 | void LiquidSim::_register_methods() { 8 | register_method("_ready", &LiquidSim::_ready); 9 | register_method("_process", &LiquidSim::_process); 10 | register_method("start", &LiquidSim::start); 11 | register_method("stop", &LiquidSim::stop); 12 | register_method("clear", &LiquidSim::clear); 13 | register_method("update_simulation", &LiquidSim::update_simulation); 14 | register_method("cleanup_empty_cells", &LiquidSim::cleanup_empty_cells); 15 | register_method("add_liquid", &LiquidSim::add_liquid); 16 | register_method("del_liquid", &LiquidSim::del_liquid); 17 | register_method("set_liquid", &LiquidSim::set_liquid); 18 | register_method("get_liquid", &LiquidSim::get_liquid); 19 | // we register the properties to be able to modify them from the godot editor 20 | register_property("cell_width", &LiquidSim::sprite_width, 64.0f); 21 | register_property("cell_height", &LiquidSim::sprite_height, 64.0f); 22 | register_property("flow_speed", &LiquidSim::flow_speed, 1.0f); 23 | } 24 | 25 | LiquidSim::LiquidSim() {} 26 | 27 | LiquidSim::~LiquidSim() {} 28 | 29 | void LiquidSim::_init() { 30 | time_passed = 0.0f; 31 | refresh_rate = 0.08f; 32 | max_liquid_value = 1.0f; 33 | min_liquid_value = 0.005f; 34 | max_liquid_compression = 0.25f; 35 | max_flow_value = 4.0f; 36 | min_flow_value = 0.005f; 37 | flow_speed = 1.0f; 38 | total_liquid_amount = 0.0; 39 | // we initialize the variables 40 | sprite_width = 64.0f; 41 | sprite_height = 64.0f; 42 | } 43 | 44 | void LiquidSim::_ready() { 45 | world = godot::Object::cast_to(get_parent()); 46 | liquid_scene = ResourceLoader::get_singleton()->load( 47 | "res://addons/liquidsim/LiquidNode.tscn"); 48 | start(); 49 | } 50 | 51 | void LiquidSim::_process(float delta) { 52 | if (!started) { 53 | return; 54 | } 55 | 56 | time_passed += delta; 57 | 58 | if (time_passed >= refresh_rate) { 59 | update_simulation(); 60 | update_simulation(); 61 | update_simulation(); 62 | update_simulation(); 63 | refresh_all(); 64 | 65 | iteration += 1; 66 | time_passed = 0.0; 67 | 68 | // Cleanup empty cells every 100 iterations 69 | if (iteration >= 100) { 70 | cleanup_empty_cells(50); 71 | iteration = 0; 72 | } 73 | } 74 | } 75 | 76 | void LiquidSim::update_simulation() { 77 | std::vector new_cells; 78 | std::vector::iterator it; 79 | 80 | for (it = cells.begin(); it != cells.end(); it++) { 81 | Cell *cell = (*it); 82 | 83 | cell->dir_bottom = false; 84 | 85 | if (cell->liquid_amount == 0.0f) { 86 | continue; 87 | } 88 | if (cell->liquid_amount < min_liquid_value) { 89 | cell->liquid_amount = 0.0f; 90 | continue; 91 | } 92 | 93 | // Check rule #1 94 | if (world->get_cell(cell->x, cell->y + 1) == -1) { 95 | float bottom_liquid_amount; 96 | Cell *bottom_cell = get_cell_by_position(cell->x, cell->y + 1); 97 | 98 | if (bottom_cell == nullptr) { 99 | bottom_liquid_amount = 0.0f; 100 | } else { 101 | bottom_liquid_amount = bottom_cell->liquid_amount; 102 | } 103 | 104 | float flow = get_vertical_flow_value(cell->new_liquid_amount, 105 | bottom_liquid_amount) - 106 | bottom_liquid_amount; 107 | if (bottom_liquid_amount > 0.0f && flow > min_flow_value) { 108 | flow *= flow_speed; 109 | } 110 | 111 | flow = std::max(flow, 0.0f); 112 | if (flow > std::min(max_flow_value, cell->liquid_amount)) { 113 | flow = std::min(max_flow_value, cell->liquid_amount); 114 | } 115 | 116 | if (flow != 0.0f) { 117 | if (bottom_cell == nullptr) { 118 | bottom_cell = create_cell(cell->x, cell->y + 1, 0.0); 119 | new_cells.push_back(bottom_cell); 120 | cells_positions.insert( 121 | std::make_pair(bottom_cell->uid, bottom_cell)); 122 | } 123 | 124 | bottom_cell->new_liquid_amount += flow; 125 | cell->new_liquid_amount -= flow; 126 | cell->dir_bottom = true; 127 | } 128 | } 129 | 130 | // Check if there is still some liquid 131 | if (cell->new_liquid_amount < min_liquid_value) { 132 | cell->new_liquid_amount -= cell->new_liquid_amount; 133 | continue; 134 | } 135 | 136 | // Check rule #2 137 | if (world->get_cell(cell->x - 1, cell->y) == -1) { 138 | float left_liquid_amount; 139 | Cell *left_cell = get_cell_by_position(cell->x - 1, cell->y); 140 | 141 | if (left_cell == nullptr) { 142 | left_liquid_amount = 0.0f; 143 | } else { 144 | left_liquid_amount = left_cell->liquid_amount; 145 | } 146 | 147 | if (left_liquid_amount < cell->liquid_amount) { 148 | float flow = (cell->new_liquid_amount - left_liquid_amount) / 3; 149 | if (flow > min_flow_value) { 150 | flow *= flow_speed; 151 | } 152 | 153 | flow = std::max(flow, 0.0f); 154 | if (flow > std::min(max_flow_value, cell->new_liquid_amount)) { 155 | flow = std::min(max_flow_value, cell->new_liquid_amount); 156 | } 157 | 158 | if (flow != 0.0f) { 159 | if (left_cell == nullptr) { 160 | left_cell = create_cell(cell->x - 1, cell->y, 0.0f); 161 | new_cells.push_back(left_cell); 162 | cells_positions.insert( 163 | std::make_pair(left_cell->uid, left_cell)); 164 | } 165 | 166 | left_cell->new_liquid_amount += flow; 167 | cell->new_liquid_amount -= flow; 168 | } 169 | } 170 | } 171 | 172 | // Check if there is still some liquid 173 | if (cell->new_liquid_amount < min_liquid_value) { 174 | cell->new_liquid_amount -= cell->new_liquid_amount; 175 | continue; 176 | } 177 | 178 | if (world->get_cell(cell->x + 1, cell->y) == -1) { 179 | float right_liquid_amount; 180 | Cell *right_cell = get_cell_by_position(cell->x + 1, cell->y); 181 | 182 | if (right_cell == nullptr) { 183 | right_liquid_amount = 0.0f; 184 | } else { 185 | right_liquid_amount = right_cell->liquid_amount; 186 | } 187 | 188 | if (right_liquid_amount < cell->liquid_amount) { 189 | float flow = 190 | (cell->new_liquid_amount - right_liquid_amount) / 3; 191 | if (flow > min_flow_value) { 192 | flow *= flow_speed; 193 | } 194 | 195 | flow = std::max(flow, 0.0f); 196 | if (flow > std::min(max_flow_value, cell->new_liquid_amount)) { 197 | flow = std::min(max_flow_value, cell->new_liquid_amount); 198 | } 199 | 200 | if (flow != 0.0f) { 201 | if (right_cell == nullptr) { 202 | right_cell = create_cell(cell->x + 1, cell->y, 0.0f); 203 | new_cells.push_back(right_cell); 204 | cells_positions.insert( 205 | std::make_pair(right_cell->uid, right_cell)); 206 | } 207 | 208 | right_cell->new_liquid_amount += flow; 209 | cell->new_liquid_amount -= flow; 210 | } 211 | } 212 | } 213 | 214 | // Check if there is still some liquid 215 | if (cell->new_liquid_amount < min_liquid_value) { 216 | cell->new_liquid_amount -= cell->new_liquid_amount; 217 | continue; 218 | } 219 | 220 | // Check rule #3 221 | if (world->get_cell(cell->x, cell->y - 1) == -1) { 222 | float top_liquid_amount; 223 | Cell *top_cell = get_cell_by_position(cell->x, cell->y - 1); 224 | 225 | if (top_cell == nullptr) { 226 | top_liquid_amount = 0.0f; 227 | } else { 228 | top_liquid_amount = top_cell->liquid_amount; 229 | } 230 | 231 | float flow = cell->new_liquid_amount - 232 | get_vertical_flow_value(cell->new_liquid_amount, 233 | top_liquid_amount); 234 | if (flow > min_flow_value) { 235 | flow *= flow_speed; 236 | } 237 | 238 | flow = std::max(flow, 0.0f); 239 | if (flow > std::min(max_flow_value, cell->new_liquid_amount)) { 240 | flow = std::min(max_flow_value, cell->new_liquid_amount); 241 | } 242 | 243 | if (flow != 0.0f) { 244 | if (top_cell == nullptr) { 245 | top_cell = create_cell(cell->x, cell->y - 1, 0.0); 246 | new_cells.push_back(top_cell); 247 | cells_positions.insert( 248 | std::make_pair(top_cell->uid, top_cell)); 249 | } 250 | 251 | top_cell->new_liquid_amount += flow; 252 | cell->new_liquid_amount -= flow; 253 | } 254 | } 255 | 256 | // Check if there is still some liquid 257 | if (cell->new_liquid_amount < min_liquid_value) { 258 | cell->new_liquid_amount -= cell->new_liquid_amount; 259 | continue; 260 | } 261 | } 262 | 263 | // Add new cells 264 | cells.insert(std::end(cells), std::begin(new_cells), std::end(new_cells)); 265 | 266 | // Update cells 267 | total_liquid_amount = 0.0; 268 | for (it = cells.begin(); it != cells.end(); it++) { 269 | Cell *cell = (*it); 270 | 271 | if (cell->liquid_amount == cell->new_liquid_amount) { 272 | cell->iteration_since_last_change += 1; 273 | } else { 274 | cell->iteration_since_last_change = 0; 275 | cell->liquid_amount = cell->new_liquid_amount; 276 | } 277 | 278 | refresh_cell_sprite(cell); 279 | 280 | total_liquid_amount += cell->liquid_amount; 281 | } 282 | } 283 | 284 | int LiquidSim::cleanup_empty_cells(int limit) { 285 | int removed = 0; 286 | std::vector::iterator it; 287 | 288 | for (it = cells.begin(); it != cells.end();) { 289 | Cell *cell = (*it); 290 | 291 | if (cell->liquid_amount == 0.0f && 292 | cell->iteration_since_last_change > 10) { 293 | it = cells.erase(it); 294 | cells_positions.erase(cell->uid); 295 | remove_child(cell->node); 296 | cell->node->queue_free(); 297 | delete cell; 298 | removed++; 299 | 300 | if (removed >= limit) { 301 | break; 302 | } 303 | } else { 304 | it++; 305 | } 306 | } 307 | 308 | return removed; 309 | } 310 | 311 | Cell *LiquidSim::get_cell_by_position(int x, int y) { 312 | int uid = hash_position(x, y); 313 | std::unordered_map::iterator it; 314 | 315 | it = cells_positions.find(uid); 316 | if (it != cells_positions.end()) { 317 | return cells_positions[uid]; 318 | } 319 | 320 | return nullptr; 321 | } 322 | 323 | Cell *LiquidSim::create_cell(int x, int y, float amount) { 324 | Node2D *node = 325 | godot::Object::cast_to(liquid_scene->instance()); 326 | // we pass the height and width of the tilemap cells to the new sprite 327 | Cell *cell = new Cell(node, x, y, amount, sprite_width, sprite_height); 328 | add_child(node); 329 | return cell; 330 | } 331 | 332 | float LiquidSim::get_vertical_flow_value(float src_liquid_amount, 333 | float dst_liquid_amount) { 334 | float sum = src_liquid_amount + dst_liquid_amount; 335 | float value = 0.0; 336 | 337 | if (sum <= max_liquid_value) { 338 | value = max_liquid_value; 339 | } else if (sum < (2 * max_liquid_value + max_liquid_compression)) { 340 | value = (max_liquid_value * max_liquid_value + 341 | sum * max_liquid_compression) / 342 | (max_liquid_value + max_liquid_compression); 343 | } else { 344 | value = (sum + max_liquid_compression) / 2.0; 345 | } 346 | 347 | return value; 348 | } 349 | 350 | void LiquidSim::refresh_cell_sprite(Cell *cell) { 351 | float translation; 352 | float scale = std::min(cell->liquid_amount, 1.0f); 353 | 354 | // Check if liquid is flowing down for better rendering 355 | Cell *top_cell = get_cell_by_position(cell->x, cell->y - 1); 356 | if (top_cell != nullptr && 357 | (top_cell->liquid_amount >= min_liquid_value || top_cell->dir_bottom)) { 358 | scale = 1.0f; 359 | } 360 | 361 | translation = (sprite_height - (sprite_height * scale)); 362 | cell->node->set_position(world->map_to_world(Vector2(cell->x, cell->y))); 363 | cell->node->translate(Vector2(0.0, translation)); 364 | cell->node->set_scale(Vector2(1.0, scale)); 365 | 366 | float m = lerp(1.4f, 0.2f, cell->liquid_amount / 4.0f); 367 | cell->sprite_node->set_modulate(Color(m, m, m)); 368 | } 369 | 370 | void LiquidSim::refresh_all() { 371 | std::vector::iterator it; 372 | 373 | for (it = cells.begin(); it != cells.end(); it++) { 374 | Cell *cell = (*it); 375 | refresh_cell_sprite(cell); 376 | } 377 | } 378 | 379 | void LiquidSim::start() { started = true; } 380 | 381 | void LiquidSim::stop() { started = false; } 382 | 383 | void LiquidSim::clear() { 384 | std::vector::iterator it; 385 | 386 | for (it = cells.begin(); it != cells.end(); it++) { 387 | Cell *cell = (*it); 388 | remove_child(cell->node); 389 | cell->node->queue_free(); 390 | delete cell; 391 | } 392 | 393 | cells.clear(); 394 | cells_positions.clear(); 395 | started = false; 396 | } 397 | 398 | float LiquidSim::add_liquid(int x, int y, float amount) { 399 | Cell *cell = get_cell_by_position(x, y); 400 | if (cell == nullptr) { 401 | cell = create_cell(x, y, amount); 402 | cells.push_back(cell); 403 | cells_positions.insert(std::make_pair(cell->uid, cell)); 404 | } else { 405 | cell->new_liquid_amount += amount; 406 | } 407 | 408 | refresh_cell_sprite(cell); 409 | 410 | return cell->new_liquid_amount; 411 | } 412 | 413 | void LiquidSim::del_liquid(int x, int y) { 414 | Cell *cell = get_cell_by_position(x, y); 415 | if (cell == nullptr) { 416 | return; 417 | } 418 | 419 | cell->new_liquid_amount = 0.0f; 420 | refresh_cell_sprite(cell); 421 | } 422 | 423 | void LiquidSim::set_liquid(int x, int y, float amount) { 424 | Cell *cell = get_cell_by_position(x, y); 425 | if (cell == nullptr) { 426 | cell = create_cell(x, y, amount); 427 | cells.push_back(cell); 428 | cells_positions.insert(std::make_pair(cell->uid, cell)); 429 | } else { 430 | cell->new_liquid_amount = amount; 431 | } 432 | 433 | refresh_cell_sprite(cell); 434 | } 435 | 436 | float LiquidSim::get_liquid(int x, int y) { 437 | Cell *cell = get_cell_by_position(x, y); 438 | if (cell == nullptr) { 439 | return 0.0f; 440 | } 441 | 442 | return cell->liquid_amount; 443 | } --------------------------------------------------------------------------------