summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/audio_stream_sample.cpp5
-rw-r--r--scene/resources/environment.cpp4
-rw-r--r--scene/resources/material.cpp2
-rw-r--r--scene/resources/material.h6
-rw-r--r--scene/resources/style_box.cpp27
-rw-r--r--scene/resources/style_box.h3
6 files changed, 41 insertions, 6 deletions
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index 5b61654c5d..286f9e37cd 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -95,8 +95,8 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds
// this function will be compiled branchless by any decent compiler
int32_t final, final_r, next, next_r;
- while (amount--) {
-
+ while (amount) {
+ amount--;
int64_t pos = offset >> MIX_FRAC_BITS;
if (is_stereo && !is_ima_adpcm)
pos <<= 1;
@@ -444,6 +444,7 @@ int AudioStreamSample::get_loop_end() const {
void AudioStreamSample::set_mix_rate(int p_hz) {
+ ERR_FAIL_COND(p_hz == 0);
mix_rate = p_hz;
}
int AudioStreamSample::get_mix_rate() const {
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index bc96b5e9f3..ddf97f48d1 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -978,7 +978,9 @@ void Environment::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "background_sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_sky_custom_fov", PROPERTY_HINT_RANGE, "0,180,0.1"), "set_sky_custom_fov", "get_sky_custom_fov");
ADD_PROPERTY(PropertyInfo(Variant::BASIS, "background_sky_orientation"), "set_sky_orientation", "get_sky_orientation");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "background_sky_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_sky_rotation", "get_sky_rotation");
+ // Only display rotation in degrees in the inspector (like in Spatial).
+ // This avoids displaying the same information twice.
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "background_sky_rotation", PROPERTY_HINT_NONE, "", 0), "set_sky_rotation", "get_sky_rotation");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "background_sky_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_sky_rotation_degrees", "get_sky_rotation_degrees");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_bg_color", "get_bg_color");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_bg_energy", "get_bg_energy");
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index fab0aace14..41bf7f4bf0 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -1405,8 +1405,8 @@ void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> &p_te
textures[p_param] = p_texture;
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
VS::get_singleton()->material_set_param(_get_material(), shader_names->texture_names[p_param], rid);
- _queue_shader_change();
_change_notify();
+ _queue_shader_change();
}
Ref<Texture> SpatialMaterial::get_texture(TextureParam p_param) const {
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 2423d6d48b..11f8f20cf3 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -252,7 +252,7 @@ private:
uint64_t flags : 18;
uint64_t detail_blend_mode : 2;
uint64_t diffuse_mode : 3;
- uint64_t specular_mode : 2;
+ uint64_t specular_mode : 3;
uint64_t invalid_key : 1;
uint64_t deep_parallax : 1;
uint64_t billboard_mode : 2;
@@ -260,6 +260,8 @@ private:
uint64_t proximity_fade : 1;
uint64_t distance_fade : 2;
uint64_t emission_op : 1;
+ uint64_t texture_metallic : 1;
+ uint64_t texture_roughness : 1;
};
uint64_t key;
@@ -305,6 +307,8 @@ private:
mk.proximity_fade = proximity_fade_enabled;
mk.distance_fade = distance_fade;
mk.emission_op = emission_op;
+ mk.texture_metallic = textures[TEXTURE_METALLIC].is_valid() ? 1 : 0;
+ mk.texture_roughness = textures[TEXTURE_ROUGHNESS].is_valid() ? 1 : 0;
return mk;
}
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 9ee7c2936e..f26b57b572 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -81,6 +81,10 @@ Size2 StyleBox::get_center_size() const {
return Size2();
}
+Rect2 StyleBox::get_draw_rect(const Rect2 &p_rect) const {
+ return p_rect;
+}
+
void StyleBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("test_mask", "point", "rect"), &StyleBox::test_mask);
@@ -175,6 +179,10 @@ float StyleBoxTexture::get_style_margin(Margin p_margin) const {
return margin[p_margin];
}
+Rect2 StyleBoxTexture::get_draw_rect(const Rect2 &p_rect) const {
+ return p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]);
+}
+
void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const {
if (texture.is_null())
return;
@@ -685,6 +693,19 @@ inline void adapt_values(int p_index_a, int p_index_b, int *adapted_values, cons
adapted_values[p_index_a] = MIN(p_max_a, adapted_values[p_index_a]);
adapted_values[p_index_b] = MIN(p_max_b, adapted_values[p_index_b]);
}
+
+Rect2 StyleBoxFlat::get_draw_rect(const Rect2 &p_rect) const {
+ Rect2 draw_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]);
+
+ if (shadow_size > 0) {
+ Rect2 shadow_rect = draw_rect.grow(shadow_size);
+ shadow_rect.position += shadow_offset;
+ draw_rect = draw_rect.merge(shadow_rect);
+ }
+
+ return draw_rect;
+}
+
void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
//PREPARATIONS
@@ -694,6 +715,11 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
return;
}
+ Rect2 style_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]);
+ if (Math::is_zero_approx(style_rect.size.width) || Math::is_zero_approx(style_rect.size.height)) {
+ return;
+ }
+
bool rounded_corners = (corner_radius[0] > 0) || (corner_radius[1] > 0) || (corner_radius[2] > 0) || (corner_radius[3] > 0);
bool aa_on = rounded_corners && anti_aliased;
@@ -701,7 +727,6 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
bool blend_on = blend_border && draw_border;
- Rect2 style_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]);
Rect2 border_style_rect = style_rect;
if (aa_on && !blend_on) {
float aa_size_grow = 0.5 * ((aa_size + 1) / 2);
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index d02e107480..ec07b5e885 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -56,6 +56,7 @@ public:
float get_margin(Margin p_margin) const;
virtual Size2 get_center_size() const;
+ virtual Rect2 get_draw_rect(const Rect2 &p_rect) const;
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const = 0;
CanvasItem *get_current_item_drawn() const;
@@ -133,6 +134,7 @@ public:
void set_modulate(const Color &p_modulate);
Color get_modulate() const;
+ virtual Rect2 get_draw_rect(const Rect2 &p_rect) const;
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
StyleBoxTexture();
@@ -227,6 +229,7 @@ public:
virtual Size2 get_center_size() const;
+ virtual Rect2 get_draw_rect(const Rect2 &p_rect) const;
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
StyleBoxFlat();