Asophix 189 Posted February 12 Behind the scenes In the original SHK Editor there is a weird quirk, when it comes to displaying buildings. Even not long after its release, people complained about the Engineer's Guild being off by one tile, when rotated east. Even though this itself is an easily fixable problem, delving into the buildings list reveals that almost every building has a whole slew of corrections applied on top. When adapting the Editor for the Legends buildings, all buildings got vastly different dimensions, so all corrections had to be painstakingly found out and updated. Still, the in-game Map Editor in SH2 & SHL is able to effortlessly rotate buildings. Is the math behind it so complex and difficult? What could cause this mismatch in HicRic's interpretation? The answer lies in the anatomy of a building. See, building footprints starting with SH2 are slightly more complex than for example in SHC, as buildings are comprised of two components: Occupied Area: this footprint is reserved for the building itself, and can't be built on Walkable Area: this footprint outlines a general area for peasants / units to approach the building. While still can't be built on, walkable areas can overlap for multiple buildings. Since most buildings effectively carve out a rectangle or square, HicRic's interpretation was that this could apply to every building, and as such a rectangular 2D area was assigned to each of them. There are however buildings with more complex footprints, like the Keep, where the campfire's 4x4 area is attached to the occupied area of the building: Going further with the above theory, it seems that rotation around a center point always results in a consistent position, however it is almost never the case, if the building's footprint is not a perfect square and is included a walkable area. HicRic also realised this and implemented a correction system on top, which adjusts the building to its real position. This does not follow a pattern however and takes unjustified effort to implement. What HicRic failed to account for, is the fact that the focal point of the rotation is the center of the occupied area, not the center of the building's effective rectangle footprint. See how the yellow point is about two tiles away compared to the real point of rotation, visibly misplaced: In short, all buildings in SH2 & SHL have occupied areas each that assumes the shape of a rectangle or square. Using this knowledge, the brute force correction system can be dropped and building administration can become more intelligent, further improving invalid building placement checks and other related features. Thanks for reading! 🙂 4 Share this post Link to post Share on other sites
Planewalker 25 Posted February 12 Well that makes a lot more sense. I always felt like it was a bit off. 0 Share this post Link to post Share on other sites