ronantakizawa/codereview-bench huggingface dataset:
Repository: godotengine/godot
File: platform/linuxbsd/os_linuxbsd.cpp (C++)

Code before:
	}
	return machine_id;
}

String OS_LinuxBSD::get_processor_name() const {
	Ref<FileAccess> f = FileAccess::open("/proc/cpuinfo", FileAccess::READ);
	ERR_FAIL_COND_V_MSG(f.is_null(), "", String("Couldn't open `/proc/cpuinfo` to get the CPU model name. Returning an empty string."));

	while (!f->eof_reached()) {
		const String line = f->get_line();
		if (line.find("model name") != -1) {
			return line.split(":")[1].strip_edges();
		}
	}

	ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name from `/proc/cpuinfo`. Returning an empty string."));
}

bool OS_LinuxBSD::is_sandboxed() const {
	// This function is derived from SDL:
	// https://github.com/libsdl-org/SDL/blob/main/src/core/linux/SDL_sandbox.c#L28-L45

	if (access("/.flatpak-info", F_OK) == 0) {
		return true;
	}

	// For Snap, we check multiple variables because they might be set for
	// unrelated reasons. This is the same thing WebKitGTK does.
	if (has_environment("SNAP") && has_environment("SNAP_NAME") && has_environment("SNAP_REVISION")) {
		return true;
	}

	if (access("/run/host/container-manager", F_OK) == 0) {
		return true;
	}

	return false;
}

void OS_LinuxBSD::finalize() {
	if (main_loop) {
		memdelete(main_loop);
	}
	main_loop = nullptr;

#ifdef ALSAMIDI_ENABLED
	driver_alsamidi.close();
#endif

#ifdef JOYDEV_ENABLED
	if (joypad) {

Review comment (suggestion):
```suggestion
	if (sysctl(mib, 2, buf, &len, 0x0, 0) == -1) {
		return String();
	}
```

Code after:
		char buf[4096];
		memset(buf, 0, sizeof(buf));
		size_t len = sizeof(buf) - 1;
		if (sysctl(mib, 2, buf, &len, 0x0, 0) != -1) {
			machine_id = String::utf8(buf).replace("-", "");
		}
#else
		Ref<FileAccess> f = FileAccess::open("/etc/machine-id", FileAccess::READ);
		if (f.is_valid()) {
			while (machine_id.is_empty() && !f->eof_reached()) {
				machine_id = f->get_line().strip_edges();
			}
		}
#endif
	}
	return machine_id;
}

String OS_LinuxBSD::get_processor_name() const {
#if defined(__FreeBSD__)
	const int mib[2] = { CTL_HW, HW_MODEL };
	char buf[4096];
	memset(buf, 0, sizeof(buf));
	size_t len = sizeof(buf) - 1;
	if (sysctl(mib, 2, buf, &len, 0x0, 0) != -1) {
		return String::utf8(buf);
	}
#else
	Ref<FileAccess> f = FileAccess::open("/proc/cpuinfo", FileAccess::READ);
	ERR_FAIL_COND_V_MSG(f.is_null(), "", String("Couldn't open `/proc/cpuinfo` to get the CPU model name. Returning an empty string."));

	while (!f->eof_reached()) {
		const String line = f->get_line();
		if (line.find("model name") != -1) {
			return line.split(":")[1].strip_edges();
		}
	}
#endif

	ERR_FAIL_V_MSG("", String("Couldn't get the CPU model. Returning an empty string."));
}

bool OS_LinuxBSD::is_sandboxed() const {
	// This function is derived from SDL:
	// https://github.com/libsdl-org/SDL/blob/main/src/core/linux/SDL_sandbox.c#L28-L45

	if (access("/.flatpak-info", F_OK) == 0) {
		return true;
	}

	// For Snap, we check multiple variables because they might be set for
Repository: godotengine/godot
File: platform/linuxbsd/os_linuxbsd.cpp (C++)

Code before:
	crash_handler.initialize();

	OS_Unix::initialize_core();

	system_dir_desktop_cache = get_system_dir(SYSTEM_DIR_DESKTOP);
}

void OS_LinuxBSD::initialize_joypads() {
#ifdef JOYDEV_ENABLED
	joypad = memnew(JoypadLinux(Input::get_singleton()));
#endif
}

