EVENT JITTER FIX
RPG Maker VX Ace
Display Rounding Error Fix
- Archeia_Nessiah
- 09/01/2013 04:36 PM
- 2183 views
I originally asked Neonblack for this fix~
And this was his answer:
Recently it was brought to my attention that when scrolling the map with a lot of events on screen, the events would "jump" by a single pixel and would be improperly positioned. I initially shrugged this off as lag, but when I saw the same effects on my absolutely awesome machine I wasn't quite sure what was up. I decided I would look into it a little bit more. When I tried to recreate it on my own by packing a screen full of events and then scrolling I was unable to reproduce the results. It wasn't until I tested the issue with the demo in a related topic that I noticed the issue seemed to have to do with slow speed panning.
Essentially what I discovered is that events and the tilemap were rounding extremely low values from "display_x" and "display_y" differently. The tilemap always rounded up while characters/events always rounded down. What do I mean by extremely low values? Because of the formula used to calculate scroll distance (2 ** @scroll_speed / 256.0) the display points can end up being values such as 15.5 pixels. As mentioned earlier, the tilemap would round this up to 16 while the events would round this down to 15. This would cause events to display 1 pixel away from where they were supposed to.
To fix the issue I modified two things to ensure that tilemaps and events would always get the same value. First of all I added two methods to replace the normal reader methods for the displays. In these I just multiplied by 32, used .floor to round down, switched it back to a floating point value, and divided it by 32. This ensured that when received by anything that might use the display values, it was always rounded to the lowest values without any further need for coercing. Secondly, I modified the two "adjust" methods used to determine the X and Y positions of events to reference the new reader methods rather than using the variable directly.
Anyway, all that done, here's the snippet. Be sure to place this under materials and above all additional custom scripts since this is meant to be a bugfix of the default scripts.
Pastebin link: http://pastebin.com/XDd0tVWJ
And this was his answer:
Recently it was brought to my attention that when scrolling the map with a lot of events on screen, the events would "jump" by a single pixel and would be improperly positioned. I initially shrugged this off as lag, but when I saw the same effects on my absolutely awesome machine I wasn't quite sure what was up. I decided I would look into it a little bit more. When I tried to recreate it on my own by packing a screen full of events and then scrolling I was unable to reproduce the results. It wasn't until I tested the issue with the demo in a related topic that I noticed the issue seemed to have to do with slow speed panning.
Essentially what I discovered is that events and the tilemap were rounding extremely low values from "display_x" and "display_y" differently. The tilemap always rounded up while characters/events always rounded down. What do I mean by extremely low values? Because of the formula used to calculate scroll distance (2 ** @scroll_speed / 256.0) the display points can end up being values such as 15.5 pixels. As mentioned earlier, the tilemap would round this up to 16 while the events would round this down to 15. This would cause events to display 1 pixel away from where they were supposed to.
To fix the issue I modified two things to ensure that tilemaps and events would always get the same value. First of all I added two methods to replace the normal reader methods for the displays. In these I just multiplied by 32, used .floor to round down, switched it back to a floating point value, and divided it by 32. This ensured that when received by anything that might use the display values, it was always rounded to the lowest values without any further need for coercing. Secondly, I modified the two "adjust" methods used to determine the X and Y positions of events to reference the new reader methods rather than using the variable directly.
Anyway, all that done, here's the snippet. Be sure to place this under materials and above all additional custom scripts since this is meant to be a bugfix of the default scripts.
Pastebin link: http://pastebin.com/XDd0tVWJ