Code Monkey home page Code Monkey logo

caveeditor's People

Contributors

piratux avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

boyquotes

caveeditor's Issues

Toggle help window doesn't work

_unhandled_input() in HelpWindow.gd doesn't fire when mouse is captured (mouse is hidden) from capture_mouse in SmoothWorld.gd:

capture_mouse(value):
#...
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
ui_root.process_mode = Node.PROCESS_MODE_DISABLED
set_ui_element_mouse_filter(ui_root, false)

This makes H to toggle help window not work when mouse is captured.

Consider integrating do_flatten into godot_voxel module

As title says, consider adding do_flatten function to VoxelTool. This is basically do_hemisphere, with addition of gradual appearance overtime (similar to that of Unreal Engine voxel plugin flatten tool):

// Apply falloff for gradual effect
float weight = std::max(0.0f, (sphere_radius - dist) / sphere_radius);

do_flatten source code example (outdated, but gets the idea across):

void do_flatten(const VoxelBufferInternal &src, VoxelBufferInternal &dst, Vector3 flat_direction, float smoothness, Vector3f sphere_pos,
		float sphere_radius, float sdf_scale, bool mode_add) {
	ZN_PROFILE_SCOPE();

	const Vector3i dst_size = src.get_size();

	ZN_ASSERT_RETURN(sphere_radius > 0);

	ZN_ASSERT_RETURN(dst_size.x > 0);
	ZN_ASSERT_RETURN(dst_size.y > 0);
	ZN_ASSERT_RETURN(dst_size.z > 0);

	dst.create(dst_size);

	const Vector3 sphere_pos_vec3 = Vector3(sphere_pos.x, sphere_pos.y, sphere_pos.z);

	Vector3 dst_pos;
	Vector3 center = Vector3(0, 0, 0);
	// TODO: avoid offsetting plane to go through center?
	real_t plane_d = 0;
	for (dst_pos.z = 0; dst_pos.z < dst_size.z; ++dst_pos.z) {
		for (dst_pos.x = 0; dst_pos.x < dst_size.x; ++dst_pos.x) {
			for (dst_pos.y = 0; dst_pos.y < dst_size.y; ++dst_pos.y) {
				const float src_sd = src.get_voxel_f(dst_pos, VoxelBufferInternal::CHANNEL_SDF);

				Vector3 pos = dst_pos - sphere_pos_vec3;
				float sd_new = sdf_scale *
				math::sdf_smooth_subtract( //
						math::sdf_sphere(pos, center, sphere_radius), //
						math::sdf_plane(pos, flat_direction, plane_d), smoothness);

				float sd = 0.0f;

				if (mode_add){
					sd = math::sdf_union(src_sd, sd_new);
				}
				else{
					sd = math::sdf_subtract(src_sd, sd_new);
				}
				
				float dist = pos.length();
				// Apply falloff for gradual effect
				float weight = std::max(0.0f, (sphere_radius - dist) / sphere_radius);
				
				// TODO: consider adding parameter that controls falloff
				weight = math::clamp(weight * 2.0, 0.1, 1.0);
				
				sd = Math::lerp(src_sd, sd, weight);

				dst.set_voxel_f(sd, dst_pos, VoxelBufferInternal::CHANNEL_SDF);
			}
		}
	}
}

Code improvements

Here is a list of things that should be implemented, to improve code quality:

  • Swap dynamic types to static types where possible. This will improve code readability and performance.
  • Prefix script global variables with underscore. This will improve code readability and avoids name clashes when passing same name variable to function.

Surface tool broken

Surface tool performs edits far slower than intended with newest godot_voxel version.

Investigate why is that.

Potential clues:

  • grow_sphere was reworked in wrong way.
  • godot_voxel's sdf_scale rework affects this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.