You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-04 17:04:49 +00:00
Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
This commit is contained in:
@@ -64,6 +64,7 @@ void LightmapperRD::add_directional_light(bool p_static, const Vector3 &p_direct
|
||||
l.size = p_angular_distance;
|
||||
lights.push_back(l);
|
||||
}
|
||||
|
||||
void LightmapperRD::add_omni_light(bool p_static, const Vector3 &p_position, const Color &p_color, float p_energy, float p_range, float p_attenuation, float p_size) {
|
||||
Light l;
|
||||
l.type = LIGHT_TYPE_OMNI;
|
||||
@@ -80,6 +81,7 @@ void LightmapperRD::add_omni_light(bool p_static, const Vector3 &p_position, con
|
||||
l.size = p_size;
|
||||
lights.push_back(l);
|
||||
}
|
||||
|
||||
void LightmapperRD::add_spot_light(bool p_static, const Vector3 &p_position, const Vector3 p_direction, const Color &p_color, float p_energy, float p_range, float p_attenuation, float p_spot_angle, float p_spot_attenuation, float p_size) {
|
||||
Light l;
|
||||
l.type = LIGHT_TYPE_SPOT;
|
||||
@@ -1700,17 +1702,21 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
|
||||
int LightmapperRD::get_bake_texture_count() const {
|
||||
return bake_textures.size();
|
||||
}
|
||||
|
||||
Ref<Image> LightmapperRD::get_bake_texture(int p_index) const {
|
||||
ERR_FAIL_INDEX_V(p_index, bake_textures.size(), Ref<Image>());
|
||||
return bake_textures[p_index];
|
||||
}
|
||||
|
||||
int LightmapperRD::get_bake_mesh_count() const {
|
||||
return mesh_instances.size();
|
||||
}
|
||||
|
||||
Variant LightmapperRD::get_bake_mesh_userdata(int p_index) const {
|
||||
ERR_FAIL_INDEX_V(p_index, mesh_instances.size(), Variant());
|
||||
return mesh_instances[p_index].data.userdata;
|
||||
}
|
||||
|
||||
Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const {
|
||||
ERR_FAIL_COND_V(bake_textures.size() == 0, Rect2());
|
||||
Rect2 uv_ofs;
|
||||
@@ -1719,6 +1725,7 @@ Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const {
|
||||
uv_ofs.size = Vector2(mesh_instances[p_index].data.albedo_on_uv2->get_width(), mesh_instances[p_index].data.albedo_on_uv2->get_height()) / atlas_size;
|
||||
return uv_ofs;
|
||||
}
|
||||
|
||||
int LightmapperRD::get_bake_mesh_texture_slice(int p_index) const {
|
||||
ERR_FAIL_INDEX_V(p_index, mesh_instances.size(), Variant());
|
||||
return mesh_instances[p_index].slice;
|
||||
|
||||
Reference in New Issue
Block a user