Skip to content

Commit

Permalink
Add half vertex offset to brush editor to center on mouse position
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Nov 19, 2023
1 parent ee5bcda commit e5e0ee2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/terrain_3d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di
for (int x = 0; x < brush_size; x++) {
for (int y = 0; y < brush_size; y++) {
Vector2i brush_offset = Vector2i(x, y) - (Vector2i(brush_size, brush_size) / 2);
Vector3 brush_global_position = Vector3(p_global_position.x + real_t(brush_offset.x), p_global_position.y, p_global_position.z + real_t(brush_offset.y));
Vector3 brush_global_position = Vector3(0.5f, 0.f, 0.5f) +
Vector3(p_global_position.x + real_t(brush_offset.x), p_global_position.y,
p_global_position.z + real_t(brush_offset.y));

// If we're brushing across a region boundary, possibly add a region, and get the other map
int new_region_index = storage->get_region_index(brush_global_position);
Expand Down

0 comments on commit e5e0ee2

Please sign in to comment.