{"id":53,"date":"2011-05-16T02:55:00","date_gmt":"2011-05-16T08:55:00","guid":{"rendered":"http:\/\/elysianshadows.com\/2011\/05\/basic-mass-aggregate-physics-engine\/"},"modified":"2011-05-16T02:55:00","modified_gmt":"2011-05-16T08:55:00","slug":"basic-mass-aggregate-physics-engine","status":"publish","type":"post","link":"http:\/\/elysianshadows.com\/updates\/basic-mass-aggregate-physics-engine\/","title":{"rendered":"Basic Mass-Aggregate Physics Engine"},"content":{"rendered":"\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">Then, as I said, we can add gravity to the simulation with pretty much one line of code:<\/p>\n<pre>for(unsigned int i = 0; i &lt; _partCount; ++i) { \t_partPool[i ]._forceAccumulator.y += 10000.0f; } <\/pre>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">The initial frame.<\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-48\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_gyro_sim1.png\" border=\"0\" alt=\"\" width=\"775\" height=\"484\" width=\"1280\" height=\"800\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_gyro_sim1.png 1280w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_gyro_sim1-300x187.png 300w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_gyro_sim1-1024x640.png 1024w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">Everything is starting to fall.<\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-49\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim1.png\" border=\"0\" alt=\"\" width=\"743\" height=\"464\" width=\"1280\" height=\"800\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim1.png 1280w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim1-300x187.png 300w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim1-1024x640.png 1024w\" sizes=\"auto, (max-width: 743px) 100vw, 743px\" \/><\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">Shit is colliding and bouncing around.<\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-50\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim2.png\" border=\"0\" alt=\"\" width=\"739\" height=\"462\" width=\"1280\" height=\"800\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim2.png 1280w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim2-300x187.png 300w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim2-1024x640.png 1024w\" sizes=\"auto, (max-width: 739px) 100vw, 739px\" \/><\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">Bouncing and scattering more.<\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-51\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim3.png\" border=\"0\" alt=\"\" width=\"731\" height=\"457\" width=\"1280\" height=\"800\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim3.png 1280w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim3-300x187.png 300w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim3-1024x640.png 1024w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">The final screenshot shows the simulation after all of the bouncing has been resolved. You&#8217;ll notice that things still aren&#8217;t quite resting on each other. This is a common problem in most physics engines caused by micro collisions between resting contacts. I haven&#8217;t really begun to resolve this yet, but I&#8217;m definitely going to have to. Luckily for us, ES doesn&#8217;t have gravity&#8230; but for the sake of having a kickass engine (and maybe some cool minigames\/weird places in ES like a windy mountain), we need to support this.<\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">To the left you can also see all of the beautiful floating-point linear algebra required to handle collision resolution. When a bunch of bodies are lumped together with resting contacts, the resolution process is the most intensive by tenfold for just a few contacts easily. The problem is that the resolution of one contact can easily push one of the other bodies deeper into another contact&#8230; so the resolution process is iterative through entire groups of bodies touching one another. Collision resolution is definitely the bottleneck of the simulation (and all physics simulations).<\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-52\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim4.png\" border=\"0\" alt=\"\" width=\"745\" height=\"466\" width=\"1280\" height=\"800\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim4.png 1280w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim4-300x187.png 300w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_grav_sim4-1024x640.png 1024w\" sizes=\"auto, (max-width: 745px) 100vw, 745px\" \/><\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">Anyway, time to get the fuck back to rotations. I&#8217;ll be posting them just as soon as I finish.&nbsp; \ud83d\ude42<\/p>\n<p class=\"readmore\"><a href=\"http:\/\/forums.elysianshadows.com\/viewtopic.php?f=48&amp;t=8475\">Discussion Topic<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\"><strong>Originally posted in our Private Development forum on 5.16.11.<\/strong><\/p>\n<p style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">So as I said, this is a standalone C library using on the minimal LibGyro2.0. The screenshots aren&#8217;t very cute (bare, untextured quads), but they get the point across. While I&#8217;m developing, I&#8217;m linking a simple driver program against libKineticGyro.framework to test its functionality. Big ass screenshots below, so make sure to right click and &#8220;view image&#8221; to see the whole thing. (I don&#8217;t know how to cut out the irrelevant shit on my Mac. \ud83d\ude09 ).<\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\">So here&#8217;s the first real test simulation I&#8217;ve been working with. You&#8217;ll notice a few quads are oriented arbitrarily, and that some are bigger and smaller (for mass testing). You can&#8217;t tell from the screenshot, but I&#8217;m controlling one of the smaller quads (as a player) and am pushing shit around and bumping into it:<\/p>\n<p class=\"p1\" style=\"color: #333333; font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px;\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-47\" src=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_gyro_sim2.png\" border=\"0\" alt=\"\" width=\"729\" height=\"456\" width=\"1280\" height=\"800\" srcset=\"http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_gyro_sim2.png 1280w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_gyro_sim2-300x187.png 300w, http:\/\/elysianshadows.com\/updates\/wp-content\/uploads\/2011\/05\/kinetic_gyro_sim2-1024x640.png 1024w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/p>\n","protected":false},"author":1,"featured_media":47,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[26,28,27,29,13,31,30,25,35],"class_list":["post-53","post","type-post","status-publish","format-standard","hentry","category-underlying-technology","tag-2d-rpg","tag-adventures-in-game-develoment","tag-chrono-trigger","tag-dreamcast","tag-elysian-shadows","tag-engine","tag-homebrew","tag-indie-rpg","tag-sprites"],"_links":{"self":[{"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/posts\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":0,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/posts\/53\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/media\/47"}],"wp:attachment":[{"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/media?parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/categories?post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/elysianshadows.com\/updates\/wp-json\/wp\/v2\/tags?post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}