Skip to content

Commit

Permalink
Merge branch 'master' into refactor_gpu
Browse files Browse the repository at this point in the history
# Conflicts:
#	doc/source/changelog.md
  • Loading branch information
Zylann committed Feb 2, 2025
2 parents 9ab8cab + a979c87 commit e82d399
Show file tree
Hide file tree
Showing 124 changed files with 4,652 additions and 1,349 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
# the working directory for all following steps.
- name: Setup buildroot
run: |
wget https://download.tuxfamily.org/godotengine/toolchains/linux/x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2
wget https://github.com/godotengine/buildroot/releases/download/godot-2023.08.x-4/x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2
tar -xjf x86_64-godot-linux-gnu_sdk-buildroot.tar.bz2
cd x86_64-godot-linux-gnu_sdk-buildroot
./relocate-sdk.sh
Expand Down
5 changes: 4 additions & 1 deletion common.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def get_sources(env, is_editor_build, include_tests):
"util/godot/classes/geometry_2d.cpp",
"util/godot/classes/geometry_instance_3d.cpp",
"util/godot/classes/input_event_key.cpp",
"util/godot/classes/image_texture_3d.cpp",
"util/godot/classes/material.cpp",
"util/godot/classes/mesh.cpp",
"util/godot/classes/multimesh.cpp",
"util/godot/classes/node.cpp",
Expand Down Expand Up @@ -137,7 +139,8 @@ def get_sources(env, is_editor_build, include_tests):
"util/godot/classes/editor_property.cpp",
"util/godot/classes/editor_settings.cpp",
"util/godot/classes/graph_edit.cpp", # Not editor-only, but only used in editor for now
"util/godot/classes/graph_node.cpp" # Not editor-only, but only used in editor for now
"util/godot/classes/graph_node.cpp", # Not editor-only, but only used in editor for now
"util/godot/classes/shape_3d.cpp" # Not editor-only, but only used in editor for now
]

if include_tests:
Expand Down
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def get_doc_classes():
"VoxelBlockyModel",
"VoxelBlockyModelCube",
"VoxelBlockyModelEmpty",
"VoxelBlockyModelFluid",
"VoxelBlockyModelMesh",
"VoxelBlockyFluid",
"VoxelBlockyType",
"VoxelBlockyTypeLibrary",
"VoxelBoxMover",
Expand Down
14 changes: 14 additions & 0 deletions constants/cube_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const Vector3f g_corner_position[CORNER_COUNT] = {
Vector3f(1, 1, 1)
};

