{"id":52,"date":"2022-07-18T12:07:23","date_gmt":"2022-07-18T12:07:23","guid":{"rendered":"https:\/\/blogs.scummvm.org\/grisenti\/?p=52"},"modified":"2022-07-18T12:07:23","modified_gmt":"2022-07-18T12:07:23","slug":"working-on-scripting-and-physics","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/grisenti\/2022\/07\/18\/working-on-scripting-and-physics\/","title":{"rendered":"Working on scripting and physics"},"content":{"rendered":"<p><span data-contrast=\"auto\">This week I finally got the game to run, although it\u2019s still in a rough shape.\u00a0\u00a0<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559685&quot;:0,&quot;335559737&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">The first thing I did was to add the scripting library. This didn\u2019t take very long, with only a few compilation issues. Here, there is still some cleanup required to remove the unused platform specific calling conventions. Additional components were also added to support passing and receiving standard strings, which continue being used now for simplicity, and another one that implements calling script functions by passing them\u00a0as a string.\u00a0<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559685&quot;:0,&quot;335559737&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Next, I worked on getting the game running. This required enabling some previously disabled systems and debugging the resulting errors, which overall was not too hard.\u00a0\u00a0<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559685&quot;:0,&quot;335559737&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<figure id=\"attachment_53\" aria-describedby=\"caption-attachment-53\" style=\"width: 1290px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-53 size-full\" src=\"https:\/\/blogs.scummvm.org\/grisenti\/wp-content\/uploads\/sites\/53\/2022\/07\/working_game.png\" alt=\"first level of the game\" width=\"1290\" height=\"755\" srcset=\"https:\/\/blogs.scummvm.org\/grisenti\/wp-content\/uploads\/sites\/53\/2022\/07\/working_game.png 1290w, https:\/\/blogs.scummvm.org\/grisenti\/wp-content\/uploads\/sites\/53\/2022\/07\/working_game-300x176.png 300w, https:\/\/blogs.scummvm.org\/grisenti\/wp-content\/uploads\/sites\/53\/2022\/07\/working_game-1024x599.png 1024w, https:\/\/blogs.scummvm.org\/grisenti\/wp-content\/uploads\/sites\/53\/2022\/07\/working_game-768x449.png 768w, https:\/\/blogs.scummvm.org\/grisenti\/wp-content\/uploads\/sites\/53\/2022\/07\/working_game-1200x702.png 1200w\" sizes=\"auto, (max-width: 1290px) 100vw, 1290px\" \/><figcaption id=\"caption-attachment-53\" class=\"wp-caption-text\">(the untextured barrels are normal and a weird effect of the game without played at the lowest setting)<\/figcaption><\/figure>\n<p><span data-contrast=\"auto\">After getting the game working, the first interesting problem was that movement did not work. This was caused by a conversion error in the scripting system which resulted in engine functions always getting false boolean values from the scripting system, even if the value true was specified in the script. The solution was to substitute the <code>GetArgDWord<\/code> function with <code>GetArgByte<\/code> if the parameter was a boolean value. <\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559685&quot;:0,&quot;335559737&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Next, I worked the bugs in the <\/span><span data-contrast=\"auto\">physics system. The first was that none of the objects could be picked up. This was caused by a call to the <code>NewtonFreezeBody<\/code> function with a wrong parameter. Now that objects could be picked up, the first apparent problem was that these started to shake as soon as the player interacted with them. The solution here was to adjust the torque values passed into the physics system, which I was lucky to find in the HPL1R project (<a href=\"https:\/\/github.com\/zenmumbler\/HPL1R\">https:\/\/github.com\/zenmumbler\/HPL1R<\/a>). Next was the bug of the player being pushed around by some physics objects in the scene. I still don\u2019t really understand the cause of the problem, but the solution, which I got from the HPL2 sources, was to change the value of the normal vectors for some collisions checks.\u00a0 The final bug I solved this week was that of slider joints (a physics construct mainly used for drawers). The problem was that, in the physics library, the code to initialize some matrices was commented out, resulting in weird and inconsistent behavior.\u00a0 \u00a0 <\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559685&quot;:0,&quot;335559737&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\"><br \/>\n<\/span><\/p>\n<p><span data-contrast=\"auto\">Overall, I was lucky with the bugs mentioned above as a solution was already available somewhere else or it came relatively quickly. This streak ended on the last bug. The problem is that the notebook item, which in the original game appears on the desk, does not appear. I\u2019ve worked for quite a lot of time on the issue, but I still don\u2019t feel like I really understand what is going on. The hardest part is that the problem presents itself only for one object in the first level and another in the second while other work correctly without issues. I\u2019ve tried looking at the resource files for these objects, but I didn\u2019t find anything particular about them. Two things I found were that if the objects are frozen, they appear, but much smaller than they should be and without any thickness (the notebook in the above picture is an example), and if rotation and scale are taken away in the initial loading of the objects they appear and interact regularly with the physics, but they cannot be picked up.\u00a0\u00a0I don\u2019t yet have an idea of how these things are connected but I\u2019m extremely curious to find out. <\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559685&quot;:0,&quot;335559737&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">For next week I don\u2019t have any plans yet, but hopefully I can finally figure out the bug I described above but it&#8217;s getting a little frustrating and maybe I\u2019m going to give it up for a bit.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559685&quot;:0,&quot;335559737&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Thanks for reading.\u00a0<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559685&quot;:0,&quot;335559737&quot;:0,&quot;335559738&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week I finally got the game to run, although it\u2019s still in a rough shape.\u00a0\u00a0\u00a0 The first thing I did was to add the scripting library. This didn\u2019t take very long, with only a few compilation issues. Here, there is still some cleanup required to remove the unused platform specific calling conventions. Additional components [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/52\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}