String OS_LinuxBSD::get_unique_id() const {
	static String machine_id;
	if (machine_id.is_empty()) {
		Ref<FileAccess> f = FileAccess::open("/etc/machine-id", FileAccess::READ);
		if (f.is_valid()) {
			while (machine_id.is_empty() && !f->eof_reached()) {
				machine_id = f->get_line().strip_edges();
			}
		}
	}
	return machine_id;
}

String OS_LinuxBSD::get_processor_name() const {
	Ref<FileAccess> f = FileAccess::open("/proc/cpuinfo", FileAccess::READ);
	ERR_FAIL_COND_V_MSG(f.is_null(), "", String("Couldn't open `/proc/cpuinfo` to get the CPU model name. Returning an empty string."));

	while (!f->eof_reached()) {
		const String line = f->get_line();
		if (line.find("model name") != -1) {
			return line.split(":")[1].strip_edges();
		}
	}

	ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name from `/proc/cpuinfo`. Returning an empty string."));
}

bool OS_LinuxBSD::is_sandboxed() const {
	// This function is derived from SDL:
	// https://github.com/libsdl-org/SDL/blob/main/src/core/linux/SDL_sandbox.c#L28-L45

	if (access("/.flatpak-info", F_OK) == 0) {
		return true;
	}

	// For Snap, we check multiple variables because they might be set for
	// unrelated reasons. This is the same thing WebKitGTK does.
	if (has_environment("SNAP") && has_environment("SNAP_NAME") && has_environment("SNAP_REVISION")) {

Review comment (suggestion):
Assuming this returns ASCII only? Otherwise you need to use `String::utf8(buf)` instead of `String(buf)`

Code after:
	}
}

void OS_LinuxBSD::initialize() {
	crash_handler.initialize();

	OS_Unix::initialize_core();

	system_dir_desktop_cache = get_system_dir(SYSTEM_DIR_DESKTOP);
}

void OS_LinuxBSD::initialize_joypads() {
#ifdef JOYDEV_ENABLED
	joypad = memnew(JoypadLinux(Input::get_singleton()));
#endif
}

String OS_LinuxBSD::get_unique_id() const {
	static String machine_id;
	if (machine_id.is_empty()) {
#if defined(__FreeBSD__)
		const int mib[2] = { CTL_KERN, KERN_HOSTUUID };
		char buf[4096];
		memset(buf, 0, sizeof(buf));
		size_t len = sizeof(buf) - 1;
		if (sysctl(mib, 2, buf, &len, 0x0, 0) != -1) {
			machine_id = String::utf8(buf).replace("-", "");
		}
#else
		Ref<FileAccess> f = FileAccess::open("/etc/machine-id", FileAccess::READ);
		if (f.is_valid()) {
			while (machine_id.is_empty() && !f->eof_reached()) {
				machine_id = f->get_line().strip_edges();
			}
		}
#endif
	}
	return machine_id;
}

String OS_LinuxBSD::get_processor_name() const {
#if defined(__FreeBSD__)
	const int mib[2] = { CTL_HW, HW_MODEL };
	char buf[4096];
	memset(buf, 0, sizeof(buf));
	size_t len = sizeof(buf) - 1;
	if (sysctl(mib, 2, buf, &len, 0x0, 0) != -1) {
		return String::utf8(buf);
	}
#else
	Ref<FileAccess> f = FileAccess::open("/proc/cpuinfo", FileAccess::READ);
Repository: godotengine/godot
File: platform/linuxbsd/os_linuxbsd.cpp (C++)

Code before:
		}
#endif
	}
	return machine_id;
}

String OS_LinuxBSD::get_processor_name() const {
#if defined(__FreeBSD__)
	const int mib[2] = { CTL_HW, HW_MODEL };
	char buf[4096];
	memset(buf, 0, sizeof(buf));
	size_t len = sizeof(buf) - 1;
	if (sysctl(mib, 2, buf, &len, 0x0, 0) == -1) {
		return String();
	}
	return String(buf);
#else
	Ref<FileAccess> f = FileAccess::open("/proc/cpuinfo", FileAccess::READ);
	ERR_FAIL_COND_V_MSG(f.is_null(), "", String("Couldn't open `/proc/cpuinfo` to get the CPU model name. Returning an empty string."));

	while (!f->eof_reached()) {
		const String line = f->get_line();
		if (line.find("model name") != -1) {
			return line.split(":")[1].strip_edges();
		}
	}
#endif

	ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name from `/proc/cpuinfo`. Returning an empty string."));
}

