Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored entire microbe stage to switch to an ECS approach for performance reasons #4521

Merged
merged 79 commits into from Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
324a6fa
Started working on a native code side of things to prototype this
hhyyrylainen May 30, 2023
4edd032
Implemented a basic collision listener class
hhyyrylainen Jun 1, 2023
a3c2714
Wrote a basic layers implementation based on the Jolt sample approach
hhyyrylainen Jun 1, 2023
b9a8fd6
Added needed boost libs just for intrusive_ptr
hhyyrylainen Jun 2, 2023
bfb09e8
First full implementation of a reference counting mechanism for intru…
hhyyrylainen Jun 2, 2023
6551487
Started on creating physics bodies
hhyyrylainen Jun 2, 2023
2a27edd
Added boost::circular_buffer lib
hhyyrylainen Jun 6, 2023
8a99835
Refactored physical world a bit to include less headers, added time t…
hhyyrylainen Jun 6, 2023
aaf34e6
A more comprehensive physics comparison test
hhyyrylainen Jun 6, 2023
e23ca04
Improved the physics test scene, more GUI info, added restarting
hhyyrylainen Jun 9, 2023
292d2ac
Updated physics test to have different spawn patterns, not rendering …
hhyyrylainen Jun 12, 2023
8233820
Started the big refactor of remaking microbe logic
hhyyrylainen Jun 16, 2023
9351de3
Starting to get some stuff done (cell burst effect entity)
hhyyrylainen Jun 28, 2023
9ae8e8e
Converted agent projectile to the new system
hhyyrylainen Jun 28, 2023
3e3e136
Implemented more physics systems and properties
hhyyrylainen Jun 29, 2023
035f725
Handle `FORCE_INLINE` macro for MSVC if `WIN32` is defined
athariqk Aug 8, 2023
0fcb170
Updated Jolt version
hhyyrylainen Aug 8, 2023
cf4235a
Make intrusive_ptr depend on smart_ptr
hhyyrylainen Aug 8, 2023
9964580
More microbe system code changes towards getting things compiling
hhyyrylainen Aug 8, 2023
b3c4af4
Did a small micro-optimization as the compiler anyway used ldelema
hhyyrylainen Aug 8, 2023
76bc9cd
Fix compound cloud plane dispose error when it was not initialized
hhyyrylainen Aug 9, 2023
a5efbd2
Switched to new Jolt axis lock approach
hhyyrylainen Aug 9, 2023
2615cd1
Added some more stuff that'll be needed by chunks, started creating m…
hhyyrylainen Aug 10, 2023
593bb46
Microbe benchmark now opens
hhyyrylainen Aug 15, 2023
2f70217
Added boost pool library
hhyyrylainen Aug 18, 2023
c90eb08
Fixing the collision count variable to exist in native memory
hhyyrylainen Aug 18, 2023
c414a06
Set to C++ 20 to allow using likely attribute
hhyyrylainen Aug 23, 2023
620bdb2
AI run gets now slightly further along
hhyyrylainen Aug 24, 2023
b1bc70b
Correct one incorrect branch hint
hhyyrylainen Aug 25, 2023
c6c2c3c
Added a pretty basic spinlock implementation
hhyyrylainen Aug 25, 2023
58f7983
Switched physics collision recording to write directly to C# memory
hhyyrylainen Aug 25, 2023
2da1635
Compound absorbing is now reimplemented
hhyyrylainen Aug 25, 2023
b61ad8f
Added guard against running out of species ID numbers
hhyyrylainen Aug 25, 2023
a50db5a
Created a dedicated signalling command system
hhyyrylainen Aug 28, 2023
10f1920
Microbe AI is now mostly ported to the ECS approach
hhyyrylainen Aug 29, 2023
e34c0a4
Fixed jittery physics and adjusted microbe movement
hhyyrylainen Aug 30, 2023
df5f3a7
Started on getting the microbe stage working with the new entities
hhyyrylainen Aug 31, 2023
0572b02
Updated common module and Jolt
hhyyrylainen Sep 1, 2023
48cc2d5
Implemented converting Godot convex shapes to Jolt
hhyyrylainen Sep 1, 2023
59534bc
Fixed a combined spawn queue unimplemented check is spawn still possible
hhyyrylainen Sep 4, 2023
aa2d8f0
Fixed look direction vector and increased turning speed
hhyyrylainen Sep 4, 2023
27d8ab5
Implemented the sound effect system
hhyyrylainen Sep 5, 2023
9784d82
More various work on the systems, mostly movement
hhyyrylainen Sep 6, 2023
6915a4e
Added some TODOs unrelated to the refactoring
hhyyrylainen Sep 19, 2023
eafe6f7
More work on the microbe collision related systems
hhyyrylainen Sep 19, 2023
0bd1ad1
Partial conversion of organelle components to the new system
hhyyrylainen Sep 26, 2023
7632a2a
Started on getting the colony and engulf systems working again
hhyyrylainen Oct 4, 2023
dc90fd3
Multicellular brain volume calculation fix, unrelated to
hhyyrylainen Oct 9, 2023
bf505b8
Engulfing system now compiles again
hhyyrylainen Oct 10, 2023
11ad0ea
Made more of the multicellular related code compile
hhyyrylainen Oct 13, 2023
bc8f849
Moved max simulation time per update from the reproduction system to …
hhyyrylainen Oct 13, 2023
b60bdf6
Put back in the AI chance to eat indigestible things
hhyyrylainen Oct 16, 2023
eb6b599
Reimplemented the microbe species chemoreceptor for the new approach
hhyyrylainen Oct 16, 2023
477f0e5
Reimplemented injectisome changes for the ECS approach
hhyyrylainen Oct 16, 2023
134b5c5
Made things from the old Microbe class compile entirely to continue
hhyyrylainen Oct 16, 2023
e36cf4a
Fixed up the specific compound type storage for the ECS changes
hhyyrylainen Oct 17, 2023
147e633
Fixed most immediate problems that show up when trying to start the m…
hhyyrylainen Oct 17, 2023
e2393a9
Fixed base reproduction cost handling
hhyyrylainen Oct 18, 2023
a0c0e3e
Fixed double membrane graphics creation
hhyyrylainen Oct 18, 2023
b6cf40c
Fixed various problems in the microbe stage after conversion
hhyyrylainen Oct 18, 2023
97bc938
Added a system that should stop chunk organelle animations
hhyyrylainen Oct 19, 2023
dfd91a5
More various bug fixing for the microbe stage systems
hhyyrylainen Oct 19, 2023
0eebd82
Bumped version and prevented saving for now, various small microbe fixes
hhyyrylainen Oct 20, 2023
9f08200
Added background membrane generation and microbe shape caching
hhyyrylainen Oct 23, 2023
82b7990
Implemented visuals only microbe simulation for the editor
hhyyrylainen Oct 25, 2023
1d80dac
Removed the old Microbe class and scene
hhyyrylainen Oct 25, 2023
fe9d18e
Full gameplay cycle of going to the editor and back now works
hhyyrylainen Oct 25, 2023
f80f331
Fixed storage space calculation
hhyyrylainen Oct 25, 2023
fd8a894
Implemented building and linking for use of native libs on Linux
hhyyrylainen Oct 25, 2023
5468b8d
Updated Jolt version
hhyyrylainen Oct 26, 2023
6d37ccf
Wrote half of the scripts needed to manage compiling the native libs
hhyyrylainen Oct 26, 2023
70775d2
Reimplemented pilus physics shape creation
hhyyrylainen Oct 26, 2023
e1ca3a3
Improved microbe shape creation and fixed it not being updated
hhyyrylainen Oct 27, 2023
8f8417a
Got kind of reasonable rotation speed calculation done
hhyyrylainen Oct 27, 2023
5586d11
Fixed a bunch of warnings and adjusted flagellum force down
hhyyrylainen Oct 27, 2023
526c648
Fixed new errors and warnings after latest master branch changes
hhyyrylainen Oct 27, 2023
01f1fa8
Added PreUpdate and PostUpdate to the rewrite tool
hhyyrylainen Oct 27, 2023
130ca10
Fixed compiling the native library with MSVC and made the script work…
hhyyrylainen Oct 27, 2023
8c8acf6
Added documentation on compiling the native libs, removed a leftover …
hhyyrylainen Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
215 changes: 152 additions & 63 deletions .clang-format
@@ -1,75 +1,164 @@
---
Language: Cpp
AccessModifierOffset: '-4'
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlinesLeft: Left
AlignTrailingComments: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: All
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'false'
BinPackArguments: 'true'
BinPackParameters: 'false'
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: Right
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BreakBeforeBraces: Allman
#BreakBeforeBraces: Custom
#BraceWrapping:
# AfterClass: false
# AfterControlStatement: false
# AfterEnum: false
# AfterFunction: true
# AfterNamespace: false
# AfterStruct: false
# AfterUnion: false
# # AfterExternBlock: false
# BeforeCatch: false
# BeforeElse: false
# IndentBraces: false
# SplitEmptyFunction: true
# SplitEmptyRecord: false
# SplitEmptyNamespace: true
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
# BreakBeforeBraces: Attach
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterStruct: false
AfterUnion: false
# AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeInheritanceComma: 'false'
BreakBeforeTernaryOperators: 'false'
BreakBeforeConceptDeclarations: Never
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterComma
BreakStringLiterals: false
ColumnLimit: 120
# Works fine even without this
# CommentPragmas: '^! \\'
CompactNamespaces: 'true'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
IndentCaseLabels: 'false'
IndentWidth: '4'
IndentWrappedFunctionNames: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'true'
MaxEmptyLinesToKeep: '3'
CompactNamespaces: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
IncludeBlocks: Regroup
IncludeCategories:
- Regex: "(<|\")(Jolt|boost)\/.*"
Priority: 2
- Regex: "<.*>"
Priority: 1
- Regex: "\"Include\\.h.*"
Priority: 3
SortPriority: 3
- Regex: "\"(core\/ForwardDefinitions\\.hpp).*"
Priority: 3
SortPriority: 4
- Regex: "\".*\/"
Priority: 5
- Regex: ".*"
Priority: 6
IndentAccessModifiers: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: false
IndentPPDirectives: None
IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertBraces: false
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
# MacroBlockBegin:
# MacroBlockEnd:
# Macros:
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
# NamespaceMacros:
# -
PPIndentWidth: 1
PackConstructorInitializers: BinPack
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 20
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: Never
# This is also a new setting not yet available
# SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '1'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
QualifierAlignment: Custom
QualifierOrder:
- static
- constexpr
- inline
- const
- volatile
- restrict
- friend
- type
# This needs to be left as otherwise functions will look ugly
ReferenceAlignment: Left
ReflowComments: true
RemoveSemicolon: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 0
SortIncludes: CaseInsensitive
SortUsingDeclarations: Lexicographic
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Before
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: 1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++17
# StatementAttributeLikeMacros:
# -
StatementMacros:
- JPH_ADD_ATTRIBUTE
- JPH_ADD_BASE_CLASS
TabWidth: 4
# TypenameMacros:
# -
UseTab: Never
# WhitespaceSensitiveMacros:
# -

