Skip to content

Commit

Permalink
Rename index to texture_id
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Nov 11, 2023
1 parent f93cab8 commit d6bbdb8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
8 changes: 4 additions & 4 deletions project/addons/terrain_3d/editor/components/ui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ func _on_setting_changed() -> void:
brush_data = {
"size": int(toolbar_settings.get_setting("size")),
"opacity": toolbar_settings.get_setting("opacity") / 100.0,
"height": toolbar_settings.get_setting("height"),
"color": toolbar_settings.get_setting("color"),
"roughness": toolbar_settings.get_setting("roughness"),
"gamma": toolbar_settings.get_setting("gamma"),
"height": toolbar_settings.get_setting("height"),
"jitter": toolbar_settings.get_setting("jitter"),
"texture_index": plugin.texture_dock.get_selected_index(),
"automatic_regions": toolbar_settings.get_setting("automatic_regions"),
"align_with_view": toolbar_settings.get_setting("align_with_view"),
"show_cursor_while_painting": toolbar_settings.get_setting("show_cursor_while_painting"),
"index": plugin.texture_dock.get_selected_index(),
"gamma": toolbar_settings.get_setting("gamma"),
"jitter": toolbar_settings.get_setting("jitter"),
}
var brush_imgs: Array = toolbar_settings.get_setting("brush")
brush_data["image"] = brush_imgs[0]
Expand Down
24 changes: 13 additions & 11 deletions src/terrain_3d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ void Terrain3DEditor::Brush::set_data(Dictionary p_data) {
for (int i = 0; i < ks.size(); i++) {
LOG(DEBUG, ks[i], ": ", p_data[ks[i]]);
}
_size = p_data["size"];
_index = p_data["index"];
_opacity = p_data["opacity"];
_height = p_data["height"];
_color = p_data["color"];
_roughness = p_data["roughness"];
_gamma = p_data["gamma"];
_jitter = p_data["jitter"];
_texture = p_data["texture"];
_image = p_data["image"];
if (_image.is_valid()) {
_img_size = Vector2(_image->get_size());
} else {
_img_size = Vector2(0, 0);
}
_align_to_view = p_data["align_with_view"];
_texture = p_data["texture"];

_size = p_data["size"];
_opacity = p_data["opacity"];
_height = p_data["height"];
_color = p_data["color"];
_roughness = p_data["roughness"];
_texture_index = p_data["texture_index"];

_auto_regions = p_data["automatic_regions"];
_align_to_view = p_data["align_with_view"];
_gamma = p_data["gamma"];
_jitter = p_data["jitter"];
}

///////////////////////////
Expand Down Expand Up @@ -104,7 +106,7 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di

Ref<Image> map = storage->get_map_region(map_type, region_index);
int brush_size = _brush.get_size();
int index = _brush.get_index();
int texture_id = _brush.get_texture_index();
Vector2 img_size = _brush.get_image_size();
real_t opacity = _brush.get_opacity();
real_t height = _brush.get_height();
Expand Down
27 changes: 16 additions & 11 deletions src/terrain_3d_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,36 +57,41 @@ class Terrain3DEditor : public Object {

class Brush {
private:
Ref<ImageTexture> _texture;
Ref<Image> _image;
Vector2 _img_size;
Ref<ImageTexture> _texture;

int _size = 0;
int _index = 0;
real_t _opacity = 0.0;
real_t _height = 0.0;
Color _color = COLOR_ROUGHNESS;
real_t _roughness = 0.5;
real_t _jitter = 0.0;
real_t _gamma = 1.0;
bool _align_to_view = false;
int _texture_index = 0;

bool _auto_regions = false;
bool _align_to_view = false;
real_t _gamma = 1.0;
real_t _jitter = 0.0;

public:
void set_data(Dictionary p_data);
real_t get_alpha(Vector2i p_position) { return _image->get_pixelv(p_position).r; }

Ref<ImageTexture> get_texture() const { return _texture; }
Ref<Image> get_image() const { return _image; }
Vector2 get_image_size() const { return _img_size; }
void set_data(Dictionary p_data);
real_t get_alpha(Vector2i p_position) { return _image->get_pixelv(p_position).r; }

int get_size() const { return _size; }
int get_index() const { return _index; }
real_t get_opacity() const { return _opacity; }
real_t get_height() const { return _height; }
Color get_color() const { return _color; }
real_t get_roughness() const { return _roughness; }
real_t get_jitter() const { return _jitter; }
real_t get_gamma() const { return _gamma; }
bool is_aligned_to_view() const { return _align_to_view; }
int get_texture_index() const { return _texture_index; }

bool auto_regions_enabled() const { return _auto_regions; }
bool is_aligned_to_view() const { return _align_to_view; }
real_t get_gamma() const { return _gamma; }
real_t get_jitter() const { return _jitter; }
};

// Object references
Expand Down
2 changes: 1 addition & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
///////////////////////////

// Given a float and a 0-1 range array like { 0.0f, .125f, .25f, .334f, .5f, .667f, .8f, 1.0f }
// This function returns the closest index
// This function returns the closest index of a C array of floats
int Util::closest_index(float value, const float *p_array, int size) {
int index = size - 1;
for (int k = 0; k < size; k++) {
Expand Down

0 comments on commit d6bbdb8

Please sign in to comment.