bool OS_LinuxBSD::is_sandboxed() const {
	// This function is derived from SDL:
	// https://github.com/libsdl-org/SDL/blob/main/src/core/linux/SDL_sandbox.c#L28-L45

	if (access("/.flatpak-info", F_OK) == 0) {
		return true;
	}

	// For Snap, we check multiple variables because they might be set for
	// unrelated reasons. This is the same thing WebKitGTK does.
	if (has_environment("SNAP") && has_environment("SNAP_NAME") && has_environment("SNAP_REVISION")) {
		return true;
	}

	if (access("/run/host/container-manager", F_OK) == 0) {
		return true;
	}

	return false;
}

Review comment (bug):
Shouldn't the `#endif` go below?

```
ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name from `/proc/cpuinfo`. Returning an empty string."));
```

Otherwise that's unreachable code for FreeBSD (since we always return before it)

Code after:
		}
#endif
	}
	return machine_id;
}

String OS_LinuxBSD::get_processor_name() const {
#if defined(__FreeBSD__)
	const int mib[2] = { CTL_HW, HW_MODEL };
	char buf[4096];
	memset(buf, 0, sizeof(buf));
	size_t len = sizeof(buf) - 1;
	if (sysctl(mib, 2, buf, &len, 0x0, 0) != -1) {
		return String::utf8(buf);
	}
#else
	Ref<FileAccess> f = FileAccess::open("/proc/cpuinfo", FileAccess::READ);
	ERR_FAIL_COND_V_MSG(f.is_null(), "", String("Couldn't open `/proc/cpuinfo` to get the CPU model name. Returning an empty string."));

	while (!f->eof_reached()) {
		const String line = f->get_line();
		if (line.find("model name") != -1) {
			return line.split(":")[1].strip_edges();
		}
	}
#endif

	ERR_FAIL_V_MSG("", String("Couldn't get the CPU model. Returning an empty string."));
}

bool OS_LinuxBSD::is_sandboxed() const {
	// This function is derived from SDL:
	// https://github.com/libsdl-org/SDL/blob/main/src/core/linux/SDL_sandbox.c#L28-L45

	if (access("/.flatpak-info", F_OK) == 0) {
		return true;
	}

	// For Snap, we check multiple variables because they might be set for
	// unrelated reasons. This is the same thing WebKitGTK does.
	if (has_environment("SNAP") && has_environment("SNAP_NAME") && has_environment("SNAP_REVISION")) {
		return true;
	}

	if (access("/run/host/container-manager", F_OK) == 0) {
		return true;
	}

	return false;
}
Repository: godotengine/godot
File: editor/plugins/canvas_item_editor_plugin.cpp (C++)

Code before:
		}
	}

	return true;
}

void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
	bool is_shift = Input::get_singleton()->is_key_pressed(Key::SHIFT);
	bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT);

	selected_files.clear();
	Dictionary d = p_data;
	if (d.has("type") && String(d["type"]) == "files") {
		selected_files = d["files"];
	}
	if (selected_files.size() == 0) {
		return;
	}

	List<Node *> selected_nodes = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
	Node *root_node = EditorNode::get_singleton()->get_edited_scene();
	if (selected_nodes.size() > 0) {
		Node *selected_node = selected_nodes.front()->get();
		target_node = selected_node;
		if (is_alt) {
			target_node = root_node;
		} else if (is_shift && selected_node != root_node) {
			target_node = selected_node->get_parent();
		}
	} else {
		if (root_node) {
			target_node = root_node;
		} else {
			target_node = nullptr;
		}
	}

	drop_pos = p_point;

	if (is_alt && is_shift && !_only_packed_scenes_selected()) {
		_show_resource_type_selector();
	} else {
		_perform_drop_data();
	}
}

void CanvasItemEditorViewport::_update_theme() {
	List<BaseButton *> btn_list;
	button_group->get_buttons(&btn_list);

	for (BaseButton *btn : btn_list) {

Review comment (suggestion):
```suggestion
		} else { // Default behavior.
```
For both, please use US English 

Code after:
	}

	return true;
}

void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
	bool is_shift = Input::get_singleton()->is_key_pressed(Key::SHIFT);
	bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT);

	selected_files.clear();
	Dictionary d = p_data;
	if (d.has("type") && String(d["type"]) == "files") {
		selected_files = d["files"];
	}
	if (selected_files.size() == 0) {
		return;
	}

	List<Node *> selected_nodes = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
	Node *root_node = EditorNode::get_singleton()->get_edited_scene();
	if (selected_nodes.size() > 0) {
		Node *selected_node = selected_nodes.front()->get();
		if (is_alt) {
			target_node = root_node;
		} else if (is_shift) {
			target_node = selected_node;
		} else { // Default behavior.
			target_node = (selected_node != root_node) ? selected_node->get_parent() : root_node;
		}
	} else {
		if (root_node) {
			target_node = root_node;
		} else {
			target_node = nullptr;
		}
	}

	drop_pos = p_point;

	if (is_alt && is_shift && !_only_packed_scenes_selected()) {
		_show_resource_type_selector();
	} else {
		_perform_drop_data();
	}
}

