tag:blogger.com,1999:blog-44470906420493400232024-03-05T09:46:01.191-08:00Angelus blogWater ... that adapts itself to the flow, that breaks everything like a swordAngelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.comBlogger183125tag:blogger.com,1999:blog-4447090642049340023.post-17136165343754930682021-08-18T18:03:00.006-07:002021-08-18T18:47:23.457-07:00Hierarchy - UI improvement<p>This time light topic of UI designing :] But before this let's discuss how the hierarchy in the engine works. So it was easier to understand these, let's look at the tooling of it: </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrsXJyx9pA0qvN0F5VwzTnCHZTTABPpwA0evs119PQSYrhX0WLOa0u8HFEujO4NgfhTWpxAzwdYlwCdimyBfEgsD07pHUkLlNvyCELVt2L04XqTrPQAtkRnJT89jxo1s-o9twIZddkPJU/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="311" data-original-width="360" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrsXJyx9pA0qvN0F5VwzTnCHZTTABPpwA0evs119PQSYrhX0WLOa0u8HFEujO4NgfhTWpxAzwdYlwCdimyBfEgsD07pHUkLlNvyCELVt2L04XqTrPQAtkRnJT89jxo1s-o9twIZddkPJU/" width="278" /></a></div><br />We have there:<p></p><p></p><ul style="text-align: left;"><li>World (ID:0)</li><li>Loaded Stream (Citadel Island)</li><li>Loaded SubStream (CI.Citadel)</li><li>Unloaded SubStream (CI.Logic)</li><li>Folders (f.ex. Park)</li><li>Entities (f.ex. Ferry)</li></ul><div style="text-align: justify;">If you are curious what a <b>Stream </b>is, you can think about it as a scene or a level.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Now that we know all of this let's look a little bit closer at what we have. <b>Streams </b>and <b>SubStreams </b>are exactly the same I change the name based on their position in the hierarchy. The <b>Folders </b>may look different than <b>Entities </b>but they are exactly the same. They are <b>Entities </b>with a folder component. If we go this way streams are also just <b>Entities </b>with a Stream Component. This leaves us with a bunch of the entities under the <b>World</b>. Which as you can suspect is just an <b>Entity </b>with ID equal to 0. </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">If everything is an entity, what was the reason I came with all these weird names? The answer is simplicity. People have a hard time thinking about abstract concepts, by introducing Folders, Entities, Streams it becoming a lot easier for most people to understand what happens. As you can notice I did not stop on using naming, I also introduced different icons:</div><div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;"><ul style="text-align: left;"><li>World: <span style="font-size: large;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRMymdm_f0_dG8ZtWTX_TcYRbsWXNA4Urx4-Sw3r6_Yfs4iQANngx2Vc9S0tkb8Lz8dfhKjWtQUxwjYiLyeg5tL8mv89Mf_PTooGAQyzpQ_aXCHzCCnwH_kVRqq5oPOc9t0Ob1SNZhDFo/" style="background-color: #eeeeee; margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRMymdm_f0_dG8ZtWTX_TcYRbsWXNA4Urx4-Sw3r6_Yfs4iQANngx2Vc9S0tkb8Lz8dfhKjWtQUxwjYiLyeg5tL8mv89Mf_PTooGAQyzpQ_aXCHzCCnwH_kVRqq5oPOc9t0Ob1SNZhDFo/s16000/World16.png" /></a></span></li><li>Stream: <span style="font-size: large;"><span style="background-color: #eeeeee; font-size: large;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span></span>/<span style="background-color: #eeeeee; font-size: large;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span></li><li>Folder: <span style="background-color: #eeeeee; font-size: large;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjoPRyKMX87FjUyVKB7_GVddnLbsHPkwH6is_IpPN63GoRDA6dj47mMC5zh_odnXHVF3m0kNhUpDb_Iedixj33ZbKAv-fb1ZtAIbRnXCvfHTH8dmwgcaJNSi3ng1Is6u4qo7sIacv8BWs/s16000/Folder16.png" /></span></li><li>Entity: <span style="background-color: #eeeeee; font-size: large;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW5GHoeTg8Os7b_JVDrPWdyoEIYIJhGhbtpstWW13BLa_stqu3BgM2XDYEh7wR-0aTZ07B58h9b_TQBGmM2vOrWxo00F8Xv_YgiMk1vIE0_C35Pql_fi-oFtf1VkLQEN3RmS6szQcwDxE/s16000/Item16.png" /></span></li></ul></div><div class="separator" style="clear: both; text-align: justify;">There is also a standard black arrow showing if the entry has some children. All of that was done to make clear what is what and how hierarchy looks. There are also special cases like a stream, where I introduced two icons so users intuitively know about its state:</div><div class="separator" style="clear: both; text-align: left;"><br /></div></div></div><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;"><span style="background-color: #eeeeee; font-size: large;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span>Unloaded</div></div></div></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;"><span style="background-color: #eeeeee; font-size: large;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span>Loaded </div></div></div></blockquote><div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: justify;">Today I realized that this was not good enough. Stream has four different states and not only two. So far I have had this kind of iconography: </div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;">Unloaded<span style="background-color: #eeeeee;"><span style="font-size: large;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span></span>⟷ Loaded<span style="background-color: #eeeeee;"><span style="font-size: large;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span></span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: justify;">The issue is that transition between these two states is not instantaneous. There is some, Δt > 1 sec that is involved there. This makes transitions to another state a state itself. We need to think about that this way because otherwise there is confusion :</div><div class="separator" style="clear: both; text-align: left;"><br /><div style="text-align: center;">Unloaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span>→ Streaming In<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span> → Loaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span></div></div><div class="separator" style="clear: both; text-align: center;">Loaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span>→ Streaming Out<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span> → Unloaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">I could probably change it into:</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both;"><div style="text-align: center;">Unloaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span>→ Streaming In<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span> → Loaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span></div></div><div class="separator" style="clear: both; text-align: center;">Loaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span>→ Streaming Out<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span> → Unloaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span></div></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: justify;">This would make some people happy but in the end, it does not solve the underlying issue: We informing that stream is loaded/unloaded when it is not. For a lot probably not a big issue but if you know about it, it is pretty annoying. In the end, the solution is pretty trivial:</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both;"><div style="text-align: center;">Unloaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span>→ Streaming In<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdFXtnDDqWAs63LrvS5FqiPWP4npOl4l9OtV5H1R0RYJZVRJvRrRmanbzJcdBYl2hp6tmXpWanSAKOHGiyiUo0sEh6nErrRg_y8nMHm7UcGlGI8kQrzqJNRbWJqiZ7cJqUNHdE8R1Bua4/s16000/StreamIn16.png" /></span> → Loaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span></div></div><div class="separator" style="clear: both; text-align: center;">Loaded<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFMM0QHxQ44ef_yZ7hL4hqtEs9FHwmBSJ_IHG_0iz-SA5Bpv74hO4goLzyRD1boqAR4KIO9r8Lco8t1fgkJixvtB5IJuvP-20A4_345PTsIfsPdQAY-TkeoGoPB0TbUzNi5YZyoEQANlY/s16000/Level16.png" /></span>→ Streaming Out<span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZNVzY024FpJ65dRWU7MY3zFdq5Vddzh9rsTSzdWX5i1xlgrd-EPRNvi9L8RCPLeOXsSZFx2ju-uSts9gCk9OrrYwtAuoTipoMHgDP6W9ELc62LeoWIv3c3Uy7-R9OH37pka_0tyolmYM/s16000/StreamOut16.png" /></span> → Unloaded <span style="background-color: #eeeeee;"><img alt="" data-original-height="16" data-original-width="16" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj8DVI1e5N-RZYc-KVHo-s0K5oi5ezytBJjFKts-rmxSRgt9y6rwfMRqDu-5EQGEzh1OSoHbzsOtwgO91qLT_ySSNDiyLNJd09zsb3Crd6YBpgI-xpZSGjer_olOInSQL3Gbv-zqO-Db0/s16000/LevelUnloaded16.png" /></span><div class="separator" style="clear: both; text-align: center;"><br /></div><div style="text-align: justify;">Two new icons make a big difference. The whole thing took just a few minutes because I already had icons for these operations laying around (I use them in the context menu). This of course not include the time that it took me to realize there was a problem in the first place. Then I would need to put there more than two years. </div><div class="separator" style="clear: both; text-align: justify;"><br /></div><br /></div></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"> </div></div></div>Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com1tag:blogger.com,1999:blog-4447090642049340023.post-62039542852586509542021-08-17T07:55:00.009-07:002021-08-19T14:05:19.277-07:00Nvidia - unsigned integer issues <p>Yesterday I experienced another bunch of fun while using my laptop. My normal working environment is a desktop with an AMD graphics card, while choosing a laptop it was important for me to get some Nvidia GPU so I could test code on both machines. This was a smart decision as there are so many differences between them. This time I encounter another one.</p><h2 style="text-align: left;">History</h2><p>Like always a little bit of the background: while doing tooling you need to think about nice interactive objects selections. The beginning was rough as I decided to use a physics ray-trace system to execute picking. This was a simple system where I was sanding a ray thru the world and tried to pick objects that collide with it. </p><p>The issue was:</p><p></p><ul style="text-align: left;"><li>every object needed to have a collision body </li><li>it did not work very well with objects that had an alpha mask </li><li>did not support geometry that was deformed in shaders.</li></ul>I did not like any of these limitations so I decided one day to change the whole thing. I took this time a different approach. I added a GBuffer of type uint where I storing ID of the object.<p></p><p>With a little bit of struggle with retrieving data from GPU, I finally had a working system. It resolved all the problems that I had with the old one and added a few new ones. This was:<br /></p><ul style="text-align: left;"><li>filling this new GBuffer in the shader, </li><li>retrieving data on CPU, </li><li>the issue with selecting objects that are behind the selected objects (I just do not do this).</li></ul>In the end, nothing is really critical but as you can see nothing is only cupcakes and rainbows. <p></p><p>Thanks to this system I also could do a rendering of selection. I just sacrificed one bit of ID and used it as info if the object is selected or not. This way I can highlight it nicely using this shader code:<br /></p><br /><span style="font-family: courier;">uvec4 pix = texelFetch(texMrt1, ivec2(gl_FragCoord.xy), 0);<br />if (pix & (1<<31) == 0)<br /> discard;<br />return vec4(1.0, 1.0, 0.0 ,0.5);</span><div><span style="font-family: courier;"><br /></span><p>and that worked nice: <br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiI_i-veCUyH3Ra9lbqDtfX9hFQhjZW_ckiyYxXHKO7Q8PopldtqICEFUhARNQmkkkGq24TMOg9zZ1L6QlgDBqZJrEZNwy0Buw_8KcesRJr8xrOfZiQE5ksOOCQeP_thnx4LQ4KHWmhXtk/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="634" data-original-width="735" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiI_i-veCUyH3Ra9lbqDtfX9hFQhjZW_ckiyYxXHKO7Q8PopldtqICEFUhARNQmkkkGq24TMOg9zZ1L6QlgDBqZJrEZNwy0Buw_8KcesRJr8xrOfZiQE5ksOOCQeP_thnx4LQ4KHWmhXtk/" width="278" /></a></div><br />Sadly it is pretty visually obstructive, so I decided to improve it and add an outline. This worked well and it was super easy. I just compare if neighbor values are the same as the ones we testing and if they are not rendered more intense color.<div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-KcUczu8bdidPyOMeVsFivIiKOn9f_Yb8uIwwdMdTBgt8lXzg0O3pXYg-_CskiLv439xzIiX47TFnGJgvHNeMwScibKZWg3qL0fRRf70S0z0KQ3vT-CFQmqFY14iFwgRulNjYNVAZKCQ/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="665" data-original-width="834" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-KcUczu8bdidPyOMeVsFivIiKOn9f_Yb8uIwwdMdTBgt8lXzg0O3pXYg-_CskiLv439xzIiX47TFnGJgvHNeMwScibKZWg3qL0fRRf70S0z0KQ3vT-CFQmqFY14iFwgRulNjYNVAZKCQ/" width="301" /></a></div><br /><br /><h2 style="text-align: left;">Problem</h2>This is the place where the real story starts. The above screenshot is taken from AMD Radeon R9 390 where everything looks great. On other hand my laptop with Nvidia GTX 1660 Ti gave me a super weird result:<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCk-sNjQvaDo5T0qe9xUFSxVmccQPBvx5LsoW8f3sS-Ph-LoygKIq_xddI76eQi58ZFrFi313gA6foDoypvB6oWB9mG86yNWIt3_JvaLmratBy_U-tPF5DTtGjp8xILWQoPskFBnUuQTw/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="634" data-original-width="735" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCk-sNjQvaDo5T0qe9xUFSxVmccQPBvx5LsoW8f3sS-Ph-LoygKIq_xddI76eQi58ZFrFi313gA6foDoypvB6oWB9mG86yNWIt3_JvaLmratBy_U-tPF5DTtGjp8xILWQoPskFBnUuQTw/" width="278" /></a></div><br />Because it is always easier to investigate stuff on a smaller scale I decided to do scanning only by testing one direction. <p></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><br /><br /></blockquote></div><span style="font-family: courier;">uvec4 pix = texelFetch(texMrt1, ivec2(gl_FragCoord.xy), 0);<br />if (pix & (1<<31) == 0)<br /> discard;</span></div><div><span style="font-family: courier;"><br />uvec4 pixLeft = texelFetch(texMrt1, ivec2(gl_FragCoord.xy)-ivec2(1,0), 0);<br />if (pix.x != pixLeft.x)<br /> return vec4(1.0, 1.0, 0.0 ,0.5);</span></div><div><span style="font-family: courier;"><br /></span><div style="text-align: left;"><span style="font-family: courier;">return vec4(1.0, 1.0, 0.0 ,0.2);</span></div><div style="text-align: left;"><br /></div><div><p>This still resulted in the same effect: </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUdCuBKc-GIALarViClv7WT6DRyVbXNJ-46BMeYsE2TVVGVUMvj6FqTP_8psLnzRJ4ZHF5AEnlDiAPtlRldxHKL0D71qCReArD_29s99KX2Xr6Zmota2UIC9a-P5whNA8gvsqR9bSdYgE/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="634" data-original-width="735" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUdCuBKc-GIALarViClv7WT6DRyVbXNJ-46BMeYsE2TVVGVUMvj6FqTP_8psLnzRJ4ZHF5AEnlDiAPtlRldxHKL0D71qCReArD_29s99KX2Xr6Zmota2UIC9a-P5whNA8gvsqR9bSdYgE/" width="278" /></a></div><br />Now the weird part is that if I replace <p></p><span style="font-family: courier;">if (pix.x != pixLeft.x) </span><p>with </p><span style="font-family: courier;">if (pix.x < pixLeft.x)</span><p>we get: </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZpLLwcmjg7u-tUx1p7cnsGUET0U-NyhrPKQXkKXGVVs9N4ELBB4mtteIWx7W56vjTa9JnQo2IErxwsW1vYboSt7pLPqmNz44r_UaO6xOPPCpyIIohCxHNhg4sI6mayeKU03kzkvy0-K0/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="634" data-original-width="735" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZpLLwcmjg7u-tUx1p7cnsGUET0U-NyhrPKQXkKXGVVs9N4ELBB4mtteIWx7W56vjTa9JnQo2IErxwsW1vYboSt7pLPqmNz44r_UaO6xOPPCpyIIohCxHNhg4sI6mayeKU03kzkvy0-K0/" width="278" /></a></div><br />Which is stable, but then when I replace it with :</div><div><br /><div><span style="font-family: courier;">if (pix.x > pixLeft.x)</span></div><div><span style="font-family: courier;"><br /></span></div><div>instead, we get: </div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqTdRKEmgWRclQfQ520MCV6R2YGB3Vbtqp8FUMGLWXexJNq7VoaCulqcFWp_XxFOXG0HYecIrkC4dhY0gQ8vEnDMI9eH0eygImrmw8MTgc1LKgbtls5t8DFNwxLvGbs9RSfVjBzJXVaJg/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="634" data-original-width="735" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqTdRKEmgWRclQfQ520MCV6R2YGB3Vbtqp8FUMGLWXexJNq7VoaCulqcFWp_XxFOXG0HYecIrkC4dhY0gQ8vEnDMI9eH0eygImrmw8MTgc1LKgbtls5t8DFNwxLvGbs9RSfVjBzJXVaJg/" width="278" /> <br /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqTdRKEmgWRclQfQ520MCV6R2YGB3Vbtqp8FUMGLWXexJNq7VoaCulqcFWp_XxFOXG0HYecIrkC4dhY0gQ8vEnDMI9eH0eygImrmw8MTgc1LKgbtls5t8DFNwxLvGbs9RSfVjBzJXVaJg/" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>No matter what I do I cannot overcome this issue :/ On AMD this whole system works perfectly fine where on Nvidia it feels that there is some issue with the way how they handle uint operations.<br /><p></p></div></div><div>If you are curious how did I fix it? I did not. I went with a really ugly solution that uses dFdx/dFdy and gives crappy result but at least it works on both architectures:<br /><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8lMxrch5gHprBaS0x9l-xDsM4ge5zIsGdmqerXr7K4qnUcxHxaHVHWptHEYhvLU51kKpc166yXJAhV2PMRMkRqgfn0l9wzQHr4_Fst0brrx6dwBlP0mY2BtWVU5tPWj3dPLkCdnFsDn0/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="665" data-original-width="834" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8lMxrch5gHprBaS0x9l-xDsM4ge5zIsGdmqerXr7K4qnUcxHxaHVHWptHEYhvLU51kKpc166yXJAhV2PMRMkRqgfn0l9wzQHr4_Fst0brrx6dwBlP0mY2BtWVU5tPWj3dPLkCdnFsDn0/" width="301" /></a></div></div><br />I'm not really happy about it but this is a visual thing to which I can return back to when I will have some spare time, which right now I do not have.</div></div>Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-58269410956462110552021-08-14T14:50:00.001-07:002021-08-19T14:02:30.233-07:00Resource Center - High CPU usage<p style="text-align: justify;">This is one of the recent issues that I was tracking This issue is pretty simple but because of that, its solution is not so trivial. So let's dig into it. The resource center is a standalone app that:</p><p></p><ul style="text-align: left;"><li style="text-align: justify;">Is a remote file system server </li><li style="text-align: justify;">Integrate with Version Control System (currently P4)</li><li style="text-align: justify;">Is a resource server that is responsible for building resources</li><li style="text-align: justify;">Manage remote resource builders. </li><li style="text-align: justify;">Manage the creation of game build</li><li style="text-align: justify;">Have UI which allows to browse the file system and trigger compilation of resources and build. </li></ul><div style="text-align: justify;">All communication uses TCP/IP sockets and most operations are async for performance reasons. </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Recently I was doing changes to speed up the remote file system. I decided to switch all calls into async processing. While doing that I was put in front of the decision: Should I put all processing of connection read/write operations to a single thread? or maybe I should create a separate thread for each of them? I naively decided to go with a single-thread idea. </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">The whole code looked more or less like this:</div><span style="font-family: courier;"><br />while (true)<br />{<br /> for (auto* connection : m_connections)<br /> connection->processIncoming();<br />}</span><div><span style="font-family: courier;"></span><div style="text-align: left;"><span style="font-family: courier;"></span></div><p>on top of this:</p><span style="font-family: courier;">bool Connection::processIncoming()<br />{<br /> if (!socket->isDataAvailable())<br /> return false;<br /> .. // process data<br /> return true;<br />}</span><div style="text-align: left;"><span style="font-family: courier;"></span></div><p>Well as you can see this is a pretty tight loop that when there is no data sent, will occupy most of the CPU. For my stationary PC, this was not an issue but while using the laptop sound of the fans was accompanying me for a whole time the app was running. </p><p>This was a simple overlook. We can come with a simple solution:</p><span style="font-family: courier;">int32_t runReadThread(Server* server)<br />{ <br /> while (server->isAlive())<br /> {<br /> for (auto* connection : server->m_connections)<br /> connection->processIncoming();<br /> Sleep(kSleepTime); <br /> } <br />}</span><div><br /></div><div>One run of the app and high CPU use is gone, just like the performance of the whole app. But you can of course cover this by tweaking of kSleepTime to have some balance. A little bit of spoiler: doing this is a bad idea. That is why we may change a little bit approach may and do this:</div><div><br /></div><span style="font-family: courier;">while (true)<br />{<br /> bool hasWork = false;<br /> <br /> for (auto* connection : m_connections)<br /> if (connection->processIncoming())<br /> hasWork = true;<br /> <br /> if (hasWork)<br /> Sleep(kSleepTime);<br />} </span><div><div><span></span></div></div><div><br /></div><div style="text-align: justify;">Now if there is work we do not sleep and gain some performance, only that in practice we did not. Now I know that no matter what I would try to do this approach would not work. We can think about the whole processing as being into one of the states:</div><div><ol><li>connections have no data</li><li>connections have a continuous stream of data </li><li>connections have data from time to time </li></ol></div><div style="text-align: justify;">Let's analyze all cases. The second code example covers cases 1 and 2 which are the trivial ones. We put a thread to sleep when there is no data. When there is a continuous stream of data we just do not sleep.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Issues start with the 3rd case which in practice is the most common one. We have some data, then there is some gap without it, and so on. The presented approach introduces a delay to processing data after encounter gaps. These delays will be between 0 - kSleepTime. You can tweak it to find something acceptable but we will still slow processing. There may exist some tricks to drop sleep time when there are events and then increase it when there is no data. But to my knowledge, there will be always loose of performance.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><div>So here I'm wanting to return back to the writing game and not fixing the underlying system. I have done this for the past 3-4 weeks and feel that I drifted too much into tech. On the other hand, I cannot allow for high CPU use because this is annoying for all devs who work on tech (2 right now). That is why initially I decided to go naively with the sleep which was really a mistake. Once again by trying to save time I lost more of it. </div><div style="text-align: start;"><div style="text-align: justify;"><br /></div></div></div><div style="text-align: justify;">Before we get to my final solution I need to mention that I'm not a fan of putting the sleep in the code. I'm also not a big fan of the code that locks execution till something happens. In real-time app's they often can be replaced by async calls or delaying them till later execution. The problem is that what I do is not a real-time app. What I working on is just a normal app, you can think about it even as a demon that running somewhere in the background and does not use a lot of resources.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">In the end, I think I understood my mistake and decided to do stuff differently. I mentioned earlier "<span style="text-align: justify;">I naively decided to use a single thread.". The logic behind it was that one resource center right now can have more than </span><span style="text-align: justify;">16 connections at a time, which gives us more than 32 threads (separate for the read and write data). I</span><span style="text-align: justify;">n my opinion, this was a lot so I tried to avoid it. But this is the road that I decided to follow in the end. </span>Now my code looks more or less like this: </div><div style="text-align: justify;"><br /></div><span style="font-family: courier;"> int32_t runReadThread(Connection* a_connection)<br /> { <br /> while (connection->isConnected())<br /> connection->processIncoming(500);<br /> return 0;<br /> }</span><div><p style="text-align: start;">and function is modified:</p><span style="font-family: courier;">void Connection::processIncoming(msec_t timeout)<br />{<br /> if (!socket->isDataAvailable(timeout))<br /> return;<br /> .. // process data <br />}</span><p>The idea here is that we pushing waiting on the operating system. Whenever there is data, <span style="text-align: left;">isDataAvailable(timeout) </span>will awake the thread and start processing. In case it times out we just checking if the connection was not requested to shut down and if not, return to waiting. There is also no way of combining the processing of multiple connections into a single thread. If we do that we will need to wait for a timeout of all other connections before processing the next data. This would introduce a significant delay in the processing of events. <br /><br />Is this solution worked? I would say yes. I dropped CPU use from 30% to 0.16%, no matter if there is an app attached or not. </p><p>If I'm happy about it? I'm not really sure, somehow deep inside I suspect that there is a lot more elegant solution. Sadly I don't know it and being 3 days later in the problem I run out of the time that I can spend on it. </p><p>For now, I will take this issue as a reminder that we programmers, like to go down the rabbit holes. We try to improve our solution, tweak it, change some equations, add a null check. Everything to make it work. We do that even when deep down we know that we should not do this. I would love to say that I'm free of this behavior but I'm just like everyone else and sometimes falling into this trap. </p><p>Like always if you have some comments on the topic, suggestions about different solutions I would love to hear about them. </p><p><br /></p><div><br /></div></div></div>Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-42249471356757599602020-04-15T12:50:00.001-07:002020-04-15T12:50:24.246-07:00Configuration scripts - part 3In <a href="http://angelusda.blogspot.com/2020/04/configuration-scripts-part-1.html">Part 1</a> I described the configuration system in the engine. In <a href="https://angelusda.blogspot.com/2020/04/configuration-scripts-part-2.html">Part 2</a> I described the reason and thoughts behind the topic: Designing intuitive API that makes sense. Now time for Part 3. This time we will analyze changes in script and reason behind it. <h3>
Compute shader script</h3>
<div>
Let's start with the simplest compute shader script that doing anything :<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span>{<br /> <span style="color: #3d85c6;">ShaderFile </span>= <span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span>}</blockquote>
New version:<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span>{<br /> <span style="color: #3d85c6;">Shader</span><span style="color: #3d85c6;">.Bind</span>(<span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span>);<br />}</blockquote>
This may look like a small change but it brings consistency to script. From now on there is only function style calls with ';' at the end.<br />
<h3>
Defines</h3>
Let's now add Define to script. In original format this would look like this:<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span>{<br /><span style="color: #3d85c6;"> Define</span>(<span style="color: #cc0000;">"MY_DEFINE"</span>)<br /> <span style="color: #3d85c6;">ShaderFile </span>= <span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span>}</blockquote>
The new one is more flexible and allows to do it in 3 ways:<br />
<br />
1st:<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span>{<br /> <span style="color: #3d85c6;">Shader</span>.<span style="color: #3d85c6;">Define</span>(<span style="color: #cc0000;">"MY_DEFINE"</span>);<br /> <span style="color: #3d85c6;">Shader</span><span style="color: #3d85c6;">.Bind</span>(<span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span>);<br />}</blockquote>
2nd:<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span>{<br /> <span style="color: #3d85c6;">Shader</span> .<span style="color: #3d85c6;">Define</span>(<span style="color: #cc0000;">"MY_DEFINE"</span>)<br /><span style="color: #3d85c6;"> </span><span style="color: #3d85c6;">.Bind</span>(<span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span>);<br />}</blockquote>
3rd:<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span>{<br /> <span style="color: #3d85c6;">Shader</span><span style="color: #3d85c6;"> </span>{<br /> <span style="color: #3d85c6;">Define</span>(<span style="color: #cc0000;">"MY_DEFINE"</span>)<br /><span style="color: #3d85c6;"> </span><span style="color: #3d85c6;">Bind</span>(<span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span>);<br /> }<br />}</blockquote>
This is the first big improvement. Thanks to a new format I have a lot more flexibility in a way how I write scripts and bringing context to calls. OpenGL compute program is built using a combination of defines and shader files. The new format reflects that by syntax.<br />
<h3>
Registers</h3>
This was the biggest change in the whole script. Originally this would look like this:<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span>{<br /> <span style="color: #3d85c6;">Define</span>(<span style="color: #cc0000;">"MY_DEFINE"</span>)<br /> <span style="color: #3d85c6;">Reg</span>(0) = <span style="color: #3d85c6;">UserImage</span>(0, <span style="color: #cc0000;">"Write"</span>, 0)<br /> <span style="color: #3d85c6;">Reg</span>(1:4) = <span style="color: #3d85c6;">UserTexture</span>(4)<br /> <span style="color: #3d85c6;">Reg</span>(4) = <span style="color: #3d85c6;">Texture</span>(<span style="color: #cc0000;">"sys://Textures/Texture.dds"</span>)<br /> <span style="color: #3d85c6;">Reg</span>(5) = <span style="color: #3d85c6;">UserTexture</span>(7)<br /> <span style="color: #3d85c6;">ShaderFile </span>= <span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span>}</blockquote>
The new version:<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span>{<br /> <span style="color: #3d85c6;">Shader</span> .<span style="color: #3d85c6;">Define</span>(<span style="color: #cc0000;">"MY_DEFINE"</span>)<br /><span style="color: #3d85c6;"> </span><span style="color: #3d85c6;">.Bind</span>(<span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span>);<br /> <span style="color: #3d85c6;">Registers</span>[0]<br /> .<span style="color: #3d85c6;">Bind</span><span style="color: #3d85c6;">UserImage</span>(0, <span style="color: #cc0000;">"Write"</span>, 0);<br /> <span style="color: #3d85c6;">Registers</span>[1:4]<br /> .<span style="color: #3d85c6;">BindUserTexture</span>([4:7]);<br /> <span style="color: #3d85c6;">Registers</span>[4]<br /> .<span style="color: #3d85c6;">Bind</span><span style="color: #3d85c6;">Texture</span>(<span style="color: #cc0000;">"sys://Textures/Texture.dds"</span>);<br /> <span style="color: #3d85c6;">Registers</span>[5]<br /> .<span style="color: #3d85c6;">Bind</span><span style="color: #3d85c6;">UserTexture</span>(7);<br />}</blockquote>
As you can see once again I switched to version that gives you context and introduced python styles multi indexing. Thanks to that there is no more confusion between:<br />
<br />
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Registers</span>[1:4].<span style="color: #3d85c6;">BindUserTexture</span>(4); <span style="color: #6aa84f;">-- Assign user texture 4 to registers [1,2,3]</span><span style="color: #3d85c6;">Registers</span>[1:4].<span style="color: #3d85c6;">BindUserTexture</span>([4:8]); <span style="color: #6aa84f;">-- Assign user texture [4,5,6] to registers [1,2,3]</span></blockquote>
</div>
<div>
<h3>
Summary</h3>
<div>
All of this may sound like a trivial change but it makes a big difference. This was also a "gate" to further thoughts about coding in general.</div>
<div>
<br /></div>
<div>
<b>When we creating API we spend so much thinking about what it should do and not so much how we want to use it.</b> This is cool you now have the most efficient system that does all this cool stuff... but ... Yeah if there is no good API that is intuitive to use and kind of lead coder what it should do then all your work may be wasted. </div>
<div>
<br /></div>
<div>
From my experience awaiting you one of a few scenarios:</div>
<div>
<ol>
<li>This system will look scary to people and they will want to avoid it as much as they can. You will be one of the few chosen ones that touch this code. For everybody else, this will be a black box that they don't want to use. </li>
<li>People will start using your code but won't fully understand what they do. A simple mistake here and there, some wrong use cases and your system will always be at fault. Awaiting you a lot of discussing that this is not a fault of your system and support of all kinds of weird use cases. </li>
<li>People will decide that this is unusable and will start creating a custom wrapper around your code. This wrapper often will add a lot of overhead that will be blamed on your system. Often the reason behind this is that wrapper does more than just making your API simpler. It mixes the use of your code with their use cases. You will be lucky if in codebase there will be only one of them. </li>
<li>This code is black magic but people still want its functionality. Answer: write own version of it. Sadly, in the end, there will be probably a few versions of it and none of them will be as efficient or secured like yours.</li>
</ol>
<div>
You may, of course, argue that this is not your fault and responsible are these incompetent programmers that cannot use your beautiful system. Then good luck in life, the reality is that in the work environment we deal with different people. Some are great programmers other not so much (They may be at the same time grate in math, shaders or UX). </div>
<div>
<br /></div>
<div>
From my personal experience: </div>
<div>
<br /></div>
<div>
Some systems that I wrote in the past I relearn every time I work with them. They feel somehow wrong, I need to think about what to fill into them, they are really easy to make mistakes or they just have inconsistent API which forces me to think how to use some function and not just code. </div>
<div>
<br /></div>
<div>
Remember: I write here about my own code. Yeah ... this is sad ... But the reality is that all of us wrote code like that. These days my priority is to have fun with coding. That is why when I encounter code like that I try to improve it. When I write a new code I try to make it a way that is fun to use it even if it will affect in some way the underlying system. </div>
<div>
<br /></div>
<div>
For clarification in no means I promoting here making bad code. What I mean is to make good code with a nice API. </div>
</div>
<div>
<br /></div>
<div>
<div style="text-align: right;">
To next time.</div>
<div style="text-align: right;">
Greg</div>
</div>
<div>
<br /></div>
<div>
<br /></div>
</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-33002865365262141672020-04-13T06:17:00.000-07:002020-04-15T11:16:25.550-07:00Configuration scripts - part 2In <a href="http://angelusda.blogspot.com/2020/04/configuration-scripts-part-1.html">Part 1</a> I described how my configuration script system works. Part 2 will focus more on the real reason why I decided to write this post:<br />
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Designing intuitive API that makes sense.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
The more I code and work on complex systems the more I see how important good API is. There is of course 1001 articles describing how to do that and if you are searching for one of them you are not in the right place. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
My focus will be on my personal evolution in a way how I think about API. Whole thought came from improving compute shader scripts. They had a really simple form:</div>
<div style="text-align: left;">
<div>
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span><br />
{<br />
<span style="color: #3d85c6;">Define</span>(<span style="color: #cc0000;">"MY_DEFINE"</span>)<br />
<span style="color: #3d85c6;">Reg</span>(0) = <span style="color: #3d85c6;">UserImage</span>(0, <span style="color: #cc0000;">"Write"</span>, 0)<br />
<span style="color: #3d85c6;">Reg</span>(1) = <span style="color: #3d85c6;">UserTexture</span>(4)<br />
<span style="color: #3d85c6;">Reg</span>(2) = <span style="color: #3d85c6;">UserTexture</span>(5)<br />
<span style="color: #3d85c6;">Reg</span>(3) = <span style="color: #3d85c6;">UserTexture</span>(6)<br />
<span style="color: #3d85c6;">Reg</span>(4) = <span style="color: #3d85c6;">Texture</span>(<span style="color: #cc0000;">"sys://Textures/Texture.dds"</span>)<br />
<span style="color: #3d85c6;">Reg</span>(5) = <span style="color: #3d85c6;">UserTexture</span>(7)<br />
<span style="color: #3d85c6;">ShaderFile </span>= <span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span><br />
}</blockquote>
</div>
<div>
This was nice but defining N users texture registers felt pretty robust so in the past I have done my first improvement: </div>
<blockquote class="tr_bq">
<span style="color: #3d85c6;">Compute</span><br />
{<br />
<span style="color: #3d85c6;">Define</span>(<span style="color: #cc0000;">"MY_DEFINE"</span>)<br />
<span style="color: #3d85c6;">Reg</span>(0) = <span style="color: #3d85c6;">UserImage</span>(0, <span style="color: #cc0000;">"Write"</span>, 0)<br />
<span style="color: #3d85c6;">Reg</span>(1:4) = <span style="color: #3d85c6;">UserTexture</span>(4)<br />
<span style="color: #3d85c6;">Reg</span>(4) = <span style="color: #3d85c6;">Texture</span>(<span style="color: #cc0000;">"sys://Textures/Texture.dds"</span>)<br />
<span style="color: #3d85c6;">Reg</span>(5) = <span style="color: #3d85c6;">UserTexture</span>(7)<br />
<span style="color: #3d85c6;">ShaderFile </span>= <span style="color: #cc0000;">"sys://Shaders/ComputeShader.glsl"</span><br />
}</blockquote>
In this form, I was using a script for some time. Everything was "perfect" till I started to work on the next iteration of material scripts and decided to also improve compute shaders scripts. At this point for the first time, I really started to think what I like and dislike in this format.<br />
<br />
What I like:<br />
<br />
<ul>
<li>Script doing what it should.</li>
<li>I like the possibility of working on multiple registers (this saves a lot of time).</li>
</ul>
What I did not like:<br />
<br />
<ul>
<li>API feels inconsistent. </li>
<li>Working on multiple registers is not really intuitive.</li>
</ul>
<h3>
Problem</h3>
<div>
What irritated me the most was the point "Working on multiple registers is counterintuitive.".</div>
<div>
<ol>
<li><span style="color: #3d85c6;">Reg</span>(1:4) = <span style="color: #3d85c6;">UserTexture</span>(4) </li>
<li><span style="color: #3d85c6;">Reg</span>(5) = <span style="color: #3d85c6;">UserTexture</span>(7) </li>
</ol>
</div>
Why line 1. expands into:<br />
<br />
<span style="color: #3d85c6;">Reg</span>(1) = <span style="color: #3d85c6;">UserTexture</span>(4)<br />
<span style="color: #3d85c6;">Reg</span>(2) = <span style="color: #3d85c6;">UserTexture</span>(5)<br />
<span style="color: #3d85c6;">Reg</span>(3) = <span style="color: #3d85c6;">UserTexture</span>(6)</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Where line 2. is untouched? How I can assign the same user texture to the same register? At this moment my thoughts started drifting and I started thinking about API in general and my past experience.</div>
<div style="text-align: left;">
<br />
We, programmers, love to write API (especially new ones). When we do it we thinking what new piece of code should do. When we expanding existing API we modify it by adding functionality we need to continue our work. We take pride in the systems that we designing and code that we wrote. These are awesome pieces of technology that push industry forward.<br />
<br />
This, of course, applies only to our code. The Code of others is mostly to rewrite. It not necessarily doing what it should and even if it does, we could do it better.<br />
<br />
In the end, this is a really dangerous way of thinking.<br />
<h3>
This is a trap</h3>
The code is just a code. Depending on your skills, background, experience, language you use or just how long your code you may see a different piece of code as a good one. That is why it is important to analyze the existing piece of code not only in terms of how it looks right now but also reasoning and intention behind it.<br />
<br />
Sometimes you may be surprised that code that looks bizarre is this way because it couldn't be done a lot better without major refactoring which could endanger the shipment. Another possibility is that it touching such a critical code path that it would take too long to fix it. I have seen also code that became worse when somebody started modifying code without fully understanding its intention. There is, of course, the possibility that code is just bad but while working with experienced people you should put this option at the end of the list.<br />
<br />
While you should trying to not judge the code of others to fast, you should also be open for comments from other coders. If somebody criticizes your code don't be an asshole, sit silently and later badmouth them behind their back. Approach them and start a discussion about the reason they think this code is bad. Maybe they are right and this code could be done better and you will learn something new. Maybe they just missing context or doing some wrong assumptions and after your explanation, they will know more and see this code a little bit differently.<br />
<br />
In the end, everything falls into the topic I discussed in <a href="http://angelusda.blogspot.com/2015/04/code-review-story.html">Code review story ...</a> if you don't want to throw away your pride and start a constructive discussion you will never improve.<br />
<br />
<br />
<br />
<br />
When I started doing part 2 I didn't expect this topic to have part 3 but well surprise surprise. This feels like right place to have another split. In the last part, I will discuss how I changed my compute shader script and try to explain why I did it in the way I did.<br />
<div style="text-align: right;">
<br /></div>
<div style="text-align: right;">
To next time.</div>
<div style="text-align: right;">
Greg</div>
<br />
<br />
<br /></div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-24160119534558657552020-04-10T13:40:00.000-07:002020-04-10T13:40:31.457-07:00Configuration scripts - part 1<div>
This may sound weird in days where everything needs to have some kind of UI but the recent time I spend upgrading some of my configurations scripts. My current workflow is to define parsing rules and generate from them parser. To give you an idea what I talk about this is simple rules for the logging configuration file:</div>
<div>
<blockquote>
<i>%name = LogConfig</i> </blockquote>
<blockquote>
<i>%%<br />.input : /* empty */<br /> | LogAllow .input<br /> | LogBlock .input<br /> | AllLogBlock .input<br /> | AllLogAllow .input<br />;<br />LogAllow<br /> : 'LogAllow' '(' $(CStringID) ')' ';'<br />;<br />LogBlock<br /> : 'LogBlock' '(' $(CStringID) ')' ';'<br />;<br />AllLogBlock<br /> : 'AllLogBlock' '(' ')' ';'<br />;<br />AllLogAllow<br /> : 'AllLogAllow' '(' ')' ';'<br />;<br />%%</i></blockquote>
<div>
It allows me then to parse a file that looks like this:</div>
</div>
<div>
<blockquote class="tr_bq">
<i>LogAllow("Crash");<br />LogAllow("Assert");<br />LogBlock("Scripts");<br />LogBlock("Audio");</i></blockquote>
</div>
<div>
This may sound like a lot to parse simple format like this but in practice, I like it. If you interested why:</div>
<div>
<ul>
<li>The generation of a parser is compile-time.</li>
<li>There is a validation of format while parsing script (I get a line where there is an error).</li>
<li>I can generate a more compact binary format for a script.</li>
<li>I get a lot of freedom in generating parsers.</li>
</ul>
<div>
Parsing of this file would be done then this way: </div>
</div>
<div>
<div>
<br /></div>
<div>
<span style="color: #3d85c6;">CScriptParserBase</span><<span style="color: #3d85c6;">CVmCodeLogConfig</span>> parser;</div>
<div>
<span style="color: #a64d79;">wrErrorRetCheck</span>(parser.parse(script));</div>
<div>
<br /></div>
<div>
<span style="color: #3d85c6;">CStringID </span>filter;</div>
<div>
<br /></div>
<div>
<span style="color: #3d85c6;">for </span>(<span style="color: #3d85c6;">auto </span>node : parser)</div>
<div>
{</div>
<div>
<span style="color: #3d85c6;">switch </span>(node.h_name())</div>
<div>
{</div>
<div>
<span style="color: #3d85c6;">case </span><span style="color: #cc0000;">"LogAllow"_Hash64</span>:</div>
<div>
node.arguments(filter);</div>
<div>
allow(filter);</div>
<div>
<span style="color: #3d85c6;">break</span>;</div>
<div>
<span style="color: #3d85c6;">case </span><span style="color: #cc0000;">"LogBlock"_Hash64</span>:</div>
<div>
node.arguments(filter);</div>
<div>
allow(filter);</div>
<div>
<span style="color: #3d85c6;">break</span>;</div>
<div>
<span style="color: #3d85c6;">case </span><span style="color: #cc0000;">"AllLogBlock"_Hash64</span>:</div>
<div>
m_defaultFilter = <span style="color: #674ea7;">EBlock</span>;</div>
<div>
m_filters.clear();</div>
<div>
<span style="color: #3d85c6;">break</span>;</div>
<div>
<span style="color: #3d85c6;">case </span><span style="color: #cc0000;">"AllLogAllow"_Hash64</span>:</div>
<div>
m_defaultFilter = <span style="color: #674ea7;">EAllow</span>;</div>
<div>
m_filters.clear();</div>
<div>
<span style="color: #3d85c6;">break</span>;</div>
<div>
<span style="color: #3d85c6;">default</span>:</div>
<div>
<span style="color: #3d85c6;">break</span>;</div>
<div>
}</div>
<div>
}</div>
</div>
<div>
<br /></div>
<div>
This introduction got a little bit longer than I planned. Yeah ... this is not really a topic that I wanted to discuss. At the same time, it is important to understand where I go with all of this. </div>
<div>
<br /></div>
<div>
The real topic I wanted to discuss is: </div>
<div>
<br /></div>
<div style="text-align: center;">
Designing intuitive API that makes sense. </div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
and because this post came out long already I will split the topic into multiple parts. The next one will describe in more detail why this topic.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<div style="text-align: right;">
To next time. </div>
<div style="text-align: right;">
Greg </div>
</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-52434038965158873262020-03-01T09:42:00.001-08:002020-03-01T09:42:33.019-08:00Hobby or Work<div style="text-align: justify;">
Interesting topic for a post came recently to my mind when one of my friends commented on me taking a day off from work to relax as:</div>
<blockquote class="tr_bq" style="text-align: center;">
"Anyway, you will wake up that day and work."</blockquote>
<div style="text-align: justify;">
This was, of course, comment on me developing LBA remake in my free time. What is interesting about it I'm not fully sure what to think about it. Because how what I doing in my free time is different than other people's hobbies? On another hand how it is different than what I do in a work?</div>
<h3 style="text-align: justify;">
What is a hobby?</h3>
<div style="text-align: justify;">
All of this thinking brought me to this simple question on which I don't have really a definite answer. In the end, what is a hobby for one person can be a work for others. There is a lot of examples of that: </div>
<blockquote class="tr_bq" style="text-align: justify;">
riding a bike, skateboarding, painting, drawing, writing stories, creating graphics, woodworking, restoration of items, fixing electronics, traveling, singing, dancing and even stuff like cosplay. </blockquote>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
All of that and a lot more can be a hobby but at the same time, it can be a work. So where is the boundary that separates these two states of a mind? Let's select two of the examples and focus on them more. My not random choice will be <b>woodworking </b>and <b>dancing</b>. </div>
<h4 style="text-align: justify;">
Woodworking </h4>
<div style="text-align: justify;">
Woodworking can be not only a job but also a hobby, if you don't believe check youtube there is a lot of hobbyist youtube channels that do awesome stuff. Another personal example is my dad that also do it for fun in his free time. What is interesting about this example is the wording we use regards it:</div>
<div>
<br /></div>
<div style="text-align: center;">
"Woodworking skills"</div>
<div style="text-align: center;">
"Working in wood"</div>
<div style="text-align: center;">
"Working with wood"</div>
<div style="text-align: center;">
"Tools for woodworking"</div>
<div style="text-align: center;">
"Woodworking equipment"</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
All of them talking about working, skills, equipment, and tools. I don't want to enter here some specialized naming of techniques and tools but I think you see mine point.</div>
<h4 style="text-align: left;">
Dancing</h4>
<div style="text-align: justify;">
Just like woodworking, we know dancing can be a hobby but at the same time it can be a work. That is why we have all these professional competitions, dancing schools and so on. Just like in the previous example let's find some wording that comes to my mind regards it: </div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
"Dancing skills."<br />"Dancing moves." </div>
<div style="text-align: center;">
"Dancing choreography."</div>
<div style="text-align: center;">
"Dancing styles"</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: justify;">
I had a really hard time to come with some examples here. I can write a lot about dancing about feeling regards it but not a lot of these short more technical sentences. So let's try some other example:</div>
<h4 style="text-align: left;">
Traveling</h4>
<div style="text-align: justify;">
Not everybody travels as a hobby for a lot of people this is part of their work. Where they go to different places and meet people they need to meet for business reasons. Like in the previous two cases lets think about wording that comes to my mind:</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: center;">
"Travel destination"</div>
<div style="text-align: center;">
"Traveling guide"</div>
<div style="text-align: center;">
"Traveling equipment"</div>
<div style="text-align: center;">
"Exploring"</div>
<div style="text-align: center;">
"Meeting new people"</div>
<div style="text-align: center;">
"Seeing new places"</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
This was a lot easier than Dancing so the choice was right.</div>
<h3 style="text-align: left;">
Self-reflection</h3>
<div style="text-align: justify;">
While writing these examples I found that I myself am very biased in regard to how I feel about them. Look that in case of woodworking I was from start pointing out that this can be a hobby while in the other two cases I was pointing opposite proving that they are not only a hobby.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Then came the wording and this proves the same thing. In the woodworking case, the first things that came to my mind contained "work", "tools", "skills", "equipment". Which is not so much truth in other examples. So even I am biased here. And I know that activities like woodworking can be a hobby.</div>
<h3 style="text-align: justify;">
Conclusion</h3>
<div style="text-align: justify;">
With this, I can see how my friends seeing me, programming and developing a game in my free time as work and not a hobby. But it still hurts because for me I have a lot of fun doing it, learning new skills and seeing the result of my efforts (If you think that efforts sound weird here it is because I thought about using word "work" but I don't really want to use it here in this context).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
If you think about it more as I struggle to convince others that what I do after work is a hobby there are also pepole that have a hard time convincing others that what they do is a work and not a hobby.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now I'm curious if I overthinking stuff or not. What is your opinion about all of this? </div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-5725860006871125102019-04-09T01:37:00.003-07:002019-04-09T01:37:57.971-07:00constexpr<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUEKSjhGZiNrZg-46LPTkgIffIr9q1Ku3EUxiHcDBTE_FQKfWRhiNIOw2gJuZH0eLwJs5ajEVvHUI15J1F3V-q7sP9v8x3gRJEBFhLiXufp9xuMRm4Hd1STGTA3b93eDjtZ0KPjaD5Ikw/s1600/Screenshot+2019-04-09+at+10.32.55.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="839" data-original-width="1600" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUEKSjhGZiNrZg-46LPTkgIffIr9q1Ku3EUxiHcDBTE_FQKfWRhiNIOw2gJuZH0eLwJs5ajEVvHUI15J1F3V-q7sP9v8x3gRJEBFhLiXufp9xuMRm4Hd1STGTA3b93eDjtZ0KPjaD5Ikw/s400/Screenshot+2019-04-09+at+10.32.55.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><a href="https://gcc.godbolt.org/z/sGd-Dp">https://gcc.godbolt.org/z/sGd-Dp</a></td></tr>
</tbody></table>
<br /><div>
I recently were introducing friends to constexpr and I'm super surprise how inconsistently it works between different compilers. I will need to look more into my code to assure that its do what I want. </div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-82375718497389459632019-04-06T15:39:00.004-07:002019-04-06T15:39:47.353-07:00Clean design ...<div style="text-align: justify;">
I would love to say you a story how awesome my code designing skills are but with time I learned that I still have long way to go. Now we know what this story won't be about and focus on what we will be talking about: My recent issue and how I solved it.</div>
<div>
<div>
<h3 style="text-align: justify;">
Introduction</h3>
<div style="text-align: justify;">
The story taking place in one of many days when I was doing something for project. I was working on content an once again stumble upon problem with editing multiple terrain groups. I knew about it and delayed it already few times but this time it finally blocked me from further progress. This meant only one thing: fixing day arrived. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
"Cool" I thought and started checking what going wrong. Destiny wanted that in meantime of testing some irritating issue surfaced: I was not able to display in inspector properties of <b>World Terrain System. </b>I was trying to select it in hierarchy but only level properties were displayed. </div>
<div style="text-align: justify;">
<br /></div>
<div>
<div style="text-align: justify;">
And this will be topic of my story: How I approached fixing this "trivial" thing. <b> </b></div>
<div style="text-align: justify;">
<br /></div>
</div>
</div>
<h3 style="text-align: justify;">
Stage 1: Investigation</h3>
<div style="text-align: justify;">
There are two use cases to display properties inside the inspector: </div>
<div style="text-align: justify;">
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEfJR4e64MzSYozEfzTkwr5viGyMF2bxhoakz431SSoPTThvr8radQkZPf2QtVcw-0h6IpVaVcP4ns-ZsmrRObGDC0K_wD9FwXSwlOkWoARrw9vh5DyNVSYuCGaw2cXlkMV8nqxjt2p4g/s1600/Graph.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="283" data-original-width="599" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEfJR4e64MzSYozEfzTkwr5viGyMF2bxhoakz431SSoPTThvr8radQkZPf2QtVcw-0h6IpVaVcP4ns-ZsmrRObGDC0K_wD9FwXSwlOkWoARrw9vh5DyNVSYuCGaw2cXlkMV8nqxjt2p4g/s320/Graph.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Color of nodes are important here because green nodes mean that selected object have EntityID and orange that it uses something different. Following this thought process I quickly checked which objects I could select and turned out that only levels and entities worked. This was some good lead.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
In code this two system are supported differently: </div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIQKKaRY1CpxOKSlYRs_B9IZC329XjQnuPqkSqtY74RGoBfPcwUeUhY4MWRVuVR2BFTKQwIXLrq0RS1XAtS5hPhANuj9WyLvr4rkTdt7T2dFZJJNw1dlzk6fDiYwR3D_z6o7QOLLb55N8/s1600/FlowOfData1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="515" data-original-width="993" height="206" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIQKKaRY1CpxOKSlYRs_B9IZC329XjQnuPqkSqtY74RGoBfPcwUeUhY4MWRVuVR2BFTKQwIXLrq0RS1XAtS5hPhANuj9WyLvr4rkTdt7T2dFZJJNw1dlzk6fDiYwR3D_z6o7QOLLb55N8/s400/FlowOfData1.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
As you see the selecting of Level/Entity in hierarchy windows works different than selecting of systems. When you select the Level/Entity item, <span style="font-family: Courier New, Courier, monospace;">UI</span> send <span style="font-family: "courier new" , "courier" , monospace;">SelectObjectEvent</span> to back-end which update the selection. This operations triggers the <span style="font-family: "courier new" , "courier" , monospace;">SelectionChangedEvent</span> which then processed by <span style="font-family: Courier New, Courier, monospace;">UI</span> update hierarchy windows and Inspector. Uff... this was intense but let's continue.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
In case of selecting in the hierarchy, the information what properties should be displayed going directly to the inspector. This would be whole story ... except that when you select System/Level you inform back-end that you deselected all entities. As you probably figured out : I using <span style="font-family: "courier new" , "courier" , monospace;">SelectObjectEvent</span> to do that :]</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="clear: both; text-align: justify;">
Stage 2: Explanation</h3>
</div>
</div>
<div>
We know what happening: </div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl-ScNVhwjA_QNQvcY5FDw0Sj_U9jpSmOPhUKrfIdPB3dOBsP_JUni_mP5SVbs7BhH0prn9tG81xWIg0qgrRLcWQLAhVjgZfMzlxFjD6Nq64ZH_rPlZX8L4T7nGfJZZiaoSAhxgMghyc0/s1600/TimeFlow.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="390" data-original-width="1054" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl-ScNVhwjA_QNQvcY5FDw0Sj_U9jpSmOPhUKrfIdPB3dOBsP_JUni_mP5SVbs7BhH0prn9tG81xWIg0qgrRLcWQLAhVjgZfMzlxFjD6Nq64ZH_rPlZX8L4T7nGfJZZiaoSAhxgMghyc0/s400/TimeFlow.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Turned out that this whole problem was really simple.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h3 style="clear: both; text-align: left;">
Stage 3: Solution </h3>
<div style="text-align: justify;">
Finally we got to point where the title of post will be relevant. Figuring out of this particular issue wasn't supper complicated. Fixing it was a little bit different.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Everybody have their own way of handling bugs. I believe that you should always find real source of the issue. This will take more time, will be more challenging if you don't know/remember code you working and may result in bigger changes to fix it. But I still believe that it is worth it. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
In this specific example it is not only important how to fix the issue but also how to prevent more issues with inspector. My conclusion was that whole issue was created by me trying to be smart. I create system that reacted to any changes inside selection. This was done so I didn't miss any of them.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
In the reality this turned out fatal. There was so much happening with selection that I missed few cases and lost control over overall system. If you look on graph of interactions between system from second stage it may look easy but it have a lot of this small cases that made whole system tricky to follow.<br />
<br />
With this fix I switched to simpler version: </div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivZrXK2hl63c1kBVKVpNKVsKPF8U1buTJKKCcPu9oVTw9TCVeDJGB2vHeUoSJyAFQwhys7O6-rQXSzzhiGAclA7s5lA0itZ4enNrIDXIzQCFVv0fdxpgby6RtYTaJoGGQJCprDBjoAZrk/s1600/FlowOfData2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="516" data-original-width="993" height="166" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivZrXK2hl63c1kBVKVpNKVsKPF8U1buTJKKCcPu9oVTw9TCVeDJGB2vHeUoSJyAFQwhys7O6-rQXSzzhiGAclA7s5lA0itZ4enNrIDXIzQCFVv0fdxpgby6RtYTaJoGGQJCprDBjoAZrk/s320/FlowOfData2.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<ol>
<li>All interaction with hierarchy inform inspector directly what properties it should display. </li>
<li>Mouse picking of object from view port also can affect inspector as separate code path.</li>
<li>Updating of selection is done by each operation separately.</li>
</ol>
I also left <span style="font-family: "courier new" , "courier" , monospace;">SelectionChangedEvent </span>in case that other systems wanted to react on this event. All of this changes resulted in cleaner flow of data that is unified for each of its parts and this is what I can call clean design.</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-46723580107742802442018-08-20T16:15:00.001-07:002018-08-20T16:15:27.937-07:00How the fate like to play with us (3rd generation of RTTI)<div style="text-align: justify;">
Life bring to us surprises everyday but today I was impressed how fate works.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Whole story started few years ago when I decided to make my own RTTI system for White Rabbit Engine. Then I was still young and naive and thought like everybody at this age that I know how to write complicated systems. This experience teach me that I really can write complicate systems ... but not necessarily should. System was working fine but was over complicated and resulted in lot of stability issues.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This realization lead to the series of improvement. I like to call it 2nd generation of RTTI system. Changes are covered by <a href="https://angelusda.blogspot.com/2015/09/rtti-changes-for-better.html#more">on of my posts</a>. This was already big step: system was simpler, easier and what most important more stable. This sentence could probably end this story if not the fact that I always felt that it is still not final form of this piece of code. This wasn't what I fully wanted.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
There was one particular feature that I struggled to add but failed to achieve: <b>virtual members</b>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Concept was simple. In RTTI v2 declaration of members look like that:</div>
<br />
<div id="Class_HeaderA">
<pre class="brush: cpp">RTTI_DECLARATION_BEGIN(CMyRttiClass)
RTTI_ATTRIB(m_name)
.setAlias("Name")
.setEditorParams("[Unique]");
RTTI_ATTRIB(m_meshResource)
.setAlias("Mesh Resource")
.bindSetCallback(&CMyRttiClass ::setResource)
.setEditorParams("[Ext:'msh','mshxml']");
RTTI_DECLARATION_END
</pre>
</div>
<br />
And I wanted to do something like this: <br />
<br />
<div id="Class_HeaderB">
<pre class="brush: cpp">RTTI_DECLARATION_BEGIN(CMyRttiClass)
RTTI_ATTRIB(m_name)
.setAlias("Name")
.setEditorParams("[Unique]");<pre class="brush: cpp"> RTTI_ATTRIB(m_meshResource)
.setAlias("Mesh Resource")
.bindSetCallback(&CMyRttiClass ::setResource)
.setEditorParams("[Ext:'msh','mshxml']");</pre>
RTTI_ATTRIB(VirtualMemberOfClass)
.setAlias("VirtualMember")
.setSerializers(WriteVirtualMember, ReadVirtualMember);
RTTI_DECLARATION_END
</pre>
</div>
<br />
<div style="text-align: justify;">
<b>VirtualMember </b>is variable that don't exist in <b>CMyRttiClass</b> but you can specify custom reader/writer and everything will works like it is a member of the class. I tried to add it for some time but there were some many issues and edge cases that I gave up because of time constrains. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now we are three years later and I already using 3rd generation of my RTTI system which looks like that:</div>
<br />
<div id="Class_HeaderB">
<pre class="brush: cpp">RTTI_DECLARATION_BEGIN(CMyRttiClass)
RTTI_ATTRIB(m_name)
.setDefaultSerialization<CStringID>();
RTTI_ATTRIB(m_meshResource)
.setDefaultSerialization<CMeshResource::Handle>();
RTTI_DECLARATION_END
</pre>
</div>
<br />
I drop all the edition information from code and moved it to special definition file. Its describe how to display class in inspector. Example of class definition bellow:<br />
<blockquote class="tr_bq">
def("CMyRttiClass")<br />
{<br />
"m_name" : CStringID <"Alias": "Name">;<br />
"m_meshResource" : FilePath < "Alias": "Mesh Resource", "Filter":"#meshes#" >;<br />
}</blockquote>
Advantages of this solution is:<br />
<ul>
<li>Thanks to hot reloading I can change this filein run time</li>
<li>It created separation between code and edition (I going more and more into this direction).</li>
<li>Whole change simplified my RTTI code.</li>
</ul>
<div>
Disadvantages:</div>
<div>
<ul>
<li>I need to manually modify this script when I modify code.</li>
<li>I needed to create pretty extensive validation and bug reporting for whole system.</li>
</ul>
<div>
<div style="text-align: justify;">
RTTI v3 is in use for some time already and I'm somehow surprised how solid this concept hold. Only thing that I didn't expect from this change is that it will made <b style="text-align: justify;">virtual members </b><span style="text-align: justify;">concept possible. I can say even more it was pretty trivial to do.</span></div>
<span style="text-align: justify;"><br /></span>
<div style="text-align: justify;">
That is why I mentioned that fate like to play with us. When I wanted to add virtual members I couldn't but when I stopped trying it just happened. Of course this is simplification and in practice this it result of all this years of changes. In the end don't think that this feature would be possible to achieve in other way.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Normally I probably wouldn't able to see how much I grow as a developer over the years but I'm one of this few who still work on the same code base after years. This allow me to see where I am, where I was and how naive I was when I was starting this project. Now I'm one step closer to its epic final...</div>
</div>
</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-12176295159279636042018-02-07T16:53:00.001-08:002018-02-07T16:53:17.615-08:00Little -> Monster<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgQk1ttEUg9GO2CJKipRI77okVYvCM05MjkAI4mlw0sPeiXD0_lA-6Tjf221rqYPCRS2YRwj_DHORWIaLhMv_Qu6-GttzT_4_zl1b639o0kznI1vShaL3SqgIu4OEuaaLkrS6H2DPP-Rk/s1600/Tests.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="128" data-original-width="128" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgQk1ttEUg9GO2CJKipRI77okVYvCM05MjkAI4mlw0sPeiXD0_lA-6Tjf221rqYPCRS2YRwj_DHORWIaLhMv_Qu6-GttzT_4_zl1b639o0kznI1vShaL3SqgIu4OEuaaLkrS6H2DPP-Rk/s1600/Tests.png" /></a><br />
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Often when I do coding I asking myself how this small modification that I wanted to do converted into this monster that I working on ... Good example is my recent decision to add regressions tests. I want to validating that I'm still able load some of the resources. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Spoiler alert : I spend already few hours and still don't have this tests. </div>
<br />
<div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</div>
<a name='more'></a></div>
<div>
<div style="text-align: justify;">
Current setup look like this:</div>
</div>
<div>
<ul>
<li style="text-align: justify;"><b>native tests -</b> don't require initialization of whole engine and testing mostly low level stuff. </li>
<li style="text-align: justify;"><b>tools tests </b>- run inside in tools with initialized engine but don't have direct access to it API. </li>
</ul>
<div>
<div>
<div style="text-align: justify;">
Plan was simple. I want to add:</div>
</div>
<div>
<ul>
<li style="text-align: justify;"><b>run-time tests</b> - run inside engine (they have direct access to it).</li>
</ul>
<div>
<div style="text-align: justify;">
This would allow me to easy load resources and do some simple check on it to validate that there is no major problems with them. So far so good...</div>
</div>
</div>
<h2>
Clean vision what I want to do</h2>
<div>
<div style="text-align: justify;">
Because this is pretty straight forward modification there is no need for too much planning. I just need to jump into code and expand a little bit <a href="https://github.com/unittest-cpp/unittest-cpp">UnitTest-Cpp</a> to support what I want. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
To do that like always I poking around in test runner. Adding some code here and there. With time I start realizing that there is issue with my approach. I want to have nice progress bar that follow executed tests and this approach don't support it.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Turning out this will be a little bit harder just because of this "stupid" feature but I really want to support it because it is cool to have it. Jumping into code again to add even more stuff ... </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
(2 hours later)</div>
<h2 style="text-align: justify;">
Not so clean execution of what I wanted to do</h2>
</div>
<div style="text-align: justify;">
Finally. Code works but I don't like it. Can you imagine ? I spend all this time just to came to this conclusion. What I have now is mess which is hard to follow. Somewhere around this point of time I came to realization that it would be really cool if GUI handle all tests the same way and the best thing I have idea how to do it. Time to do some cleanup and more work. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
(2 hours later)</div>
<h2 style="text-align: justify;">
Something went wrong</h2>
<div style="text-align: justify;">
Whole change taking shape and is what I want. Doing some final testing ... and something is wrong. I just noticed that after finishing whole run I have more than thousand of test finished. This wouldn't be weird if not the fact that I have just eight hundred of them. Taking deep breath and starting debugging... </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
(0.5 hour later ) </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Found issue in filtering of tests. Small mistake in code but could propagate pretty badly. Adding some additional tests for founded cases and re-running all tests... f.. . Taking another deep breath and returning to debugging. There is still too many tests executed.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
(0.5 hour later ) </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Found second issue. One of changes I added on top of <a href="https://github.com/unittest-cpp/unittest-cpp" style="text-align: justify;">UnitTest-Cpp</a> had some issue that allow to define duplicated tests. Fix is on it way.</div>
<h2 style="text-align: justify;">
Happy ending</h2>
<div style="text-align: justify;">
I don't see any more issues. Whole thing works, bugs are fixed, additional test are in place and whole change-list ended with 64 files modified, added 2 new ones and total od: +720 lines / -232 lines. Not so small change anymore.</div>
<div>
<h2 style="text-align: justify;">
Conclusion</h2>
</div>
<div style="text-align: justify;">
This is not first time that turning out that my initial vision was more like wish which when confronted with reality crumbling and need to be changed. Small modification then escalating and became something bigger. Bigger code require more effort to make it into something that fit whole engine architecture and code standards. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
In the end I'm most of the time satisfy with result but in the same time tiring. I know how much work is still ahead me to finish this project and the worst thing is that I probably once again underestimating amount of works :/ Do you guys have similar experience when you working on some features ? or this is just me? </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: right;">
Greg</div>
<div>
<ul></ul>
</div>
</div>
</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-66987004587016177612017-06-05T06:48:00.003-07:002017-06-05T06:48:19.602-07:00Catching up<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">There is so much going on this year that I don’t have too much time to write posts. For this who don’t follow my</span><a href="http://coffemonsters.com/" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"> other blog</span></a><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> this is some summary of most important changes: </span></div>
<ul style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">In February I started working for Unity Technologies.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Engine slowly transit to Physics Base Rendering (PBR).</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I released new video </span><a href="https://youtu.be/q6Ql9MX4baM" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">https://youtu.be/q6Ql9MX4baM</span></a><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> with game progress.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Been at </span><a href="https://blogs.unity3d.com/2017/05/26/running-with-ideas-at-hack-week-xii/" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">Unity HackWeek XII</span></a><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> (I’m even on one of photos at blog, find me if you can :P)</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Dropping kinematic character physics in game. </span></div>
</li>
</ul>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Now that I think about it each of this points could be separate post. But well there is no point in thinking about past and let’s focus on present and topics I work on in the same time:</span></div>
<ol style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">PBR transition.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Physics changes.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Game not working smooth.</span></div>
</li>
</ol>
<h3 dir="ltr" style="line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt; text-align: justify;">
<span style="background-color: transparent; color: #434343; font-family: Arial; font-size: 14pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">PBR transition </span></h3>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">This slow down a little bit because I try to read in free time recommended by friend </span><a href="http://www.frostbite.com/2014/11/moving-frostbite-to-pbr/" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">moving frostbite to pbr</span></a><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">. I start to see how much knowledge I missing to do it properly. There is all this sections about lights parameters that I never thought about, lenses configuration and so on. </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Maybe you have some other good articles/presentations which explain this in details ? I personally missing some information how to put all this together :( there is so much sources explaining each step of pipeline but non really explain how to put all this together. If you have something like that I would love to hear about this :D</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Summarizing</span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">: till I figure out all of this and finally define all masks I cannot really start work on game assets. So for now I don’t focusing on new content too much and adding mostly placeholder geometry</span></div>
<h3 dir="ltr" style="line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt; text-align: justify;">
<span style="background-color: transparent; color: #434343; font-family: Arial; font-size: 14pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Physics changes</span></h3>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Changes in physics are always hard for me because I’m not feeling fully comfortable with whole code base. With each iteration I try to understand how things work internally but this is rather slow process. Problem is that most of stuff I do right now require this knowledge.</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Currently my task is to switch from kinematic character physics to just RigidBody + Constraints. This is mostly because I noticed that I paying big price for supporting kinematic body (I spend a lot of time on it and also performance of it wasn’t good). So now I have already some work in progress of new system and slowly progress with more improvements.</span></div>
<h3 dir="ltr" style="line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt; text-align: justify;">
<span style="background-color: transparent; color: #434343; font-family: Arial; font-size: 14pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Game not working smoothly</span></h3>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">This is task I focusing the most and I found out already few different reasons behind it. </span></div>
<ul style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Wrong organized update loop.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Small issue with calculating elapsed time. </span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Issue with physics update.</span></div>
</li>
</ul>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">All of them worked but there were this small issues which combining together gave this weird impression that game not running smoothly. Now I think everything look a lot better but I’m still investigating everything to achieve the best results.</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">So as you see I doing everything and nothing :/ This is frustrating because I would like to focus on game more but well slowly I will get there. </span></div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-3621626359588166282017-02-18T11:39:00.001-08:002017-02-18T11:39:36.961-08:00Good programmer ... <div style="text-align: justify;">
I don't know about you but after all this years that I'm into programming (18 year already) I'm still hesitate to call myself good programmer. I have some knowledge and experience but am I really good ? </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This question really often return when you look around in net. You founding another awesome looking project that somebody done. In my case is even worse because most of the time it's also done a lot quicker ( I'm 7 years stuck in the same project). Always then I feel a little bit down because there coming other questions like: what you done in all this time, what you achieved and are you really good.</div>
<div style="text-align: justify;">
<br /></div>
I still don't have clear answer how to deal with this mood and thoughts. Do you have any ? If you have I'm really open to listen them.<br />
<br />
So far I start to thinking that we are in time when a lot of people want to show of their skills and show how better they are than others. I'm sometimes have pity for them when they doing that.<br />
<br />
Recently I was asked if one of my friend is better programmer than me and my answer was yes. And the more I think about it's great. By simple fact that I know that there are better people I know I have a lot of new possibilities in front of me. I still can be better than I'm right now.<br />
<br />
So in the end who cares if I'm called good programmer. I'm just trying my best in programming and I think this is great because there is so much new interesting things to be discovered. <br />
<br />
<div style="text-align: right;">
Greg</div>
<br />
<br />Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-12340536995380104862017-02-15T13:12:00.000-08:002017-02-15T13:12:13.196-08:00Editor disaster ... updateSo I was digging a little bit more into my issue of TCP/IP on Linux and I found out about socket option:<br />
<br />
<div style="text-align: center;">
<a href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_MRG/1.2/html/Realtime_Tuning_Guide/sect-Realtime_Tuning_Guide-Application_Tuning_and_Deployment-TCP_NODELAY_and_Small_Buffer_Writes.html">TCP_NODELAY</a></div>
<br />
One of description in given link is:<br />
<blockquote class="tr_bq">
2. For this to be used effectively, applications must avoid doing small, logically related buffer writes. Because <code class="command">TCP_NODELAY</code> is enabled, these small writes will make TCP send these multiple
buffers as individual packets, which can result in poor overall
performance. ...</blockquote>
In my case default behavior created delay because I was basing (probably stupidly) my whole system on fact that each message will be delivered as soon as possible.<br />
<br />
This option switched everything to expected from me behavior. Of course I don't saying this is solution to all problems and probably introduce me some issues somewhere else.<br />
<br />
I'm still feel like novice in serious network programming :/ But well as far as project go I'm really happy with all this improvements and knowledge that I gain in meantime of doing them.<br />
<br />
But well time to return tracing bugs in my changes so I could push my code to repository before going sleep.<br />
<br />
<div style="text-align: right;">
Greg</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-36387068932407671452017-01-30T14:05:00.000-08:002017-01-30T14:05:17.993-08:00Editor disaster ...<div style="text-align: justify;">
So I'm still waiting for starting of my new job in Unity Technologies so I have some spare time. I use it to see Copenhagen, drink coffee, meet new people and of course as always: coding. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGd4BTO3Wm8LOo_WTWFdNitvv51pt9DLslgGCEAKwQeP-AZZVubqiwCTeo9ar9XDlz9Mt996NlAOeizgzlaiTFkOKH9vCdFt2M9INXxH3x5X4bJzkIOJ7JihJ9NHPVVINHM7b0HnKObE/s1600/20170130.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGd4BTO3Wm8LOo_WTWFdNitvv51pt9DLslgGCEAKwQeP-AZZVubqiwCTeo9ar9XDlz9Mt996NlAOeizgzlaiTFkOKH9vCdFt2M9INXxH3x5X4bJzkIOJ7JihJ9NHPVVINHM7b0HnKObE/s320/20170130.jpg" width="320" /></a>This time in my coding journey I try to figure out reason behind my slow reaction time of editor. My windows machine handed everything perfectly fine but my a lot slower laptop with Linux gave terrible results :/ How bad? I tried to rotate scene and there was few second delay between action and reaction So really bad. There was no choice but to fix it. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</div>
<a name='more'></a><div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
First like always my setup:</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<br />
Currently when I start editor I running: </div>
<ul style="text-align: justify;">
<li>Editor UI:</li>
<ul>
<li>Main Thread </li>
<li>Editor event processing thread (TCP/IP connection with Engine)</li>
</ul>
<li>Engine:</li>
<ul>
<li>Main Thread</li>
<li>App Thread</li>
<li>Worker thread A</li>
<li>Worker thread B</li>
<li>Editor events processing thread (TCP/IP connection with UI)</li>
</ul>
<li>Resource Builder Server:</li>
<ul>
<li>Main Thread</li>
<li>Thread per remote file system connection (TCP/IP connection with Client)</li>
<li>Thread for file system server</li>
<li>Thread per builder node (TCP/IP connection with Building Node)</li>
<li>Dir watch threads (right now running around 2)</li>
</ul>
<li>Resource Builder Node: </li>
<ul>
<li>Main Thread</li>
</ul>
</ul>
<div style="text-align: justify;">
So as you can see I have a lot to handle for my Quad Core machine. But well looking on editor whole scene was running properly so I decided to first focus on <b>Editor events processing thread. </b>This was my starting point for my search. <br />
<span style="color: #999999;"><br /></span><span style="color: #999999;"><i>// Well I wish if it was like that but well first I found few issues with compilation of resources on Linux which made me busy for few hours. But then...</i></span><br />
<br />
I started my investigation by checking my CPU usage and verifying if priorities of threads not affected they performance. As you can guest non of them shown anything weird. My other idea was that maybe I have some mistake in my network code and there is bottleneck. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Hacked quickly profiles shown me something interesting: my receiving of data taking a lot more time comparing to sending. But after a little bit of looking around and thinking: This is not something weird (at least in my opinion). When we sending data we just filling buffers receiving need more processing to send data. I will need to read about this a little bit more in my free time. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="color: #999999;"><i>// I also have theory that Linux processing lo connection (on the same computer between processes) slower then windows :( I may be here wrong and will need to verify this (Anybody know something about this topic ? or know some good sources ?)</i></span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Well after that came the phase where I tried to poke some pretty random places to collect more information about problem. Affinities added to threads had no effect at all so I gave up on idea that there is some issue with threading. Few other leads also didn't shown anything interesting but what interested me my random breaks in debugger were stuck into exchange of data about changed files with Resource Builder Server. Because I didn't need this code to run editor I decided to run it without it and there was improvement :)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Rest is pretty straight forward because of course mistake was on my side. I tried be smart and created just one connection between Editor UI and Engine which resulted in some gymnastic to be able send and receive asynchronously data both way. Well this didn't make too much sense when I look on it right now and now I just opening two separate connection for sending and receiving. I need also to say that Linux was here really useful: <b>tcpdump </b>gave me enough information to understand that my way of using TCP/IP connection was here the biggest bottleneck.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Well this is not the first time and for sure not the last time when after switching on slower machine there shown some issues which we never seen before. But for now I can finally relax a little bit and move to recovering rest of broken stuff :) I slowly get used to debugging in lldb but I still missing Visual Studio :( </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: right;">
Greg</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-34823305500971041812017-01-25T14:26:00.001-08:002017-01-25T14:26:49.891-08:00Resource building<div style="text-align: justify;">
As you may notice I like to push my tech to it's limit. Because of that I recently decided to switch to a lot better way of building resources. I took my app that were containing everything and split it on 3 different one.</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbQvlwypdC-1TJjtWwL49I2ganHU-pQxreiIvrDlAxBzJGTJHvnekf2-zQjKGtFe6697blBqqzmwFlsaqIfzFQ5gKajV46uEpejpBdgNmDuCpnne6MhUw-67X8PHsmmnSkk2OOigYihxA/s1600/ResourceServerFlow.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbQvlwypdC-1TJjtWwL49I2ganHU-pQxreiIvrDlAxBzJGTJHvnekf2-zQjKGtFe6697blBqqzmwFlsaqIfzFQ5gKajV46uEpejpBdgNmDuCpnne6MhUw-67X8PHsmmnSkk2OOigYihxA/s1600/ResourceServerFlow.png" /></a></div>
<div style="text-align: justify;">
They run as separate processes which connect with each other using TCP/IP. Comparing to previous setup this solution have a lot of advantages and this is some of them:</div>
<ul style="text-align: justify;">
<li>If one node crash I can just restart it and run whole setup further.</li>
<li>Whole node setup is scalable so I can have 100 of nodes.</li>
<li>I can run nodes on different machines. </li>
<li>I can dispatch new version of building nodes to different machines automatically.</li>
<li>I can build specialized Python nodes for some of work. </li>
<li>Application don't need to have all this shitty code of resource compilation.</li>
<li>Whole concept became a lot easier to control. </li>
</ul>
<div style="text-align: justify;">
So as you can see there is a lot of improvement :) comparing to previous one.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</div>
<a name='more'></a><div style="text-align: justify;">
</div>
<div style="text-align: justify;">
And here to my mind coming my recent discussion with friend: </div>
<div style="text-align: justify;">
<blockquote class="tr_bq">
<i>By telling only truth you can easily manipulate people. </i></blockquote>
</div>
<div style="text-align: justify;">
What you read above is not lie. But it's also not fully representing reality. And about this missing part this post will be.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
When I decided to switch to this system everything looked exactly like you read above there is so much possibilities and cool features. In reality there came problems which still following me till this day.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>If one node crash I can just restart it and run whole setup further.</b></div>
<div style="text-align: justify;">
Well yes I can but there is<b> </b>question what we want to do with resource that crashed it ? Crash may be unrelated to resource itself: i.e. memory leak, some memory stomping in other compilation code (yes they happening in all code bases and it's f....g hard to find them). On other hand we may try to restart it and run compilation of it again. But you need to do it only on this new node not any other because we would be back to begin.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Whole node setup is scalable so I can have 100 of nodes.</b></div>
<div style="text-align: justify;">
Dreams :] 100 processes running on one machine would kill performance of all nodes. Especially when run on slower machines (like my laptop). There is also issue of dispatching work to all this nodes which is big problem on it's own. I personally right now doing some trivial dependencies building just to use 4 nodes I have now and most of the time I use 1 but well this is still work in progress. Proper resolving of this will be some predictions and scaling amount of internal nodes depending on amount of work.</div>
<div style="text-align: justify;">
<b> </b></div>
<div style="text-align: justify;">
<b>I can run nodes on different machines. </b></div>
<div style="text-align: justify;">
Yes I can but if I should :) Well I still need to do here some testing to see how it will work. Most of resource building is really simple and probably just communication with different machine by TCP/IP may introduce some delay which probably will take some time. I thought about getting 5-10 Orage PI<b> </b>machines<b> </b>which I would use as cluster. I want to do it for fun to see if I will be able to handle nice scalable amount of machines. And there are also some challenges here f.ex:<br /><ul>
<li>Collecting of statistics for future improvement and balancing of system.</li>
<li>Handling crashes of building nodes and reporting issue.</li>
<li>Reconnecting node after loosing network. </li>
<li>Handling power fails (they may corrupt some data).</li>
<li>Caching of some files for quicker execution.</li>
<li>Handling running out of space.</li>
<li>Approximations where to send work (sometimes it may be more optimal to just build data locally than do it remotely). </li>
</ul>
And this is just the one that came to my mind right now.<br />
</div>
<div style="text-align: justify;">
<b>I can dispatch new version of building nodes to different machines automatically.</b></div>
<div style="text-align: justify;">
Yes I can :) but I would need to build infrastructure to restart new processes and handle few other stuff and I really don't have too much time for this (there are so many other things to do :/). </div>
<div style="text-align: justify;">
<b> </b></div>
<div style="text-align: justify;">
<b>I can build specialized Python nodes for some of work.</b></div>
<div style="text-align: justify;">
I still considering this because Idea is cool but maintenance of it would make me staying whole nights. So for now I saying "<i>no" </i>to this idea :/</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<b>Application don't need to have all this shitty code of resource compilation.</b></div>
<div style="text-align: justify;">
This is good :) but then to separate application to build resources I need sometimes to duplicate code. I want building nodes be as much separated from higher level engine features and code as I can.</div>
<div style="text-align: justify;">
<b> </b></div>
<div style="text-align: justify;">
<b>Whole concept became a lot easier to control. </b></div>
<div style="text-align: justify;">
Concept became more clear and easier to control but execution just got a lot more complicated and introduced all this issues and problems that I didn't had previously.<b> </b>But well it's our job as programmers to resolve problems (just I have too much of them in my code base right now :( )</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
So yeah. Cool system that you read at begin is still there but it sound probably a lot more messy right now. It also coming with its own set of problems which weren't there before. I don't need to hide them because why? Sadly some of articles/papers skipping this most funny part of our work: </div>
<div style="text-align: justify;">
<ul>
<li>What went wrong ?</li>
<li>What may go wrong ?</li>
<li>Where whole system failing ?</li>
</ul>
</div>
<div style="text-align: justify;">
My release code finished building (on my laptop it's taking so long to rebuild project :( )<b> </b>so I can return to coding. See you next time. <b></b></div>
<div style="text-align: justify;">
<b><br /></b></div>
<div style="text-align: right;">
Greg<b><br /></b></div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-32695574319246912422016-11-25T02:42:00.001-08:002016-11-25T02:42:33.425-08:00Engine interview questionMy friend know someone who is going to have skype interview for a position as engine junior programmer. I was asked for some guide or hints for this person. I think that this topic is interesting enough to change my long reply into nice post and hear what you think about it:) My email to him looked like this:<br /><br /><i>" First he should stop being stressful and asking question of others what can be on interview. If he has knowledge and luck he will pass. Sometimes is more about luck than knowledge but generally If he will get too stressful, even luck won’t help him.<br /><br />About question they can ask whatever they want from just: </i><ul>
<li><i>How are you?</i></li>
<li><i>Where you were studding?</i></li>
<li><i>What you were studding?</i></li>
<li><i>Why do you decide to have interview with us?</i></li>
</ul>
<i>To more technical one like:</i><div>
<ul>
<li><i>What programming languages you know and how well?</i></li>
<li><i>What engines you know?</i></li>
</ul>
</div>
<div>
<i>If he sent them CV there will be probably few question about stuff you put there. If he worked previously somewhere I would expect question like:</i><ul>
<li><i>What you done in previous job?</i></li>
<li><i>Why you decide to change job?</i></li>
</ul>
<i>Otherwise:</i></div>
<div>
<ul>
<li><i>What projects you done in university?</i></li>
<li><i>Why you think this position is for you?</i></li>
</ul>
<i>After that may come true technical questions which can by anything from question about: pointers, graphics rendering, memory management, disc access and 1001 other topics. There is just too much of them to be prepare for them. </i></div>
<div>
<i><br /></i></div>
<div>
<i>So returning to first line if he has knowledge he will answer questions better or worse but he will do this. From my experience, there are always different questions on each interview (but maybe this is just for me). He should chill-out and just see this as learning experience. If he will fail, world don’t end and he should just learn from it and try again. If they will see potential in him there is still big chance they will at least give him programming task.<br /><br />Cheers, <br />Greg </i></div>
<div>
<i>"</i></div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-23147169493761799112016-08-16T13:52:00.001-07:002016-08-16T13:52:10.983-07:00Game development<div style="text-align: justify;">
This time something inspired by this twit:</div>
<div style="text-align: justify;">
<br /></div>
<center>
<blockquote class="twitter-tweet" data-lang="en">
<div dir="ltr" lang="en">
I guess this illustrates a serious problem with how gamers see game development effort :/ <a href="https://twitter.com/hashtag/NoMansSky?src=hash">#NoMansSky</a> <a href="https://twitter.com/hashtag/gamedev?src=hash">#gamedev</a> <a href="https://t.co/H0ZDxojWpk">pic.twitter.com/H0ZDxojWpk</a></div>
— Kornel Kisielewicz (@epyoncf) <a href="https://twitter.com/epyoncf/status/764927275464814598">August 14, 2016</a></blockquote>
<script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script>
</center>
<br />
If you look really general on game development you can compare it to assembling puzzles. A lot of people know about game development from articles, making of videos and few other sources. They also know that there are different options that developer choose when they started:<br />
<ul>
<li>5000 pieces - Making small game on ready technology.</li>
<li>8000 pieces - Making small game with technology.</li>
<li>12500 pieces - Making game on ready technology.</li>
<li>25000 pieces - Making game with technology. </li>
</ul>
<div>
This don't sound so bad, so why developer don't make their job properly? People complain about some bugs, some features, about how simple it would be to just add this one feature. This is so frustrating for them because this is so simple (like assembling puzzles).</div>
<div>
<br /></div>
<div>
<a name='more'></a></div>
<div>
Then one fateful day some chosen one of them decide to make game on their own and discover that yes this simple like puzzle but this kind of puzzles:</div>
<div style="text-align: justify;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://www.ravensburger.com/us/shop/2d-puzzles/adult-puzzles/krypt-silver-15964/index.html" style="margin-left: auto; margin-right: auto;"><img border="0" height="456" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKh5gly2R1oBfaTtc7t0_EPjCQlOcoROXBpKe93ie17HchzgUdM1yAuI974iWWUlLg8jgEVxPGXVglZEAaYL9aMVYJza0CE9YnD4MCFOEzytZmaC7unlGAI2HDSURt_OP7W-_q1UN4zHrd/s640/puzzles.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><a href="https://www.ravensburger.com/us/shop/2d-puzzles/adult-puzzles/krypt-silver-15964/index.html">Ravensburger: Krypt silver</a></td></tr>
</tbody></table>
<div style="text-align: justify;">
Don't understand me wrong: Bugs are bugs, issues with game are still issues and missing features would be probably nice to have.<br />
<br />
My point is game developments is time limited, challenging and complex task. On top of that complexity of games increase with each years so even if whole process looks easy on first glance it not necessary really is. This mistake is done by people who never developed games and also this who do it (they get over optimistic about progress of their work).<br />
<br />
<div style="text-align: right;">
Greg</div>
<br /></div>
<div style="text-align: justify;">
<br /></div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com3tag:blogger.com,1999:blog-4447090642049340023.post-86061149822347321002016-06-01T09:00:00.000-07:002016-06-01T09:00:46.032-07:00Code pollution<div style="text-align: justify;">
Well time fly by and animation system starting take shape. Thanks to it I could do even some not bad looking animations in game (http://coffemonsters.blogspot.co.uk/2016/05/lba-preview-15.html) but well this is just another milestone in road to finished game. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Because of this thoughts I already moved to next issue: recovering of movie system. So far its going fine I added new movie resource, movie editor module. No I starting adding basic functionality: adding keys. This operation require list of selected objects in level.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This part was designed great :D Because I can have N levels loaded in memory in the same time I created new level component which exist only in editor. It contain some editor specific data i.e. selection. It's added on loading from editor and it's not saved with level. When you want list of selected objects just pick component from level and I have access to selection. Great idea right ? </div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMOi7AhEONeW8FlmGWgdHW5rsW0VjKGde36VDQDSXtYP7LIkTbfLR4LH4AME40648U29Zv87_cn1z4dnIcKn3Ev4v0JNImpbiG7sAyeRjNLH6Szz8HKmyxbGCsAc7h5hOx609NgjpVB3Q/s1600/graphBefore.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="311" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMOi7AhEONeW8FlmGWgdHW5rsW0VjKGde36VDQDSXtYP7LIkTbfLR4LH4AME40648U29Zv87_cn1z4dnIcKn3Ev4v0JNImpbiG7sAyeRjNLH6Szz8HKmyxbGCsAc7h5hOx609NgjpVB3Q/s400/graphBefore.png" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I thought this way when I was writing it. Right now I think it was good direction but it's still "Code pollution". Editor code and game code start mixing which is always harder to manage. On top of that Editor tools component is visible in level properties and yes I know I could hide it in code but then you create hack/some new code path which create new issues. Leaving it is also not any option because this is weird for person who work in tools. When there is something you didn't add you have temptation to remove it (I know what this it and that I shouldn't remove it but still don't like how it pollute my level setup) :D</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
My another iteration over this problem will be: </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6UCdR07RdTTJ8ioSJoX7k_CxUaJLP478gHoBx5woKsUGPgp2sQ5-GuF7NQOz39VRlGxZSohRhAdk5ZnOdy8PV0d1rLaIxA0yJJFCb8pVkydz2mJxU2YtsUcHzyJXwpPcF7ITg6Bi6HO4/s1600/graphAfter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6UCdR07RdTTJ8ioSJoX7k_CxUaJLP478gHoBx5woKsUGPgp2sQ5-GuF7NQOz39VRlGxZSohRhAdk5ZnOdy8PV0d1rLaIxA0yJJFCb8pVkydz2mJxU2YtsUcHzyJXwpPcF7ITg6Bi6HO4/s320/graphAfter.png" width="302" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div style="text-align: justify;">
LevelEditorModule would replace level component and thanks to that became independent from level. Advantage of this system is that it should be relatively easy progression from existing code. Just a little bit of time. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This may look like something stupid to do when I'm already limited by time and doing so many other stuff. Yeah you may be right. I never was too wise in this situations I prefers spending evening or two improving code which works than add new feature to game. Thanks to that I won't have maybe nice feature which will look nice at picture or video but I will have code which will supporting my efforts in creating games. Then features will be easier and funnier to work on :)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: right;">
Greg</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-30941116037996736532016-05-17T04:48:00.001-07:002016-05-18T14:45:58.665-07:00C++ riddleThis time small C++ riddle which took me some time to figure out :)<br />
<br />
<b>Background:</b><br />
My editor currently use sockets connection to pass data between Qt UI and "Editor module" in engine. Inside editor module this happen on two threads:<br />
<ol>
<li>Processing events on editor module side</li>
<li>Receive data and send result of events back to UI. </li>
</ol>
Code of two main function execute on them can found bellow:<br />
<br />
<center>
<button onclick="if(document.getElementById('processEditorEvents') .style.display=='none') {document.getElementById('processEditorEvents') .style.display=''}else{document.getElementById('processEditorEvents') .style.display='none'}" title="Click to show/hide content" type="button">Processing events (Show/hide)</button></center>
<br />
<div id="processEditorEvents" style="display: none;">
<pre class="brush: cpp">EError CAppEditor::processEditorEvents( void )
{
if (!m_eventsToProcess)
{
return EErrors::Succeeded_NothingToDo;
}
SEvent * events = wrAtomic::exchange(&m_eventsToProcess, (SEvent*)nullptr);
if (events != nullptr && events->next != nullptr)
{
SEvent * rEvents = nullptr;
while(events != nullptr)
{
SEvent* tmp = events;
events = events->next;
tmp->next = rEvents;
rEvents = tmp;
}
events = rEvents;
}
while(events != nullptr)
{
wrUniquePtr<sevent> event = events;
events = events->next;
SEventResult* eventResult = wrNewAutoTag SEventResult;
// Some code to processing events.
WR_ERROR(eventResult->memory.size() > 0);
do
{
eventResult->next = m_eventsToFinalize;
}
while (wrAtomic::compareexchange(&m_eventsToFinalize, eventResult, eventResult->next) == eventResult->next);
}
return EErrors::Succeeded;
}
</pre>
</div>
<center>
<button onclick="if(document.getElementById('threadEventServer') .style.display=='none') {document.getElementById('threadEventServer') .style.display=''}else{document.getElementById('threadEventServer') .style.display='none'}" title="Click to show/hide content" type="button">Sending results (Show/hide)</button></center>
<br />
<div id="threadEventServer" style="display: none;">
<pre class="brush: cpp">
void CAppEditor::threadEventServer( void )
{
wrUniquePtr<inetsocket> socket = INetSocket::create();
socket->setVerbose(true);
EError errorCode = socket->openServerConnection(ms_port);
if (errorCode.isFailed())
{
WR_ERROR_MSG("Failed to create event server.");
return;
}
wrVector<uint8> memory;
uint32 inputMemory = 0;
SEventResult* results = nullptr;
while(socket->receiveDataSafe(&inputMemory, sizeof(inputMemory)))
{
if (inputMemory > 0)
{
memory.resize(inputMemory);
uint32 size = socket->receiveDataSafe(&memory.front(), memory.size());
WR_ERROR(size == memory.size(), "There was error");
submitEvent(memory);
}
if (m_eventsToFinalize == nullptr && results == nullptr)
{
uint32 batchesCount = 0;
socket->sendData(&batchesCount, sizeof(batchesCount));
}
else
{
if (results == nullptr)
{
SEventResult* events = wrAtomic::exchange<seventresult>(&m_eventsToFinalize, nullptr);
// We inverting list to get the same order in which we submitted them
while(events != nullptr)
{
SEventResult* tmp = events;
events = events->next;
tmp->next = results;
results = tmp;
}
wrAssert(results != nullptr);
}
wrUniquePtr<seventresult> event = results;
WR_ERROR(event->memory.size() > 0);
results = results->next;
// Add error code to memory
event->memory.resize(event->memory.size() + 4);
((uint32&)event->memory[event->memory.size()-4]) = event->errorCode.getCode();
// batches size;
uint32 memorySize = event->memory.size();
socket->sendData(&memorySize, sizeof(memorySize));
socket->sendData(&event->memory.front(), memorySize);
}
}
}
</pre>
</div>
<b>Issue:</b><br />
This worked fine except my editor were crashing sometimes. This happen on random operations : moving, selecting, changing properties. Visual Studio debugger where showing me that crash were happening in this code:<br />
<pre class="brush: cpp">
do
{
eventResult->next = m_eventsToFinalize;
}
while (wrAtomic::compareexchange(&m_eventsToFinalize, eventResult, eventResult->next) == eventResult->next);
</pre>
<br />
Data in <b>eventResult </b>was looking like corrupted event or already deleted class.<br />
<br />
<b>Question:</b><br />
What is wrong with this code :D ?<br />
<div style="text-align: right;">
<br /></div>
<div style="text-align: right;">
Greg</div>
<b>EDIT:</b> There was small mistake in original version of code which should not be there (I fixed this in post). Line :<br />
while (!wrAtomic::compareexchange(&m_eventsToFinalize, eventResult, eventResult->next) == eventResult->next);<br />
should be:<br />
while (wrAtomic::compareexchange(&m_eventsToFinalize, eventResult, eventResult->next) == eventResult->next);Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com2tag:blogger.com,1999:blog-4447090642049340023.post-11674175189876120692016-05-11T15:53:00.002-07:002016-05-11T15:53:47.390-07:00My little monster<div style="text-align: justify;">
This story started long ago while I was still student at University of Technology in Wrocław. It was probably year 2006 but I'm not sure right now. With time passing by all previous years slowly starting blending together but well I'm already at this age where this is pardonable.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
On one of C++ courses we got exercise to do program of our choice to show that we learned language. I decided that isometric game in SDL software mode will be great idea. And so I started working on it. What a great joy I had when everything finally started working together and I was able to send it to person conducting classes. I got passing marks and this was end of story. </div>
<div>
<br /></div>
<div>
Well at least for a lot of project this would be truth but in this cases there is a lot more. Some time passed and with friend we decided to make casual game. Code from course project was really useful but software rendering were too slow so I switched whole stuff on OpenGL and some time later we finished <a href="http://www.indiedb.com/games/pirate-crystals">"Pirate Crystal's: Adventure of Julia".</a></div>
<div>
<br /></div>
<div style="text-align: justify;">
Another semester started and in advance C++ course I decided to connect physics to engine which at this point had already some basic 3D functionality. This wasn't easy because this was my first encounter with proper physics implementation. But well all of that couldn't prepare me for what came on other course <span style="text-align: justify;">conducted by </span><a href="http://chaosforge.org/">Kornel Kisielewicz</a> about shaders. I still remember his comment when he was rejecting my idea of doing normal mapping: but this is standard now. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This may sound silly but for me this meant a lot. I was hiding in save zone avoiding shaders however I could but then I was informed that I'm far behind what happening in industry. This was crucial moment for me because I quickly get out of my save bubble, learned shaders and decided that I never want to stop learning new stuff and ending in this bubble again.<br />
<br />
But what the hell this post is about? This is for sure not post about me but "My little monster". I sometimes hate it, sometimes need break from it sometimes I messing with it but in the end this is my "little monster" which I put a lot effort into and try to make it the best engine I can.<br />
<br />
<b>Why Monster ? </b><br />
<br />
People who done work on bigger projects probably know this feeling of being lost in code. In my case it often happen when I move to new part of code which I never had occasion to work on. Now imagine the same situation happening in your own code base. This is moment when you start understanding how big project you working on really is.<br />
<br />
Other thing is that a lot of people seeing personal projects as "toys" they don't treat it seriously when you talk that you work on them. In my case I don't see difference between my personal project and projects I worked on in work. Of course code base is smaller but if you look on how much code is handled by programmer then I'm sure that I handle a lot more in my personal project.<br />
<br />
There are also issues which you need to deal with yourselves:<br />
<ul>
<li>Code paths that aren't used quickly became broken. </li>
<li>There is issue of tools that you don't compile when I do some changes in engine.</li>
<li>Differences between GPU vendors.</li>
<li>Memory management,</li>
<li>Threading issue like: timing, race conditions.</li>
<li>Multi platform development.</li>
<li>Code which you don't even know how worked in first place.</li>
<li>Build system.</li>
<li>Building of game package (ideal if it was automatic).</li>
<li>And a lot more.</li>
</ul>
<div>
I personally don't try hack any of this or just do quick prototype. I try to make proper solution which I would also create if I needed to resolve this issue in work. And this change really a lot. </div>
<div>
<br /></div>
This was really visible when I were changing work. The first time when I was doing it and mentioned my project people were like good you do something on your own but what you done in previous job. Things changed last time. When I was showing it to people that interview me they sometimes even skipped some tests and we ended talking how I done stuff or they give me their opinion how they would do something. This project was seen as one of projects that I was working on commercially and I think this was great.<br />
<br />
<span style="font-weight: bold;">Why Little Monster ? </span><br />
<span style="font-weight: bold;"><br /></span>
Well this is not name of engine because its called <a href="http://coffemonsters.blogspot.co.uk/p/i-believe-that-game-development-is.html">White Rabbit Engine</a>. This is name that I using when I end in bed after doing some work for engine and finally realizing what kind of technology I creating. I'm scared of it complexity because sometimes I got lost in my own code. What will future bring I don't know but this project carring ten years of development, all my knowledge and well it still my "little monster". I may sometimes have enough of but but I still like what I do and will carry work on it for a little bit more :)<br />
<div style="text-align: right;">
Greg</div>
</div>
<div>
<br />
<br /></div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-74712204500784201862016-04-29T02:57:00.000-07:002016-04-29T03:01:07.331-07:00My bookshelves.<div style="text-align: justify;">
I realize recently that I'm weird programmer. If you would look on my bookshelves you will find there:</div>
<ul>
<li style="text-align: justify;">manga, </li>
<li style="text-align: justify;">fantasy books,</li>
<li style="text-align: justify;">movies art books,</li>
<li style="text-align: justify;">games art books,</li>
<li style="text-align: justify;">books about drawing, </li>
<li style="text-align: justify;">books about anatomy,</li>
<li style="text-align: justify;">books about animations,</li>
<li style="text-align: justify;">D&D manuals.</li>
</ul>
<div>
<div style="text-align: justify;">
What you won't find there is any programming book. My only book kind of in this topic is Showstopper about development of windows NT on my kindle. Which is in the fact not programming book but more story of people who created it and I'm still in middle of reading it :) </div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
The other book I reading is "The Animator's Survival Kit: A Manual of Methods, Principles and Formulas for Classical, Computer, Games, Stop Motion and Internet Animators." which is for me really interesting. So far I finding there a lot of interesting advice which some even apply to programming.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
And this is weird because as programmer I probably should read some books in my field of work. But I don't fell any push into this direction. I don't wan't to read book about programming language because what for? I tried long time ago and they are boring like hell :/ If I need to learn syntax I can just look into online tutorials.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
All new stuff about C++ I learning when I searching online for solutions of problems or discuss with others. Sometimes I spend more time on trying understand small piece of example code than on fixing the initial issue. This happening mostly because I go from one page to another and finding more and more interesting stuff.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
I would really love to read programming book which is not about language or algorithms but more about programming itself. I imagine such a book would contain stories of development, tips and tricks how to be better programmer. You know this kind of book which you start reading and before you noticing its ends.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Do you know book like that ? If you know I would really like to know its title.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: right;">
<div style="text-align: justify;">
Greg</div>
</div>
</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-66477930187008179022016-04-24T08:32:00.000-07:002016-04-24T08:32:44.152-07:00Plans, real life and monkey job.<div style="text-align: justify;">
Funny thing about planning is that sometimes its not working out the way you want. This was case this week I planned to work on animations and ended doing small upgrade for resource system. The best thing is that I don't even feel bad about stuff ending this way :D </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
How I ended doing that is other story. Because I have policy of moving everything what I can to resource system which I have (this make stuff more consistent) I moved my rendering script to it. Everything would be good if not the fact that render script is initialized on main thread and my resource system never was prepared for request from other thread than game thread. So it was time to do improvement to allow for this :D</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This was even more important because there were sometimes crashes at startup of game. I split my task on 3 sub task:</div>
<br />
<ol>
<li style="text-align: justify;">Access to resource data require locking of resource (i.e. meshRes->lock()->getMaterial();)</li>
<li style="text-align: justify;">Separation of resource from data so you could have resource handle and it was still loading </li>
<li style="text-align: justify;">Moving prepared stuff on multithreading.</li>
</ol>
<div style="text-align: justify;">
First two task were robust :/ required iterating over all my resource types and changing it's interface. This was boring like hell but well programming is not only about interesting stuff.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
My mind was blank when I was doing this so I had time to think and came to conclusion:</div>
<blockquote class="tr_bq" style="text-align: justify;">
Some people saying that programming is about creating stuff. But reality is different. We as programmer spend most of our time improving existing stuff, changing them, fixing and redesigning. When we do all of this we make small piece of code which do something new and we once again starting whole thing again. This is also true in personal projects.</blockquote>
<div style="text-align: justify;">
Few hour later changes were ready and I could start preparing functions which worked on one thread but were already separated in a way part of it could be moved to other thread. This was more interesting task which resulted in changes for some of resources. Generally my resource system look like this:</div>
<br />
class ResourceXYZ<br />
{<br />
ResourceId m_id;<br />
DataType* m_privateData;<br />
};<br />
<br />
Till now private data was part which control whole resource but now in some cases I want to hold some data in resource so even when private data change it will still be the same. I.e. LevelID (Yes level is also resource).<br />
<br />
Another hour later I was ready. I know that my game worked because I were changes step by step with running game to be sure it at least work. Next step was mutli-threaded code which went smoothly.<br />
<br />
Thanks to lock system I would add simple wait for loading of resource if it was still loading. There were small issue with dependencies of compiling GPU programs (they expected other resources to be already loaded) but well thanks to my split on soft and hard references fixing it was also easy.<br />
<br />
And so my code working now and my previous 700 ms loading on debug configuration resulted in 600 ms loading now :) There are still few things I want to make:<br />
<br />
<ul>
<li>File asynchronous loading with forward loading for better performance.</li>
<li>Reloading of resources</li>
<li>Cleanup iteration over whole system</li>
</ul>
<div>
But well you cannot have everything in life but some day I will make this all work :) For now I will return to animation topic to push everything forward :)</div>
<div>
<br /></div>
<div style="text-align: right;">
Greg</div>
<br />
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-68145424755441937262016-04-14T16:31:00.000-07:002016-04-14T16:31:04.106-07:00After break<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYZPxqgs8TmdE3t7ypEOcUX8AnRQclaCH82mNVak1YN-BCrQpL_SO93YSVOquqZ-f6HmZRBkYteWm-lOwrLiN_jZ5c-U4_FYgJ3B9SRtARvVBIyVYszId91fDxkcfdJ7pzOlsPikCQ9jc/s1600/BlendGraph.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="173" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYZPxqgs8TmdE3t7ypEOcUX8AnRQclaCH82mNVak1YN-BCrQpL_SO93YSVOquqZ-f6HmZRBkYteWm-lOwrLiN_jZ5c-U4_FYgJ3B9SRtARvVBIyVYszId91fDxkcfdJ7pzOlsPikCQ9jc/s320/BlendGraph.jpg" width="320" /></a></div>
<div style="text-align: justify;">
I took some break from writing on this blog but I had busy last few months. In this time I done a lot of changes in engine one of biggest "finished" one are changes in file system. But this time I don't to talk about what I done but more about what will come and what I working on right now.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
And I do some stuff with which I'm not feel most comfortable: Animation system. So I decided to seek some advice and explain what I do, why and how I would like to improve it. So be free to comment and critique.</div>
<div>
<h4>
I don't fell that system I have right now is what I really want to have.</h4>
<h4>
<div style="font-weight: normal; text-align: justify;">
This is this weird felling when you fell that system that you created is working but you fell that it's limiting you. Because of this felling recently more often I turn of computer and sit down with pen and notebook and think what I really want to do with this system. So far my conclusion is because I'm iterative develop White Rabbit Engine technology I didn't notice till now that what was I searching for was different thing from what I have now. </div>
<div style="font-weight: normal; text-align: justify;">
<br /></div>
<div style="font-weight: normal; text-align: justify;">
What I have now is "decent" system for playing animation using blends trees. And what I was searching for are behavior trees. I already have some idea how to make this system part of existing code. This will require some changes because I want blend trees to be just input nodes for behaviors nodes. Everything so whole system was consistent on all levels.</div>
<div style="font-weight: normal; text-align: justify;">
<br /></div>
<div style="font-weight: normal; text-align: justify;">
<span style="font-weight: bold; text-align: start;">New movement system</span></div>
<div style="text-align: justify;">
<span style="font-weight: normal; text-align: start;">Right now there is simple system which apply on character: orientation </span><span style="font-weight: normal;">from pad/keyboard </span><span style="font-weight: normal; text-align: start;">relative to camera direction and then play walk/run animation. This work but don't look nice when you try to change direction.</span></div>
<div style="text-align: justify;">
<span style="font-weight: normal; text-align: start;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-weight: normal; text-align: start;">Because of that currently I started experimenting with simple system which based on direction vector try to choose the animation which will allow to get root bone position to destiny point. How it will work I don't know this is more R&D. So far I'm still not convinced by result. I will also probably postpone this "task" to first do proper behavior tree which will allow me on easier experimenting.</span></div>
</h4>
<h4>
I am doing animations so if it possible I want to optimize whole workflow as much as I can.</h4>
<div style="text-align: justify;">
This is for more simpler problem than it may sound. Currently I can create "Animation Database" (AnimDB) resource which contain link to animations resource and blends trees inside. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Sound good but it's not because I cannot reuse the same blend tree between different AnimDB. This was one of this problem I didn't thought so much when I was doing initial system and if I decide to do different animations for each race in <b>Little Big Adventure: Remake</b> it would require from me supporting multiple copies of the same tree which would be really inefficient. So I need to fix :)</div>
<div>
<h4>
<b>Animations in White Rabbit Engine are used to locomotion of character.</b></h4>
<div>
<div style="text-align: justify;">
Right now this happening by calculating root bone relative movement and applying this to kinematic physics in each frame. This works nice but you need to be really careful how you do animations because slight foot movement may result in sliding effects of foots.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
What I would like to experiment with is possibility to lock one of bones in world space and retrieving root offset from this.This would look like we have animation with marked when left or right foot touch ground and when it do it I lock position of marked <b>bone in world space (b.w.s.) </b>and store <b>local animation position (b.l.a.p) </b>of it. Bone is locked as long as distance between stored <b>(b.l.a.p)</b> and current <b>(b.l.a.p) </b>won't be bigger then some delta.<b> </b>I would use this lock to apply corrections to root offset so even if foot slightly move in animation in engine it would still look good</div>
</div>
</div>
<h4>
Conclusion</h4>
<div style="text-align: justify;">
As you can see I think about a lot of stuff and try to improve a lot of different issues. Right now we redoing assets for <b style="text-align: justify;">Little Big Adventure: Remake</b><span style="text-align: justify;">. Thanks to that we don't need to put extra effort into changing content. But once I will define whole </span>workflow there will be only place for small improvement. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
There will be no second chance so it would be nice to do it right so I'm going back to my pen and notebook to figure out in my head how I want this whole stuff to work. When whole idea will be in my head coding should be the easiest part.</div>
</div>
Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com0tag:blogger.com,1999:blog-4447090642049340023.post-26426335349345380332015-12-16T12:48:00.000-08:002016-01-15T04:21:12.731-08:00Postmortem - 7 hours of hell<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1_k72mc3ZZZ81hd4paxWXv9ZbcNkPDy9v6u9RHLLXYTYaK_ZscJoYPct5m6H3T8QuJ3wCe2wdvcvRf4MniuRjGlTm5QiQcRnT1kDuky40hzVNQYCP6NgqLP7Uirh2nJdZfIuzIePS_sA/s1600/OneIconPlugin.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1_k72mc3ZZZ81hd4paxWXv9ZbcNkPDy9v6u9RHLLXYTYaK_ZscJoYPct5m6H3T8QuJ3wCe2wdvcvRf4MniuRjGlTm5QiQcRnT1kDuky40hzVNQYCP6NgqLP7Uirh2nJdZfIuzIePS_sA/s400/OneIconPlugin.png" /></a>If you remember my <a href="http://angelusda.blogspot.co.uk/2015/10/7-hours-of-hell.html">7 hours of hell post</a> you probably wonder why postmortem.<br />
<br />
To give you introduction to this you need to know that I recently done port to Visual Studio 2013 (I used vs2010 till now). This migration was planned for some time already. I even started it in the past. But never finished because rebuilding of external libraries was pain in the a.. . Now I fixed this issue by automated building script and without bigger problems I was able to compile everything with Microsoft compiler ver: 12.0.<br />
<br />
If this was good idea I still don't know but for sure I know that I still fixing bugs and issues that shown in meantime. I don't mind it so much because some of stuff I do right now were also in plan for future.<br />
<br />
Probably you are curious what my one button plugin postmortem have to do with this changes ? Answer is simple I miss my one button plugin in Visual Studio 2013 ;(<br />
<br />
I tried to use plugin without any modification but it didn't work and for now I work without it. I need to say you really can get used to this small improvement in workflow and after time I almost sure that I will bring this feature back into vs2013. Even if this will cost me another 7 hours of work :D<br />
<br />
<div style="text-align: right;">
Greg</div>
<br />
<br />
<br />Angelushttp://www.blogger.com/profile/02218727575338098906noreply@blogger.com2