-
-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||
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 commentThe 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, |
||
</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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Polyline is probably the best term. It may be lingo, but is used in various open APIs and in AutoCAD. |
||
</description> | ||
</method> | ||
<method name="do_point"> | ||
<return type="void" /> | ||
<param index="0" name="pos" type="Vector3i" /> | ||
<description> | ||
Used to edit single voxels. More useful with Blocky terrain, and might not look nice if editing [VoxelBuffer.CHANNEL_SDF]. | ||
</description> | ||
</method> | ||
<method name="do_sphere"> | ||
<return type="void" /> | ||
<param index="0" name="center" type="Vector3" /> | ||
<param index="1" name="radius" type="float" /> | ||
<description> | ||
Operate on all voxels in `radius` around `point`. See also [method do_box]. | ||
</description> | ||
</method> | ||
<method name="get_voxel"> | ||
<return type="int" /> | ||
<param index="0" name="pos" type="Vector3i" /> | ||
<description> | ||
Gets data from voxel at `pos` coordinates as an unsigned integer. This is an encoded value, so non-integer values may be obtained by converting it. The kind of data you get depends on [member channel] the tool is set to. | ||
</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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to distill the details and got something like this: |
||
</description> | ||
</method> | ||
<method name="get_voxel_metadata" qualifiers="const"> | ||
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
</description> | ||
</method> | ||
<method name="normalize_color" qualifiers="static"> | ||
<return type="Color" /> | ||
<param index="0" name="_unnamed_arg0" type="Color" /> | ||
<description> | ||
A helper method to set the sum of channels of the `Color` to 1. | ||
</description> | ||
</method> | ||
<method name="paste"> | ||
|
@@ -230,7 +240,7 @@ | |
Set which channel will be edited. When used on a terrain node, it will default to the first available channel, based on the stream and generator. | ||
</member> | ||
<member name="eraser_value" type="int" setter="set_eraser_value" getter="get_eraser_value"> | ||
Sets which value will be used to erase voxels when editing the [constant VoxelBuffer.CHANNEL_TYPE] channel in [constant MODE_REMOVE] mode. | ||
Sets which value will be used to erase voxels when editing the [constant VoxelBuffer.CHANNEL_TYPE] channel in [constant MODE_REMOVE] mode. Only relevant for Blocky voxels. | ||
</member> | ||
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="VoxelTool.Mode"> | ||
Sets how [code]do_*[/code] functions will behave. This may vary depending on the channel. | ||
|
@@ -240,13 +250,17 @@ | |
|
||
This is related to the [enum VoxelBuffer.Depth] configuration on voxels. For 8-bit and 16-bit, there is a limited range of values the Signed Distance Field can take, and by default it is clamped to -1..1, so the gradient can only range across 2 voxels. But when LOD is used, it is better to stretch that range over a longer distance, and this is achieved by scaling SDF values. | ||
</member> | ||
<member name="sdf_strength" type="float" setter="set_sdf_strength" getter="get_sdf_strength"> | ||
<member name="sdf_strength" type="float" setter="set_sdf_strength" getter="get_sdf_strength" default="1.0"> | ||
When editing [constant VoxelBuffer.CHANNEL_SDF] of Smooth Terrains in [constant VoxelTool.MODE_ADD] or [constant VoxelTool.MODE_REMOVE] determines the interpolation phase between current values and values set by the tool. Effectively represents the amount of "matter" added or subtracted. | ||
</member> | ||
<member name="texture_falloff" type="float" setter="set_texture_falloff" getter="get_texture_falloff"> | ||
<member name="texture_falloff" type="float" setter="set_texture_falloff" getter="get_texture_falloff" default="0.5"> | ||
Range [0.001..1.0]. Determines texture blending strength when tool is set to [constant VoxelTool.MODE_TEXTURE_PAINT]. Lower values produce sharper transitions. Can be compared to brush softness in an image editing program. | ||
</member> | ||
<member name="texture_index" type="int" setter="set_texture_index" getter="get_texture_index"> | ||
Determines which texture's weights will be edited when tool is set to [constant VoxelTool.MODE_TEXTURE_PAINT]. | ||
</member> | ||
<member name="texture_opacity" type="float" setter="set_texture_opacity" getter="get_texture_opacity"> | ||
<member name="texture_opacity" type="float" setter="set_texture_opacity" getter="get_texture_opacity" default="1.0"> | ||
Range [0.0..1.0]. Determines the maximum weight of a [member texture_index] when tool is set to [constant VoxelTool.MODE_TEXTURE_PAINT]. Can be compared to brush opacity in an image editing program. | ||
</member> | ||
<member name="value" type="int" setter="set_value" getter="get_value"> | ||
Sets which voxel value will be used. This is not relevant when editing [constant VoxelBuffer.CHANNEL_SDF]. | ||
|
@@ -263,6 +277,7 @@ | |
Replace voxel values without any blending. Useful for blocky voxels. | ||
</constant> | ||
<constant name="MODE_TEXTURE_PAINT" value="3" enum="Mode"> | ||
When editing [constant VoxelBuffer.CHANNEL_SDF] in Smooth Terrain, enables texture painting. The value of [member texture_index] will be added to texture indices of the affected voxels. The texture's weight will be blended based on the values of [member texture_falloff] and [member texture_opacity]. | ||
</constant> | ||
</constants> | ||
</class> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.^^ |
||
</description> | ||
</method> | ||
<method name="do_hemisphere"> | ||
|
@@ -25,6 +26,7 @@ | |
<param index="2" name="flat_direction" type="Vector3" /> | ||
<param index="3" name="smoothness" type="float" default="0.0" /> | ||
<description> | ||
See [method VoxelToolTerrain.do_hemisphere]. | ||
</description> | ||
</method> | ||
<method name="do_sphere_async"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "hemisphe"
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh nö, my bad!^^' With //funcs.h:353
math::sdf_smooth_subtract( //
math::sdf_sphere(pos, center, radius), //
math::sdf_plane(pos, flat_direction, plane_d),
smoothness
); |
||
</description> | ||
</method> | ||
<method name="for_each_voxel_metadata_in_area"> | ||
|
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.^^'