void CanvasItemEditorViewport::_update_theme() {
	List<BaseButton *> btn_list;
	button_group->get_buttons(&btn_list);

	for (BaseButton *btn : btn_list) {
Repository: godotengine/godot
File: editor/plugins/texture_layered_editor_plugin.cpp (C++)

Code before:

void TextureLayeredEditor::_make_shaders() {
	shaders[0].instantiate();
	shaders[0]->set_code(R"(
// TextureLayeredEditor preview shader (2D array).

shader_type canvas_item;

uniform sampler2DArray tex;
uniform float layer;

void fragment() {
	COLOR = textureLod(tex, vec3(UV, layer), 0.0);
}
)");

	shaders[1].instantiate();
	shaders[1]->set_code(R"(
// TextureLayeredEditor preview shader (cubemap).

shader_type canvas_item;

uniform samplerCube tex;
uniform vec3 normal;
uniform mat3 rot;

void fragment() {
	vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z));
	COLOR = textureLod(tex, n, 0.0);
}
)");

	shaders[2].instantiate();
	shaders[2]->set_code(R"(
// TextureLayeredEditor preview shader (cubemap array).

shader_type canvas_item;

uniform samplerCubeArray tex;
uniform vec3 normal;
uniform mat3 rot;
uniform float layer;

void fragment() {
	vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z));
	COLOR = textureLod(tex, vec4(n, layer), 0.0);
}
)");

	for (int i = 0; i < 3; i++) {
		materials[i].instantiate();

Review comment (suggestion):
```suggestion
				info->set_text(vformat(String::utf8("%d×%d (×%d) %s\n") + TTR("%s Mipmaps") + "\n" + TTR("Memory: %s"),
```

Code after:

	_texture_rect_update_area();

	const String format = Image::get_format_name(texture->get_format());
	String texture_info;

	switch (texture->get_layered_type()) {
		case TextureLayered::LAYERED_TYPE_2D_ARRAY: {
			layer->set_max(texture->get_layers() - 1);

			texture_info = vformat(String::utf8("%d×%d (×%d) %s\n"),
					texture->get_width(),
					texture->get_height(),
					texture->get_layers(),
					format);

		} break;
		case TextureLayered::LAYERED_TYPE_CUBEMAP: {
			layer->hide();

			texture_info = vformat(String::utf8("%d×%d %s\n"),
					texture->get_width(),
					texture->get_height(),
					format);

		} break;
		case TextureLayered::LAYERED_TYPE_CUBEMAP_ARRAY: {
			layer->set_max(texture->get_layers() / 6 - 1);

			texture_info = vformat(String::utf8("%d×%d (×%d) %s\n"),
					texture->get_width(),
					texture->get_height(),
					texture->get_layers() / 6,
					format);

		} break;

		default: {
		}
	}

	if (texture->has_mipmaps()) {
		const int mip_count = Image::get_image_required_mipmaps(texture->get_width(), texture->get_height(), texture->get_format());
		const int memory = Image::get_image_data_size(texture->get_width(), texture->get_height(), texture->get_format(), true) * texture->get_layers();

		texture_info += vformat(TTR("%s Mipmaps") + "\n" + TTR("Memory: %s"),
				mip_count,
				String::humanize_size(memory));

	} else {
		const int memory = Image::get_image_data_size(texture->get_width(), texture->get_height(), texture->get_format(), false) * texture->get_layers();
Repository: godotengine/godot
File: editor/plugins/texture_layered_editor_plugin.cpp (C++)

Code before:
shader_type canvas_item;

uniform samplerCube tex;
uniform vec3 normal;
uniform mat3 rot;

void fragment() {
	vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z));
	COLOR = textureLod(tex, n, 0.0);
}
)");

	shaders[2].instantiate();
	shaders[2]->set_code(R"(
// TextureLayeredEditor preview shader (cubemap array).

shader_type canvas_item;

uniform samplerCubeArray tex;
uniform vec3 normal;
uniform mat3 rot;
uniform float layer;

void fragment() {
	vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z));
	COLOR = textureLod(tex, vec4(n, layer), 0.0);
}
)");

	for (int i = 0; i < 3; i++) {
		materials[i].instantiate();
		materials[i]->set_shader(shaders[i]);
	}
}