// 3---2
// | |
// 0---1
const int g_side_quad_triangles[SIDE_COUNT][6] = {
{ 0, 2, 1, 0, 3, 2 }, // LEFT (+x)
{ 0, 2, 1, 0, 3, 2 }, // RIGHT (-x)
Expand All @@ -52,6 +55,8 @@ const int g_side_quad_triangles[SIDE_COUNT][6] = {
{ 0, 2, 1, 0, 3, 2 }, // FRONT (+z)
};

// const int g_side_quad_triangles_alt[6] = { 0, 3, 1, 1, 3, 2 };

// const unsigned int g_side_coord[SIDE_COUNT] = { 0, 0, 1, 1, 2, 2 };
// const unsigned int g_side_sign[SIDE_COUNT] = { 0, 1, 0, 1, 0, 1 };

Expand Down Expand Up @@ -213,6 +218,15 @@ const Vector3i g_ordered_moore_area_3d[MOORE_AREA_3D_COUNT] = { //
Vector3i(1, 1, 1)
};

const int g_opposite_side[6] = {
Cube::SIDE_NEGATIVE_X, //
Cube::SIDE_POSITIVE_X, //
Cube::SIDE_POSITIVE_Y, //
Cube::SIDE_NEGATIVE_Y, //
Cube::SIDE_POSITIVE_Z, //
Cube::SIDE_NEGATIVE_Z //
};

// clang-format on

Cube::Side dir_to_side(Vector3i d) {
Expand Down
2 changes: 2 additions & 0 deletions constants/cube_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ extern const Vector3i g_edge_inormals[EDGE_COUNT];

extern const unsigned int g_edge_corners[EDGE_COUNT][2];

extern const int g_opposite_side[6];

const unsigned int MOORE_NEIGHBORING_3D_COUNT = 26;
extern const Vector3i g_moore_neighboring_3d[MOORE_NEIGHBORING_3D_COUNT];

Expand Down
23 changes: 23 additions & 0 deletions doc/classes/VoxelBlockyFluid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VoxelBlockyFluid" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Properties of a blocky fluid.
</brief_description>
Common properties of a specific fluid. It may be shared between multiple blocky models, each representing a level/state of the fluid.
<description>
</description>
<tutorials>
</tutorials>
<members>
<member name="dip_when_flowing_down" type="bool" is_experimental="true" setter="set_dip_when_flowing_down" getter="get_dip_when_flowing_down" default="false">
When enabled, if all following conditions are met for a given fluid voxel:
- It doesn't have maximum level
- It isn't covered by another voxel of the same fluid type
- It can flow downwards (below is air or fluid of the same type)
Then the shape of the voxel will change to be "pushed" downwards, creating steeper slopes. Note, this also means the voxel will look as if it has minimum level in some situations. However, in practice these cases don't occur often. You may decide whether to use this option depending on how your fluid simulates.
</member>
<member name="material" type="Material" setter="set_material" getter="get_material">
Material used by all states of the fluid. Note that UVs of a fluid are different than a regular model, so you may need a [ShaderMaterial] to handle flowing animation.
</member>
</members>
</class>
15 changes: 15 additions & 0 deletions doc/classes/VoxelBlockyModel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
Gets the material override for a specific surface of the model.
</description>
</method>
<method name="get_mesh_ortho_rotation_index" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="is_mesh_collision_enabled" qualifiers="const">
<return type="bool" />
<param index="0" name="surface_index" type="int" />
Expand Down Expand Up @@ -47,6 +52,12 @@
Enables or disables mesh-based collision on a specific surface. It allows a model to have solid parts and others where players can pass through.
</description>
</method>
<method name="set_mesh_ortho_rotation_index">
<return type="void" />
<param index="0" name="i" type="int" />
<description>
</description>
</method>
</methods>
<members>
<member name="collision_aabbs" type="AABB[]" setter="set_collision_aabbs" getter="get_collision_aabbs" default="[]">
Expand All @@ -61,6 +72,10 @@
<member name="culls_neighbors" type="bool" setter="set_culls_neighbors" getter="get_culls_neighbors" default="true">
If enabled, this voxel culls the faces of its neighbors. Disabling can be useful for denser transparent voxels, such as foliage.
</member>
<member name="lod_skirts_enabled" type="bool" setter="set_lod_skirts_enabled" getter="get_lod_skirts_enabled" default="true">
If enabled and the terrain has LODs, this model will produce skirts when located at the edge of a chunk. This is intented to hide "cracks" between chunks of different LOD.
You may turn this off if the model is transparent, as the skirt would become visible from behind other surfaces.
</member>
<member name="random_tickable" type="bool" setter="set_random_tickable" getter="is_random_tickable" default="false">
If enabled, voxels having this ID in the TYPE channel will be used by [method VoxelToolTerrain.run_blocky_random_tick].
</member>
Expand Down
2 changes: 2 additions & 0 deletions doc/classes/VoxelBlockyModelCube.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@
<member name="collision_aabbs" type="AABB[]" setter="set_collision_aabbs" getter="get_collision_aabbs" overrides="VoxelBlockyModel" default="[AABB(0, 0, 0, 1, 1, 1)]" />
<member name="height" type="float" setter="set_height" getter="get_height" default="1.0">
</member>
<member name="mesh_ortho_rotation_index" type="int" setter="set_mesh_ortho_rotation_index" getter="get_mesh_ortho_rotation_index" default="0">
</member>
</members>
</class>
23 changes: 23 additions & 0 deletions doc/classes/VoxelBlockyModelFluid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VoxelBlockyModelFluid" inherits="VoxelBlockyModel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Model representing a specific state of a fluid.
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<members>
<member name="fluid" type="VoxelBlockyFluid" setter="set_fluid" getter="get_fluid">
Which fluid this model is part of. Note, fluid resources are supposed to be shared between multiple models, in order to make those models recognized as states of that fluid.
</member>
<member name="level" type="int" setter="set_level" getter="get_level" default="0">
Fluid level, usually representing how much fluid the model contains. Levels should start from 0, and must be lower than 256. Fluids can have multiple models with the same level. It is also preferable to define at least one model per level (avoid missing levels). It is also recommended to assign models with consecutive levels to consecutive library IDs, however this is not required.
</member>
</members>
<constants>
<constant name="MAX_LEVELS" value="256">
Maximum amount of supported fluid levels.
</constant>
</constants>
</class>
3 changes: 3 additions & 0 deletions doc/classes/VoxelBlockyModelMesh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
Orthogonal rotation applied to the mesh when baking. Values are taken from the same convention as [GridMap] tiles.
([GridMap] provides a conversion method from [Basis], unfortunately it is not a static method so it requires a [GridMap] instance to exist. A helper method could be added in the future if requested)
</member>
<member name="side_cutout_enabled" type="bool" is_experimental="true" setter="set_side_cutout_enabled" getter="is_side_cutout_enabled" default="false">
When a neighbor voxel partially covers a side of this voxel, the occluded geometry of the side will be cut away. This only works if the shape of both sides is a rectangle. Note, enabling this option can actually produce more triangles than when it is enabled.
</member>
<member name="side_vertex_tolerance" type="float" setter="set_side_vertex_tolerance" getter="get_side_vertex_tolerance" default="0.001">
Margin below which triangles located near one of the 6 sides of the voxel will be considered on that side. Sides get culled or not by comparing between triangles of neighbor sides.
</member>
Expand Down
34 changes: 34 additions & 0 deletions doc/classes/VoxelBuffer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@
Clears the buffer and gives it the specified size.
</description>
</method>
<method name="create_3d_texture_from_sdf_zxy" qualifiers="const">
<return type="ImageTexture3D" />
<param index="0" name="output_format" type="int" enum="Image.Format" />
<description>
Creates a 3D texture from the SDF channel.
If [code]output_format[/code] is a 8-bit pixel format, the texture will contain normalized signed distances, where 0.5 is the isolevel, 0 is the furthest away under surface, and 1 is the furthest away above surface.
Only 16-bit SDF channel is supported.
Only [constant Image.FORMAT_R8] and [constant Image.FORMAT_L8] output formats are suported.
Note: when sampling this texture in a shader, you need to swizzle 3D coordinates with [code].yxz[/code]. This is how voxels are internally stored, and this function does not change this convention.
</description>
</method>
<method name="debug_print_sdf_y_slices" qualifiers="const">
<return type="Image[]" />
<param index="0" name="scale" type="float" default="1.0" />
Expand Down Expand Up @@ -173,6 +184,14 @@
Gets metadata associated to this [VoxelBuffer].
</description>
</method>
<method name="get_channel_as_byte_array" qualifiers="const">
<return type="PackedByteArray" />
<param index="0" name="channel_index" type="int" enum="VoxelBuffer.ChannelId" />
<description>
Gets voxel data from a channel as uncompressed raw bytes. Check [enum VoxelBuffer.Depth] for information about the data format.
Note: if the channel is compressed, it will be decompressed on the fly into the returned array. If you want a different behavior in this case, check [method get_channel_compression] before calling this method.
</description>
</method>
<method name="get_channel_compression" qualifiers="const">
<return type="int" enum="VoxelBuffer.Compression" />
<param index="0" name="channel" type="int" />
Expand Down Expand Up @@ -316,6 +335,14 @@
Changes the bit depth of a given channel. This controls the range of values a channel can hold. See [enum VoxelBuffer.Depth] for more information.
</description>
</method>
<method name="set_channel_from_byte_array">
<return type="void" />
<param index="0" name="channel_index" type="int" enum="VoxelBuffer.ChannelId" />
<param index="1" name="data" type="PackedByteArray" />
<description>
Overwrites the contents of a channel from raw voxel data. Check [enum VoxelBuffer.Depth] for information about the expected data format.
</description>
</method>
<method name="set_voxel">
<return type="void" />
<param index="0" name="value" type="int" />
Expand Down Expand Up @@ -355,6 +382,13 @@
<description>
</description>
</method>
<method name="update_3d_texture_from_sdf_zxy" qualifiers="const">
<return type="void" />
<param index="0" name="existing_texture" type="ImageTexture3D" />
<description>
Updates an existing 3D texture from the SDF channel. See [method create_3d_texture_from_sdf_zxy] for more information.
</description>
</method>
</methods>
<constants>
<constant name="CHANNEL_TYPE" value="0" enum="ChannelId">
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/VoxelGeneratorNoise.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<member name="channel" type="int" setter="set_channel" getter="get_channel" enum="VoxelBuffer.ChannelId" default="1">
Channel into which the generator will produce voxel data. This depends on the type of meshing you need.
</member>
<member name="height_range" type="float" setter="set_height_range" getter="get_height_range" default="300.0">
<member name="height_range" type="float" setter="set_height_range" getter="get_height_range" default="200.0">
Range of altitudes within which the shape variations will be found. The higher this range, the more overhangs there will be.
Shapes will start at maximum density near the base of the shape (low probability to find air), and progressively loose density until it reaches maximum height.
</member>
<member name="height_start" type="float" setter="set_height_start" getter="get_height_start" default="0.0">
<member name="height_start" type="float" setter="set_height_start" getter="get_height_start" default="-100.0">
Base of the shape. Everything below it will be filled with ground.
</member>
<member name="noise" type="FastNoiseLite" setter="set_noise" getter="get_noise">
Expand Down
33 changes: 32 additions & 1 deletion doc/classes/VoxelInstanceGenerator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,29 @@
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_voxel_texture_filter_mask" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="set_voxel_texture_filter_mask">
<return type="void" />
<param index="0" name="mask" type="int" />
<description>
</description>
</method>
</methods>
<members>
<member name="density" type="float" setter="set_density" getter="get_density" default="0.1">
Controls how many instances are generated. Might give different results depending on the type of emission chosen.
</member>
<member name="emit_mode" type="int" setter="set_emit_mode" getter="get_emit_mode" enum="VoxelInstanceGenerator.EmitMode" default="0">
In which way instances are primarily emitted.
</member>
<member name="jitter" type="float" setter="set_jitter" getter="get_jitter" default="1.0">
Controls randomness of spawning position when [member emit_mode] is set to [constant EMIT_ONE_PER_TRIANGLE].
</member>
<member name="max_height" type="float" setter="set_max_height" getter="get_max_height" default="3.40282e+38">
Instances will not be created above this height.
This also depends on the chosen [member VoxelInstancer.up_mode].
Expand Down Expand Up @@ -63,12 +79,24 @@
<member name="scale_distribution" type="int" setter="set_scale_distribution" getter="get_scale_distribution" enum="VoxelInstanceGenerator.Distribution" default="1">
Sets how random scales are distributed.
</member>
<member name="triangle_area_threshold" type="float" setter="set_triangle_area_threshold" getter="get_triangle_area_threshold" default="0.0">
If set greater than zero, triangles of the ground with an area lower than this threshold will be ignored.
Some meshing algorithms can often produce thin or small triangles that can affect distribution quality of spawned instances. If this happens, use this property to filter them out.
Note: this property is relative to LOD0. The generator will scale it when spawning instances on meshes of different LOD index.
</member>
<member name="vertical_alignment" type="float" setter="set_vertical_alignment" getter="get_vertical_alignment" default="1.0">
Sets how much instances will align with the ground.
If 0, they will completely align with the ground.
If 1, they will completely align with whichever direction is considered "up".
This depends on [member VoxelInstancer.up_mode].
</member>
<member name="voxel_texture_filter_array" type="PackedInt32Array" setter="set_voxel_texture_filter_array" getter="get_voxel_texture_filter_array" default="PackedInt32Array(0)">
Specifies which voxel texture indices on top of which instances may spawn.
This only works when [member voxel_texture_filter_enabled] is enabled, and [VoxelMesherTransvoxel] is used with [member VoxelMesherTransvoxel.texturing_mode] set to [constant VoxelMesherTransvoxel.TEXTURES_BLEND_4_OVER_16].
</member>
<member name="voxel_texture_filter_enabled" type="bool" setter="set_voxel_texture_filter_enabled" getter="is_voxel_texture_filter_enabled" default="false">
When true, enables filtering of instances based on voxel texture indices. See [member voxel_texture_filter_array].
</member>
</members>
<constants>
<constant name="EMIT_FROM_VERTICES" value="0" enum="EmitMode">
Expand All @@ -80,7 +108,10 @@
<constant name="EMIT_FROM_FACES" value="2" enum="EmitMode">
Uses faces of the mesh to spawn instances. This is the slowest option, but should produce no noticeable patterns.
</constant>
<constant name="EMIT_MODE_COUNT" value="3" enum="EmitMode">
<constant name="EMIT_ONE_PER_TRIANGLE" value="3" enum="EmitMode">
Uses faces of the mesh to spawn instances (where faces are triangles). Only one instance is spawned per triangle. By default, it spawns in the middle of triangles. Randomness can be added to this position with [member jitter].
</constant>
<constant name="EMIT_MODE_COUNT" value="4" enum="EmitMode">
</constant>
<constant name="DISTRIBUTION_LINEAR" value="0" enum="Distribution">
Uniform distribution.
Expand Down
6 changes: 6 additions & 0 deletions doc/classes/VoxelInstanceLibrary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
</description>
</method>
</methods>
<members>
<member name="_data" type="Array" setter="_set_data" getter="_get_data" default="[0]">
</member>
<member name="_selected_item" type="VoxelInstanceLibraryItem" setter="_set_selected_item" getter="_get_selected_item">
</member>
</members>
<constants>
<constant name="MAX_ID" value="65535">
</constant>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/VoxelLodTerrain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
Collision layer used by generated colliders. Check Godot documentation for more information.
</member>
<member name="collision_lod_count" type="int" setter="set_collision_lod_count" getter="get_collision_lod_count" default="0">
How many LOD levels are set to generate colliders, starting from LOD 0.
How many LOD levels are set to generate colliders, starting from LOD 0. Setting this property to 0 means all LODs have collision.
</member>
<member name="collision_margin" type="float" setter="set_collision_margin" getter="get_collision_margin" default="0.04">
Collision margin used by generated colliders. Note that it may depend on which physics engine is used under the hood, as some don't use margins.
Expand Down
Loading

0 comments on commit e82d399

Please sign in to comment.