diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-09-13 19:30:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-13 19:30:47 +0200 |
commit | 97a2ed6fa6ef49a5249916cd1c8b22bf77e58906 (patch) | |
tree | 7a245e3270a7d988b2b6b31035cdd3bb8e283cfe /editor/plugins | |
parent | fe3bbaa9d075625a31bf3181b7d3f3d92cfa6d09 (diff) | |
parent | f8dad1e61b7df2c8c1d1d2bf0e09294f8b456ac6 (diff) |
Merge pull request #11081 from djrm/pr_better_3d_grid
Better looking spatial editor grid
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 93d12fd3d2..704d474746 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -3696,18 +3696,50 @@ void SpatialEditor::_init_indicators() { origin_colors.push_back(Color(axis.x, axis.y, axis.z)); origin_points.push_back(axis * 4096); origin_points.push_back(axis * -4096); -#define ORIGIN_GRID_SIZE 25 +#define ORIGIN_GRID_SIZE 100 for (int j = -ORIGIN_GRID_SIZE; j <= ORIGIN_GRID_SIZE; j++) { - grid_colors[i].push_back(grid_color); - grid_colors[i].push_back(grid_color); - grid_colors[i].push_back(grid_color); - grid_colors[i].push_back(grid_color); - grid_points[i].push_back(axis_n1 * ORIGIN_GRID_SIZE + axis_n2 * j); - grid_points[i].push_back(-axis_n1 * ORIGIN_GRID_SIZE + axis_n2 * j); - grid_points[i].push_back(axis_n2 * ORIGIN_GRID_SIZE + axis_n1 * j); - grid_points[i].push_back(-axis_n2 * ORIGIN_GRID_SIZE + axis_n1 * j); + for (int k = -ORIGIN_GRID_SIZE; k <= ORIGIN_GRID_SIZE; k++) { + + Vector3 p = axis_n1 * j + axis_n2 * k; + float trans = Math::pow(MAX(0, 1.0 - (Vector2(j, k).length() / ORIGIN_GRID_SIZE)), 2); + + Vector3 pj = axis_n1 * (j + 1) + axis_n2 * k; + float transj = Math::pow(MAX(0, 1.0 - (Vector2(j + 1, k).length() / ORIGIN_GRID_SIZE)), 2); + + Vector3 pk = axis_n1 * j + axis_n2 * (k + 1); + float transk = Math::pow(MAX(0, 1.0 - (Vector2(j, k + 1).length() / ORIGIN_GRID_SIZE)), 2); + + Color trans_color = grid_color; + trans_color.a *= trans; + + Color transk_color = grid_color; + transk_color.a *= transk; + + Color transj_color = grid_color; + transj_color.a *= transj; + + if (j % 10 == 0 || k % 10 == 0) { + trans_color.a *= 2; + } + if ((k + 1) % 10 == 0) { + transk_color.a *= 2; + } + if ((j + 1) % 10 == 0) { + transj_color.a *= 2; + } + + grid_points[i].push_back(p); + grid_points[i].push_back(pk); + grid_colors[i].push_back(trans_color); + grid_colors[i].push_back(transk_color); + + grid_points[i].push_back(p); + grid_points[i].push_back(pj); + grid_colors[i].push_back(trans_color); + grid_colors[i].push_back(transj_color); + } } grid[i] = VisualServer::get_singleton()->mesh_create(); |