-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated docs for VoxelTool class family #683
base: master
Are you sure you want to change the base?
Conversation
@@ -41,39 +41,47 @@ | |||
<param index="0" name="begin" type="Vector3i" /> | |||
<param index="1" name="end" type="Vector3i" /> | |||
<description> | |||
Operate on a rectangular cuboid section of the terrain. [code]begin[/code] and [code]end[/code] are inclusive. Choose operation and which voxel to use by setting [code]value[/code] and [code]mode[/code] before calling this function. | |||
Operate on a rectangular cuboid section of the terrain. [code]begin[/code] and [code]end[/code] are inclusive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, end
is not inclusive with smooth voxels. For example if you pass (0,0,0) and (0,0,0), that's an empty box and it won't do anything. It might have been a mistake that the blocky mode was inconsistent, because generally I code everything dealing with boxes using an exclusive max point. But thats how things have been so far, it's quite old.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay, then I'll try to reflect that in revised description.^^'
@@ -41,39 +41,47 @@ | |||
<param index="0" name="begin" type="Vector3i" /> | |||
<param index="1" name="end" type="Vector3i" /> | |||
<description> | |||
Operate on a rectangular cuboid section of the terrain. [code]begin[/code] and [code]end[/code] are inclusive. Choose operation and which voxel to use by setting [code]value[/code] and [code]mode[/code] before calling this function. | |||
Operate on a rectangular cuboid section of the terrain. [code]begin[/code] and [code]end[/code] are inclusive. | |||
You must choose operation by setting [code]mode[/code] and set parameters relevant to the type of tool before calling this function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true of every operation, so I'm not sure how relevant it is to indicate that on do_box
specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I thought of linking every do_* op to Box as the most documented one, but now I'm thinking that maybe this and the next comment can be moved to ''Using VoxelTool" section of Scripting article in the main doc. Maybe even with code examples and stuff. Does it sound reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice, but at the same time it requires putting absolute links in there, while it could also be in the description of the class. But I dont think we can link to that description somehow.
Operate on a rectangular cuboid section of the terrain. [code]begin[/code] and [code]end[/code] are inclusive. | ||
You must choose operation by setting [code]mode[/code] and set parameters relevant to the type of tool before calling this function. | ||
If working with blocky terrain, you can choose which voxel to use by setting [member value]. | ||
If working with smooth terrain, use [member sdf_scale] and [member sdf_strength] in [constant VoxelTool.MODE_ADD] or [constant VoxelTool.MODE_REMOVE]. See also [constant VoxelTool.MODE_TEXTURE_PAINT]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again, not sure if all this should be indicated here, because that's true of many do_* functions. In addition, sdf_scale
is getting less recommended unless you know what you're doing, it was originally present to allow improving the encoding fixed-point scale, which is now automatic.
</description> | ||
</method> | ||
<method name="do_path"> | ||
<return type="void" /> | ||
<param index="0" name="points" type="PackedVector3Array" /> | ||
<param index="1" name="radii" type="PackedFloat32Array" /> | ||
<description> | ||
Performs an edit similar to `do_sphere` along a spline defined by `points`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a spline, it's a list of points connected by linear segments. They are not smoothed out. Not sure how to call that, but a spline is something different.
Also radii
(radius, plural) needs to be explained, it is the width of the "tube" along each point.
Internally, this is equivalent to carving/building capsules end-to-end, where the radius of the base and the top of each capsule is taken from the radii. The original reason I started exposing that function was to do cave worms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see! So maybe something like
"Performs an edit along a series of tubular sections with junctions defined by points
array. radii
(plural of radius) array defines tube's thickness at the point with corresponding index. The main purpose of this function is efficiently carving tunnels."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a spline, it's a list of points connected by linear segments. They are not smoothed out. Not sure how to call that, but a spline is something different.
Polyline is probably the best term. It may be lingo, but is used in various open APIs and in AutoCAD.
</description> | ||
</method> | ||
<method name="get_voxel_f"> | ||
<return type="float" /> | ||
<param index="0" name="pos" type="Vector3i" /> | ||
<description> | ||
Returns data from voxel at `pos` coordinates as float. If set to operate on [constant VoxelBuffer.CHANNEL_SDF] returns the voxel's SDF value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the channel doesn't actually matter: it will always decode voxel data the same way. But it is indeed meant to read SDF values. Also, the range of precision is not exactly like a float, it is set to quantized values when using 8-bit and 16-bit depths, which are tuned for signed distances. However when using 32-bit it does use actual floats.
This is actually something that boils down to VoxelBuffer
, because that's where this encoding/decoding takes place.
Anyways, not sure if it needs all these details, "float" is ok, but it's just that not the full range of float values work here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to distill the details and got something like this:
"Returns data from voxel at pos coordinates as a float value. This method is intended to read SDF values and will be decoded as such regardless of the channel value of the tool.
Note: Return value's actual precision depends on VoxelBuffer.Depth set for the SDF channel."
@@ -100,12 +108,14 @@ | |||
<return type="bool" /> | |||
<param index="0" name="box" type="AABB" /> | |||
<description> | |||
Returns false if the blocks within `box` are not fully loaded. Not implemented in this class, because it only makes sense if editing with [VoxelToolTerrain] or [VoxelToolLodTerrain] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it should say that it's not implemented in this class? Because that method won't appear in derived classes in the docs. Also it should already being known that VoxelTool
itself should never be used as-is, it's only a base class acting as a common interface. The woes of OOP inheritance docs :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, yeah, I wrote this looking at base implementation without realizing it won't appear in child class docs. I'm new to this xD
If links to main docs will work, maybe it can mention "Useful to check if edited area is within bounds and in LOD0 in case of LOD terrain" and link back to the section about this in Scripting.
@@ -16,6 +16,7 @@ | |||
<param index="1" name="transform" type="Transform3D" /> | |||
<param index="2" name="area_size" type="Vector3" /> | |||
<description> | |||
Allows using a [VoxelGeneratorGraph] as a brush, which opens possibility for various advanced scenarios. See [related article](../Generators.md#using-voxelgeneratorgraph-as-a-brush). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[related
has no precedent in Godot's documentation. XML files follow features supported by Godot, because this is the same file used to display API docs in the editor.
Maybe you should use the [url=https://...]text[/url]
syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, yeah. 'related' is not intended as a keyword here, it's just "related article" x) I'll try the new syntax and see if the bbcode converter still complains at me.^^
@@ -17,6 +17,7 @@ | |||
<param index="2" name="flat_direction" type="Vector3" /> | |||
<param index="3" name="smoothness" type="float" default="0.0" /> | |||
<description> | |||
Operates on a hemisphe, where the "dome" part's summit is pointed in `flat_direction`. `smoothness` determines how the flat part blends with the rounded part, with higher values producing softer more rounded edge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "hemisphe"
flat_direction
is actually supposed to point away from the flat side. If that's not the case I think it should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nö, my bad!^^'
With flat_direction
I was expecting it to work as you say, but yeah, it's flipped.
//funcs.h:353
math::sdf_smooth_subtract( //
math::sdf_sphere(pos, center, radius), //
math::sdf_plane(pos, flat_direction, plane_d),
smoothness
);
8fdf450
to
a393969
Compare
I tried to fill some blanks in VoxelTool docs based on some experiments and looking at source. I might have still gotten something wrong and would appreciate feedback and suggestions on how to do things better.
PS: I was unsure how to do links from class ref to main articles, so I used relative path. bbcode_to_markdown complains about such syntax, but the link works well in vscode markdown preview. Hope it doesn't break in readthedocs ^^'