void TextureLayeredEditor::_texture_rect_update_area() {
	Size2 size = get_size();
	int tex_width = texture->get_width() * size.height / texture->get_height();
	int tex_height = size.height;

	if (tex_width > size.width) {
		tex_width = size.width;
		tex_height = texture->get_height() * tex_width / texture->get_width();
	}

	// Prevent the texture from being unpreviewable after the rescale, so that we can still see something
	if (tex_height <= 0) {
		tex_height = 1;
	}
	if (tex_width <= 0) {
		tex_width = 1;

Review comment (suggestion):
```suggestion
				info->set_text(vformat(String::utf8("%d×%d (×%d) %s\n") + TTR("No Mipmaps") + "\n" + TTR("Memory: %s"),
```

Code after:
			texture_info = vformat(String::utf8("%d×%d %s\n"),
					texture->get_width(),
					texture->get_height(),
					format);

		} break;
		case TextureLayered::LAYERED_TYPE_CUBEMAP_ARRAY: {
			layer->set_max(texture->get_layers() / 6 - 1);

			texture_info = vformat(String::utf8("%d×%d (×%d) %s\n"),
					texture->get_width(),
					texture->get_height(),
					texture->get_layers() / 6,
					format);

		} break;

		default: {
		}
	}

	if (texture->has_mipmaps()) {
		const int mip_count = Image::get_image_required_mipmaps(texture->get_width(), texture->get_height(), texture->get_format());
		const int memory = Image::get_image_data_size(texture->get_width(), texture->get_height(), texture->get_format(), true) * texture->get_layers();

		texture_info += vformat(TTR("%s Mipmaps") + "\n" + TTR("Memory: %s"),
				mip_count,
				String::humanize_size(memory));

	} else {
		const int memory = Image::get_image_data_size(texture->get_width(), texture->get_height(), texture->get_format(), false) * texture->get_layers();

		texture_info += vformat(TTR("No Mipmaps") + "\n" + TTR("Memory: %s"),
				String::humanize_size(memory));
	}

	info->set_text(texture_info);
}

void TextureLayeredEditor::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_RESIZED: {
			_texture_rect_update_area();
		} break;

		case NOTIFICATION_DRAW: {
			Ref<Texture2D> checkerboard = get_editor_theme_icon(SNAME("Checkerboard"));
			Size2 size = get_size();

			draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
		} break;
Repository: godotengine/godot
File: editor/plugins/texture_layered_editor_plugin.cpp (C++)

Code before:
uniform vec3 normal;
uniform mat3 rot;
uniform float layer;

void fragment() {
	vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z));
	COLOR = textureLod(tex, vec4(n, layer), 0.0);
}
)");

	for (int i = 0; i < 3; i++) {
		materials[i].instantiate();
		materials[i]->set_shader(shaders[i]);
	}
}

void TextureLayeredEditor::_texture_rect_update_area() {
	Size2 size = get_size();
	int tex_width = texture->get_width() * size.height / texture->get_height();
	int tex_height = size.height;

	if (tex_width > size.width) {
		tex_width = size.width;
		tex_height = texture->get_height() * tex_width / texture->get_width();
	}

	// Prevent the texture from being unpreviewable after the rescale, so that we can still see something
	if (tex_height <= 0) {
		tex_height = 1;
	}
	if (tex_width <= 0) {
		tex_width = 1;
	}

	int ofs_x = (size.width - tex_width) / 2;
	int ofs_y = (size.height - tex_height) / 2;

	texture_rect->set_position(Vector2(ofs_x, ofs_y));
	texture_rect->set_size(Vector2(tex_width, tex_height));
}