...
5 changes: 5 additions & 0 deletions .clang-tidy
@@ -0,0 +1,5 @@
---
Checks: '-*,boost-*,bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,hicpp-*,
llvm-*,-llvm-header-guard,misc-*,-misc-no-recursion,modernize-*,-modernize-use-trailing-return-type,
performance-*,portability-*,readability-*'
ShortStatementLines: 1
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -2,6 +2,7 @@
/.import
export.cfg
/builds
/cmake-build*

/inspect_results.xml
/files_to_check.txt
Expand Down Expand Up @@ -67,7 +68,6 @@ _ReSharper*/
*.vssscc
$tf*/
[Bb]in
[Dd]ebug*/

# Libraries
*.lib
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,3 +1,6 @@
[submodule "RevolutionaryGamesCommon"]
path = RevolutionaryGamesCommon
url = https://github.com/Revolutionary-Games/RevolutionaryGamesCommon.git
[submodule "third_party/JoltPhysics"]
path = third_party/JoltPhysics
url = https://github.com/jrouwe/JoltPhysics.git
38 changes: 19 additions & 19 deletions CIConfiguration.yml
Expand Up @@ -5,15 +5,15 @@ jobs:
image: thrive/godot-ci:v21
cache:
loadFrom:
- v7-{Branch}-build
- v7-master-build
writeTo: v7-{Branch}-build
- v8-{Branch}-build
- v8-master-build
writeTo: v8-{Branch}-build
shared:
.git/lfs: v4-lfs
.import: v7-import
builds: v3-builds
.git/lfs: v5-lfs
.import: v8-import
builds: v4-builds
system:
/root/.nuget: v3-nuget
/root/.nuget: v4-nuget
steps:
- run:
name: Make project valid for compile
Expand All @@ -33,15 +33,15 @@ jobs:
image: thrive/godot-ci:v21
cache:
loadFrom:
- v4-{Branch}-jetbrains
- v4-master-jetbrains
writeTo: v4-{Branch}-jetbrains
- v5-{Branch}-jetbrains
- v5-master-jetbrains
writeTo: v5-{Branch}-jetbrains
shared:
.git/lfs: v4-lfs
.import: v7-import
builds: v3-jetbrains-dummy-builds
.git/lfs: v5-lfs
.import: v8-import
builds: v4-jetbrains-dummy-builds
system:
/root/.nuget: v3-nuget
/root/.nuget: v4-nuget
artifacts:
paths:
- files_to_check.txt
Expand Down Expand Up @@ -94,13 +94,13 @@ jobs:
image: thrive/godot-ci:v21
cache:
loadFrom:
- v4-{Branch}-format
- v4-master-format
writeTo: v4-{Branch}-format
- v5-{Branch}-format
- v5-master-format
writeTo: v5-{Branch}-format
shared:
.git/lfs: v4-lfs
.git/lfs: v5-lfs
system:
/root/.nuget: v3-nuget
/root/.nuget: v4-nuget
artifacts:
paths:
- format_diff.patch
Expand Down
75 changes: 75 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,75 @@
# Native code side of Thrive
cmake_minimum_required(VERSION 3.10)

