summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/audio_stream_player_3d.cpp24
-rw-r--r--scene/animation/tween.cpp127
-rw-r--r--scene/gui/button.cpp2
-rw-r--r--scene/gui/line_edit.cpp8
-rw-r--r--scene/gui/text_edit.cpp16
-rw-r--r--scene/gui/tree.cpp2
-rw-r--r--scene/resources/particles_material.cpp2
7 files changed, 119 insertions, 62 deletions
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 320457a3f2..ecd0c9114e 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -98,11 +98,18 @@ static const Vector3 speaker_directions[7] = {
void AudioStreamPlayer3D::_calc_output_vol(const Vector3 &source_dir, real_t tightness, AudioStreamPlayer3D::Output &output) {
unsigned int speaker_count; // only main speakers (no LFE)
switch (AudioServer::get_singleton()->get_speaker_mode()) {
- default: //fallthrough
- case AudioServer::SPEAKER_MODE_STEREO: speaker_count = 2; break;
- case AudioServer::SPEAKER_SURROUND_31: speaker_count = 3; break;
- case AudioServer::SPEAKER_SURROUND_51: speaker_count = 5; break;
- case AudioServer::SPEAKER_SURROUND_71: speaker_count = 7; break;
+ case AudioServer::SPEAKER_MODE_STEREO:
+ speaker_count = 2;
+ break;
+ case AudioServer::SPEAKER_SURROUND_31:
+ speaker_count = 3;
+ break;
+ case AudioServer::SPEAKER_SURROUND_51:
+ speaker_count = 5;
+ break;
+ case AudioServer::SPEAKER_SURROUND_71:
+ speaker_count = 7;
+ break;
}
Spcap spcap(speaker_count, speaker_directions); //TODO: should only be created/recreated once the speaker mode / speaker positions changes
@@ -113,18 +120,19 @@ void AudioStreamPlayer3D::_calc_output_vol(const Vector3 &source_dir, real_t tig
case AudioServer::SPEAKER_SURROUND_71:
output.vol[3].l = volumes[5]; // side-left
output.vol[3].r = volumes[6]; // side-right
- //fallthrough
+ [[fallthrough]];
case AudioServer::SPEAKER_SURROUND_51:
output.vol[2].l = volumes[3]; // rear-left
output.vol[2].r = volumes[4]; // rear-right
- //fallthrough
+ [[fallthrough]];
case AudioServer::SPEAKER_SURROUND_31:
output.vol[1].r = 1.0; // LFE - always full power
output.vol[1].l = volumes[2]; // center
- //fallthrough
+ [[fallthrough]];
case AudioServer::SPEAKER_MODE_STEREO:
output.vol[0].r = volumes[1]; // front-right
output.vol[0].l = volumes[0]; // front-left
+ break;
}
}
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 161c6d04af..f72d50a1a9 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -67,7 +67,6 @@ void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const
count = 0;
// Add the specified arguments to the command
- // TODO: Make this a switch statement?
if (count > 0)
cmd.arg[0] = p_arg1;
if (count > 1)
@@ -459,6 +458,20 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
result = r;
} break;
+ case Variant::RECT2: {
+ // Get the Rect2 for initial and delta value
+ Rect2 i = initial_val;
+ Rect2 d = delta_val;
+ Rect2 r;
+
+ // Execute the equation for the position and size of Rect2
+ APPLY_EQUATION(position.x);
+ APPLY_EQUATION(position.y);
+ APPLY_EQUATION(size.x);
+ APPLY_EQUATION(size.y);
+ result = r;
+ } break;
+
case Variant::VECTOR3: {
// Get vectors for initial and delta values
Vector3 i = initial_val;
@@ -473,26 +486,6 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
result = r;
} break;
- case Variant::BASIS: {
- // Get the basis for initial and delta values
- Basis i = initial_val;
- Basis d = delta_val;
- Basis r;
-
- // Execute the equation on all the basis and mutate the r basis
- // This uses the custom APPLY_EQUATION macro defined above
- APPLY_EQUATION(elements[0][0]);
- APPLY_EQUATION(elements[0][1]);
- APPLY_EQUATION(elements[0][2]);
- APPLY_EQUATION(elements[1][0]);
- APPLY_EQUATION(elements[1][1]);
- APPLY_EQUATION(elements[1][2]);
- APPLY_EQUATION(elements[2][0]);
- APPLY_EQUATION(elements[2][1]);
- APPLY_EQUATION(elements[2][2]);
- result = r;
- } break;
-
case Variant::TRANSFORM2D: {
// Get the transforms for initial and delta values
Transform2D i = initial_val;
@@ -509,6 +502,7 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
APPLY_EQUATION(elements[2][1]);
result = r;
} break;
+
case Variant::QUAT: {
// Get the quaternian for the initial and delta values
Quat i = initial_val;
@@ -523,6 +517,7 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
APPLY_EQUATION(w);
result = r;
} break;
+
case Variant::AABB: {
// Get the AABB's for the initial and delta values
AABB i = initial_val;
@@ -539,6 +534,27 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
APPLY_EQUATION(size.z);
result = r;
} break;
+
+ case Variant::BASIS: {
+ // Get the basis for initial and delta values
+ Basis i = initial_val;
+ Basis d = delta_val;
+ Basis r;
+
+ // Execute the equation on all the basis and mutate the r basis
+ // This uses the custom APPLY_EQUATION macro defined above
+ APPLY_EQUATION(elements[0][0]);
+ APPLY_EQUATION(elements[0][1]);
+ APPLY_EQUATION(elements[0][2]);
+ APPLY_EQUATION(elements[1][0]);
+ APPLY_EQUATION(elements[1][1]);
+ APPLY_EQUATION(elements[1][2]);
+ APPLY_EQUATION(elements[2][0]);
+ APPLY_EQUATION(elements[2][1]);
+ APPLY_EQUATION(elements[2][2]);
+ result = r;
+ } break;
+
case Variant::TRANSFORM: {
// Get the transforms for the initial and delta values
Transform i = initial_val;
@@ -561,6 +577,7 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
APPLY_EQUATION(origin.z);
result = r;
} break;
+
case Variant::COLOR: {
// Get the Color for initial and delta value
Color i = initial_val;
@@ -575,6 +592,7 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
APPLY_EQUATION(a);
result = r;
} break;
+
default: {
// If unknown, just return the initial value
result = initial_val;
@@ -1129,26 +1147,18 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
delta_val = final_val.operator Vector2() - initial_val.operator Vector2();
break;
+ case Variant::RECT2: {
+ // Build a new Rect2 and use the new position and sizes to make a delta
+ Rect2 i = initial_val;
+ Rect2 f = final_val;
+ delta_val = Rect2(f.position - i.position, f.size - i.size);
+ } break;
+
case Variant::VECTOR3:
// Convert to Vectors and find the delta
delta_val = final_val.operator Vector3() - initial_val.operator Vector3();
break;
- case Variant::BASIS: {
- // Build a new basis which is the delta between the initial and final values
- Basis i = initial_val;
- Basis f = final_val;
- delta_val = Basis(f.elements[0][0] - i.elements[0][0],
- f.elements[0][1] - i.elements[0][1],
- f.elements[0][2] - i.elements[0][2],
- f.elements[1][0] - i.elements[1][0],
- f.elements[1][1] - i.elements[1][1],
- f.elements[1][2] - i.elements[1][2],
- f.elements[2][0] - i.elements[2][0],
- f.elements[2][1] - i.elements[2][1],
- f.elements[2][2] - i.elements[2][2]);
- } break;
-
case Variant::TRANSFORM2D: {
// Build a new transform which is the difference between the initial and final values
Transform2D i = initial_val;
@@ -1175,6 +1185,21 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
delta_val = AABB(f.position - i.position, f.size - i.size);
} break;
+ case Variant::BASIS: {
+ // Build a new basis which is the delta between the initial and final values
+ Basis i = initial_val;
+ Basis f = final_val;
+ delta_val = Basis(f.elements[0][0] - i.elements[0][0],
+ f.elements[0][1] - i.elements[0][1],
+ f.elements[0][2] - i.elements[0][2],
+ f.elements[1][0] - i.elements[1][0],
+ f.elements[1][1] - i.elements[1][1],
+ f.elements[1][2] - i.elements[1][2],
+ f.elements[2][0] - i.elements[2][0],
+ f.elements[2][1] - i.elements[2][1],
+ f.elements[2][2] - i.elements[2][2]);
+ } break;
+
case Variant::TRANSFORM: {
// Build a new transform which is the difference between the initial and final values
Transform i = initial_val;
@@ -1203,10 +1228,34 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
delta_val = Color(f.r - i.r, f.g - i.g, f.b - i.b, f.a - i.a);
} break;
- default:
- // TODO: Should move away from a 'magic string'?
- ERR_PRINT("Invalid param type, except(int/real/vector2/vector/matrix/matrix32/quat/aabb/transform/color)");
+ default: {
+ static Variant::Type supported_types[] = {
+ Variant::BOOL,
+ Variant::INT,
+ Variant::REAL,
+ Variant::VECTOR2,
+ Variant::RECT2,
+ Variant::VECTOR3,
+ Variant::TRANSFORM2D,
+ Variant::QUAT,
+ Variant::AABB,
+ Variant::BASIS,
+ Variant::TRANSFORM,
+ Variant::COLOR,
+ };
+
+ int length = *(&supported_types + 1) - supported_types;
+ String error_msg = "Invalid parameter type. Supported types are: ";
+ for (int i = 0; i < length; i++) {
+ if (i != 0) {
+ error_msg += ", ";
+ }
+ error_msg += Variant::get_type_name(supported_types[i]);
+ }
+ error_msg += ".";
+ ERR_PRINT(error_msg);
return false;
+ }
};
return true;
}
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 04ff11f20c..784d298bff 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -106,7 +106,7 @@ void Button::_notification(int p_what) {
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case DRAW_PRESSED: {
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 86fe6d7630..700eaecf43 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -355,7 +355,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_LEFT: {
@@ -402,7 +402,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_RIGHT: {
@@ -509,7 +509,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_HOME: {
@@ -522,7 +522,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_END: {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 313b82035c..1c8d7c542b 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -3068,7 +3068,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
scancode_handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_LEFT: {
@@ -3144,7 +3144,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
scancode_handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_RIGHT: {
@@ -3205,7 +3205,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
scancode_handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_UP: {
@@ -3258,7 +3258,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
scancode_handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_DOWN: {
@@ -3381,7 +3381,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
scancode_handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_HOME: {
#ifdef APPLE_STYLE_KEYS
@@ -3442,7 +3442,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
scancode_handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_END: {
#ifdef APPLE_STYLE_KEYS
@@ -3489,7 +3489,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
scancode_handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_PAGEUP: {
@@ -3512,7 +3512,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
scancode_handled = false;
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case KEY_PAGEDOWN: {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 0a11b94f48..940692ebd7 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1020,7 +1020,7 @@ int Tree::compute_item_height(TreeItem *p_item) const {
int check_icon_h = cache.checked->get_height();
if (height < check_icon_h)
height = check_icon_h;
- FALLTHROUGH;
+ [[fallthrough]];
}
case TreeItem::CELL_MODE_STRING:
case TreeItem::CELL_MODE_CUSTOM:
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index d852dca7fa..cb8f14c109 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -189,7 +189,7 @@ void ParticlesMaterial::_update_shader() {
} break;
case EMISSION_SHAPE_DIRECTED_POINTS: {
code += "uniform sampler2D emission_texture_normal : hint_black;\n";
- FALLTHROUGH;
+ [[fallthrough]];
}
case EMISSION_SHAPE_POINTS: {
code += "uniform sampler2D emission_texture_points : hint_black;\n";