Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from V-Sekai/next
Browse files Browse the repository at this point in the history
Merge latest master.
  • Loading branch information
fire authored Oct 31, 2024
2 parents 9c2bb1f + 743e784 commit 3d924b6
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 320 deletions.
6 changes: 3 additions & 3 deletions godot/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
;
[subrepo]
remote = https://github.com/V-Sekai/godot.git
branch = groups-staging-4.4
commit = 480aa9e00aacd734ce3400a4bb98b855a6f4bcd2
parent = 1da240eaaf73afa2a2878ede5b1c09eebe455e28
branch = groups-4.4
commit = 363bc116f19235362b954433429a79f663dadf35
parent = 9c2bb1f40729f805495598c64e9a3d5c6eafee27
method = merge
cmdver = 0.4.6
3 changes: 2 additions & 1 deletion godot/doc/classes/ImporterMesh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
<param index="2" name="bone_transform_array" type="Array" />
<description>
Generates all lods for this ImporterMesh.
[param normal_merge_angle] and [param normal_split_angle] are in degrees and used in the same way as the importer settings in [code]lods[/code]. As a good default, use 25 and 60 respectively.
[param normal_merge_angle] is in degrees and used in the same way as the importer settings in [code]lods[/code].
[param normal_split_angle] is not used and only remains for compatibility with older versions of the API.
The number of generated lods can be accessed using [method get_surface_lod_count], and each LOD is available in [method get_surface_lod_size] and [method get_surface_lod_indices].
[param bone_transform_array] is an [Array] which can be either empty or contain [Transform3D]s which, for each of the mesh's bone IDs, will apply mesh skinning when generating the LOD mesh variations. This is usually used to account for discrepancies in scale between the mesh itself and its skinning data.
</description>
Expand Down
2 changes: 1 addition & 1 deletion godot/editor/import/3d/resource_importer_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,

if (p_generate_lods) {
// Use normal merge/split angles that match the defaults used for 3D scene importing.
mesh->generate_lods(60.0f, 25.0f, {});
mesh->generate_lods(60.0f, {});
}

if (p_generate_shadow_mesh) {
Expand Down
14 changes: 1 addition & 13 deletions godot/editor/import/3d/resource_importer_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2043,9 +2043,7 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/shadow_meshes", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/lightmap_uv", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/lods", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "lods/normal_split_angle", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), 25.0f));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "lods/normal_merge_angle", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), 60.0f));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "lods/raycast_normals", PROPERTY_HINT_NONE, ""), false));
} break;
case INTERNAL_IMPORT_CATEGORY_MATERIAL: {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "use_external/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
Expand Down Expand Up @@ -2475,9 +2473,7 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_
//do mesh processing

bool generate_lods = p_generate_lods;
float split_angle = 25.0f;
float merge_angle = 60.0f;
bool raycast_normals = false;
bool create_shadow_meshes = p_create_shadow_meshes;
bool bake_lightmaps = p_light_bake_mode == LIGHT_BAKE_STATIC_LIGHTMAPS;
String save_to_file;
Expand Down Expand Up @@ -2524,18 +2520,10 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_
}
}

if (mesh_settings.has("lods/normal_split_angle")) {
split_angle = mesh_settings["lods/normal_split_angle"];
}

if (mesh_settings.has("lods/normal_merge_angle")) {
merge_angle = mesh_settings["lods/normal_merge_angle"];
}

if (mesh_settings.has("lods/raycast_normals")) {
raycast_normals = mesh_settings["lods/raycast_normals"];
}

