Continue work on 3D viewshed implementation.
- Bug hunting and fixing in an effort to get the 3D implementation working
I minimised the map sampling positions so there was a grid of 4 x 4 samples. This led to a few code fixes and I returned to the larger sample size. I found a few other logic errors in the maths and made some fixes that came tantalisingly close to the required output however there were a few noticeable errors in an area of the map I used. Further digging revealed an underlying error with the logic (and indeed entire implementation).
In my haste to get the code working I inadvertently moved away from the idea of calculating in concentric squares outwards and instead used a more traditional nested for loop (iterating through x and y coords). I thought this would be reasonable as the previous coordinate has been checked however it ran into significant issues on the edge of terrain; large swathes of terrain that should be visible wasnt. This will require a pretty sizable refactoring of the code.
5 hours (38 hours running total)
As the title of this post suggests, it almost felt like I was robbed… being so close but reaching the conclusion that I have to step right back and reimplement the lions share of the logic again from scratch.
Thinking poetically for a moment though… Many trees including Paperbark and Eucalyptus thrive after a bushfire with new growth, the fire that destroys the old growth sets the conditions for new growth to thrive. The code I have (through not enough planning and an eagerness to get it functional) has become quite messy. Between ad hoc debug statements, commented out code and general poor flow, gutting the calculations to start again from scratch is a blessing in disguise. Indeed, it wont even be from scratch; the linear code works well and I am confident in a more streamlined approach to implementing the core diagonal will work well. That combined with (much) more rigorous planning prior to coding the main quadrant parts (and paper based testing to confirm the logic prior!) should mean the final product is a lot slicker and is cause for a lot less headache in the implementation phase.
After a long day though, its time to get the footy on the tele!