mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 07:23:00 +00:00
torus: finish rework
This commit is contained in:
parent
3fbfc1fb15
commit
0100725a7b
3 changed files with 16 additions and 6 deletions
|
@ -14,6 +14,7 @@ Note to self: See the bottom of this file for the release template text.
|
||||||
- Add new universal chance parsing
|
- Add new universal chance parsing
|
||||||
- Any `<chance>` can now either be a 1-in-N number (e.g. `4`, `10`), or a percentage chance (e.g. `50%`, `10%`).
|
- Any `<chance>` can now either be a 1-in-N number (e.g. `4`, `10`), or a percentage chance (e.g. `50%`, `10%`).
|
||||||
- Caveat: Percentages are converted to a 1-in-N chance, but additionally that number is rounded down in some places
|
- Caveat: Percentages are converted to a 1-in-N chance, but additionally that number is rounded down in some places
|
||||||
|
- `//torus`, `//hollowtorus`: Add optional new axes argument
|
||||||
|
|
||||||
|
|
||||||
## v1.11: The big data update (25th January 2021)
|
## v1.11: The big data update (25th January 2021)
|
||||||
|
|
|
@ -124,12 +124,15 @@ Creates a hollow ellipsoid at position 1 with the radius `(rx, ry, rz)`. Works t
|
||||||
//hollowellipsoid 21 11 41 stone
|
//hollowellipsoid 21 11 41 stone
|
||||||
```
|
```
|
||||||
|
|
||||||
## `//torus <major_radius> <minor_radius> <node_name>`
|
## `//torus <major_radius> <minor_radius> <node_name> [<axes=xy>]`
|
||||||
Creates a solid torus at position 1 with the specified major and minor radii. The major radius is the distance from the centre of the torus to the centre of the circle bit, and the minor radius is the radius of the circle bit.
|
Creates a solid torus at position 1 with the specified major and minor radii. The major radius is the distance from the centre of the torus to the centre of the circle bit, and the minor radius is the radius of the circle bit.
|
||||||
|
|
||||||
|
The optional axes sets the axes upon which the torus will lay flat. Possible values: `xy` (the default), `xz`, `yz`.
|
||||||
|
|
||||||
```
|
```
|
||||||
//torus 15 5 stone
|
//torus 15 5 stone
|
||||||
//torus 5 3 meselamp
|
//torus 5 3 meselamp
|
||||||
|
//hollowtorus 10 6 sandstone xz
|
||||||
```
|
```
|
||||||
|
|
||||||
## `//hollowtorus <major_radius> <minor_radius> <node_name>`
|
## `//hollowtorus <major_radius> <minor_radius> <node_name>`
|
||||||
|
@ -138,6 +141,7 @@ Creates a hollow torus at position 1 with the radius major and minor radii. Work
|
||||||
```
|
```
|
||||||
//hollowtorus 10 5 glass
|
//hollowtorus 10 5 glass
|
||||||
//hollowtorus 21 11 stone
|
//hollowtorus 21 11 stone
|
||||||
|
//hollowtorus 18 6 dirt xz
|
||||||
```
|
```
|
||||||
|
|
||||||
## `//line [<replace_node> [<radius>]]`
|
## `//line [<replace_node> [<radius>]]`
|
||||||
|
|
|
@ -42,8 +42,13 @@ function worldeditadditions.torus(position, major_radius, minor_radius, target_n
|
||||||
for x = -total_radius, total_radius do
|
for x = -total_radius, total_radius do
|
||||||
local x_sq = x*x
|
local x_sq = x*x
|
||||||
|
|
||||||
|
local sq = vector.new(x_sq, y_sq, z_sq)
|
||||||
|
|
||||||
|
-- Default: xy
|
||||||
if axes == "xz" then
|
if axes == "xz" then
|
||||||
-- TODO: Figure out which 2 axes we need to fiddle here
|
sq.x, sq.y, sq.z = sq.x, sq.z, sq.y
|
||||||
|
elseif axes == "yz" then
|
||||||
|
sq.x, sq.y, sq.z = sq.y, sq.z, sq.x
|
||||||
end
|
end
|
||||||
|
|
||||||
-- (x^2+y^2+z^2-(a^2+b^2))^2-4 a b (b^2-z^2)
|
-- (x^2+y^2+z^2-(a^2+b^2))^2-4 a b (b^2-z^2)
|
||||||
|
@ -51,8 +56,8 @@ function worldeditadditions.torus(position, major_radius, minor_radius, target_n
|
||||||
-- (x, y, z) is the point
|
-- (x, y, z) is the point
|
||||||
-- a is the major radius (centre to centre of circle)
|
-- a is the major radius (centre to centre of circle)
|
||||||
-- b is the minor radius (radius of circle
|
-- b is the minor radius (radius of circle
|
||||||
local comp_a = (x_sq+y_sq+z_sq - (major_radius_sq+minor_radius_sq))
|
local comp_a = (sq.x+sq.y+sq.z - (major_radius_sq+minor_radius_sq))
|
||||||
local test_value = comp_a*comp_a - 4*major_radius*minor_radius*(minor_radius_sq-z_sq)
|
local test_value = comp_a*comp_a - 4*major_radius*minor_radius*(minor_radius_sq-sq.z)
|
||||||
|
|
||||||
-- If we're inside the torus, then fill it in
|
-- If we're inside the torus, then fill it in
|
||||||
if test_value <= 1 then
|
if test_value <= 1 then
|
||||||
|
@ -60,8 +65,8 @@ function worldeditadditions.torus(position, major_radius, minor_radius, target_n
|
||||||
|
|
||||||
if not place_ok then
|
if not place_ok then
|
||||||
-- It must be hollow! Do some additional calculations.
|
-- It must be hollow! Do some additional calculations.
|
||||||
local inner_comp_a = (x_sq+y_sq+z_sq - (major_radius_sq+inner_minor_radius_sq))
|
local inner_comp_a = (sq.x+sq.y+sq.z - (major_radius_sq+inner_minor_radius_sq))
|
||||||
local inner_test_value = inner_comp_a*inner_comp_a - 4*major_radius*inner_minor_radius*(inner_minor_radius_sq-z_sq)
|
local inner_test_value = inner_comp_a*inner_comp_a - 4*major_radius*inner_minor_radius*(inner_minor_radius_sq-sq.z)
|
||||||
|
|
||||||
-- It's only ok to place it if it's outside our inner torus
|
-- It's only ok to place it if it's outside our inner torus
|
||||||
place_ok = inner_test_value >= 0
|
place_ok = inner_test_value >= 0
|
||||||
|
|
Loading…
Reference in a new issue