{"id":25127714,"url":"https://github.com/zerdicorp/soft_body_simulation","last_synced_at":"2025-09-02T03:39:38.648Z","repository":{"id":39002449,"uuid":"503400013","full_name":"ZERDICORP/soft_body_simulation","owner":"ZERDICORP","description":"In my opinion - one of the coolest simulations!","archived":false,"fork":false,"pushed_at":"2022-06-24T03:58:18.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T20:48:40.382Z","etag":null,"topics":["2d","physics","physics-simulation","simulation","soft-body","soft-body-simulation"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZERDICORP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-14T14:42:33.000Z","updated_at":"2023-06-06T03:05:43.000Z","dependencies_parsed_at":"2022-09-12T20:13:59.863Z","dependency_job_id":null,"html_url":"https://github.com/ZERDICORP/soft_body_simulation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ZERDICORP/soft_body_simulation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fsoft_body_simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fsoft_body_simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fsoft_body_simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fsoft_body_simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZERDICORP","download_url":"https://codeload.github.com/ZERDICORP/soft_body_simulation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fsoft_body_simulation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273226542,"owners_count":25067551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d","physics","physics-simulation","simulation","soft-body","soft-body-simulation"],"created_at":"2025-02-08T11:17:58.920Z","updated_at":"2025-09-02T03:39:38.630Z","avatar_url":"https://github.com/ZERDICORP.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# soft_body_simulation :panda_face: :soccer:\n#### In my opinion - one of the coolest simulations!\n\n## What can you say about it? :raising_hand:\n_**I have only two words for you: INCREDIBLY COOL!**_\n\nI've always wanted to create some kind of simulation related to physics.  \nAnd finally, **I did it**!  \n\n_P.S. The work I have done is not perfect.  \nI didn't go deep into formulas.  \nI didn't try to create a comprehensive universal soft body engine.  \nNot at all.  \nI am driven only by wild curiosity, what are you talking about? :D_\n\n## How it works? :hatching_chick:\n\u003e Everything written below is just a **crooked interpretation** of the coolest articles on **soft body physics**.  \n\u003e Want two-page formulas and buzzwords? Google it! :3\n\u003e \n\u003e _Who seeks will find._  \n\u003e _Whoever goes will come._  \n\u003e _Those who google will not notice the answer in the first link._\n\n### #1 ~ «Introduction»\nWell, let's understand how **soft body simulation** works.  \n\nFirst, we need to understand **what the body itself** is. And by the way, it won't take long to find the answer (that's why I'm here lol):\n- Particles\n\nYes, **particles** are everywhere.  \nIt is from these little freaks that everything around us consists: the phone that you hold in your hands, and the hands themselves.  \n\nAnd, you know, if you want to create a **soft body**, you don't have to **beat around the bush** - **steal the idea from nature**!\n\n### #2 ~ «Particles»\n_So, okay, we have particles. But what exactly are they?_\n\nHere is the basic set of properties for each **particle**:\n- **location**\n- **velocity**\n\nI mean, it's pretty primitive.  \nWe have a particle location **(x, y)** and a **velocity vector**.  \nIt remains for each frame to update the location, adding velocity to it.  \n\n_It's all? Do we have a soft body?_\n\n**Lol, no.. :D**\n\n### #3 ~ «Springs»\nHaving only **particles**, you can get, for example, a **gas**, but obviously not a **soft body**, because, as you know, a body is a body, because it is an **ordered set of interconnected particles** (_crystal lattice_).  \n\nAnd, if we were making a regular **rigid body**, we wouldn't even have to tie anything.  \nBut here's a **soft body**..  \nIt should behave like **jelly**, or any other **soft** object, that is, **deform, and then recover**.  \n\nAnd the **«Spring Mass System»** will help us to achieve this effect.  \n\nI will not retell [smart definitions from Wikipedia](https://en.wikipedia.org/wiki/Soft-body_dynamics), but I will explain in simple words:  \n\nOur task is to **split the particles into pairs**. Each pair forms a **spring**.  \nNext, we need to go through all the **springs** (_pairs of two particles_) and, based on some data, calculate the **next position of the particles** in space.  \n\nThus, the **particles become bound to each other**.  \nAnd the **system of spring masses** allows you to achieve the effect of **jelly**, since when the particles move away from each other, they are forced to move towards each other (**spring compression**), otherwise, if the particles are too close to each other (closer than a certain distance / **state of rest**), they forced to move in opposite directions (**stretching the spring**).  \n\nSummarizing the above, we have:\n- **Particles**\n- **Springs (a pair of two particles)**\n\nThis is actually enough to create a **soft body**.  \n\n### #4 ~ «Soft body»\nWell, let's briefly go through the main steps:\n1. Create **particles**.\n2. Connect them with **springs**.\n3. Iterate through the springs every frame and apply all **sorts of tricky formulas** to achieve the spring effect (move away the particles - they return to each other; bring the particles closer - they push each other with all their might; stretch the spring and release it - it will contract and stretch, making **harmonic oscillations**, until it reaches a **state of rest**).\n\nApart from the **spring mass system**, you will probably need a **gravity simulation** (just add a constant to the y-axis of the velocity vector every frame), a **collision resolution algorithm** (because you don't want your soft body to fall forever) and **a lot of curiosity** (no way without it)!  \n\n## Demo 🔥\n\u003ckbd\u003e\n  \u003ca href=\"https://www.youtube.com/watch?v=r1O-JMuGJYU\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/56264511/175388973-2723ae31-da4b-422f-9a5f-dac133e92698.png\"\u003e\n  \u003c/a\u003e\n\u003c/kbd\u003e\n\n## Thanks! Gonkee :sparkling_heart: (u r cutie btw)\n* #### [But How DO Soft Body Simulations Work?](https://www.youtube.com/watch?v=kyQP4t_wOGI\u0026t=527s\u0026ab_channel=Gonkee) by Gonkee\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerdicorp%2Fsoft_body_simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerdicorp%2Fsoft_body_simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerdicorp%2Fsoft_body_simulation/lists"}