Open VorTechnix opened 3 years ago
Hrm, this looks tricky. I agree that some improvements are in order, but someone would need to dive into the maths on this.
Currently it checks each node in the defined region, and if the distance from the node to the line is less than <thickness>
it set it to <replace_node>
.
As per conversation on discord: https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
Ok, just implemented Bresenham's algorithm in 2D! There is another one called DDA, but it's less efficient as it requires floating-point calculations.
Now, we just need to implement it in 3d.... I suspect I'll probably cheese it by running it twice for X/Y and Z/Y, though the 2 different runs will have different numbers of elements in them, so some projection will be needed..... I'll figure it out. Eventually.
Note that an arbitrary thickness of the line requires a modification of the algorithm.
Here's a sample output with some random lines:
Now, we just need to implement it in 3d.... I suspect I'll probably cheese it by running it twice for X/Y and Z/Y
I would do the calculations for X/Z, put them in a table A and then run the calculations again for A/Y.
Note that an arbitrary thickness of the line requires a modification of the algorithm.
Why? Why not just run it once and then for each node just create a solid circle around it of [radius] facing roughly in the same direction as the line?
3d implementation we might be able to copy: http://members.chello.at/easyfilter/bresenham.html
Why? Why not just run it once and then for each node just create a solid circle around it of [radius] facing roughly in the same direction as the line?
Then we'd need to implement a Bresenham circle or something as well haha
This is not out of the question, but implementing these upgrades will have to wait some more I think. I currently have other priorities in WorldEditAdditions. Maybe after the next release?
Ok here goes:
2d lines
//line
currently behaves when radius is 1. The green line is how it should behave when radius is 1.That said instead of having a single radius we should have the option to input separate width and vertical thickness values. The new syntax would be:
//line <replacenode> <thickness> [<width>]
.Further the line creation process should be made iterative based on the central line. The yellow line in the screenshot would be and example of the result of
//line <node> 2 1
3d lines