Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtarsia committed Jan 20, 2025
1 parent c3aa6f7 commit 47d1503
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/terrain_3d_material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ String Terrain3DMaterial::_inject_editor_code(const String &p_shader) const {

// Insert at the end of the shader, before the end of `fragment(){ }`
// Check for each nested {} pair until the closing } is found.
regex->compile("void\\s+fragment\\s*\\(");
regex->compile("void\\s*fragment\\s*\\(\\s*\\)\\s*{");
match = regex->search(shader);
idx = -1;
if (match.is_valid()) {
int start_idx = shader.find("{", match->get_start());
int start_idx = match->get_end() - 1;
int pair = 0;
for (int i = start_idx; i < shader.length(); i++) {
if (shader[i] == '{') {
Expand Down Expand Up @@ -274,7 +274,7 @@ String Terrain3DMaterial::_inject_editor_code(const String &p_shader) const {
}
for (int i = 0; i < insert_names.size(); i++) {
String insert = _shader_code[insert_names[i]];
shader = shader.insert(idx - 1, "\n" + insert);
shader = shader.insert(idx, "\n" + insert);
idx += insert.length();
}
return shader;
Expand Down

0 comments on commit 47d1503

Please sign in to comment.