Skip to content

Commit

Permalink
Re-formatted all source files. Added .clang-format. Added source form…
Browse files Browse the repository at this point in the history
…atting scripts. Added github action to auto-format sources after a commit.
  • Loading branch information
pboechat committed May 24, 2024
1 parent 04fb23d commit 5877768
Show file tree
Hide file tree
Showing 177 changed files with 9,880 additions and 9,349 deletions.
246 changes: 246 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
---
Language: Cpp
# BasedOnStyle: Microsoft
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakScopeResolution: 500
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Right
PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SkipMacroDefinitionBody: false
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterPlacementOperator: true
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...

39 changes: 39 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Format C++ Code

on:
push:
branches:
- main
- 'feature/**'
pull_request:
branches:
- main

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install clang-format
run: sudo apt-get install -y clang-format

- name: Run clang-format
run: |
chmod +x ./format_sources.sh
./format_sources.sh
- name: Check for code format changes
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add .
if ! git diff --cached --exit-code; then
git commit -m "Applied format changes."
git push
echo "Applied format changes."
else
echo "No formatting changes required."
fi
5 changes: 3 additions & 2 deletions FastCG/include/FastCG/Assets/AssetSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <FastCG/Core/System.h>

#include <vector>
#include <string>
#include <vector>

namespace FastCG
{
Expand All @@ -21,7 +21,8 @@ namespace FastCG
inline std::vector<std::string> List(const std::string &rRelDirectoryPath, bool recursive = false) const;
inline bool Resolve(const std::string &rRelFilePath, std::string &rAbsFilePath) const;
inline std::string Resolve(const std::string &rRelFilePath) const;
inline void Expand(const std::string &rRelFilePath, std::vector<std::string> &rAbsFilePaths, bool includeNonExistant = false) const;
inline void Expand(const std::string &rRelFilePath, std::vector<std::string> &rAbsFilePaths,
bool includeNonExistant = false) const;
inline std::vector<std::string> Expand(const std::string &rRelFilePath, bool includeNonExistant = false) const;

private:
Expand Down
8 changes: 5 additions & 3 deletions FastCG/include/FastCG/Assets/AssetSystem.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <FastCG/Platform/File.h>
#include <FastCG/Platform/Directory.h>
#include <FastCG/Platform/File.h>

#include <algorithm>

Expand Down Expand Up @@ -38,7 +38,8 @@ namespace FastCG
return absFilePath;
}

void AssetSystem::Expand(const std::string &rRelFilePath, std::vector<std::string> &rAbsFilePaths, bool includeNonExistant /* = false*/) const
void AssetSystem::Expand(const std::string &rRelFilePath, std::vector<std::string> &rAbsFilePaths,
bool includeNonExistant /* = false*/) const
{
rAbsFilePaths.clear();
for (const auto &rBundleRoot : mBundleRoots)
Expand All @@ -51,7 +52,8 @@ namespace FastCG
}
}

std::vector<std::string> AssetSystem::Expand(const std::string &rRelFilePath, bool includeNonExistant /* = false*/) const
std::vector<std::string> AssetSystem::Expand(const std::string &rRelFilePath,
bool includeNonExistant /* = false*/) const
{
std::vector<std::string> absFilePaths;
Expand(rRelFilePath, absFilePaths, includeNonExistant);
Expand Down
52 changes: 26 additions & 26 deletions FastCG/include/FastCG/Core/AABB.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@

namespace FastCG
{
struct AABB
{
glm::vec3 min{0, 0, 0};
glm::vec3 max{0, 0, 0};

inline glm::vec3 getExtent() const
{
return max - min;
}

inline glm::vec3 getCenter() const
{
return min + getExtent() * 0.5f;
}

inline void Expand(const AABB &other)
{
max = glm::max(max, other.max);
min = glm::min(min, other.min);
}

inline bool IsDegenerated() const
{
return max.x <= min.x || max.y <= min.y || max.z <= min.z;
}
};
struct AABB
{
glm::vec3 min{0, 0, 0};
glm::vec3 max{0, 0, 0};

inline glm::vec3 getExtent() const
{
return max - min;
}

inline glm::vec3 getCenter() const
{
return min + getExtent() * 0.5f;
}

inline void Expand(const AABB &other)
{
max = glm::max(max, other.max);
min = glm::min(min, other.min);
}

inline bool IsDegenerated() const
{
return max.x <= min.x || max.y <= min.y || max.z <= min.z;
}
};

}

Expand Down
Loading

0 comments on commit 5877768

Please sign in to comment.