mrudat wrote:Very nifty, but a number of comments:
For reasons of UPS, I'd probably prefer the more CPU-efficient algorithm; then again, trig functions are I think single-cycle on modern processors, but branch instructions can take significant numbers of cycles to resolve, so I'm uncertain which would actually be more efficient.
I've noticed that the current algorithm seems to have a certain amount of jitter; over multiple rotations it seems to only sometimes chart certain chunks that are on the edge of the scan radius.
It also seems to skip charting chunks at (I suspect) around 0 degrees; specifically, to the right of the radar, but only sometimes.
I attempted to move the radar, but when mined, it does not return the original object.
There are many reasons I switched to a trig based calculation method. The most flippant one being the advances in modern CPUs. The Bresenham's circle rasterization algorithm is an optimization for integer math which draws a complete circle. But I had to be able to step the outside and scan between that and the center. This would leave a radially symmetrical pattern of holes within the plot. This required adding a fudge factor to get a complete fill. This is when I discovered the LUA does not actually have an integer type, everything is floating point calculations anyway. Accounting for that and allowing for more flexible rotation speed, dynamic direction, oscillating between two angle, etc. I chose to simplify the algorithm.
The jitter you are seeing on the outside edge is because the outside edge is a calculation of a radius from the center. Because of fractional stepping to get a complete fill, sometimes the next point will be on the inside corner of a chunk on one pass and an outside corner of an adjacent chunk on the next. The smallest unit to scan is a full chunk and I had planned to leave this as is rather than require a fixed stepping or storing a lot more state data.
Skipping chunks around zero degrees is something that I am afraid that I completely missed. The map that most of the testing was done has a railroad line extending east past 13500 with some existing vanilla radar coverage. I will take a look at that when I get home from a business trip at the end of the week.
Hand mining the radar should work correctly and always has for me in testing. Deconstruction with bots and adding to blueprints is not yet implemented and is where the next planned effort was to be directed.