Compare commits
76 Commits
68e062faa1
...
feat/light
| Author | SHA1 | Date | |
|---|---|---|---|
| c00f05aafd | |||
| dc1ef70231 | |||
| e224110452 | |||
| 74b0aebc9f | |||
| be425a705c | |||
| 31bf337f6f | |||
| 662f10047a | |||
| 943c6f1f46 | |||
| 7ede49da72 | |||
| a4f92e3659 | |||
| f43ef64691 | |||
|
|
f4114c2699 | ||
|
|
932463663f | ||
|
|
bac3df801b | ||
|
|
d0bc8d627f | ||
|
|
2906106597 | ||
|
|
a0139dd315 | ||
|
|
5901ab7cd9 | ||
|
|
bbf8b4e969 | ||
|
|
a54e87dbc6 | ||
|
|
1a26474a05 | ||
|
|
d986e03f9c | ||
|
|
9d200f31be | ||
|
|
a02bfad639 | ||
|
|
a63dfa7f47 | ||
|
|
d4d761b2aa | ||
|
|
315c60e4a6 | ||
|
|
9a8e76d25f | ||
| 14c942333c | |||
| b88bc30756 | |||
| a526d37f97 | |||
| fb86836e19 | |||
| f2f00ce658 | |||
| 611a795481 | |||
| dc3be5a4bc | |||
| 932c11a646 | |||
| 5b2f06b3ec | |||
| bd5665c935 | |||
| 59ab47d317 | |||
| e34a20599d | |||
| c5a78185ba | |||
| a3eb19e58f | |||
| 9402847e89 | |||
| a95ad796ce | |||
| 8b5717a655 | |||
| 055c4d687b | |||
| 4ca2133ff3 | |||
| ada0603a2f | |||
| dc3926e47f | |||
| 3e27ab675c | |||
| 106cc3d398 | |||
| 2409734e89 | |||
| 8f8e2c1bd5 | |||
| 2707748843 | |||
| e90b0ce2f4 | |||
| c7a0aff0c1 | |||
| c2321a0a6e | |||
| 6c74f4582c | |||
| 553955841b | |||
| ca82d6a447 | |||
| 0a0024361d | |||
| 47ce4cf2d3 | |||
| af34d7eb82 | |||
| 03ea97055f | |||
| 639648969b | |||
| de4df4b476 | |||
| 11b6e88d0d | |||
| 099b1cbdd7 | |||
| 955c4ddec7 | |||
| bb888fd7b7 | |||
| 63930dcdc7 | |||
| 30a4713092 | |||
| f2328d19fd | |||
| e69d38ad94 | |||
| 5723c17f94 | |||
| be176ff18a |
321
.clang-format
Normal file
@@ -0,0 +1,321 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
AlignAfterOpenBracket: true
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionDeclarations: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: true
|
||||||
|
AlignConsecutiveBitFields:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionDeclarations: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveDeclarations:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionDeclarations: true
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveMacros:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionDeclarations: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveShortCaseStatements:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCaseArrows: false
|
||||||
|
AlignCaseColons: false
|
||||||
|
AlignConsecutiveTableGenBreakingDAGArgColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionDeclarations: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveTableGenCondOperatorColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionDeclarations: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveTableGenDefinitionColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionDeclarations: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments:
|
||||||
|
AlignPPAndNotPP: true
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowBreakBeforeNoexceptSpecifier: Never
|
||||||
|
AllowBreakBeforeQtProperty: false
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseExpressionOnASingleLine: true
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortCompoundRequirementOnASingleLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortNamespacesOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackLongBracedList: true
|
||||||
|
BinPackParameters: BinPack
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BracedInitializerIndentWidth: -1
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakAdjacentStringLiterals: true
|
||||||
|
BreakAfterAttributes: Leave
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakAfterOpenBracketBracedList: false
|
||||||
|
BreakAfterOpenBracketFunction: false
|
||||||
|
BreakAfterOpenBracketIf: false
|
||||||
|
BreakAfterOpenBracketLoop: false
|
||||||
|
BreakAfterOpenBracketSwitch: false
|
||||||
|
BreakAfterReturnType: None
|
||||||
|
BreakArrays: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeCloseBracketBracedList: false
|
||||||
|
BreakBeforeCloseBracketFunction: false
|
||||||
|
BreakBeforeCloseBracketIf: false
|
||||||
|
BreakBeforeCloseBracketLoop: false
|
||||||
|
BreakBeforeCloseBracketSwitch: false
|
||||||
|
BreakBeforeConceptDeclarations: Always
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
|
BreakBeforeTemplateCloser: false
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakBinaryOperations: Never
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakFunctionDefinitionParameters: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
BreakTemplateDeclarations: MultiLine
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: AlignFirstComment
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
EnumTrailingComma: Leave
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
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
|
||||||
|
IndentExportBlock: true
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentRequiresClause: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertBraces: false
|
||||||
|
InsertNewlineAtEOF: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
IntegerLiteralSeparator:
|
||||||
|
Binary: 0
|
||||||
|
BinaryMinDigitsInsert: 0
|
||||||
|
BinaryMaxDigitsRemove: 0
|
||||||
|
Decimal: 0
|
||||||
|
DecimalMinDigitsInsert: 0
|
||||||
|
DecimalMaxDigitsRemove: 0
|
||||||
|
Hex: 0
|
||||||
|
HexMinDigitsInsert: 0
|
||||||
|
HexMaxDigitsRemove: 0
|
||||||
|
BinaryMinDigits: 0
|
||||||
|
DecimalMinDigits: 0
|
||||||
|
HexMinDigits: 0
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLines:
|
||||||
|
AtEndOfFile: false
|
||||||
|
AtStartOfBlock: true
|
||||||
|
AtStartOfFile: true
|
||||||
|
KeepFormFeed: false
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
LineEnding: DeriveLF
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MainIncludeChar: Quote
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
NumericLiteralCase:
|
||||||
|
ExponentLetter: Leave
|
||||||
|
HexDigit: Leave
|
||||||
|
Prefix: Leave
|
||||||
|
Suffix: Leave
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
OneLineFormatOffRegex: ''
|
||||||
|
PackConstructorInitializers: BinPack
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakBeforeMemberAccess: 150
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakScopeResolution: 500
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Left
|
||||||
|
PPIndentWidth: -1
|
||||||
|
QualifierAlignment: Leave
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: Always
|
||||||
|
RemoveBracesLLVM: false
|
||||||
|
RemoveEmptyLinesInUnwrappedLines: false
|
||||||
|
RemoveParentheses: Leave
|
||||||
|
RemoveSemicolon: false
|
||||||
|
RequiresClausePosition: OwnLine
|
||||||
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Leave
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SkipMacroDefinitionBody: false
|
||||||
|
SortIncludes:
|
||||||
|
Enabled: true
|
||||||
|
IgnoreCase: false
|
||||||
|
IgnoreExtension: false
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: LexicographicNumeric
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterOperatorKeyword: 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
|
||||||
|
AfterNot: false
|
||||||
|
AfterOverloadedOperator: false
|
||||||
|
AfterPlacementOperator: true
|
||||||
|
AfterRequiresInClause: false
|
||||||
|
AfterRequiresInExpression: false
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBraces: Never
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParens: Never
|
||||||
|
SpacesInParensOptions:
|
||||||
|
ExceptDoubleParentheses: false
|
||||||
|
InCStyleCasts: false
|
||||||
|
InConditionalStatements: false
|
||||||
|
InEmptyParentheses: false
|
||||||
|
Other: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Latest
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TableGenBreakInsideDAGArg: DontBreak
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Never
|
||||||
|
VerilogBreakBetweenInstancePorts: true
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- STRINGIZE
|
||||||
|
WrapNamespaceBodyWithEmptyLines: Leave
|
||||||
|
...
|
||||||
|
|
||||||
3
.clang-format-ignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
third_party/
|
||||||
|
build/
|
||||||
|
vendor/
|
||||||
2
.clangd
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
CompileFlags:
|
||||||
|
Add: [-Wall, -Wextra, -Wpedantic, -Wno-unused-parameter]
|
||||||
17
.github/workflows/format-check.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# .github/workflows/format-check.yml
|
||||||
|
name: Code Format Check
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
formatting:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: silkeh/clang:latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Run clang-format
|
||||||
|
run: |
|
||||||
|
find src include -name '*.cpp' -o -name '*.h' -print0 | xargs -0 clang-format --dry-run --Werror
|
||||||
4
.gitignore
vendored
@@ -39,4 +39,6 @@ CMakeError.log
|
|||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*~
|
*~
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
assets/config.toml
|
||||||
|
.venv/
|
||||||
8
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
|
rev: "v22.1.4"
|
||||||
|
hooks:
|
||||||
|
- id: clang-format
|
||||||
|
args: ["--style=file"]
|
||||||
|
types_or: ["c++", "c"]
|
||||||
|
exclude: '^third_party/.*$'
|
||||||
1
.python-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.14
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.14...3.24)
|
cmake_minimum_required(VERSION 3.14...3.24)
|
||||||
project(Cubed LANGUAGES C CXX)
|
project(Cubed LANGUAGES C CXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
@@ -58,6 +58,21 @@ if (WIN32)
|
|||||||
if(TARGET freetype)
|
if(TARGET freetype)
|
||||||
add_library(Freetype::Freetype ALIAS freetype)
|
add_library(Freetype::Freetype ALIAS freetype)
|
||||||
endif()
|
endif()
|
||||||
|
set(_BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS})
|
||||||
|
set(BUILD_SHARED_LIBS ON)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
onetbb
|
||||||
|
GIT_REPOSITORY https://github.com/uxlfoundation/oneTBB.git
|
||||||
|
GIT_TAG v2023.0.0
|
||||||
|
)
|
||||||
|
set(BUILD_TESTING OFF CACHE BOOL "Build tests" FORCE)
|
||||||
|
set(TBB_TEST OFF CACHE BOOL "Build TBB tests" FORCE)
|
||||||
|
FetchContent_MakeAvailable(onetbb)
|
||||||
|
|
||||||
|
set(BUILD_SHARED_LIBS ${_BUILD_SHARED_LIBS_SAVED})
|
||||||
|
unset(_BUILD_SHARED_LIBS_SAVED)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
@@ -74,6 +89,14 @@ FetchContent_Declare(
|
|||||||
|
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(soil2)
|
FetchContent_MakeAvailable(soil2)
|
||||||
|
FetchContent_Declare(
|
||||||
|
tomlplusplus
|
||||||
|
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
|
||||||
|
GIT_TAG v3.4.0
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(tomlplusplus)
|
||||||
|
|
||||||
|
add_subdirectory(third_party/imgui)
|
||||||
|
|
||||||
set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
|
set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
@@ -82,34 +105,55 @@ add_executable(${PROJECT_NAME}
|
|||||||
src/app.cpp
|
src/app.cpp
|
||||||
src/debug_collector.cpp
|
src/debug_collector.cpp
|
||||||
src/camera.cpp
|
src/camera.cpp
|
||||||
|
src/config.cpp
|
||||||
|
src/dev_panel.cpp
|
||||||
|
src/gameplay/biome.cpp
|
||||||
src/gameplay/chunk.cpp
|
src/gameplay/chunk.cpp
|
||||||
|
src/gameplay/chunk_generator.cpp
|
||||||
src/gameplay/player.cpp
|
src/gameplay/player.cpp
|
||||||
|
src/gameplay/tree.cpp
|
||||||
src/gameplay/world.cpp
|
src/gameplay/world.cpp
|
||||||
src/input.cpp
|
src/input.cpp
|
||||||
src/map_table.cpp
|
src/map_table.cpp
|
||||||
src/renderer.cpp
|
src/renderer.cpp
|
||||||
src/shader.cpp
|
src/shader.cpp
|
||||||
src/texture_manager.cpp
|
src/texture_manager.cpp
|
||||||
|
src/tools/cubed_random.cpp
|
||||||
src/tools/math_tools.cpp
|
src/tools/math_tools.cpp
|
||||||
src/tools/shader_tools.cpp
|
src/tools/shader_tools.cpp
|
||||||
src/tools/font.cpp
|
src/tools/font.cpp
|
||||||
src/tools/log.cpp
|
|
||||||
src/tools/perlin_noise.cpp
|
src/tools/perlin_noise.cpp
|
||||||
src/ui/text.cpp
|
src/ui/text.cpp
|
||||||
src/window.cpp
|
src/window.cpp
|
||||||
|
src/gameplay/builders/biome_builder.cpp
|
||||||
|
src/gameplay/builders/plain_builder.cpp
|
||||||
|
src/gameplay/builders/mountain_builder.cpp
|
||||||
|
src/gameplay/builders/river_builder.cpp
|
||||||
|
src/gameplay/builders/desert_builder.cpp
|
||||||
|
src/gameplay/builders/forest_builder.cpp
|
||||||
|
src/gameplay/cave_carver.cpp
|
||||||
|
src/gameplay/cave_path.cpp
|
||||||
|
src/gameplay/builders/snowy_plain_builder.cpp
|
||||||
|
src/gameplay/river_worm.cpp
|
||||||
|
src/gameplay/river_path.cpp
|
||||||
|
src/block.cpp
|
||||||
|
src/gameplay/vertex_data.cpp
|
||||||
|
src/gameplay/builders/ocean_builder.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
message(STATUS "Building with AddressSanitizer enabled for target: ${PROJECT_NAME}")
|
message(STATUS "Building with AddressSanitizer enabled for target: ${PROJECT_NAME}")
|
||||||
|
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE
|
target_compile_options(${PROJECT_NAME} PRIVATE
|
||||||
-fsanitize=address
|
#-fsanitize=address
|
||||||
|
#-fsanitize=thread
|
||||||
-fno-omit-frame-pointer
|
-fno-omit-frame-pointer
|
||||||
-g
|
-g
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_options(${PROJECT_NAME} PRIVATE
|
target_link_options(${PROJECT_NAME} PRIVATE
|
||||||
-fsanitize=address
|
#-fsanitize=address
|
||||||
|
#-fsanitize=thread
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE DEBUG_MODE)
|
target_compile_definitions(${PROJECT_NAME} PRIVATE DEBUG_MODE)
|
||||||
@@ -132,8 +176,15 @@ target_link_libraries(${PROJECT_NAME}
|
|||||||
OpenGL::GL
|
OpenGL::GL
|
||||||
soil2
|
soil2
|
||||||
Freetype::Freetype
|
Freetype::Freetype
|
||||||
|
tomlplusplus::tomlplusplus
|
||||||
|
imgui
|
||||||
|
tbb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
# target_link_libraries(${PROJECT_NAME} PRIVATE tbb)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
@@ -151,3 +202,19 @@ if (UNIX AND NOT APPLE)
|
|||||||
|
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE ${EGL_CFLAGS_OTHER} ${Wayland_CFLAGS_OTHER})
|
target_compile_options(${PROJECT_NAME} PRIVATE ${EGL_CFLAGS_OTHER} ${Wayland_CFLAGS_OTHER})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
foreach(TBB_LIB IN ITEMS tbb tbbmalloc tbbmalloc_proxy)
|
||||||
|
if(TARGET ${TBB_LIB})
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${PROJECT_NAME} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
$<TARGET_FILE:${TBB_LIB}>
|
||||||
|
$<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||||
|
COMMENT "Copying ${TBB_LIB}.dll"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "Target ${TBB_LIB} not found, skipping copy")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
21
README.md
@@ -1,2 +1,21 @@
|
|||||||
## What's it
|
## What's it
|
||||||
A cube game like Minecraft, using C++ and OpenGL.
|
A cube game like Minecraft, using C++ and OpenGL.
|
||||||
|
|
||||||
|
## Build Guide
|
||||||
|
### Prerequisites
|
||||||
|
- **CMake** (>= 3.24)
|
||||||
|
- **C++ 23** compatible compiler
|
||||||
|
### Step
|
||||||
|
1. Clone the repository
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/zhenyan121/Cubed.git && cd Cubed
|
||||||
|
```
|
||||||
|
2. Configure with CMake
|
||||||
|
```bash
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake -G "Ninja" ..
|
||||||
|
```
|
||||||
|
3. Build the project
|
||||||
|
```bash
|
||||||
|
ninja
|
||||||
|
```
|
||||||
10
assets/data/block/air.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 0
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = true
|
||||||
|
is_gas = true
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = true
|
||||||
|
is_transitional = false
|
||||||
|
is_transparent = true
|
||||||
|
name = 'air'
|
||||||
10
assets/data/block/dirt.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 2
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = false
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = false
|
||||||
|
is_transitional = true
|
||||||
|
is_transparent = false
|
||||||
|
name = 'dirt'
|
||||||
10
assets/data/block/grass.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 9
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = true
|
||||||
|
is_discard = true
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = true
|
||||||
|
is_transitional = false
|
||||||
|
is_transparent = true
|
||||||
|
name = 'grass'
|
||||||
10
assets/data/block/grass_block.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 1
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = false
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = false
|
||||||
|
is_transitional = true
|
||||||
|
is_transparent = false
|
||||||
|
name = 'grass_block'
|
||||||
10
assets/data/block/leaf.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 6
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = true
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = false
|
||||||
|
is_transitional = false
|
||||||
|
is_transparent = true
|
||||||
|
name = 'leaf'
|
||||||
10
assets/data/block/log.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 5
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = false
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = false
|
||||||
|
is_transitional = false
|
||||||
|
is_transparent = false
|
||||||
|
name = 'log'
|
||||||
10
assets/data/block/sand.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 4
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = false
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = false
|
||||||
|
is_transitional = true
|
||||||
|
is_transparent = false
|
||||||
|
name = 'sand'
|
||||||
10
assets/data/block/snowy_grass_block.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 8
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = false
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = false
|
||||||
|
is_transitional = true
|
||||||
|
is_transparent = false
|
||||||
|
name = 'snowy_grass_block'
|
||||||
10
assets/data/block/stone.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 3
|
||||||
|
is_blend = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = false
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = false
|
||||||
|
is_passable = false
|
||||||
|
is_transitional = true
|
||||||
|
is_transparent = false
|
||||||
|
name = 'stone'
|
||||||
10
assets/data/block/template.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
name = "template"
|
||||||
|
id = 0
|
||||||
|
is_liquid = false
|
||||||
|
is_gas = false
|
||||||
|
is_passable = false
|
||||||
|
is_cross_plane = false
|
||||||
|
is_transparent = false
|
||||||
|
is_discard = false
|
||||||
|
is_blend = false
|
||||||
|
is_transitional = false
|
||||||
10
assets/data/block/water.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
id = 7
|
||||||
|
is_blend = true
|
||||||
|
is_cross_plane = false
|
||||||
|
is_discard = false
|
||||||
|
is_gas = false
|
||||||
|
is_liquid = true
|
||||||
|
is_passable = true
|
||||||
|
is_transitional = false
|
||||||
|
is_transparent = true
|
||||||
|
name = 'water'
|
||||||
28
assets/shaders/block_accumulation_f_shader.glsl
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
layout (location = 0) out vec4 accum;
|
||||||
|
layout (location = 1) out float reveal;
|
||||||
|
|
||||||
|
in vec2 tc;
|
||||||
|
flat in int tex_layer;
|
||||||
|
in float v_depth;
|
||||||
|
layout (binding = 0) uniform sampler2DArray samp;
|
||||||
|
|
||||||
|
float weight(float z, float a) {
|
||||||
|
float intermediate = 0.03 / (1e-5 + pow(z / 200.0, 4.0));
|
||||||
|
|
||||||
|
return a * clamp(intermediate, 1e-2, 3e2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 color = texture(samp, vec3(tc, tex_layer));
|
||||||
|
float alpha = color.a;
|
||||||
|
if (alpha < 1e-4) discard;
|
||||||
|
|
||||||
|
|
||||||
|
float w = weight(v_depth, alpha);
|
||||||
|
|
||||||
|
accum = vec4(color.rgb * alpha * w, alpha * w);
|
||||||
|
|
||||||
|
reveal = alpha;
|
||||||
|
}
|
||||||
21
assets/shaders/block_accumulation_v_shader.glsl
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 pos;
|
||||||
|
layout (location = 1) in vec2 texCoord;
|
||||||
|
layout (location = 2) in float layer;
|
||||||
|
out vec2 tc;
|
||||||
|
flat out int tex_layer;
|
||||||
|
out float v_depth;
|
||||||
|
|
||||||
|
uniform mat4 mv_matrix;
|
||||||
|
uniform mat4 proj_matrix;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec4 view_pos = mv_matrix * vec4(pos, 1.0);
|
||||||
|
gl_Position = proj_matrix * view_pos;
|
||||||
|
tc = texCoord;
|
||||||
|
tex_layer = int(layer);
|
||||||
|
v_depth = -view_pos.z;
|
||||||
|
}
|
||||||
19
assets/shaders/block_composite_f_shader.glsl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
uniform sampler2D u_accumTex;
|
||||||
|
uniform sampler2D u_revealTex;
|
||||||
|
in vec2 TexCoord;
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 a = texture(u_accumTex, TexCoord);
|
||||||
|
float r = texture(u_revealTex, TexCoord).r;
|
||||||
|
|
||||||
|
if (a.a < 1e-4) discard;
|
||||||
|
|
||||||
|
vec3 color = a.rgb / max(a.a, 1e-5);
|
||||||
|
float transmittance = r;
|
||||||
|
float opacity = 1.0 - transmittance;
|
||||||
|
|
||||||
|
FragColor = vec4(color * opacity, opacity);
|
||||||
|
}
|
||||||
11
assets/shaders/block_composite_v_shader.glsl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
layout (location = 0) in vec2 pos;
|
||||||
|
layout (location = 1) in vec2 texCoord;
|
||||||
|
|
||||||
|
out vec2 TexCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(pos.x, pos.y, 0.0, 1.0);
|
||||||
|
TexCoord = texCoord;
|
||||||
|
}
|
||||||
@@ -1,12 +1,125 @@
|
|||||||
#version 460
|
#version 460
|
||||||
|
|
||||||
in vec2 tc;
|
in vec2 tc;
|
||||||
|
in vec3 normal;
|
||||||
|
in vec3 vert_pos;
|
||||||
|
in vec4 FragPosLightSpace;
|
||||||
flat in int tex_layer;
|
flat in int tex_layer;
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
layout (binding = 0) uniform sampler2D shadowMap;
|
||||||
|
layout (binding = 1) uniform sampler2DArray samp;
|
||||||
|
|
||||||
|
uniform float ambientStrength;
|
||||||
|
uniform vec3 sunlightColor;
|
||||||
|
uniform vec3 sunlightDir;
|
||||||
|
uniform bool shader_on;
|
||||||
|
uniform int shadowMode;
|
||||||
|
|
||||||
|
const vec2 poissonDisk[8] = vec2[](
|
||||||
|
vec2( 0.1440, 0.7659), vec2(-0.5761, 0.4479),
|
||||||
|
vec2(-0.3220, -0.6058), vec2( 0.5693, -0.4048),
|
||||||
|
vec2(-0.1276, 0.1657), vec2(-0.0649, -0.0165),
|
||||||
|
vec2( 0.2773, -0.0305), vec2(-0.1134, -0.2122)
|
||||||
|
);
|
||||||
|
|
||||||
|
float random(vec3 seed) {
|
||||||
|
return fract(sin(dot(seed, vec3(12.9898,78.233,45.5432))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
float ShadowCalculation(vec4 fragPosLightSpace, vec3 norm, vec3 lightDir)
|
||||||
|
{
|
||||||
|
|
||||||
|
vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w;
|
||||||
|
|
||||||
|
projCoords = projCoords * 0.5 + 0.5;
|
||||||
|
if (projCoords.x < 0.0 || projCoords.x > 1.0 ||
|
||||||
|
projCoords.y < 0.0 || projCoords.y > 1.0 ||
|
||||||
|
projCoords.z < 0.0 || projCoords.z > 1.0) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
float currentDepth = projCoords.z;
|
||||||
|
vec2 texelSize = 1.0 / vec2(textureSize(shadowMap, 0));
|
||||||
|
float shadow = 0.0;
|
||||||
|
float bias =
|
||||||
|
max(
|
||||||
|
0.0003,
|
||||||
|
0.001 * (1.0 - dot(norm, lightDir))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (shadowMode == 0) {
|
||||||
|
vec3 seed = vert_pos * 37.0 + sin(vert_pos * 91.7) * 13.0;
|
||||||
|
float angle = random(seed) * 6.2831853;; // 2*PI
|
||||||
|
float s = sin(angle), c = cos(angle);
|
||||||
|
mat2 rot = mat2(c, -s, s, c);
|
||||||
|
|
||||||
|
float radius = 0.7;
|
||||||
|
|
||||||
|
|
||||||
|
const int samples = 8;
|
||||||
|
for (int i = 0; i < samples; ++i) {
|
||||||
|
vec2 offset = rot * poissonDisk[i] * radius * texelSize;
|
||||||
|
float pcfDepth = texture(shadowMap, projCoords.xy + offset).r;
|
||||||
|
shadow += (currentDepth - bias > pcfDepth ? 1.0 : 0.0);
|
||||||
|
}
|
||||||
|
shadow /= float(samples);
|
||||||
|
} else if (shadowMode == 1) {
|
||||||
|
for (int x = -1; x <= 1; ++x) {
|
||||||
|
for (int y = -1; y <= 1; ++y) {
|
||||||
|
vec2 offset = vec2(x, y) * texelSize;
|
||||||
|
float pcfDepth = texture(shadowMap, projCoords.xy + offset).r;
|
||||||
|
shadow += (currentDepth - bias > pcfDepth ? 1.0 : 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shadow /= 9.0;
|
||||||
|
} else if (shadowMode == 2) {
|
||||||
|
// pcf off
|
||||||
|
float pcfDepth =
|
||||||
|
texture(shadowMap, projCoords.xy).r;
|
||||||
|
|
||||||
|
shadow =
|
||||||
|
currentDepth - bias > pcfDepth
|
||||||
|
? 1.0
|
||||||
|
: 0.0;
|
||||||
|
} else {
|
||||||
|
float pcfDepth =
|
||||||
|
texture(shadowMap, projCoords.xy).r;
|
||||||
|
|
||||||
|
shadow =
|
||||||
|
currentDepth - bias > pcfDepth
|
||||||
|
? 1.0
|
||||||
|
: 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return shadow;
|
||||||
|
}
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2DArray samp;
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
color = texture(samp, vec3(tc, tex_layer));
|
vec4 objectColor = texture(samp, vec3(tc, tex_layer));
|
||||||
|
|
||||||
|
if (objectColor.a < 0.8) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
if (!shader_on) {
|
||||||
|
color = objectColor;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 lightDir = normalize(-sunlightDir);
|
||||||
|
|
||||||
|
vec3 ambient = ambientStrength * sunlightColor;
|
||||||
|
|
||||||
|
vec3 norm = normalize(normal);
|
||||||
|
|
||||||
|
float diff = max(dot(norm, lightDir), 0.0);
|
||||||
|
|
||||||
|
vec3 diffuse = diff * sunlightColor;
|
||||||
|
|
||||||
|
float shadow = ShadowCalculation(FragPosLightSpace, norm, lightDir);
|
||||||
|
|
||||||
|
color = vec4((ambient + (1.0 - shadow) * (diffuse)) * objectColor.rgb, objectColor.a);
|
||||||
|
|
||||||
//color = varyingColor;
|
//color = varyingColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
layout (location = 0) in vec3 pos;
|
layout (location = 0) in vec3 pos;
|
||||||
layout (location = 1) in vec2 texCoord;
|
layout (location = 1) in vec2 texCoord;
|
||||||
layout (location = 2) in float layer;
|
layout (location = 2) in float layer;
|
||||||
|
layout (location = 3) in vec3 aNormal;
|
||||||
out vec2 tc;
|
out vec2 tc;
|
||||||
|
out vec3 normal;
|
||||||
|
out vec3 vert_pos;
|
||||||
flat out int tex_layer;
|
flat out int tex_layer;
|
||||||
|
out vec4 FragPosLightSpace;
|
||||||
|
|
||||||
mat4 buildRotateX(float rad);
|
mat4 buildRotateX(float rad);
|
||||||
mat4 buildRotateY(float rad);
|
mat4 buildRotateY(float rad);
|
||||||
@@ -13,13 +17,21 @@ mat4 buildTranslate(float x, float y, float z);
|
|||||||
|
|
||||||
uniform mat4 mv_matrix;
|
uniform mat4 mv_matrix;
|
||||||
uniform mat4 proj_matrix;
|
uniform mat4 proj_matrix;
|
||||||
|
uniform mat4 norm_matrix;
|
||||||
|
uniform mat4 lightSpaceMatrix;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_Position = proj_matrix * mv_matrix * vec4(pos, 1.0);
|
vec4 viewPos = mv_matrix * vec4(pos, 1.0);
|
||||||
|
|
||||||
|
vert_pos = pos;
|
||||||
|
|
||||||
tc = texCoord;
|
tc = texCoord;
|
||||||
|
|
||||||
tex_layer = int(layer);
|
tex_layer = int(layer);
|
||||||
|
|
||||||
|
normal = mat3(norm_matrix) * aNormal;
|
||||||
|
FragPosLightSpace = lightSpaceMatrix * vec4(pos, 1.0);
|
||||||
|
gl_Position = proj_matrix * viewPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
mat4 buildTranslate(float x, float y, float z) {
|
mat4 buildTranslate(float x, float y, float z) {
|
||||||
|
|||||||
16
assets/shaders/depth_fragment_shader.glsl
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
in vec2 tc;
|
||||||
|
flat in int tex_layer;
|
||||||
|
layout (binding = 1) uniform sampler2DArray samp;
|
||||||
|
|
||||||
|
uniform bool is_discard_tranparent;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
if (is_discard_tranparent) {
|
||||||
|
vec4 texColor = texture(samp, vec3(tc, tex_layer));
|
||||||
|
if (texColor.a < 0.8)
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
//gl_FragDepth = gl_FragCoord.z;
|
||||||
|
}
|
||||||
12
assets/shaders/depth_shader.glsl
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#version 460
|
||||||
|
layout (location = 0) in vec3 pos;
|
||||||
|
layout (location = 1) in vec2 texCoord;
|
||||||
|
layout (location = 2) in float layer;
|
||||||
|
uniform mat4 lightSpaceMatrix;
|
||||||
|
out vec2 tc;
|
||||||
|
flat out int tex_layer;
|
||||||
|
void main() {
|
||||||
|
tc = texCoord;
|
||||||
|
tex_layer = int(layer);
|
||||||
|
gl_Position = lightSpaceMatrix * vec4(pos, 1.0);
|
||||||
|
}
|
||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
out vec4 frag_color;
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
uniform vec3 color;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
|
|
||||||
frag_color = vec4(0.529, 0.808, 0.922, 1.0);
|
frag_color = vec4(color, 1.0);
|
||||||
|
|
||||||
}
|
}
|
||||||
35
assets/shaders/under_water_f_shader.glsl
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
in vec2 TexCoord;
|
||||||
|
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
uniform sampler2D u_sceneTexture;
|
||||||
|
uniform float u_time;
|
||||||
|
uniform bool u_underwater;
|
||||||
|
uniform vec3 u_waterColor;
|
||||||
|
uniform float u_fogDensity;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 original = texture(u_sceneTexture, TexCoord);
|
||||||
|
|
||||||
|
if (!u_underwater) {
|
||||||
|
FragColor = original;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 distoredUV = TexCoord;
|
||||||
|
float strength = 0.003;
|
||||||
|
distoredUV.x += sin(TexCoord.y * 15.0 + u_time * 5.0) * strength;
|
||||||
|
distoredUV.y += cos(TexCoord.x * 15.0 + u_time * 4.3) * strength;
|
||||||
|
distoredUV = clamp(distoredUV, 0.001, 0.999);
|
||||||
|
vec4 distorted = texture(u_sceneTexture, distoredUV);
|
||||||
|
|
||||||
|
float caustic = 0.9 + 0.1 * sin(TexCoord.x * 20.0 + u_time) * cos(TexCoord.y * 20.0 + u_time * 1.2);
|
||||||
|
vec3 causticLight = vec3(caustic, caustic * 0.95, caustic * 0.9);
|
||||||
|
//vec3 causticLight = vec3(1.0);
|
||||||
|
float fogFactor = clamp(1.0 - (TexCoord.y * u_fogDensity * 10.0), 0.0, 1.0);
|
||||||
|
vec3 mixed = mix(u_waterColor, distorted.rgb * causticLight, fogFactor);
|
||||||
|
|
||||||
|
FragColor = vec4(mixed, 1.0);
|
||||||
|
}
|
||||||
11
assets/shaders/under_water_v_shader.glsl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
layout (location = 0) in vec2 pos;
|
||||||
|
layout (location = 1) in vec2 texCoord;
|
||||||
|
|
||||||
|
out vec2 TexCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(pos.x, pos.y, 0.0, 1.0);
|
||||||
|
TexCoord = texCoord;
|
||||||
|
}
|
||||||
BIN
assets/texture/block/grass/cross.png
Normal file
|
After Width: | Height: | Size: 277 B |
|
Before Width: | Height: | Size: 563 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 563 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 563 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 563 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 381 B |
BIN
assets/texture/block/leaf/back.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
assets/texture/block/leaf/base.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
assets/texture/block/leaf/front.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
assets/texture/block/leaf/left.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
assets/texture/block/leaf/right.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
assets/texture/block/leaf/top.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
assets/texture/block/log/back.png
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
assets/texture/block/log/base.png
Normal file
|
After Width: | Height: | Size: 215 B |
BIN
assets/texture/block/log/front.png
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
assets/texture/block/log/left.png
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
assets/texture/block/log/right.png
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
assets/texture/block/log/top.png
Normal file
|
After Width: | Height: | Size: 215 B |
BIN
assets/texture/block/sand/back.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
assets/texture/block/sand/base.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
assets/texture/block/sand/front.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
assets/texture/block/sand/left.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
assets/texture/block/sand/right.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
assets/texture/block/sand/top.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
assets/texture/block/snowy_grass_block/back.png
Normal file
|
After Width: | Height: | Size: 568 B |
BIN
assets/texture/block/snowy_grass_block/base.png
Normal file
|
After Width: | Height: | Size: 482 B |
BIN
assets/texture/block/snowy_grass_block/front.png
Normal file
|
After Width: | Height: | Size: 568 B |
BIN
assets/texture/block/snowy_grass_block/left.png
Normal file
|
After Width: | Height: | Size: 568 B |
BIN
assets/texture/block/snowy_grass_block/right.png
Normal file
|
After Width: | Height: | Size: 568 B |
BIN
assets/texture/block/snowy_grass_block/top.png
Normal file
|
After Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 418 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 418 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 418 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 418 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 418 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 418 B |
BIN
assets/texture/block/water/back.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
assets/texture/block/water/base.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
assets/texture/block/water/front.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
assets/texture/block/water/left.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
assets/texture/block/water/right.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
assets/texture/block/water/top.png
Normal file
|
After Width: | Height: | Size: 261 B |
BIN
assets/texture/item/block/air.png
Normal file
|
After Width: | Height: | Size: 99 B |
BIN
assets/texture/item/block/dirt.png
Normal file
|
After Width: | Height: | Size: 882 B |
BIN
assets/texture/item/block/grass.png
Normal file
|
After Width: | Height: | Size: 277 B |
BIN
assets/texture/item/block/grass_block.png
Normal file
|
After Width: | Height: | Size: 499 B |
BIN
assets/texture/item/block/leaf.png
Normal file
|
After Width: | Height: | Size: 890 B |
BIN
assets/texture/item/block/log.png
Normal file
|
After Width: | Height: | Size: 874 B |
BIN
assets/texture/item/block/sand.png
Normal file
|
After Width: | Height: | Size: 877 B |
BIN
assets/texture/item/block/snowy_grass_block.png
Normal file
|
After Width: | Height: | Size: 914 B |
BIN
assets/texture/item/block/stone.png
Normal file
|
After Width: | Height: | Size: 915 B |
BIN
assets/texture/item/block/water.png
Normal file
|
After Width: | Height: | Size: 874 B |
@@ -1,19 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
struct AABB {
|
struct AABB {
|
||||||
glm::vec3 min{0.0f, 0.0f, 0.0f};
|
glm::vec3 min{0.0f, 0.0f, 0.0f};
|
||||||
glm::vec3 max{0.0f, 0.0f, 0.0f};
|
glm::vec3 max{0.0f, 0.0f, 0.0f};
|
||||||
|
|
||||||
AABB(glm::vec3 min_point, glm::vec3 max_point):
|
AABB(glm::vec3 min_point, glm::vec3 max_point)
|
||||||
min(min_point),
|
: min(min_point), max(max_point) {}
|
||||||
max(max_point)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool intersects(const AABB& other) const {
|
bool intersects(const AABB& other) const {
|
||||||
return (min.x <= other.max.x && max.x >= other.min.x) &&
|
return (min.x <= other.max.x && max.x >= other.min.x) &&
|
||||||
(min.y <= other.max.y && max.y >= other.min.y) &&
|
(min.y <= other.max.y && max.y >= other.min.y) &&
|
||||||
(min.z <= other.max.z && max.z >= other.min.z);
|
(min.z <= other.max.z && max.z >= other.min.z);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
@@ -1,49 +1,68 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <Cubed/camera.hpp>
|
#include "Cubed/camera.hpp"
|
||||||
#include <Cubed/gameplay/world.hpp>
|
#include "Cubed/dev_panel.hpp"
|
||||||
#include <Cubed/input.hpp>
|
#include "Cubed/gameplay/world.hpp"
|
||||||
#include <Cubed/renderer.hpp>
|
#include "Cubed/renderer.hpp"
|
||||||
#include <Cubed/texture_manager.hpp>
|
#include "Cubed/texture_manager.hpp"
|
||||||
#include <Cubed/window.hpp>
|
#include "Cubed/window.hpp"
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
public:
|
public:
|
||||||
App();
|
App();
|
||||||
~App();
|
~App();
|
||||||
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos);
|
static void cursor_position_callback(GLFWwindow* window, double xpos,
|
||||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
double ypos);
|
||||||
static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods);
|
static void key_callback(GLFWwindow* window, int key, int scancode,
|
||||||
|
int action, int mods);
|
||||||
|
static void mouse_button_callback(GLFWwindow* window, int button,
|
||||||
|
int action, int mods);
|
||||||
static void window_focus_callback(GLFWwindow* window, int focused);
|
static void window_focus_callback(GLFWwindow* window, int focused);
|
||||||
static void window_reshape_callback(GLFWwindow* window, int new_width, int new_height);
|
static void window_reshape_callback(GLFWwindow* window, int new_width,
|
||||||
|
int new_height);
|
||||||
|
static void mouse_scroll_callback(GLFWwindow* window, double xoffset,
|
||||||
|
double yoffset);
|
||||||
|
static void cursor_enter_callback(GLFWwindow* window, int entered);
|
||||||
|
static void char_callback(GLFWwindow* window, unsigned int ch);
|
||||||
static int start_cubed_application(int argc, char** argv);
|
static int start_cubed_application(int argc, char** argv);
|
||||||
|
|
||||||
static unsigned int seed();
|
static unsigned int seed();
|
||||||
static float delte_time();
|
static float delte_time();
|
||||||
static float get_fps();
|
static float get_fps();
|
||||||
|
|
||||||
|
Camera& camera();
|
||||||
|
DevPanel& dev_panel();
|
||||||
|
Renderer& renderer();
|
||||||
|
TextureManager& texture_manager();
|
||||||
|
Window& window();
|
||||||
|
World& world();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Camera m_camera;
|
Camera m_camera;
|
||||||
TextureManager m_texture_manager;
|
TextureManager m_texture_manager;
|
||||||
World m_world;
|
World m_world;
|
||||||
Renderer m_renderer{m_camera, m_world, m_texture_manager};
|
DevPanel m_dev_panel{*this};
|
||||||
|
Renderer m_renderer{m_camera, m_world, m_texture_manager, m_dev_panel};
|
||||||
|
|
||||||
Window m_window{m_renderer};
|
Window m_window{m_renderer};
|
||||||
|
|
||||||
inline static double last_time = glfwGetTime();
|
inline static double last_time = glfwGetTime();
|
||||||
inline static double current_time = glfwGetTime();
|
inline static double current_time = glfwGetTime();
|
||||||
inline static double delta_time = 0.0f;
|
inline static double delta_time = 0.0f;
|
||||||
inline static double fps_time_count = 0.0f;
|
inline static double fps_time_count = 0.0f;
|
||||||
inline static int frame_count = 0;
|
inline static int frame_count = 0;
|
||||||
inline static int fps = 0;
|
inline static int fps = 0;
|
||||||
inline static unsigned int m_seed = 0;
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
auto init_camera();
|
auto init_camera();
|
||||||
auto init_texture();
|
auto init_texture();
|
||||||
auto init_world();
|
auto init_world();
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
void run();
|
void run();
|
||||||
void update();
|
void update();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
@@ -1,35 +1,38 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <glad/glad.h>
|
|
||||||
#include <GLFW/glfw3.h>
|
namespace Cubed {
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
|
|
||||||
|
|
||||||
class Camera {
|
class Camera {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_firse_mouse = true;
|
bool m_firse_mouse = true;
|
||||||
Player* m_player;
|
Player* m_player;
|
||||||
float m_last_mouse_x, m_last_mouse_y;
|
float m_last_mouse_x, m_last_mouse_y;
|
||||||
glm::vec3 m_camera_pos;
|
glm::vec3 m_camera_pos;
|
||||||
|
bool m_under_water = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Camera();
|
Camera();
|
||||||
|
|
||||||
void update_move_camera();
|
void update_move_camera();
|
||||||
|
|
||||||
void camera_init(Player* player);
|
void camera_init(Player* player);
|
||||||
|
void hot_reload();
|
||||||
void reset_camera();
|
void reset_camera();
|
||||||
void update_cursor_position_camera(double xpos, double ypos);
|
void update_cursor_position_camera(double xpos, double ypos);
|
||||||
|
|
||||||
const glm::mat4 get_camera_lookat() const;
|
const glm::mat4 get_camera_lookat() const;
|
||||||
const glm::vec3& get_camera_pos() const;
|
const glm::vec3& get_camera_pos() const;
|
||||||
|
|
||||||
|
bool is_under_water() const;
|
||||||
|
glm::vec3 get_camera_front() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
|
|||||||
@@ -1,150 +1,107 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
constexpr int WORLD_SIZE_Y = 256;
|
#include "Cubed/tools/cubed_assert.hpp"
|
||||||
constexpr int MAX_BLOCK_NUM = 4;
|
|
||||||
constexpr int MAX_UI_NUM = 1;
|
|
||||||
|
|
||||||
constexpr int CHUCK_SIZE = 16;
|
#include <toml++/toml.hpp>
|
||||||
constexpr int DISTANCE = 16;
|
|
||||||
constexpr int MAX_BLOCK_STATUS = 1;
|
|
||||||
constexpr int MAX_CHARACTER = 128;
|
|
||||||
constexpr float NORMAL_FOV = 70.0f;
|
|
||||||
|
|
||||||
constexpr int SEED = 999;
|
namespace Cubed {
|
||||||
|
|
||||||
constexpr float VERTICES_POS[6][6][3] = {
|
template <typename T>
|
||||||
// ===== front (z = +1) =====
|
concept TomlValueType =
|
||||||
0.0f, 0.0f, 1.0f, // bottom left
|
std::same_as<T, int> || std::same_as<T, bool> || std::same_as<T, double> ||
|
||||||
0.0f, 1.0f, 1.0f, // top left
|
std::same_as<T, const char*> || std::same_as<T, toml::date> ||
|
||||||
1.0f, 1.0f, 1.0f, // top right
|
std::same_as<T, toml::time> || std::same_as<T, toml::date_time> ||
|
||||||
1.0f, 1.0f, 1.0f, // top right
|
std::same_as<T, std::string>;
|
||||||
1.0f, 0.0f, 1.0f, // bottom right
|
|
||||||
0.0f, 0.0f, 1.0f, // bottom left
|
|
||||||
// ===== right (x = +1) =====
|
|
||||||
1.0f, 0.0f, 1.0f, // bottom front
|
|
||||||
1.0f, 0.0f, 0.0f, // bottom back
|
|
||||||
1.0f, 1.0f, 0.0f, // top back
|
|
||||||
1.0f, 1.0f, 0.0f, // top back
|
|
||||||
1.0f, 1.0f, 1.0f, // top front
|
|
||||||
1.0f, 0.0f, 1.0f, // bottom front
|
|
||||||
// ===== back (z = -1) =====
|
|
||||||
0.0f, 0.0f, 0.0f, // bottom left
|
|
||||||
1.0f, 0.0f, 0.0f, // bottom right
|
|
||||||
1.0f, 1.0f, 0.0f, // top right
|
|
||||||
1.0f, 1.0f, 0.0f, // top right
|
|
||||||
0.0f, 1.0f, 0.0f, // top left
|
|
||||||
0.0f, 0.0f, 0.0f, // bottom left
|
|
||||||
// ===== left (x = -1) =====
|
|
||||||
0.0f, 0.0f, 0.0f, // bottom back
|
|
||||||
0.0f, 0.0f, 1.0f, // bottom front
|
|
||||||
0.0f, 1.0f, 1.0f, // top front
|
|
||||||
0.0f, 1.0f, 1.0f, // top front
|
|
||||||
0.0f, 1.0f, 0.0f, // top back
|
|
||||||
0.0f, 0.0f, 0.0f, // bottom back
|
|
||||||
// ===== top (y = +1) =====
|
|
||||||
0.0f, 1.0f, 0.0f, // back left
|
|
||||||
1.0f, 1.0f, 0.0f, // back right
|
|
||||||
1.0f, 1.0f, 1.0f, // front right
|
|
||||||
1.0f, 1.0f, 1.0f, // front right
|
|
||||||
0.0f, 1.0f, 1.0f, // front left
|
|
||||||
0.0f, 1.0f, 0.0f, // back left
|
|
||||||
// ===== bottom (y = -1) =====
|
|
||||||
0.0f, 0.0f, 1.0f, // front left
|
|
||||||
1.0f, 0.0f, 1.0f, // front right
|
|
||||||
1.0f, 0.0f, 0.0f, // back right
|
|
||||||
1.0f, 0.0f, 0.0f, // back right
|
|
||||||
0.0f, 0.0f, 0.0f, // back left
|
|
||||||
0.0f, 0.0f, 1.0f // front left
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr float TEX_COORDS[6][6][2] = {
|
class Config {
|
||||||
// ===== front (z = +1) =====
|
public:
|
||||||
0.0f, 1.0f, // bottom left
|
Config();
|
||||||
0.0f, 0.0f, // top left
|
~Config();
|
||||||
1.0f, 0.0f, // top right
|
|
||||||
1.0f, 0.0f, // top right
|
static Config& get();
|
||||||
1.0f, 1.0f, // bottom right
|
|
||||||
0.0f, 1.0f, // bottom left
|
toml::table& table();
|
||||||
// ===== right (x = +1) =====
|
|
||||||
0.0f, 1.0f, // bottom front
|
void load_or_create_config();
|
||||||
1.0f, 1.0f, // bottom back
|
void save_to_file();
|
||||||
1.0f, 0.0f, // top back
|
|
||||||
1.0f, 0.0f, // top back
|
template <TomlValueType T> T get(std::string_view key) const {
|
||||||
0.0f, 0.0f, // top front
|
size_t cur = 0;
|
||||||
0.0f, 1.0f, // bottom front
|
auto pos = key.find('.');
|
||||||
// ===== back (z = -1) =====
|
const toml::table* table = &m_tbl;
|
||||||
1.0f, 1.0f, // bottom left
|
while (pos != std::string_view::npos) {
|
||||||
0.0f, 1.0f, // bottom right
|
std::string_view s = key.substr(cur, pos - cur);
|
||||||
0.0f, 0.0f, // top right
|
if (s.empty()) {
|
||||||
0.0f, 0.0f, // top right
|
Logger::error("Empty key/table name in path '{}'", key);
|
||||||
1.0f, 0.0f, // top left
|
ASSERT(false);
|
||||||
1.0f, 1.0f, // bottom left
|
std::abort();
|
||||||
// ===== left (x = -1) =====
|
}
|
||||||
1.0f, 1.0f, // bottom back
|
cur = pos + 1;
|
||||||
0.0f, 1.0f, // bottom front
|
pos = key.find('.', cur);
|
||||||
0.0f, 0.0f, // top front
|
if (auto* next = (*table)[s].as_table()) {
|
||||||
0.0f, 0.0f, // top front
|
table = next;
|
||||||
1.0f, 0.0f, // top back
|
} else {
|
||||||
1.0f, 1.0f, // bottom back
|
Logger::error("Can't find table {}", s);
|
||||||
// ===== top (y = +1) =====
|
ASSERT(false);
|
||||||
0.0f, 0.0f, // back left
|
std::abort();
|
||||||
1.0f, 0.0f, // back right
|
}
|
||||||
1.0f, 1.0f, // front right
|
}
|
||||||
1.0f, 1.0f, // front right
|
std::string_view n_key = key.substr(cur);
|
||||||
0.0f, 1.0f, // front left
|
if (n_key.empty()) {
|
||||||
0.0f, 0.0f, // back left
|
Logger::error("Trailing dot in path '{}'", key);
|
||||||
// ===== bottom (y = -1) =====
|
ASSERT(false);
|
||||||
0.0f, 0.0f, // front left
|
std::abort();
|
||||||
1.0f, 0.0f, // front right
|
}
|
||||||
1.0f, 1.0f, // back right
|
auto opt = (*table)[n_key].value<T>();
|
||||||
1.0f, 1.0f, // back right
|
if (opt) {
|
||||||
0.0f, 1.0f, // back left
|
return *opt;
|
||||||
0.0f, 0.0f, // front left
|
} else {
|
||||||
|
Logger::error("Can't find key {}", n_key);
|
||||||
|
ASSERT(false);
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template <typename T> void set(std::string_view key, T&& val) {
|
||||||
|
if constexpr (!TomlValueType<std::decay_t<T>>) {
|
||||||
|
static_assert(false, "Type Not Support");
|
||||||
|
}
|
||||||
|
size_t cur = 0;
|
||||||
|
auto pos = key.find('.');
|
||||||
|
toml::table* table = &m_tbl;
|
||||||
|
while (pos != std::string_view::npos) {
|
||||||
|
std::string_view s = key.substr(cur, pos - cur);
|
||||||
|
if (s.empty()) {
|
||||||
|
Logger::error("Empty key/table name in path '{}'", key);
|
||||||
|
ASSERT(false);
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
cur = pos + 1;
|
||||||
|
pos = key.find('.', cur);
|
||||||
|
if (auto* next = (*table)[s].as_table()) {
|
||||||
|
table = next;
|
||||||
|
} else {
|
||||||
|
auto [it, inserted] = table->insert_or_assign(s, toml::table{});
|
||||||
|
table = it->second.as_table();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string_view n_key = key.substr(cur);
|
||||||
|
if (n_key.empty()) {
|
||||||
|
Logger::error("Trailing dot in path '{}'", key);
|
||||||
|
ASSERT(false);
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
table->insert_or_assign(n_key, std::forward<T>(val));
|
||||||
|
}
|
||||||
|
template <typename T> void set_and_save(std::string_view key, T&& val) {
|
||||||
|
set(key, std::forward(val));
|
||||||
|
save_to_file();
|
||||||
|
}
|
||||||
|
toml::node_view<toml::node> val_view(std::string_view key);
|
||||||
|
|
||||||
|
private:
|
||||||
|
toml::table m_tbl;
|
||||||
|
constexpr static inline std::string_view CONGIF_PATH =
|
||||||
|
ASSETS_PATH "config.toml";
|
||||||
|
void create_config();
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr float CUBE_VER[24] = {
|
} // namespace Cubed
|
||||||
0.0, 0.0, 0.0,
|
|
||||||
1.0, 0.0, 0.0,
|
|
||||||
1.0, 1.0, 0.0,
|
|
||||||
0.0, 1.0, 0.0,
|
|
||||||
0.0, 0.0, 1.0,
|
|
||||||
1.0, 0.0, 1.0,
|
|
||||||
1.0, 1.0, 1.0,
|
|
||||||
0.0, 1.0, 1.0
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
constexpr int OUTLINE_CUBE_INDICES[24] = {
|
|
||||||
0,1, 1,2, 2,3, 3,0,
|
|
||||||
4,5, 5,6, 6,7, 7,4,
|
|
||||||
0,4, 1,5, 2,6, 3,7
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr float SQUARE_VERTICES[6][2] = {
|
|
||||||
-0.5f, -0.5f, // bottom left
|
|
||||||
-0.5f, 0.5f, // top left
|
|
||||||
0.5f, 0.5f, // top right
|
|
||||||
0.5f, 0.5f, // top right
|
|
||||||
0.5f, -0.5f, // bottom right
|
|
||||||
-0.5f, -0.5f // bottom left
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr float SQUARE_TEXTURE_POS[6][2] = {
|
|
||||||
0.0f, 0.0f,
|
|
||||||
0.0f, 1.0f,
|
|
||||||
1.0f, 1.0f,
|
|
||||||
1.0f, 1.0f,
|
|
||||||
1.0f, 0.0f,
|
|
||||||
0.0f, 0.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Vertex {
|
|
||||||
float x = 0.0f, y = 0.0f, z = 0.0f;
|
|
||||||
float s = 0.0f, t = 0.0f;
|
|
||||||
float layer = 0.0f;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Vertex2D {
|
|
||||||
float x = 0.0f, y = 0.0f;
|
|
||||||
float s = 0.0f, t = 0.0f;
|
|
||||||
float layer = 0.0f;
|
|
||||||
};
|
|
||||||
|
|||||||
35
include/Cubed/constants.hpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Cubed/gameplay/chunk_pos.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
constexpr int WORLD_SIZE_Y = 256;
|
||||||
|
constexpr int CHUNK_SIZE = 16;
|
||||||
|
constexpr int SEA_LEVEL = 63;
|
||||||
|
|
||||||
|
constexpr int MAX_UI_NUM = 1;
|
||||||
|
constexpr int MAX_BLOCK_STATUS = 1;
|
||||||
|
constexpr int MAX_BIOME_SUM = 4;
|
||||||
|
constexpr int MAX_CHARACTER = 128;
|
||||||
|
|
||||||
|
constexpr int PRE_LOAD_DISTANCE = 24;
|
||||||
|
|
||||||
|
constexpr int MAX_DISTANCE = 128;
|
||||||
|
constexpr int CROSS_PLANE_DISTANCE = 8;
|
||||||
|
constexpr float DEFAULT_FOV = 70.0f;
|
||||||
|
constexpr float DEFAULT_MAX_WALK_SPEED = 4.5f;
|
||||||
|
constexpr float DEFAULT_MAX_RUN_SPEED = 7.0f;
|
||||||
|
constexpr float DEFAULT_ACCELERATION = 10.0f;
|
||||||
|
constexpr float DEFAULT_DECELERATION = 15.0f;
|
||||||
|
constexpr float DEFAULT_G = 22.5f;
|
||||||
|
constexpr int SIZE_X = CHUNK_SIZE;
|
||||||
|
constexpr int SIZE_Y = WORLD_SIZE_Y;
|
||||||
|
constexpr int SIZE_Z = CHUNK_SIZE;
|
||||||
|
|
||||||
|
constexpr ChunkPos CHUNK_DIR[]{{1, 0}, {-1, 0}, {0, 1}, {0, -1},
|
||||||
|
{1, 1}, {-1, 1}, {1, -1}, {-1, -1}};
|
||||||
|
|
||||||
|
using HeightMapArray = std::array<std::array<int, CHUNK_SIZE>, CHUNK_SIZE>;
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Cubed/ui/text.hpp>
|
#include "Cubed/ui/text.hpp"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
class DebugCollector {
|
class DebugCollector {
|
||||||
public:
|
public:
|
||||||
static DebugCollector& get();
|
static DebugCollector& get();
|
||||||
DebugCollector();
|
DebugCollector();
|
||||||
|
|
||||||
std::unordered_map<std::size_t, Text>& all_texts();
|
std::unordered_map<std::size_t, Text>& all_texts();
|
||||||
|
|
||||||
Text& text(std::string_view name);
|
Text& text(std::string_view name);
|
||||||
@@ -17,4 +19,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::size_t, Text> m_texts;
|
std::unordered_map<std::size_t, Text> m_texts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
65
include/Cubed/dev_panel.hpp
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <toml++/toml.hpp>
|
||||||
|
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
class App;
|
||||||
|
class Player;
|
||||||
|
class DevPanel {
|
||||||
|
struct ConfigView {
|
||||||
|
float fov = 70.0f;
|
||||||
|
bool fullscreen = false;
|
||||||
|
bool v_sync = true;
|
||||||
|
float mouse_sensitivity = 0.15f;
|
||||||
|
int width = 800;
|
||||||
|
int height = 600;
|
||||||
|
int rendering_distance = 24;
|
||||||
|
int aniso = 1;
|
||||||
|
int max_aniso = 1;
|
||||||
|
bool is_enable_aniso = false;
|
||||||
|
bool is_support_aniso = true;
|
||||||
|
bool is_reload = true;
|
||||||
|
};
|
||||||
|
struct PlayerProfile {
|
||||||
|
int game_mode = 0;
|
||||||
|
int gait = 0;
|
||||||
|
float pos[3] = {0.0f, 0.0f, 0.0f};
|
||||||
|
};
|
||||||
|
struct TextEditing {
|
||||||
|
bool perlin_seed = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
DevPanel(App& app);
|
||||||
|
void init();
|
||||||
|
void render();
|
||||||
|
|
||||||
|
private:
|
||||||
|
App& m_app;
|
||||||
|
ConfigView m_config;
|
||||||
|
Player* m_player;
|
||||||
|
PlayerProfile m_player_profile;
|
||||||
|
TextEditing m_text_editing;
|
||||||
|
bool m_need_save_config = false;
|
||||||
|
bool m_gen_thread_running = true;
|
||||||
|
int m_theme = 0;
|
||||||
|
int m_pre_set_day_tick = 0;
|
||||||
|
int m_pre_set_tick_speed = 1;
|
||||||
|
bool m_tick_frezze = false;
|
||||||
|
void show_about_table_bar();
|
||||||
|
void show_biome_table_bar();
|
||||||
|
void show_time_table_bar();
|
||||||
|
void show_cave_table_bar();
|
||||||
|
void show_river_table_bar();
|
||||||
|
void show_settings_tab_item();
|
||||||
|
void show_world_tab_item();
|
||||||
|
void show_player_tab_item();
|
||||||
|
void show_items_tab_item();
|
||||||
|
void show_shader_tab_item();
|
||||||
|
|
||||||
|
void update_config_view();
|
||||||
|
void update_player_profile();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
80
include/Cubed/gameplay/biome.hpp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <array>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
constexpr float BIOME_NOISE_FREQUENCY = 0.06f;
|
||||||
|
constexpr float HEIGHTMAP_NOISE_FREQUENCY = 0.001f;
|
||||||
|
constexpr float MOUNTAINOUS_NOISE_FREQUENCY = 0.003f;
|
||||||
|
enum class BiomeType {
|
||||||
|
PLAIN = 0,
|
||||||
|
FOREST,
|
||||||
|
DESERT,
|
||||||
|
MOUNTAIN,
|
||||||
|
RIVER,
|
||||||
|
SNOWY_PLAIN,
|
||||||
|
OCEAN,
|
||||||
|
NONE
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BiomeConditions {
|
||||||
|
float temp = 0.0f;
|
||||||
|
float humid = 0.0f;
|
||||||
|
float mountainous = 0.0f;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BiomeHeightRange {
|
||||||
|
int base_y;
|
||||||
|
int amplitude;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BiomeNonAdjacent {
|
||||||
|
BiomeType first;
|
||||||
|
std::vector<BiomeType> second;
|
||||||
|
BiomeType replace;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline const std::vector<BiomeNonAdjacent> NON_ADJACENT{
|
||||||
|
{{BiomeType::PLAIN, {BiomeType::DESERT}, BiomeType::RIVER},
|
||||||
|
{BiomeType::FOREST, {BiomeType::DESERT}, BiomeType::RIVER},
|
||||||
|
{BiomeType::DESERT, {BiomeType::FOREST}, BiomeType::RIVER},
|
||||||
|
{BiomeType::MOUNTAIN, {BiomeType::NONE}, BiomeType::RIVER}}};
|
||||||
|
|
||||||
|
struct BaseBiomeParams {
|
||||||
|
BiomeType biome;
|
||||||
|
std::pair<float, float> temp;
|
||||||
|
std::pair<float, float> humid;
|
||||||
|
std::array<float, 3> frequencies;
|
||||||
|
BiomeHeightRange height_range;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PlainParams : public BaseBiomeParams {};
|
||||||
|
|
||||||
|
struct ForestParams : public BaseBiomeParams {
|
||||||
|
float tree_frequency;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DesertParams : public BaseBiomeParams {};
|
||||||
|
|
||||||
|
struct MountainParams : public BaseBiomeParams {};
|
||||||
|
|
||||||
|
struct RiverParams : public BaseBiomeParams {};
|
||||||
|
|
||||||
|
std::string get_biome_str(BiomeType biome);
|
||||||
|
// std::array<float, 3> get_noise_frequencies_for_biome(BiomeType biome);
|
||||||
|
// BiomeHeightRange get_biome_height_range(BiomeType biome);
|
||||||
|
BiomeType safe_int_to_biome(int x);
|
||||||
|
int get_interpolated_height(float world_x, float world_z, float temp,
|
||||||
|
float humid);
|
||||||
|
|
||||||
|
BiomeType determine_biome(const BiomeConditions& conditions);
|
||||||
|
|
||||||
|
PlainParams& plain_params();
|
||||||
|
ForestParams& forest_params();
|
||||||
|
DesertParams& desert_params();
|
||||||
|
MountainParams& mountain_params();
|
||||||
|
RiverParams& river_params();
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
using BlockType = uint8_t;
|
||||||
|
|
||||||
struct BlockTexture {
|
struct BlockTexture {
|
||||||
std::string name;
|
std::string name;
|
||||||
@@ -12,9 +15,7 @@ struct BlockTexture {
|
|||||||
std::vector<GLuint> texture;
|
std::vector<GLuint> texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Block : public BlockTexture{
|
struct Block : public BlockTexture {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BlockRenderData {
|
struct BlockRenderData {
|
||||||
std::vector<bool> draw_face;
|
std::vector<bool> draw_face;
|
||||||
@@ -22,12 +23,8 @@ struct BlockRenderData {
|
|||||||
BlockRenderData() = default;
|
BlockRenderData() = default;
|
||||||
BlockRenderData(const BlockRenderData&) = default;
|
BlockRenderData(const BlockRenderData&) = default;
|
||||||
BlockRenderData& operator=(const BlockRenderData&) = default;
|
BlockRenderData& operator=(const BlockRenderData&) = default;
|
||||||
BlockRenderData(BlockRenderData&& data) :
|
BlockRenderData(BlockRenderData&& data)
|
||||||
draw_face(std::move(data.draw_face)),
|
: draw_face(std::move(data.draw_face)), block_id(data.block_id) {}
|
||||||
block_id(data.block_id)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
BlockRenderData& operator=(BlockRenderData&& data) {
|
BlockRenderData& operator=(BlockRenderData&& data) {
|
||||||
draw_face = std::move(data.draw_face);
|
draw_face = std::move(data.draw_face);
|
||||||
block_id = data.block_id;
|
block_id = data.block_id;
|
||||||
@@ -38,4 +35,57 @@ struct BlockRenderData {
|
|||||||
struct LookBlock {
|
struct LookBlock {
|
||||||
glm::ivec3 pos;
|
glm::ivec3 pos;
|
||||||
glm::ivec3 normal;
|
glm::ivec3 normal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BlockData {
|
||||||
|
std::string name;
|
||||||
|
BlockType id = 0;
|
||||||
|
|
||||||
|
bool is_liquid = false;
|
||||||
|
bool is_gas = false;
|
||||||
|
|
||||||
|
bool is_passable = false;
|
||||||
|
bool is_cross_plane = false;
|
||||||
|
bool is_transparent = false;
|
||||||
|
|
||||||
|
bool is_discard = false;
|
||||||
|
bool is_blend = false;
|
||||||
|
bool is_transitional = false;
|
||||||
|
BlockData(BlockType b_id, std::string_view b_name, bool liquid,
|
||||||
|
bool passable, bool cross_plane, bool transparent, bool gas,
|
||||||
|
bool discard, bool blend, bool transitional)
|
||||||
|
: name(b_name), id(b_id), is_liquid(liquid), is_gas(gas),
|
||||||
|
is_passable(passable), is_cross_plane(cross_plane),
|
||||||
|
is_transparent(transparent), is_discard(discard), is_blend(blend),
|
||||||
|
is_transitional(transitional) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class BlockManager {
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const std::vector<BlockData>& datas();
|
||||||
|
static void init();
|
||||||
|
static unsigned sums();
|
||||||
|
static unsigned cross_plane_sum();
|
||||||
|
static const std::string& name_form_id(BlockType id);
|
||||||
|
|
||||||
|
static bool is_gas(BlockType id);
|
||||||
|
static bool is_liquid(BlockType id);
|
||||||
|
|
||||||
|
static bool is_cross_plane(BlockType id);
|
||||||
|
static bool is_transparent(BlockType id);
|
||||||
|
static bool is_passable(BlockType id);
|
||||||
|
|
||||||
|
static bool is_discard(BlockType id);
|
||||||
|
static bool is_blend(BlockType id);
|
||||||
|
static bool is_transitional(BlockType id);
|
||||||
|
static BlockType cross_plane_index(BlockType id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void set_up_cross_plane_map();
|
||||||
|
static inline std::vector<BlockData> m_datas;
|
||||||
|
static inline bool is_init = false;
|
||||||
|
static inline std::unordered_map<BlockType, BlockType> m_cross_plane_map;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
18
include/Cubed/gameplay/builders/biome_builder.hpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Cubed {
|
||||||
|
class ChunkGenerator;
|
||||||
|
class BiomeBuilder {
|
||||||
|
public:
|
||||||
|
BiomeBuilder() = default;
|
||||||
|
virtual ~BiomeBuilder() = default;
|
||||||
|
virtual ChunkGenerator& get_chunk_generator() = 0;
|
||||||
|
virtual void build_biome() = 0;
|
||||||
|
virtual void build_vegetation() = 0;
|
||||||
|
void ocean_water_build();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void build_bottom();
|
||||||
|
void place_grass();
|
||||||
|
};
|
||||||
|
} // namespace Cubed
|
||||||
21
include/Cubed/gameplay/builders/desert_builder.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
class ChunkGenerator;
|
||||||
|
|
||||||
|
class DesertBuilder : public BiomeBuilder {
|
||||||
|
public:
|
||||||
|
DesertBuilder(ChunkGenerator& chunk_generator);
|
||||||
|
void build_biome() override;
|
||||||
|
ChunkGenerator& get_chunk_generator() override;
|
||||||
|
void build_vegetation() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChunkGenerator& m_chunk_generator;
|
||||||
|
|
||||||
|
void build_blocks();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
21
include/Cubed/gameplay/builders/forest_builder.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
class ChunkGenerator;
|
||||||
|
|
||||||
|
class ForestBuilder : public BiomeBuilder {
|
||||||
|
public:
|
||||||
|
ForestBuilder(ChunkGenerator& chunk_generator);
|
||||||
|
void build_biome() override;
|
||||||
|
ChunkGenerator& get_chunk_generator() override;
|
||||||
|
void build_vegetation() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChunkGenerator& m_chunk_generator;
|
||||||
|
|
||||||
|
void build_blocks();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
21
include/Cubed/gameplay/builders/mountain_builder.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
class ChunkGenerator;
|
||||||
|
|
||||||
|
class MountainBuilder : public BiomeBuilder {
|
||||||
|
public:
|
||||||
|
MountainBuilder(ChunkGenerator& chunk_generator);
|
||||||
|
void build_biome() override;
|
||||||
|
ChunkGenerator& get_chunk_generator() override;
|
||||||
|
void build_vegetation() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChunkGenerator& m_chunk_generator;
|
||||||
|
|
||||||
|
void build_blocks();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
23
include/Cubed/gameplay/builders/ocean_builder.hpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
class ChunkGenerator;
|
||||||
|
|
||||||
|
class OceanBuilder : public BiomeBuilder {
|
||||||
|
public:
|
||||||
|
OceanBuilder(ChunkGenerator& chunk_generator);
|
||||||
|
void build_biome() override;
|
||||||
|
ChunkGenerator& get_chunk_generator() override;
|
||||||
|
void build_vegetation() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChunkGenerator& m_chunk_generator;
|
||||||
|
|
||||||
|
void build_blocks();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
21
include/Cubed/gameplay/builders/plain_builder.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
class ChunkGenerator;
|
||||||
|
|
||||||
|
class PlainBuilder : public BiomeBuilder {
|
||||||
|
public:
|
||||||
|
PlainBuilder(ChunkGenerator& chunk_generator);
|
||||||
|
void build_biome() override;
|
||||||
|
ChunkGenerator& get_chunk_generator() override;
|
||||||
|
void build_vegetation() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChunkGenerator& m_chunk_generator;
|
||||||
|
|
||||||
|
void build_blocks();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
21
include/Cubed/gameplay/builders/river_builder.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
class ChunkGenerator;
|
||||||
|
|
||||||
|
class RiverBuilder : public BiomeBuilder {
|
||||||
|
public:
|
||||||
|
RiverBuilder(ChunkGenerator& chunk_generator);
|
||||||
|
void build_biome() override;
|
||||||
|
ChunkGenerator& get_chunk_generator() override;
|
||||||
|
void build_vegetation() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChunkGenerator& m_chunk_generator;
|
||||||
|
|
||||||
|
void build_blocks();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||
21
include/Cubed/gameplay/builders/snowy_plain_builder.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
||||||
|
namespace Cubed {
|
||||||
|
|
||||||
|
class ChunkGenerator;
|
||||||
|
|
||||||
|
class SnowyPlainBuilder : public BiomeBuilder {
|
||||||
|
public:
|
||||||
|
SnowyPlainBuilder(ChunkGenerator& chunk_generator);
|
||||||
|
void build_biome() override;
|
||||||
|
ChunkGenerator& get_chunk_generator() override;
|
||||||
|
void build_vegetation() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChunkGenerator& m_chunk_generator;
|
||||||
|
|
||||||
|
void build_blocks();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cubed
|
||||||