CI: Update to clang-format 11 and apply ternary operator changes
This commit is contained in:
parent
df257f4fb6
commit
af878716f2
16 changed files with 57 additions and 43 deletions
4
.github/workflows/static_checks.yml
vendored
4
.github/workflows/static_checks.yml
vendored
|
@ -18,7 +18,9 @@ jobs:
|
|||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get install -qq dos2unix recode clang-format
|
||||
sudo apt-get install -qq dos2unix recode clang-format-11
|
||||
sudo update-alternatives --remove-all clang-format
|
||||
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
|
||||
sudo pip3 install black==20.8b1 pygments
|
||||
|
||||
- name: File formatting checks (file_format.sh)
|
||||
|
|
|
@ -790,8 +790,8 @@ Quat Basis::get_quat() const {
|
|||
temp[2] = ((m.elements[1][0] - m.elements[0][1]) * s);
|
||||
} else {
|
||||
int i = m.elements[0][0] < m.elements[1][1] ?
|
||||
(m.elements[1][1] < m.elements[2][2] ? 2 : 1) :
|
||||
(m.elements[0][0] < m.elements[2][2] ? 2 : 0);
|
||||
(m.elements[1][1] < m.elements[2][2] ? 2 : 1) :
|
||||
(m.elements[0][0] < m.elements[2][2] ? 2 : 0);
|
||||
int j = (i + 1) % 3;
|
||||
int k = (i + 2) % 3;
|
||||
|
||||
|
|
|
@ -4702,8 +4702,8 @@ void EditorNode::_scene_tab_closed(int p_tab, int option) {
|
|||
}
|
||||
|
||||
bool unsaved = (p_tab == editor_data.get_edited_scene()) ?
|
||||
saved_version != editor_data.get_undo_redo().get_version() :
|
||||
editor_data.get_scene_version(p_tab) != 0;
|
||||
saved_version != editor_data.get_undo_redo().get_version() :
|
||||
editor_data.get_scene_version(p_tab) != 0;
|
||||
if (unsaved) {
|
||||
save_confirmation->get_ok_button()->set_text(TTR("Save & Close"));
|
||||
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_filename() != "" ? scene->get_filename() : "unsaved scene"));
|
||||
|
|
|
@ -3149,16 +3149,16 @@ void CanvasItemEditor::_draw_ruler_tool() {
|
|||
|
||||
float arc_1_start_angle =
|
||||
end_to_begin.x < 0 ?
|
||||
(end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0) :
|
||||
(end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
|
||||
(end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0) :
|
||||
(end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
|
||||
float arc_1_end_angle = arc_1_start_angle + vertical_angle_rad;
|
||||
// Constrain arc to triangle height & max size
|
||||
float arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.y)), arc_max_radius);
|
||||
|
||||
float arc_2_start_angle =
|
||||
end_to_begin.x < 0 ?
|
||||
(end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad) :
|
||||
(end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
|
||||
(end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad) :
|
||||
(end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
|
||||
float arc_2_end_angle = arc_2_start_angle + horizontal_angle_rad;
|
||||
// Constrain arc to triangle width & max size
|
||||
float arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.x)), arc_max_radius);
|
||||
|
|
|
@ -353,8 +353,8 @@ void CurveEditor::open_context_menu(Vector2 pos) {
|
|||
_context_menu->add_check_item(TTR("Linear"), CONTEXT_LINEAR);
|
||||
|
||||
bool is_linear = _selected_tangent == TANGENT_LEFT ?
|
||||
_curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR :
|
||||
_curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR;
|
||||
_curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR :
|
||||
_curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR;
|
||||
|
||||
_context_menu->set_item_checked(_context_menu->get_item_index(CONTEXT_LINEAR), is_linear);
|
||||
|
||||
|
|
|
@ -3584,9 +3584,9 @@ Error CSharpScript::load_source_code(const String &p_path) {
|
|||
|
||||
ERR_FAIL_COND_V_MSG(ferr != OK, ferr,
|
||||
ferr == ERR_INVALID_DATA ?
|
||||
"Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded."
|
||||
"Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded."
|
||||
" Please ensure that scripts are saved in valid UTF-8 unicode." :
|
||||
"Failed to read file: '" + p_path + "'.");
|
||||
"Failed to read file: '" + p_path + "'.");
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
source_changed_cache = true;
|
||||
|
|
|
@ -365,7 +365,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
|
|||
xml_output.append("</c>");
|
||||
} else if (link_tag == "enum") {
|
||||
StringName search_cname = !target_itype ? target_cname :
|
||||
StringName(target_itype->name + "." + (String)target_cname);
|
||||
StringName(target_itype->name + "." + (String)target_cname);
|
||||
|
||||
const Map<StringName, TypeInterface>::Element *enum_match = enum_types.find(search_cname);
|
||||
|
||||
|
|
|
@ -735,9 +735,9 @@ Error ScriptClassParser::parse_file(const String &p_filepath) {
|
|||
|
||||
ERR_FAIL_COND_V_MSG(ferr != OK, ferr,
|
||||
ferr == ERR_INVALID_DATA ?
|
||||
"File '" + p_filepath + "' contains invalid unicode (UTF-8), so it was not loaded."
|
||||
"File '" + p_filepath + "' contains invalid unicode (UTF-8), so it was not loaded."
|
||||
" Please ensure that scripts are saved in valid UTF-8 unicode." :
|
||||
"Failed to read file: '" + p_filepath + "'.");
|
||||
"Failed to read file: '" + p_filepath + "'.");
|
||||
|
||||
run_dummy_preprocessor(source, p_filepath);
|
||||
|
||||
|
|
|
@ -593,8 +593,8 @@ ApiAssemblyInfo::Version ApiAssemblyInfo::Version::get_from_loaded_assembly(GDMo
|
|||
ApiAssemblyInfo::Version api_assembly_version;
|
||||
|
||||
const char *nativecalls_name = p_api_type == ApiAssemblyInfo::API_CORE ?
|
||||
BINDINGS_CLASS_NATIVECALLS :
|
||||
BINDINGS_CLASS_NATIVECALLS_EDITOR;
|
||||
BINDINGS_CLASS_NATIVECALLS :
|
||||
BINDINGS_CLASS_NATIVECALLS_EDITOR;
|
||||
|
||||
GDMonoClass *nativecalls_klass = p_api_assembly->get_class(BINDINGS_NAMESPACE, nativecalls_name);
|
||||
|
||||
|
@ -757,11 +757,11 @@ String GDMono::update_api_assemblies_from_prebuilt(const String &p_config, const
|
|||
#define FAIL_REASON(m_out_of_sync, m_prebuilt_exists) \
|
||||
( \
|
||||
(m_out_of_sync ? \
|
||||
String("The assembly is invalidated ") : \
|
||||
String("The assembly was not found ")) + \
|
||||
String("The assembly is invalidated ") : \
|
||||
String("The assembly was not found ")) + \
|
||||
(m_prebuilt_exists ? \
|
||||
String("and the prebuilt assemblies are missing.") : \
|
||||
String("and we failed to copy the prebuilt assemblies.")))
|
||||
String("and the prebuilt assemblies are missing.") : \
|
||||
String("and we failed to copy the prebuilt assemblies.")))
|
||||
|
||||
String dst_assemblies_dir = GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config);
|
||||
|
||||
|
@ -820,8 +820,8 @@ bool GDMono::_load_core_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, c
|
|||
|
||||
// If running the project manager, load it from the prebuilt API directory
|
||||
String assembly_dir = !Main::is_project_manager() ?
|
||||
GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) :
|
||||
GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
|
||||
GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) :
|
||||
GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
|
||||
|
||||
String assembly_path = assembly_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
|
||||
|
||||
|
@ -853,8 +853,8 @@ bool GDMono::_load_editor_api_assembly(LoadedApiAssembly &r_loaded_api_assembly,
|
|||
|
||||
// If running the project manager, load it from the prebuilt API directory
|
||||
String assembly_dir = !Main::is_project_manager() ?
|
||||
GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) :
|
||||
GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
|
||||
GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) :
|
||||
GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
|
||||
|
||||
String assembly_path = assembly_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
|
||||
|
||||
|
|
|
@ -1677,8 +1677,8 @@ Callable managed_to_callable(const M_Callable &p_managed_callable) {
|
|||
return Callable(managed_callable);
|
||||
} else {
|
||||
Object *target = p_managed_callable.target ?
|
||||
unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_callable.target)) :
|
||||
nullptr;
|
||||
unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_callable.target)) :
|
||||
nullptr;
|
||||
StringName *method_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_callable.method_string_name));
|
||||
StringName method = method_ptr ? *method_ptr : StringName();
|
||||
return Callable(target, method);
|
||||
|
@ -1723,8 +1723,8 @@ M_Callable callable_to_managed(const Callable &p_callable) {
|
|||
|
||||
Signal managed_to_signal_info(const M_SignalInfo &p_managed_signal) {
|
||||
Object *owner = p_managed_signal.owner ?
|
||||
unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_signal.owner)) :
|
||||
nullptr;
|
||||
unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_signal.owner)) :
|
||||
nullptr;
|
||||
StringName *name_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_signal.name_string_name));
|
||||
StringName name = name_ptr ? *name_ptr : StringName();
|
||||
return Signal(owner, name);
|
||||
|
|
|
@ -188,15 +188,15 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
|
|||
|
||||
if (GLUtils.use_32) {
|
||||
setEGLConfigChooser(translucent ?
|
||||
new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
|
||||
new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
|
||||
new RegularConfigChooser(8, 8, 8, 8, 16, stencil)) :
|
||||
new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
|
||||
new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
|
||||
new RegularConfigChooser(5, 6, 5, 0, 16, stencil)));
|
||||
|
||||
} else {
|
||||
setEGLConfigChooser(translucent ?
|
||||
new RegularConfigChooser(8, 8, 8, 8, 16, stencil) :
|
||||
new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
|
||||
new RegularConfigChooser(8, 8, 8, 8, 16, stencil) :
|
||||
new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -760,7 +760,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
|
|||
result = result.replace("$version_string$", version);
|
||||
|
||||
Platform arch = (Platform)(int)p_preset->get("architecture/target");
|
||||
String architecture = arch == ARM ? "arm" : arch == X86 ? "x86" : "x64";
|
||||
String architecture = arch == ARM ? "arm" : (arch == X86 ? "x86" : "x64");
|
||||
result = result.replace("$architecture$", architecture);
|
||||
|
||||
result = result.replace("$display_name$", String(p_preset->get("package/display_name")).is_empty() ? (String)ProjectSettings::get_singleton()->get("application/config/name") : String(p_preset->get("package/display_name")));
|
||||
|
|
|
@ -293,11 +293,11 @@ void GPUParticlesCollisionSDF::_find_closest_distance(const Vector3 &p_pos, cons
|
|||
SGN(cb.cross(nor).dot(pb)) +
|
||||
SGN(ac.cross(nor).dot(pc)) <
|
||||
2.0) ?
|
||||
MIN(MIN(
|
||||
MIN(MIN(
|
||||
Vector3_dot2(ba * CLAMP(ba.dot(pa) / Vector3_dot2(ba), 0.0, 1.0) - pa),
|
||||
Vector3_dot2(cb * CLAMP(cb.dot(pb) / Vector3_dot2(cb), 0.0, 1.0) - pb)),
|
||||
Vector3_dot2(ac * CLAMP(ac.dot(pc) / Vector3_dot2(ac), 0.0, 1.0) - pc)) :
|
||||
nor.dot(pa) * nor.dot(pa) / Vector3_dot2(nor));
|
||||
nor.dot(pa) * nor.dot(pa) / Vector3_dot2(nor));
|
||||
|
||||
closest_distance = MIN(closest_distance, inside_d);
|
||||
}
|
||||
|
|
|
@ -239,8 +239,8 @@ void Node3D::set_transform(const Transform &p_transform) {
|
|||
void Node3D::set_global_transform(const Transform &p_transform) {
|
||||
Transform xform =
|
||||
(data.parent && !data.top_level_active) ?
|
||||
data.parent->get_global_transform().affine_inverse() * p_transform :
|
||||
p_transform;
|
||||
data.parent->get_global_transform().affine_inverse() * p_transform :
|
||||
p_transform;
|
||||
|
||||
set_transform(xform);
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ real_t G6DOFRotationalLimitMotor3DSW::solveAngularLimits(
|
|||
|
||||
real_t oldaccumImpulse = m_accumulatedImpulse;
|
||||
real_t sum = oldaccumImpulse + clippedMotorImpulse;
|
||||
m_accumulatedImpulse = sum > hi ? real_t(0.) : sum < lo ? real_t(0.) : sum;
|
||||
m_accumulatedImpulse = sum > hi ? real_t(0.) : (sum < lo ? real_t(0.) : sum);
|
||||
|
||||
clippedMotorImpulse = m_accumulatedImpulse - oldaccumImpulse;
|
||||
|
||||
|
@ -201,7 +201,7 @@ real_t G6DOFTranslationalLimitMotor3DSW::solveLinearAxis(
|
|||
|
||||
real_t oldNormalImpulse = m_accumulatedImpulse[limit_index];
|
||||
real_t sum = oldNormalImpulse + normalImpulse;
|
||||
m_accumulatedImpulse[limit_index] = sum > hi ? real_t(0.) : sum < lo ? real_t(0.) : sum;
|
||||
m_accumulatedImpulse[limit_index] = sum > hi ? real_t(0.) : (sum < lo ? real_t(0.) : sum);
|
||||
normalImpulse = m_accumulatedImpulse[limit_index] - oldNormalImpulse;
|
||||
|
||||
Vector3 impulse_vector = axis_normal_on_a * normalImpulse;
|
||||
|
|
|
@ -4416,7 +4416,10 @@ void RendererSceneRenderRD::gi_probe_update(RID p_probe, bool p_update_light_ins
|
|||
}
|
||||
}
|
||||
|
||||
dmap.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, giprobe_lighting_shader_version_shaders[(write && plot) ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT : write ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE : GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT], 0);
|
||||
dmap.uniform_set = RD::get_singleton()->uniform_set_create(
|
||||
uniforms,
|
||||
giprobe_lighting_shader_version_shaders[(write && plot) ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT : (write ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE : GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT)],
|
||||
0);
|
||||
}
|
||||
|
||||
gi_probe->dynamic_maps.push_back(dmap);
|
||||
|
@ -4850,7 +4853,16 @@ void RendererSceneRenderRD::_debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw
|
|||
}
|
||||
|
||||
giprobe_debug_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, giprobe_debug_shader_version_shaders[0], 0);
|
||||
RD::get_singleton()->draw_list_bind_render_pipeline(p_draw_list, giprobe_debug_shader_version_pipelines[p_emission ? GI_PROBE_DEBUG_EMISSION : p_lighting ? (gi_probe->has_dynamic_object_data ? GI_PROBE_DEBUG_LIGHT_FULL : GI_PROBE_DEBUG_LIGHT) : GI_PROBE_DEBUG_COLOR].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer)));
|
||||
|
||||
int giprobe_debug_pipeline = GI_PROBE_DEBUG_COLOR;
|
||||
if (p_emission) {
|
||||
giprobe_debug_pipeline = GI_PROBE_DEBUG_EMISSION;
|
||||
} else if (p_lighting) {
|
||||
giprobe_debug_pipeline = gi_probe->has_dynamic_object_data ? GI_PROBE_DEBUG_LIGHT_FULL : GI_PROBE_DEBUG_LIGHT;
|
||||
}
|
||||
RD::get_singleton()->draw_list_bind_render_pipeline(
|
||||
p_draw_list,
|
||||
giprobe_debug_shader_version_pipelines[giprobe_debug_pipeline].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer)));
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, giprobe_debug_uniform_set, 0);
|
||||
RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(GIProbeDebugPushConstant));
|
||||
RD::get_singleton()->draw_list_draw(p_draw_list, false, cell_count, 36);
|
||||
|
|
Loading…
Reference in a new issue