project(Thrive)

# If you want to get compile commands run cmake with
# "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"

# Options
option(USE_OBJECT_POOLS
"Use object pools instead of direct memory allocation (can be turned off for memory debugging)"
ON)

option(LOCK_FREE_COLLISION_RECORDING
"If on uses lock free collision data recording which is hopefully faster than with locks" ON)

option(USE_SMALL_VECTOR_POOLS
"If on uses also pools for small list allocations in physics" OFF)

option(WARNINGS_AS_ERRORS "When on treat compiler warnings as errors" ON)

option(NULL_HAS_UNUSUAL_REPRESENTATION
"When on it is not assumed that null equals numeric 0" OFF)

# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMake")

# Also use a lib prefix on windows for consistency
if(WIN32)
set(CMAKE_SHARED_LIBRARY_PREFIX_CXX "lib")
endif()

# static building
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)

# Common options
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Set the build type, usually Debug or Distribution" FORCE)
endif()

# A bit unneeded Jolt hack
# # This and the following hack is required due to Jolt being very debug-y in
# # release mode
# elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
# set(CMAKE_BUILD_TYPE Distribution)
# elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# set(CMAKE_BUILD_TYPE Distribution)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/debug")
else()
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/release")
endif()

# Detect library version
file(READ "src/native/NativeConstants.cs" versionFile)

string(REGEX MATCH "Version = ([0-9]+);" _ "${versionFile}")
set(NATIVE_LIBRARY_VERSION ${CMAKE_MATCH_1})

if(NOT NATIVE_LIBRARY_VERSION)
message(FATAL_ERROR "Failed to parse native library version")
endif()

message(STATUS "Configured native library version ${NATIVE_LIBRARY_VERSION}")

# Configure include file
configure_file("src/native/Include.h.in" "${PROJECT_BINARY_DIR}/Include.h")
include_directories(${PROJECT_BINARY_DIR})

# Add the subfolders that define the actual things to build
add_subdirectory(third_party)

add_subdirectory(src/native)