diff options
Diffstat (limited to 'scene/3d/sprite_3d.cpp')
-rw-r--r-- | scene/3d/sprite_3d.cpp | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 85e5ebc475..9764bf77c5 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -34,7 +34,6 @@ #include "scene/scene_string_names.h" Color SpriteBase3D::_get_color_accum() { - if (!color_dirty) return color_accum; @@ -52,7 +51,6 @@ Color SpriteBase3D::_get_color_accum() { } void SpriteBase3D::_propagate_color_changed() { - if (color_dirty) return; @@ -60,15 +58,12 @@ void SpriteBase3D::_propagate_color_changed() { _queue_update(); for (List<SpriteBase3D *>::Element *E = children.front(); E; E = E->next()) { - E->get()->_propagate_color_changed(); } } void SpriteBase3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (!pending_update) _im_update(); @@ -79,9 +74,7 @@ void SpriteBase3D::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - if (parent_sprite) { - parent_sprite->children.erase(pI); pI = nullptr; parent_sprite = nullptr; @@ -90,98 +83,80 @@ void SpriteBase3D::_notification(int p_what) { } void SpriteBase3D::set_centered(bool p_center) { - centered = p_center; _queue_update(); } bool SpriteBase3D::is_centered() const { - return centered; } void SpriteBase3D::set_offset(const Point2 &p_offset) { - offset = p_offset; _queue_update(); } Point2 SpriteBase3D::get_offset() const { - return offset; } void SpriteBase3D::set_flip_h(bool p_flip) { - hflip = p_flip; _queue_update(); } bool SpriteBase3D::is_flipped_h() const { - return hflip; } void SpriteBase3D::set_flip_v(bool p_flip) { - vflip = p_flip; _queue_update(); } bool SpriteBase3D::is_flipped_v() const { - return vflip; } void SpriteBase3D::set_modulate(const Color &p_color) { - modulate = p_color; _propagate_color_changed(); _queue_update(); } Color SpriteBase3D::get_modulate() const { - return modulate; } void SpriteBase3D::set_pixel_size(float p_amount) { - pixel_size = p_amount; _queue_update(); } float SpriteBase3D::get_pixel_size() const { - return pixel_size; } void SpriteBase3D::set_opacity(float p_amount) { - opacity = p_amount; _queue_update(); } float SpriteBase3D::get_opacity() const { - return opacity; } void SpriteBase3D::set_axis(Vector3::Axis p_axis) { - ERR_FAIL_INDEX(p_axis, 3); axis = p_axis; _queue_update(); } Vector3::Axis SpriteBase3D::get_axis() const { - return axis; } void SpriteBase3D::_im_update() { - _draw(); pending_update = false; } void SpriteBase3D::_queue_update() { - if (pending_update) return; @@ -193,11 +168,9 @@ void SpriteBase3D::_queue_update() { } AABB SpriteBase3D::get_aabb() const { - return aabb; } Vector<Face3> SpriteBase3D::get_faces(uint32_t p_usage_flags) const { - return Vector<Face3>(); } @@ -260,7 +233,6 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const { } void SpriteBase3D::set_draw_flag(DrawFlags p_flag, bool p_enable) { - ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags[p_flag] = p_enable; _queue_update(); @@ -272,31 +244,26 @@ bool SpriteBase3D::get_draw_flag(DrawFlags p_flag) const { } void SpriteBase3D::set_alpha_cut_mode(AlphaCutMode p_mode) { - ERR_FAIL_INDEX(p_mode, 3); alpha_cut = p_mode; _queue_update(); } SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const { - return alpha_cut; } void SpriteBase3D::set_billboard_mode(StandardMaterial3D::BillboardMode p_mode) { - ERR_FAIL_INDEX(p_mode, 3); billboard_mode = p_mode; _queue_update(); } StandardMaterial3D::BillboardMode SpriteBase3D::get_billboard_mode() const { - return billboard_mode; } void SpriteBase3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_centered", "centered"), &SpriteBase3D::set_centered); ClassDB::bind_method(D_METHOD("is_centered"), &SpriteBase3D::is_centered); @@ -359,7 +326,6 @@ void SpriteBase3D::_bind_methods() { } SpriteBase3D::SpriteBase3D() { - color_dirty = true; centered = true; hflip = false; @@ -382,14 +348,12 @@ SpriteBase3D::SpriteBase3D() { } SpriteBase3D::~SpriteBase3D() { - RenderingServer::get_singleton()->free(immediate); } /////////////////////////////////////////// void Sprite3D::_draw() { - RID immediate = get_immediate(); RS::get_singleton()->immediate_clear(immediate); @@ -458,7 +422,6 @@ void Sprite3D::_draw() { SWAP(uvs[2], uvs[3]); } if (is_flipped_v()) { - SWAP(uvs[0], uvs[3]); SWAP(uvs[1], uvs[2]); } @@ -499,7 +462,6 @@ void Sprite3D::_draw() { AABB aabb; for (int i = 0; i < 6; i++) { - static const int index[6] = { 0, 1, 2, 0, 2, 3 }; RS::get_singleton()->immediate_normal(immediate, normal); @@ -527,7 +489,6 @@ void Sprite3D::_texture_changed() { } void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) { - if (p_texture == texture) return; if (texture.is_valid()) { @@ -541,12 +502,10 @@ void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) { } Ref<Texture2D> Sprite3D::get_texture() const { - return texture; } void Sprite3D::set_region(bool p_region) { - if (p_region == region) return; @@ -555,12 +514,10 @@ void Sprite3D::set_region(bool p_region) { } bool Sprite3D::is_region() const { - return region; } void Sprite3D::set_region_rect(const Rect2 &p_region_rect) { - bool changed = region_rect != p_region_rect; region_rect = p_region_rect; if (region && changed) { @@ -569,12 +526,10 @@ void Sprite3D::set_region_rect(const Rect2 &p_region_rect) { } Rect2 Sprite3D::get_region_rect() const { - return region_rect; } void Sprite3D::set_frame(int p_frame) { - ERR_FAIL_INDEX(p_frame, int64_t(vframes) * hframes); frame = p_frame; @@ -587,7 +542,6 @@ void Sprite3D::set_frame(int p_frame) { } int Sprite3D::get_frame() const { - return frame; } @@ -603,31 +557,26 @@ Vector2 Sprite3D::get_frame_coords() const { } void Sprite3D::set_vframes(int p_amount) { - ERR_FAIL_COND(p_amount < 1); vframes = p_amount; _queue_update(); _change_notify(); } int Sprite3D::get_vframes() const { - return vframes; } void Sprite3D::set_hframes(int p_amount) { - ERR_FAIL_COND(p_amount < 1); hframes = p_amount; _queue_update(); _change_notify(); } int Sprite3D::get_hframes() const { - return hframes; } Rect2 Sprite3D::get_item_rect() const { - if (texture.is_null()) return Rect2(0, 0, 1, 1); /* @@ -638,7 +587,6 @@ Rect2 Sprite3D::get_item_rect() const { Size2i s; if (region) { - s = region_rect.size; } else { s = texture->get_size(); @@ -656,7 +604,6 @@ Rect2 Sprite3D::get_item_rect() const { } void Sprite3D::_validate_property(PropertyInfo &property) const { - if (property.name == "frame") { property.hint = PROPERTY_HINT_RANGE; property.hint_string = "0," + itos(vframes * hframes - 1) + ",1"; @@ -669,7 +616,6 @@ void Sprite3D::_validate_property(PropertyInfo &property) const { } void Sprite3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite3D::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &Sprite3D::get_texture); @@ -705,7 +651,6 @@ void Sprite3D::_bind_methods() { } Sprite3D::Sprite3D() { - region = false; frame = 0; vframes = 1; @@ -715,7 +660,6 @@ Sprite3D::Sprite3D() { //////////////////////////////////////// void AnimatedSprite3D::_draw() { - RID immediate = get_immediate(); RS::get_singleton()->immediate_clear(immediate); @@ -792,7 +736,6 @@ void AnimatedSprite3D::_draw() { SWAP(uvs[2], uvs[3]); } if (is_flipped_v()) { - SWAP(uvs[0], uvs[3]); SWAP(uvs[1], uvs[2]); } @@ -834,7 +777,6 @@ void AnimatedSprite3D::_draw() { AABB aabb; for (int i = 0; i < 6; i++) { - static const int indices[6] = { 0, 1, 2, 0, 2, 3 @@ -861,11 +803,9 @@ void AnimatedSprite3D::_draw() { } void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { - if (!frames.is_valid()) return; if (property.name == "animation") { - property.hint = PROPERTY_HINT_ENUM; List<StringName> names; frames->get_animation_list(&names); @@ -903,10 +843,8 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { } void AnimatedSprite3D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_INTERNAL_PROCESS: { - if (frames.is_null()) return; if (!frames->has_animation(animation)) @@ -921,9 +859,7 @@ void AnimatedSprite3D::_notification(int p_what) { float remaining = get_process_delta_time(); while (remaining) { - if (timeout <= 0) { - timeout = 1.0 / speed; int fc = frames->get_frame_count(animation); @@ -950,7 +886,6 @@ void AnimatedSprite3D::_notification(int p_what) { } void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) { - if (frames.is_valid()) frames->disconnect("changed", callable_mp(this, &AnimatedSprite3D::_res_changed)); frames = p_frames; @@ -970,12 +905,10 @@ void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) { } Ref<SpriteFrames> AnimatedSprite3D::get_sprite_frames() const { - return frames; } void AnimatedSprite3D::set_frame(int p_frame) { - if (!frames.is_valid()) { return; } @@ -999,12 +932,10 @@ void AnimatedSprite3D::set_frame(int p_frame) { emit_signal(SceneStringNames::get_singleton()->frame_changed); } int AnimatedSprite3D::get_frame() const { - return frame; } Rect2 AnimatedSprite3D::get_item_rect() const { - if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) { return Rect2(0, 0, 1, 1); } @@ -1027,7 +958,6 @@ Rect2 AnimatedSprite3D::get_item_rect() const { } void AnimatedSprite3D::_res_changed() { - set_frame(frame); _change_notify("frame"); _change_notify("animation"); @@ -1035,7 +965,6 @@ void AnimatedSprite3D::_res_changed() { } void AnimatedSprite3D::_set_playing(bool p_playing) { - if (playing == p_playing) return; playing = p_playing; @@ -1044,29 +973,24 @@ void AnimatedSprite3D::_set_playing(bool p_playing) { } bool AnimatedSprite3D::_is_playing() const { - return playing; } void AnimatedSprite3D::play(const StringName &p_animation) { - if (p_animation) set_animation(p_animation); _set_playing(true); } void AnimatedSprite3D::stop() { - _set_playing(false); } bool AnimatedSprite3D::is_playing() const { - return is_processing(); } void AnimatedSprite3D::_reset_timeout() { - if (!playing) return; @@ -1083,7 +1007,6 @@ void AnimatedSprite3D::_reset_timeout() { } void AnimatedSprite3D::set_animation(const StringName &p_animation) { - if (animation == p_animation) return; @@ -1094,12 +1017,10 @@ void AnimatedSprite3D::set_animation(const StringName &p_animation) { _queue_update(); } StringName AnimatedSprite3D::get_animation() const { - return animation; } String AnimatedSprite3D::get_configuration_warning() const { - if (frames.is_null()) { return TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite3D to display frames."); } @@ -1108,7 +1029,6 @@ String AnimatedSprite3D::get_configuration_warning() const { } void AnimatedSprite3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite3D::set_sprite_frames); ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite3D::get_sprite_frames); @@ -1134,7 +1054,6 @@ void AnimatedSprite3D::_bind_methods() { } AnimatedSprite3D::AnimatedSprite3D() { - frame = 0; playing = false; animation = "default"; |