summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/animation.cpp22
-rw-r--r--scene/resources/audio_stream_sample.cpp34
-rw-r--r--scene/resources/audio_stream_sample.h4
-rw-r--r--scene/resources/color_ramp.cpp4
-rw-r--r--scene/resources/default_theme/default_theme.cpp6
-rw-r--r--scene/resources/mesh.cpp2
-rw-r--r--scene/resources/primitive_meshes.cpp16
-rw-r--r--scene/resources/scene_format_text.cpp2
-rw-r--r--scene/resources/scene_format_text.h4
-rw-r--r--scene/resources/style_box.cpp4
-rw-r--r--scene/resources/texture.cpp2
11 files changed, 54 insertions, 46 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 6e58bc88d7..7a1fffaa26 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -1603,19 +1603,19 @@ float Animation::get_step() const {
return step;
}
-void Animation::copy_track(int src_track, Ref<Animation> p_to_animation) {
+void Animation::copy_track(int p_track, Ref<Animation> p_to_animation) {
ERR_FAIL_COND(p_to_animation.is_null());
- ERR_FAIL_INDEX(src_track, get_track_count());
+ ERR_FAIL_INDEX(p_track, get_track_count());
int dst_track = p_to_animation->get_track_count();
- p_to_animation->add_track(track_get_type(src_track));
-
- p_to_animation->track_set_path(dst_track, track_get_path(src_track));
- p_to_animation->track_set_imported(dst_track, track_is_imported(src_track));
- p_to_animation->track_set_enabled(dst_track, track_is_enabled(src_track));
- p_to_animation->track_set_interpolation_type(dst_track, track_get_interpolation_type(src_track));
- p_to_animation->track_set_interpolation_loop_wrap(dst_track, track_get_interpolation_loop_wrap(src_track));
- for (int i = 0; i < track_get_key_count(src_track); i++) {
- p_to_animation->track_insert_key(dst_track, track_get_key_time(src_track, i), track_get_key_value(src_track, i), track_get_key_transition(src_track, i));
+ p_to_animation->add_track(track_get_type(p_track));
+
+ p_to_animation->track_set_path(dst_track, track_get_path(p_track));
+ p_to_animation->track_set_imported(dst_track, track_is_imported(p_track));
+ p_to_animation->track_set_enabled(dst_track, track_is_enabled(p_track));
+ p_to_animation->track_set_interpolation_type(dst_track, track_get_interpolation_type(p_track));
+ p_to_animation->track_set_interpolation_loop_wrap(dst_track, track_get_interpolation_loop_wrap(p_track));
+ for (int i = 0; i < track_get_key_count(p_track); i++) {
+ p_to_animation->track_insert_key(dst_track, track_get_key_time(p_track, i), track_get_key_value(p_track, i), track_get_key_transition(p_track, i));
}
}
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index 93ed700482..b77143cd9d 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -77,7 +77,7 @@ void AudioStreamPlaybackSample::seek(float p_time) {
if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM)
return; //no seeking in ima-adpcm
- float max = get_length();
+ float max = base->get_length();
if (p_time < 0) {
p_time = 0;
} else if (p_time >= max) {
@@ -390,22 +390,6 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
}
}
-float AudioStreamPlaybackSample::get_length() const {
-
- int len = base->data_bytes;
- switch (base->format) {
- case AudioStreamSample::FORMAT_8_BITS: len /= 1; break;
- case AudioStreamSample::FORMAT_16_BITS: len /= 2; break;
- case AudioStreamSample::FORMAT_IMA_ADPCM: len *= 2; break;
- }
-
- if (base->stereo) {
- len /= 2;
- }
-
- return float(len) / base->mix_rate;
-}
-
AudioStreamPlaybackSample::AudioStreamPlaybackSample() {
active = false;
@@ -469,6 +453,22 @@ bool AudioStreamSample::is_stereo() const {
return stereo;
}
+float AudioStreamSample::get_length() const {
+
+ int len = data_bytes;
+ switch (format) {
+ case AudioStreamSample::FORMAT_8_BITS: len /= 1; break;
+ case AudioStreamSample::FORMAT_16_BITS: len /= 2; break;
+ case AudioStreamSample::FORMAT_IMA_ADPCM: len *= 2; break;
+ }
+
+ if (stereo) {
+ len /= 2;
+ }
+
+ return float(len) / mix_rate;
+}
+
void AudioStreamSample::set_data(const PoolVector<uint8_t> &p_data) {
AudioServer::get_singleton()->lock();
diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h
index 41754301eb..5fe65c194e 100644
--- a/scene/resources/audio_stream_sample.h
+++ b/scene/resources/audio_stream_sample.h
@@ -77,8 +77,6 @@ public:
virtual void mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames);
- virtual float get_length() const; //if supported, otherwise return 0
-
AudioStreamPlaybackSample();
};
@@ -137,6 +135,8 @@ public:
void set_stereo(bool p_enable);
bool is_stereo() const;
+ virtual float get_length() const; //if supported, otherwise return 0
+
void set_data(const PoolVector<uint8_t> &p_data);
PoolVector<uint8_t> get_data() const;
diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp
index 8c09130873..b2f586d02d 100644
--- a/scene/resources/color_ramp.cpp
+++ b/scene/resources/color_ramp.cpp
@@ -71,8 +71,8 @@ void Gradient::_bind_methods() {
ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_COLORS, "colors"), &Gradient::set_colors);
ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_COLORS), &Gradient::get_colors);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "offsets"), COLOR_RAMP_SET_OFFSETS, COLOR_RAMP_GET_OFFSETS);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "colors"), COLOR_RAMP_SET_COLORS, COLOR_RAMP_GET_COLORS);
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "offsets"), COLOR_RAMP_SET_OFFSETS, COLOR_RAMP_GET_OFFSETS);
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY, "colors"), COLOR_RAMP_SET_COLORS, COLOR_RAMP_GET_COLORS);
}
Vector<float> Gradient::get_offsets() const {
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index a4049e4461..3e244aa8f8 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -448,10 +448,10 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// TextEdit
- theme->set_stylebox("normal", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3));
+ theme->set_stylebox("normal", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3, 0, 0, 0, 0));
theme->set_stylebox("focus", "TextEdit", focus);
- theme->set_stylebox("read_only", "TextEdit", make_stylebox(tree_bg_disabled_png, 4, 4, 4, 4));
- theme->set_stylebox("completion", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3));
+ theme->set_stylebox("read_only", "TextEdit", make_stylebox(tree_bg_disabled_png, 4, 4, 4, 4, 0, 0, 0, 0));
+ theme->set_stylebox("completion", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3, 0, 0, 0, 0));
theme->set_icon("tab", "TextEdit", make_icon(tab_png));
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index d59390e1b8..949ba12a4c 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -1267,6 +1267,8 @@ void ArrayMesh::_bind_methods() {
ClassDB::set_method_flags(get_class_static(), _scs_create("center_geometry"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
ClassDB::bind_method(D_METHOD("regen_normalmaps"), &ArrayMesh::regen_normalmaps);
ClassDB::set_method_flags(get_class_static(), _scs_create("regen_normalmaps"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("lightmap_unwrap"), &ArrayMesh::lightmap_unwrap);
+ ClassDB::set_method_flags(get_class_static(), _scs_create("lightmap_unwrap"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
ClassDB::bind_method(D_METHOD("get_faces"), &ArrayMesh::get_faces);
ClassDB::bind_method(D_METHOD("generate_triangle_mesh"), &ArrayMesh::generate_triangle_mesh);
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 94ce3590d7..94c54c91d3 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -361,8 +361,8 @@ void CapsuleMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CapsuleMesh::set_rings);
ClassDB::bind_method(D_METHOD("get_rings"), &CapsuleMesh::get_rings);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.1,100.0,0.1"), "set_radius", "get_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "mid_height", PROPERTY_HINT_RANGE, "0.1,100.0,0.1"), "set_mid_height", "get_mid_height");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_radius", "get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "mid_height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_mid_height", "get_mid_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1"), "set_rings", "get_rings");
}
@@ -823,9 +823,9 @@ void CylinderMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CylinderMesh::set_rings);
ClassDB::bind_method(D_METHOD("get_rings"), &CylinderMesh::get_rings);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "top_radius", PROPERTY_HINT_RANGE, "0.1,100.0,0.1"), "set_top_radius", "get_top_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "bottom_radius", PROPERTY_HINT_RANGE, "0.1,100.0,0.1"), "set_bottom_radius", "get_bottom_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.1,100.0,0.1"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "top_radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_top_radius", "get_top_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bottom_radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_bottom_radius", "get_bottom_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1"), "set_rings", "get_rings");
}
@@ -1224,7 +1224,7 @@ void PrismMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_subdivide_depth"), &PrismMesh::get_subdivide_depth);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "left_to_right", PROPERTY_HINT_RANGE, "-2.0,2.0,0.1"), "set_left_to_right", "get_left_to_right");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_RANGE, "0.1,100.0,0.1"), "set_size", "get_size");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_width", PROPERTY_HINT_RANGE, "0,100,1"), "set_subdivide_width", "get_subdivide_width");
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_height", PROPERTY_HINT_RANGE, "0,100,1"), "set_subdivide_height", "get_subdivide_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_depth", PROPERTY_HINT_RANGE, "0,100,1"), "set_subdivide_depth", "get_subdivide_depth");
@@ -1441,8 +1441,8 @@ void SphereMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_is_hemisphere", "is_hemisphere"), &SphereMesh::set_is_hemisphere);
ClassDB::bind_method(D_METHOD("get_is_hemisphere"), &SphereMesh::get_is_hemisphere);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.1,100.0,0.1"), "set_radius", "get_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.1,100.0,0.1"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_radius", "get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1"), "set_rings", "get_rings");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_hemisphere"), "set_is_hemisphere", "get_is_hemisphere");
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index 0faa0dc770..91c801c016 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -1312,6 +1312,8 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const
return ria->rename_dependencies(f, p_path, p_map);
}
+ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = NULL;
+
Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path, const String &p_dst_path) {
Error err;
diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h
index c014b9bfae..c28ded3d77 100644
--- a/scene/resources/scene_format_text.h
+++ b/scene/resources/scene_format_text.h
@@ -128,7 +128,9 @@ public:
};
class ResourceFormatLoaderText : public ResourceFormatLoader {
+
public:
+ static ResourceFormatLoaderText *singleton;
virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const;
virtual void get_recognized_extensions(List<String> *p_extensions) const;
@@ -138,6 +140,8 @@ public:
virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map);
static Error convert_file_to_binary(const String &p_src_path, const String &p_dst_path);
+
+ ResourceFormatLoaderText() { singleton = this; }
};
class ResourceFormatSaverTextInstance {
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 6811517ead..de75bb3976 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -651,8 +651,8 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
//adapt borders (prevent weired overlapping/glitchy drawings)
- int width = style_rect.size.width;
- int height = style_rect.size.height;
+ int width = MAX(style_rect.size.width, 0);
+ int height = MAX(style_rect.size.height, 0);
int adapted_border[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX };
adapt_values(MARGIN_TOP, MARGIN_BOTTOM, adapted_border, border_width, height, height, height);
adapt_values(MARGIN_LEFT, MARGIN_RIGHT, adapted_border, border_width, width, width, width);
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 067d123b83..c0f6756fd1 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -76,7 +76,7 @@ void Texture::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_data"), &Texture::get_data);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Ansiotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_flags", "get_flags");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_flags", "get_flags");
BIND_ENUM_CONSTANT(FLAGS_DEFAULT);
BIND_ENUM_CONSTANT(FLAG_MIPMAPS);