Merge pull request #12684 from mrcdk/atlastextures_fix
Added filter_clip to AtlasTexture
This commit is contained in:
commit
faf21d895e
2 changed files with 24 additions and 3 deletions
|
@ -866,6 +866,18 @@ Rect2 AtlasTexture::get_margin() const {
|
|||
return margin;
|
||||
}
|
||||
|
||||
void AtlasTexture::set_filter_clip(const bool p_enable) {
|
||||
|
||||
filter_clip = p_enable;
|
||||
emit_changed();
|
||||
_change_notify("filter_clip");
|
||||
}
|
||||
|
||||
bool AtlasTexture::has_filter_clip() const {
|
||||
|
||||
return filter_clip;
|
||||
}
|
||||
|
||||
void AtlasTexture::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_atlas", "atlas"), &AtlasTexture::set_atlas);
|
||||
|
@ -877,9 +889,13 @@ void AtlasTexture::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_margin", "margin"), &AtlasTexture::set_margin);
|
||||
ClassDB::bind_method(D_METHOD("get_margin"), &AtlasTexture::get_margin);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_filter_clip", "enable"), &AtlasTexture::set_filter_clip);
|
||||
ClassDB::bind_method(D_METHOD("has_filter_clip"), &AtlasTexture::has_filter_clip);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_atlas", "get_atlas");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region"), "set_region", "get_region");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "margin"), "set_margin", "get_margin");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_clip"), "set_filter_clip", "has_filter_clip");
|
||||
}
|
||||
|
||||
void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
@ -898,7 +914,7 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
|
|||
}
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid);
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, filter_clip);
|
||||
}
|
||||
|
||||
void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
@ -920,7 +936,7 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
|
|||
Rect2 dr(p_rect.position + margin.position * scale, rc.size * scale);
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid);
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, filter_clip);
|
||||
}
|
||||
void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) const {
|
||||
|
||||
|
@ -951,7 +967,7 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
|
|||
Rect2 dr(p_rect.position + ofs * scale, src_c.size * scale);
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, p_clip_uv);
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, filter_clip);
|
||||
}
|
||||
|
||||
bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
|
||||
|
@ -987,6 +1003,7 @@ bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect,
|
|||
}
|
||||
|
||||
AtlasTexture::AtlasTexture() {
|
||||
filter_clip = false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
|
|
|
@ -237,6 +237,7 @@ protected:
|
|||
Ref<Texture> atlas;
|
||||
Rect2 region;
|
||||
Rect2 margin;
|
||||
bool filter_clip;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
|
@ -259,6 +260,9 @@ public:
|
|||
void set_margin(const Rect2 &p_margin);
|
||||
Rect2 get_margin() const;
|
||||
|
||||
void set_filter_clip(const bool p_enable);
|
||||
bool has_filter_clip() const;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const;
|
||||
|
|
Loading…
Reference in a new issue