void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) {
	if (!texture.is_null()) {
		texture->disconnect_changed(callable_mp(this, &TextureLayeredEditor::_texture_changed));
	}

	texture = p_texture;

	if (!texture.is_null()) {
		if (shaders[0].is_null()) {
			_make_shaders();

Review comment (suggestion):
```suggestion
				info->set_text(vformat(String::utf8("%d×%d (×%d) %s\n") + TTR("No Mipmaps") + "\n" + TTR("Memory: %s"),
```

Code after:
	}

	if (texture->has_mipmaps()) {
		const int mip_count = Image::get_image_required_mipmaps(texture->get_width(), texture->get_height(), texture->get_format());
		const int memory = Image::get_image_data_size(texture->get_width(), texture->get_height(), texture->get_format(), true) * texture->get_layers();

		texture_info += vformat(TTR("%s Mipmaps") + "\n" + TTR("Memory: %s"),
				mip_count,
				String::humanize_size(memory));

	} else {
		const int memory = Image::get_image_data_size(texture->get_width(), texture->get_height(), texture->get_format(), false) * texture->get_layers();

		texture_info += vformat(TTR("No Mipmaps") + "\n" + TTR("Memory: %s"),
				String::humanize_size(memory));
	}

	info->set_text(texture_info);
}

void TextureLayeredEditor::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_RESIZED: {
			_texture_rect_update_area();
		} break;

		case NOTIFICATION_DRAW: {
			Ref<Texture2D> checkerboard = get_editor_theme_icon(SNAME("Checkerboard"));
			Size2 size = get_size();

			draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
		} break;

		case NOTIFICATION_THEME_CHANGED: {
			if (info) {
				Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), EditorStringName(EditorFonts));
				info->add_theme_font_override(SceneStringName(font), metadata_label_font);
			}
		} break;
	}
}

void TextureLayeredEditor::_texture_changed() {
	if (!is_visible()) {
		return;
	}

	setting = true;
	_update_gui();
	setting = false;
Repository: godotengine/godot
File: editor/plugins/texture_3d_editor_plugin.cpp (C++)

Code before:
	add_child(info);
	info->set_anchor(SIDE_RIGHT, 1);
	info->set_anchor(SIDE_LEFT, 1);
	info->set_anchor(SIDE_BOTTOM, 1);
	info->set_anchor(SIDE_TOP, 1);
}

Texture3DEditor::~Texture3DEditor() {
	if (!texture.is_null()) {
		texture->disconnect_changed(callable_mp(this, &Texture3DEditor::_texture_changed));
	}
}

//
bool EditorInspectorPlugin3DTexture::can_handle(Object *p_object) {
	return Object::cast_to<Texture3D>(p_object) != nullptr;
}

void EditorInspectorPlugin3DTexture::parse_begin(Object *p_object) {
	Texture3D *texture = Object::cast_to<Texture3D>(p_object);
	if (!texture) {
		return;
	}
	Ref<Texture3D> m(texture);

	Texture3DEditor *editor = memnew(Texture3DEditor);
	editor->edit(m);
	add_custom_control(editor);
}

Texture3DEditorPlugin::Texture3DEditorPlugin() {
	Ref<EditorInspectorPlugin3DTexture> plugin;
	plugin.instantiate();
	add_inspector_plugin(plugin);
}


Review comment (suggestion):
It's preferable to use `Color(1, 1, 1)` and `Color(0, 0, 0)` as it leads to slightly smaller binary sizes from my testing.

Code after:
	}

	texture = p_texture;

	if (!texture.is_null()) {
		if (shader.is_null()) {
			_make_shaders();
		}

		texture->connect_changed(callable_mp(this, &Texture3DEditor::_texture_changed));
		texture_rect->set_material(material);

		setting = true;
		layer->set_value(0);
		layer->show();
		_update_gui();
		setting = false;

		_update_material(true);
		queue_redraw();

	} else {
		hide();
	}
}

Texture3DEditor::Texture3DEditor() {
	set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
	set_custom_minimum_size(Size2(1, 256.0) * EDSCALE);

	texture_rect = memnew(Control);
	texture_rect->set_mouse_filter(MOUSE_FILTER_IGNORE);
	texture_rect->connect(SceneStringName(draw), callable_mp(this, &Texture3DEditor::_texture_rect_draw));

	add_child(texture_rect);

	layer = memnew(SpinBox);
	layer->set_step(1);
	layer->set_max(100);

	layer->set_modulate(Color(1, 1, 1, 0.8));
	layer->set_h_grow_direction(GROW_DIRECTION_BEGIN);
	layer->set_anchor(SIDE_RIGHT, 1);
	layer->set_anchor(SIDE_LEFT, 1);
	layer->connect(SceneStringName(value_changed), callable_mp(this, &Texture3DEditor::_layer_changed));

	add_child(layer);

	info = memnew(Label);
	info->add_theme_color_override(SceneStringName(font_color), Color(1, 1, 1));
	info->add_theme_color_override("font_shadow_color", Color(0, 0, 0));