if (bool(mesh_settings.get("save_to_file/enabled", false))) {
save_to_file = mesh_settings.get("save_to_file/path", String());
if (!save_to_file.is_resource_file()) {
Expand Down Expand Up @@ -2584,7 +2572,7 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_

if (generate_lods) {
Array skin_pose_transform_array = _get_skinned_pose_transforms(src_mesh_node);
src_mesh_node->get_mesh()->generate_lods(merge_angle, split_angle, skin_pose_transform_array, raycast_normals);
src_mesh_node->get_mesh()->generate_lods(merge_angle, skin_pose_transform_array);
}

if (create_shadow_meshes) {
Expand Down
23 changes: 18 additions & 5 deletions godot/editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p
vbox->add_child(offset);

VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview);
port_preview->setup(visual_shader, editor->preview_material, visual_shader->get_shader_type(), p_node_id, p_port_id, p_is_valid);
port_preview->setup(visual_shader, editor->preview_material, visual_shader->get_shader_type(), links[p_node_id].output_ports[p_port_id].type == VisualShaderNode::PORT_TYPE_VECTOR_4D, p_node_id, p_port_id, p_is_valid);
port_preview->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
vbox->add_child(port_preview);
link.preview_visible = true;
Expand Down Expand Up @@ -554,8 +554,8 @@ void VisualShaderGraphPlugin::register_link(VisualShader::Type p_type, int p_id,
links.insert(p_id, { p_type, p_visual_node, p_graph_element, p_visual_node->get_output_port_for_preview() != -1, -1, HashMap<int, InputPort>(), HashMap<int, Port>(), nullptr, nullptr, nullptr, { nullptr, nullptr, nullptr } });
}

void VisualShaderGraphPlugin::register_output_port(int p_node_id, int p_port, TextureButton *p_button) {
links[p_node_id].output_ports.insert(p_port, { p_button });
void VisualShaderGraphPlugin::register_output_port(int p_node_id, int p_port, VisualShaderNode::PortType p_port_type, TextureButton *p_button) {
links[p_node_id].output_ports.insert(p_port, { p_port_type, p_button });
}

void VisualShaderGraphPlugin::register_parameter_name(int p_node_id, LineEdit *p_parameter_name) {
Expand Down Expand Up @@ -1220,7 +1220,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
preview->set_texture_pressed(editor->get_editor_theme_icon(SNAME("GuiVisibilityVisible")));
preview->set_v_size_flags(Control::SIZE_SHRINK_CENTER);

register_output_port(p_id, j, preview);
register_output_port(p_id, j, port_right, preview);

preview->connect(SceneStringName(pressed), callable_mp(editor, &VisualShaderEditor::_preview_select_port).bind(p_id, j), CONNECT_DEFERRED);
hb->add_child(preview);
Expand Down Expand Up @@ -8031,7 +8031,15 @@ void VisualShaderNodePortPreview::_shader_changed() {
set_material(mat);
}

void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, Ref<ShaderMaterial> &p_preview_material, VisualShader::Type p_type, int p_node, int p_port, bool p_is_valid) {
void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, Ref<ShaderMaterial> &p_preview_material, VisualShader::Type p_type, bool p_has_transparency, int p_node, int p_port, bool p_is_valid) {
if (p_has_transparency) {
checkerboard = memnew(TextureRect);
checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE);
checkerboard->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
checkerboard->set_draw_behind_parent(true);
add_child(checkerboard);
}

shader = p_shader;
shader->connect_changed(callable_mp(this, &VisualShaderNodePortPreview::_shader_changed), CONNECT_DEFERRED);
preview_mat = p_preview_material;
Expand All @@ -8050,6 +8058,11 @@ Size2 VisualShaderNodePortPreview::get_minimum_size() const {

void VisualShaderNodePortPreview::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
if (checkerboard != nullptr) {
checkerboard->set_texture(get_theme_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
}
} break;
case NOTIFICATION_DRAW: {
Vector<Vector2> points = {
Vector2(),
Expand Down
6 changes: 4 additions & 2 deletions godot/editor/plugins/visual_shader_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class VisualShaderGraphPlugin : public RefCounted {
};

struct Port {
VisualShaderNode::PortType type = VisualShaderNode::PORT_TYPE_SCALAR;
TextureButton *preview_button = nullptr;
};

Expand Down Expand Up @@ -141,7 +142,7 @@ class VisualShaderGraphPlugin : public RefCounted {
void register_shader(VisualShader *p_visual_shader);
void set_connections(const List<VisualShader::Connection> &p_connections);
void register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphElement *p_graph_element);
void register_output_port(int p_id, int p_port, TextureButton *p_button);
void register_output_port(int p_id, int p_port, VisualShaderNode::PortType p_port_type, TextureButton *p_button);
void register_parameter_name(int p_id, LineEdit *p_parameter_name);
void register_default_input_button(int p_node_id, int p_port_id, Button *p_button);
void register_expression_edit(int p_node_id, CodeEdit *p_expression_edit);
Expand Down Expand Up @@ -680,6 +681,7 @@ class EditorInspectorVisualShaderModePlugin : public EditorInspectorPlugin {

class VisualShaderNodePortPreview : public Control {
GDCLASS(VisualShaderNodePortPreview, Control);
TextureRect *checkerboard = nullptr;
Ref<VisualShader> shader;
Ref<ShaderMaterial> preview_mat;
VisualShader::Type type = VisualShader::Type::TYPE_MAX;
Expand All @@ -692,7 +694,7 @@ class VisualShaderNodePortPreview : public Control {

public:
virtual Size2 get_minimum_size() const override;
void setup(const Ref<VisualShader> &p_shader, Ref<ShaderMaterial> &p_preview_material, VisualShader::Type p_type, int p_node, int p_port, bool p_is_valid);
void setup(const Ref<VisualShader> &p_shader, Ref<ShaderMaterial> &p_preview_material, VisualShader::Type p_type, bool p_has_transparency, int p_node, int p_port, bool p_is_valid);
};

class VisualShaderConversionPlugin : public EditorResourceConversionPlugin {
Expand Down
Loading

0 comments on commit 3d924b6

Please sign in to comment.