fixes
This commit is contained in:
148
.clang-tidy
Executable file
148
.clang-tidy
Executable file
@@ -0,0 +1,148 @@
|
||||
# Generated from CLion Inspection settings
|
||||
---
|
||||
Checks: '-*,
|
||||
bugprone-argument-comment,
|
||||
bugprone-assert-side-effect,
|
||||
bugprone-bad-signal-to-kill-thread,
|
||||
bugprone-branch-clone,
|
||||
bugprone-copy-constructor-init,
|
||||
bugprone-dangling-handle,
|
||||
bugprone-dynamic-static-initializers,
|
||||
bugprone-fold-init-type,
|
||||
bugprone-forward-declaration-namespace,
|
||||
bugprone-forwarding-reference-overload,
|
||||
bugprone-inaccurate-erase,
|
||||
bugprone-incorrect-roundings,
|
||||
bugprone-integer-division,
|
||||
bugprone-lambda-function-name,
|
||||
bugprone-macro-parentheses,
|
||||
bugprone-macro-repeated-side-effects,
|
||||
bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||
bugprone-misplaced-pointer-arithmetic-in-alloc,
|
||||
bugprone-misplaced-widening-cast,
|
||||
bugprone-move-forwarding-reference,
|
||||
bugprone-multiple-statement-macro,
|
||||
bugprone-no-escape,
|
||||
bugprone-not-null-terminated-result,
|
||||
bugprone-parent-virtual-call,
|
||||
bugprone-posix-return,
|
||||
bugprone-reserved-identifier,
|
||||
bugprone-sizeof-container,
|
||||
bugprone-sizeof-expression,
|
||||
bugprone-spuriously-wake-up-functions,
|
||||
bugprone-string-constructor,
|
||||
bugprone-string-integer-assignment,
|
||||
bugprone-string-literal-with-embedded-nul,
|
||||
bugprone-suspicious-enum-usage,
|
||||
bugprone-suspicious-include,
|
||||
bugprone-suspicious-memset-usage,
|
||||
bugprone-suspicious-missing-comma,
|
||||
bugprone-suspicious-semicolon,
|
||||
bugprone-suspicious-string-compare,
|
||||
bugprone-suspicious-memory-comparison,
|
||||
bugprone-suspicious-realloc-usage,
|
||||
bugprone-swapped-arguments,
|
||||
bugprone-terminating-continue,
|
||||
bugprone-throw-keyword-missing,
|
||||
bugprone-too-small-loop-variable,
|
||||
bugprone-undefined-memory-manipulation,
|
||||
bugprone-undelegated-constructor,
|
||||
bugprone-unhandled-self-assignment,
|
||||
bugprone-unused-raii,
|
||||
bugprone-unused-return-value,
|
||||
bugprone-use-after-move,
|
||||
bugprone-virtual-near-miss,
|
||||
cert-dcl21-cpp,
|
||||
cert-dcl58-cpp,
|
||||
cert-err34-c,
|
||||
cert-err52-cpp,
|
||||
cert-err60-cpp,
|
||||
cert-flp30-c,
|
||||
cert-msc50-cpp,
|
||||
cert-msc51-cpp,
|
||||
cert-str34-c,
|
||||
cppcoreguidelines-interfaces-global-init,
|
||||
cppcoreguidelines-narrowing-conversions,
|
||||
cppcoreguidelines-pro-type-member-init,
|
||||
cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
cppcoreguidelines-slicing,
|
||||
google-default-arguments,
|
||||
google-explicit-constructor,
|
||||
google-runtime-operator,
|
||||
hicpp-exception-baseclass,
|
||||
hicpp-multiway-paths-covered,
|
||||
misc-misplaced-const,
|
||||
misc-new-delete-overloads,
|
||||
misc-no-recursion,
|
||||
misc-non-copyable-objects,
|
||||
misc-throw-by-value-catch-by-reference,
|
||||
misc-unconventional-assign-operator,
|
||||
misc-uniqueptr-reset-release,
|
||||
modernize-avoid-bind,
|
||||
modernize-concat-nested-namespaces,
|
||||
modernize-deprecated-headers,
|
||||
modernize-deprecated-ios-base-aliases,
|
||||
modernize-loop-convert,
|
||||
modernize-make-shared,
|
||||
modernize-make-unique,
|
||||
modernize-pass-by-value,
|
||||
modernize-raw-string-literal,
|
||||
modernize-redundant-void-arg,
|
||||
modernize-replace-auto-ptr,
|
||||
modernize-replace-disallow-copy-and-assign-macro,
|
||||
modernize-replace-random-shuffle,
|
||||
modernize-return-braced-init-list,
|
||||
modernize-shrink-to-fit,
|
||||
modernize-unary-static-assert,
|
||||
modernize-use-auto,
|
||||
modernize-use-bool-literals,
|
||||
modernize-use-emplace,
|
||||
modernize-use-equals-default,
|
||||
modernize-use-equals-delete,
|
||||
modernize-use-nodiscard,
|
||||
modernize-use-noexcept,
|
||||
modernize-use-nullptr,
|
||||
modernize-use-override,
|
||||
modernize-use-transparent-functors,
|
||||
modernize-use-uncaught-exceptions,
|
||||
mpi-buffer-deref,
|
||||
mpi-type-mismatch,
|
||||
openmp-use-default-none,
|
||||
performance-faster-string-find,
|
||||
performance-for-range-copy,
|
||||
performance-implicit-conversion-in-loop,
|
||||
performance-inefficient-algorithm,
|
||||
performance-inefficient-string-concatenation,
|
||||
performance-inefficient-vector-operation,
|
||||
performance-move-const-arg,
|
||||
performance-move-constructor-init,
|
||||
performance-no-automatic-move,
|
||||
performance-noexcept-move-constructor,
|
||||
performance-trivially-destructible,
|
||||
performance-type-promotion-in-math-fn,
|
||||
performance-unnecessary-copy-initialization,
|
||||
performance-unnecessary-value-param,
|
||||
portability-simd-intrinsics,
|
||||
readability-avoid-const-params-in-decls,
|
||||
readability-const-return-type,
|
||||
readability-container-size-empty,
|
||||
readability-convert-member-functions-to-static,
|
||||
readability-delete-null-pointer,
|
||||
readability-deleted-default,
|
||||
readability-inconsistent-declaration-parameter-name,
|
||||
readability-make-member-function-const,
|
||||
readability-misleading-indentation,
|
||||
readability-misplaced-array-index,
|
||||
readability-non-const-parameter,
|
||||
readability-redundant-control-flow,
|
||||
readability-redundant-declaration,
|
||||
readability-redundant-function-ptr-dereference,
|
||||
readability-redundant-smartptr-get,
|
||||
readability-redundant-string-cstr,
|
||||
readability-redundant-string-init,
|
||||
readability-simplify-subscript-expr,
|
||||
readability-static-accessed-through-handle,
|
||||
readability-static-definition-in-anonymous-namespace,
|
||||
readability-string-compare,
|
||||
readability-uniqueptr-delete-release,
|
||||
readability-use-anyofallof'
|
||||
1
.gitignore
vendored
Executable file
1
.gitignore
vendored
Executable file
@@ -0,0 +1 @@
|
||||
cmake-build-debug
|
||||
8
.idea/.gitignore
generated
vendored
Executable file
8
.idea/.gitignore
generated
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
158
.idea/codeStyles/Project.xml
generated
Normal file
158
.idea/codeStyles/Project.xml
generated
Normal file
@@ -0,0 +1,158 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="LINE_SEPARATOR" value=" " />
|
||||
<Objective-C>
|
||||
<option name="INDENT_NAMESPACE_MEMBERS" value="0" />
|
||||
<option name="KEEP_STRUCTURES_IN_ONE_LINE" value="true" />
|
||||
<option name="FUNCTION_TOP_AFTER_RETURN_TYPE_WRAP" value="0" />
|
||||
<option name="FUNCTION_PARAMETERS_ALIGN_MULTILINE" value="false" />
|
||||
<option name="FUNCTION_PARAMETERS_NEW_LINE_AFTER_LPAR" value="true" />
|
||||
<option name="FUNCTION_PARAMETERS_NEW_LINE_BEFORE_RPAR" value="true" />
|
||||
<option name="LAMBDA_CAPTURE_LIST_WRAP" value="1" />
|
||||
<option name="LAMBDA_CAPTURE_LIST_NEW_LINE_AFTER_LBRACKET" value="true" />
|
||||
<option name="LAMBDA_CAPTURE_LIST_NEW_LINE_BEFORE_RBRACKET" value="true" />
|
||||
<option name="STRUCTURED_BINDING_LIST_WRAP" value="1" />
|
||||
<option name="STRUCTURED_BINDING_LIST_NEW_LINE_AFTER_LBRACKET" value="true" />
|
||||
<option name="STRUCTURED_BINDING_LIST_NEW_LINE_BEFORE_RBRACKET" value="true" />
|
||||
<option name="FUNCTION_CALL_ARGUMENTS_ALIGN_MULTILINE" value="false" />
|
||||
<option name="FUNCTION_CALL_ARGUMENTS_NEW_LINE_AFTER_LPAR" value="true" />
|
||||
<option name="FUNCTION_CALL_ARGUMENTS_NEW_LINE_BEFORE_RPAR" value="true" />
|
||||
<option name="SHIFT_OPERATION_ALIGN_MULTILINE" value="false" />
|
||||
<option name="TEMPLATE_PARAMETERS_WRAP" value="1" />
|
||||
<option name="TEMPLATE_PARAMETERS_NEW_LINE_AFTER_LT" value="true" />
|
||||
<option name="TEMPLATE_PARAMETERS_NEW_LINE_BEFORE_GT" value="true" />
|
||||
<option name="TEMPLATE_CALL_ARGUMENTS_WRAP" value="1" />
|
||||
<option name="TEMPLATE_CALL_ARGUMENTS_NEW_LINE_AFTER_LT" value="true" />
|
||||
<option name="TEMPLATE_CALL_ARGUMENTS_NEW_LINE_BEFORE_GT" value="true" />
|
||||
<option name="CLASS_CONSTRUCTOR_INIT_LIST_ALIGN_MULTILINE" value="false" />
|
||||
<option name="SUPERCLASS_LIST_WRAP" value="1" />
|
||||
<option name="SUPERCLASS_LIST_ALIGN_MULTILINE" value="false" />
|
||||
<option name="SPACE_WITHIN_TEMPLATE_DOUBLE_GT" value="false" />
|
||||
<option name="ALIGN_INIT_LIST_IN_COLUMNS" value="false" />
|
||||
<option name="SPACE_BEFORE_COLON_IN_FOREACH" value="true" />
|
||||
<option name="SPACE_BEFORE_POINTER_IN_DECLARATION" value="false" />
|
||||
<option name="SPACE_AFTER_POINTER_IN_DECLARATION" value="true" />
|
||||
<option name="SPACE_BEFORE_REFERENCE_IN_DECLARATION" value="false" />
|
||||
<option name="SPACE_AFTER_REFERENCE_IN_DECLARATION" value="true" />
|
||||
<option name="SPACE_BETWEEN_ADJACENT_BRACKETS" value="true" />
|
||||
<option name="SPACE_BEFORE_DICTIONARY_LITERAL_COLON" value="true" />
|
||||
<option name="DISCHARGED_SHORT_TERNARY_OPERATOR" value="true" />
|
||||
<option name="INSERT_VIRTUAL_WITH_OVERRIDE" value="true" />
|
||||
<option name="ADD_BRIEF_TAG" value="true" />
|
||||
<option name="ADD_GETTER_PREFIX" value="false" />
|
||||
<option name="ADD_SETTER_PREFIX" value="false" />
|
||||
</Objective-C>
|
||||
<RiderCodeStyleSettings>
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="NONE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="LINE_BREAK" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="None" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FREE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Tab" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Single" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
|
||||
</RiderCodeStyleSettings>
|
||||
<files>
|
||||
<extensions>
|
||||
<pair source="cpp" header="hpp" fileNamingConvention="SNAKE_CASE" />
|
||||
<pair source="c" header="h" fileNamingConvention="SNAKE_CASE" />
|
||||
</extensions>
|
||||
</files>
|
||||
<codeStyleSettings language="ObjectiveC">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Executable file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Executable file
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
13
.idea/misc.xml
generated
Executable file
13
.idea/misc.xml
generated
Executable file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BackendCodeEditorMiscSettings">
|
||||
<option name="/Default/Housekeeping/GlobalSettingsUpgraded/IsUpgraded/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/Environment/Hierarchy/GeneratedFilesCacheKey/Timestamp/@EntryValue" value="69" type="long" />
|
||||
<option name="/Default/Housekeeping/OptionsDialog/SelectedPageId/@EntryValue" value="CppFormatterOtherPage" type="string" />
|
||||
<option name="/Default/Housekeeping/RefactoringsMru/RenameRefactoring/DoSearchForTextInStrings/@EntryValue" />
|
||||
</component>
|
||||
<component name="CMakePythonSetting">
|
||||
<option name="pythonIntegrationState" value="YES" />
|
||||
</component>
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/point_cloud_viewer.iml" filepath="$PROJECT_DIR$/.idea/point_cloud_viewer.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
2
.idea/point_cloud_viewer.iml
generated
Normal file
2
.idea/point_cloud_viewer.iml
generated
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
||||
8
.idea/vcs.xml
generated
Executable file
8
.idea/vcs.xml
generated
Executable file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/libraries/include/glm" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/libraries/include/stb" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
196
CMakeLists.txt
Executable file
196
CMakeLists.txt
Executable file
@@ -0,0 +1,196 @@
|
||||
cmake_minimum_required(VERSION 3.27)
|
||||
project(z3d)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast -pedantic -Wall -Werror ")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/=")
|
||||
|
||||
add_executable(z3d main.cpp
|
||||
include/assets/components/material_components.hpp
|
||||
include/assets/components/point_cloud_vertex_components.hpp
|
||||
include/assets/components/mesh_vertex_components.hpp
|
||||
include/assets/dynamic_read_buffers/dynamic_material_buffer.hpp
|
||||
include/assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp
|
||||
include/assets/dynamic_read_buffers/dynamic_point_cloud_buffer.hpp
|
||||
include/assets/data_loaders/kitti_loader.hpp
|
||||
include/assets/data_loaders/obj_loader.hpp
|
||||
include/assets/data_loaders/stl_loader.hpp
|
||||
include/assets/data_loaders/uos_loader.hpp
|
||||
include/assets/components/mesh_vertex_components.hpp
|
||||
include/scene/camera.hpp
|
||||
include/scene/flying_camera.hpp
|
||||
include/opengl/handles/mesh_handle.hpp
|
||||
include/opengl/handles/point_cloud_handle.hpp
|
||||
include/opengl/handles/shader_program_handle.hpp
|
||||
include/opengl/handles/texture_handle.hpp
|
||||
include/opengl/data/mesh_data.hpp
|
||||
include/opengl/data/point_cloud_data.hpp
|
||||
include/opengl/data/shader_program_data.hpp
|
||||
include/opengl/data/texture_data.hpp
|
||||
include/scene/lighting_setup.hpp
|
||||
include/rendering/batch_renderers/mesh_batch_renderer.hpp
|
||||
include/opengl/error.hpp
|
||||
include/rendering/batches/mesh_batch.hpp
|
||||
include/rendering/batches/point_cloud_batch.hpp
|
||||
include/util/arx.hpp
|
||||
include/util/extra_arx_parsers.hpp
|
||||
include/util/for_each.hpp
|
||||
include/util/function.hpp
|
||||
include/util/image.hpp
|
||||
include/util/logger.hpp
|
||||
include/util/string_indexer.hpp
|
||||
include/util/string_literal.hpp
|
||||
include/util/uix.hpp
|
||||
source/assets/data_loaders/stl_loader.cpp
|
||||
source/assets/data_loaders/obj_loader.cpp
|
||||
source/scene/flying_camera.cpp
|
||||
source/opengl/data/point_cloud_data.cpp
|
||||
source/opengl/handles/shader_program_handle.ipp
|
||||
source/opengl/data/texture_data.ipp
|
||||
source/opengl/data/mesh_data.cpp
|
||||
include/opengl/error.hpp
|
||||
source/opengl/data/shader_program_data.cpp
|
||||
source/opengl/handles/mesh_handle.ipp
|
||||
source/opengl/handles/point_cloud_handle.ipp
|
||||
source/opengl/handles/texture_handle.ipp
|
||||
include/assets/data/surface_properties.hpp
|
||||
include/util/unroll_bool_template.hpp
|
||||
include/rendering/batch_renderers/point_cloud_batch_renderer.hpp
|
||||
source/rendering/batches/mesh_batch.ipp
|
||||
source/rendering/batches/point_cloud_batch.ipp
|
||||
include/opengl/shader_program_variable.hpp
|
||||
include/opengl/type_utils.hpp
|
||||
include/util/binary_ifstream.hpp
|
||||
source/assets/data_loaders/kitti_loader.cpp
|
||||
include/assets/data_loaders/generic/generic_3dtk_loader.hpp
|
||||
include/assets/data_loaders/uosr_loader.hpp
|
||||
include/assets/data_loaders/uos_normal_loader.hpp
|
||||
include/assets/data_loaders/uos_rgb_loader.hpp
|
||||
include/assets/dynamic_data_loaders/dynamic_mesh_loader.hpp
|
||||
source/assets/dynamic_data_loaders/dynamic_mesh_loader.cpp
|
||||
source/assets/dynamic_data_loaders/dynamic_mesh_loader.cpp
|
||||
include/assets/dynamic_data_loaders/dynamic_point_cloud_loader.hpp
|
||||
include/assets/dynamic_data_loaders/generic/base_dynamic_loader.hpp
|
||||
source/assets/dynamic_data_loaders/generic/base_dynamic_loader.ipp
|
||||
source/assets/dynamic_data_loaders/dynamic_point_cloud_loader.cpp
|
||||
include/opengl/handles/matrix_handles.hpp
|
||||
include/viewer/instance.hpp
|
||||
include/opengl/data/material_data.hpp
|
||||
include/opengl/handles/material_handle.hpp
|
||||
include/opengl/handles/surface_properties_handle.hpp
|
||||
include/opengl/handles/alpha_handle.hpp
|
||||
source/opengl/data/material_data.ipp
|
||||
include/util/specialised_lambda.hpp
|
||||
include/viewer/asset_types.hpp
|
||||
source/viewer/instance.cpp
|
||||
include/viewer/asset_loader.hpp
|
||||
source/viewer/asset_loader.cpp
|
||||
include/assets/data_loaders/glsl_loader.hpp
|
||||
include/assets/dynamic_read_buffers/dynamic_shader_buffer.hpp
|
||||
source/assets/data_loaders/glsl_loader.cpp
|
||||
include/viewer/settings.hpp
|
||||
include/opengl/data/shader_data.hpp
|
||||
source/opengl/data/shader_data.ipp
|
||||
source/opengl/data/point_cloud_data.ipp
|
||||
source/opengl/data/shader_data.cpp
|
||||
include/opengl/handles/shader_handle.hpp
|
||||
include/util/string_lookup.hpp
|
||||
include/viewer/dynamic_shader_program_loading.hpp
|
||||
source/viewer/dynamic_shader_program_loading.cpp
|
||||
source/opengl/handles/shader_program_handle.cpp
|
||||
include/opengl/shader_program_lookup.hpp
|
||||
source/opengl/shader_program_lookup.cpp
|
||||
include/shader_program/attributes/mesh_attributes.hpp
|
||||
include/shader_program/attributes/point_cloud_attributes.hpp
|
||||
include/shader_program/uniforms/mesh_uniforms.hpp
|
||||
include/shader_program/uniforms/point_cloud_uniforms.hpp
|
||||
include/shader_program/capabilities/mesh_capabilities.hpp
|
||||
include/shader_program/capabilities/point_cloud_capabilities.hpp
|
||||
include/rendering/requirements/mesh_requirements.hpp
|
||||
include/rendering/requirements/point_cloud_requirements.hpp
|
||||
include/rendering/modes/mesh_modes.hpp
|
||||
include/rendering/modes/point_cloud_modes.hpp
|
||||
source/rendering/batch_renderers/mesh_batch_renderer.cpp
|
||||
source/rendering/batch_renderers/point_cloud_batch_renderer.cpp
|
||||
include/rendering/shader_program_lookups/mesh_lookup.hpp
|
||||
include/rendering/shader_program_lookups/mesh_lookup.hpp
|
||||
source/rendering/shader_program_lookups/mesh_lookup.cpp
|
||||
source/rendering/shader_program_lookups/point_cloud_lookup.cpp
|
||||
include/rendering/shader_program_lookups/point_cloud_lookup.hpp
|
||||
include/geometry/aabb.hpp
|
||||
source/geometry/normal_estimation.cpp
|
||||
include/geometry/normal_estimation.hpp
|
||||
include/assets/components/texture_components.hpp
|
||||
include/util/enum_operators.hpp
|
||||
include/assets/dynamic_read_buffers/dynamic_texture_buffer.hpp
|
||||
source/assets/dynamic_read_buffers/dynamic_mesh_buffer.ipp
|
||||
source/assets/dynamic_read_buffers/dynamic_material_buffer.ipp
|
||||
include/assets/dynamic_read_buffers/dynamic_vertex_buffer.hpp
|
||||
source/assets/dynamic_read_buffers/dynamic_model_buffer.ipp
|
||||
source/assets/dynamic_read_buffers/dynamic_texture_buffer.ipp
|
||||
source/assets/dynamic_read_buffers/dynamic_point_cloud_buffer.ipp
|
||||
include/assets/data_loaders/mtl_loader.hpp
|
||||
include/assets/dynamic_data_loaders/dynamic_material_loader.hpp
|
||||
include/util/id_type.hpp
|
||||
include/assets/dynamic_data_stores/generic/generic_dynamic_store.hpp
|
||||
source/assets/dynamic_data_stores/generic/generic_dynamic_store.ipp
|
||||
include/assets/dynamic_data_stores/dynamic_material_store.hpp
|
||||
include/assets/dynamic_data_stores/dynamic_mesh_store.hpp
|
||||
include/assets/dynamic_data_stores/dynamic_point_cloud_store.hpp
|
||||
include/util/result.hpp
|
||||
source/assets/data_loaders/mtl_loader.cpp
|
||||
include/util/line_parser.hpp
|
||||
include/assets/dynamic_data_loaders/dynamic_texture_loader.hpp
|
||||
source/assets/dynamic_data_loaders/dynamic_texture_loader.cpp
|
||||
include/assets/dynamic_data_stores/dynamic_texture_store.hpp
|
||||
include/opengl/data_uploaders/texture_data_uploader.hpp
|
||||
include/assets/dynamic_data_stores/dynamic_vertex_store.hpp
|
||||
include/assets/prefetch_lookups/mesh_prefetch_lookup.hpp
|
||||
include/assets/prefetch_lookups/point_cloud_prefetch_lookup.hpp
|
||||
include/assets/prefetch_lookups/material_prefetch_lookup.hpp
|
||||
include/assets/prefetch_lookups/texture_prefetch_lookup.hpp
|
||||
include/assets/prefetch_lookups/pose_prefetch_lookup.hpp
|
||||
include/assets/dynamic_data_stores/dynamic_pose_store.hpp
|
||||
include/assets/data_loaders/kitti_pose_loader.hpp
|
||||
include/assets/data_loaders/threedtk_pose_loader.hpp
|
||||
source/assets/data_loaders/threedtk_pose_loader.cpp
|
||||
include/assets/dynamic_read_buffers/dynamic_pose_buffer.hpp
|
||||
source/assets/data_loaders/kitti_pose_loader.cpp
|
||||
include/assets/prefetch_queue.hpp
|
||||
include/util/string_list.hpp
|
||||
include/assets/dynamic_data_stores/dynamic_material_library_store.hpp
|
||||
include/assets/dynamic_data_stores/generic/generic_dynamic_component_store.hpp
|
||||
source/assets/dynamic_data_stores/generic/generic_dynamic_component_store.ipp
|
||||
source/assets/dynamic_data_stores/dynamic_material_store.cpp
|
||||
include/assets/dynamic_data_stores/generic/generic_dynamic_component_array_store.hpp
|
||||
source/assets/dynamic_data_stores/generic/generic_dynamic_component_array_store.ipp
|
||||
source/assets/dynamic_data_stores/dynamic_mesh_store.cpp
|
||||
include/assets/dynamic_data_stores/generic/generic_dynamic_indexed_component_array_store.hpp
|
||||
source/assets/dynamic_data_stores/dynamic_point_cloud_store.cpp
|
||||
include/assets/dynamic_read_buffers/dynamic_material_library_buffer.hpp
|
||||
include/assets/dynamic_data_loaders/dynamic_material_library_loader.hpp
|
||||
include/assets/prefetch_lookups/material_library_prefetch_lookup.hpp
|
||||
include/assets/prefetch_lookups/shader_prefetch_lookup.hpp
|
||||
include/assets/dynamic_data_stores/dynamic_shader_store.hpp
|
||||
include/assets/data_loaders/generic/generic_3dtk_loader.hpp
|
||||
source/assets/data_loaders/generic/generic_3dtk_loader.ipp
|
||||
include/assets/prefetch_lookup.hpp
|
||||
source/assets/prefetch_lookups/pose_prefetch_lookup.cpp
|
||||
include/assets/dynamic_data_store.hpp
|
||||
)
|
||||
|
||||
target_include_directories(z3d PRIVATE include)
|
||||
target_include_directories(z3d PRIVATE source) # for ipp headers
|
||||
target_include_directories(z3d PRIVATE libraries/include/glm)
|
||||
target_include_directories(z3d PRIVATE libraries/include/stb)
|
||||
|
||||
find_package(GLEW REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(SFML REQUIRED COMPONENTS graphics system)
|
||||
find_package(Eigen3 3.4 REQUIRED NO_MODULE)
|
||||
|
||||
include_directories(${SFML_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${eigen_INCLUDE_DIR})
|
||||
target_link_libraries(z3d Eigen3::Eigen sfml-graphics sfml-system sfml-window ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})
|
||||
BIN
data/fonts/JetBrainsMono_Medium.ttf
Executable file
BIN
data/fonts/JetBrainsMono_Medium.ttf
Executable file
Binary file not shown.
59
include/assets/components/material_components.hpp
Normal file
59
include/assets/components/material_components.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include "../dynamic_read_buffers"
|
||||
#include "assets/data/surface_properties.hpp"
|
||||
#include "util/enum_operators.hpp"
|
||||
|
||||
namespace components::material
|
||||
{
|
||||
using surface_properties = ::surface_properties;
|
||||
using transparency = float;
|
||||
using ambient_color_texture = ::dynamic_texture_data;
|
||||
using diffuse_color_texture = ::dynamic_texture_data;
|
||||
using specular_color_texture = ::dynamic_texture_data;
|
||||
using shininess_texture = ::dynamic_texture_data;
|
||||
using alpha_texture = ::dynamic_texture_data;
|
||||
using bump_texture = ::dynamic_texture_data;
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = std::size_t;
|
||||
inline constexpr type surface_properties = 0;
|
||||
inline constexpr type transparency = 1;
|
||||
inline constexpr type ambient_color_texture = 2;
|
||||
inline constexpr type diffuse_color_texture = 3;
|
||||
inline constexpr type specular_color_texture = 4;
|
||||
inline constexpr type shininess_texture = 5;
|
||||
inline constexpr type alpha_texture = 6;
|
||||
inline constexpr type bump_texture = 7;
|
||||
}
|
||||
|
||||
enum class flags : std::uint8_t
|
||||
{
|
||||
none = 0,
|
||||
surface_properties = 1 << indices::surface_properties,
|
||||
transparency = 1 << indices::transparency,
|
||||
ambient_filter_texture = 1 << indices::ambient_color_texture,
|
||||
diffuse_filter_texture = 1 << indices::diffuse_color_texture,
|
||||
specular_filter_texture = 1 << indices::specular_color_texture,
|
||||
shininess_texture = 1 << indices::shininess_texture,
|
||||
alpha_texture = 1 << indices::alpha_texture,
|
||||
bump_texture = 1 << indices::bump_texture
|
||||
};
|
||||
|
||||
using all = std::tuple<
|
||||
surface_properties,
|
||||
transparency,
|
||||
ambient_color_texture,
|
||||
diffuse_color_texture,
|
||||
specular_color_texture,
|
||||
shininess_texture,
|
||||
alpha_texture,
|
||||
bump_texture
|
||||
>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace material_component
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::material::flags)
|
||||
39
include/assets/components/mesh_vertex_components.hpp
Executable file
39
include/assets/components/mesh_vertex_components.hpp
Executable file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include "util/enum_operators.hpp"
|
||||
|
||||
namespace components::mesh_vertex {
|
||||
|
||||
using position = std::array<float, 3>;
|
||||
using normal = std::array<float, 3>;
|
||||
using tex_coord = std::array<float, 2>;
|
||||
using color = std::array<float, 3>;
|
||||
using reflectance = std::array<float, 1>;
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = std::size_t;
|
||||
inline constexpr type position = 0;
|
||||
inline constexpr type normal = 1;
|
||||
inline constexpr type tex_coord = 2;
|
||||
inline constexpr type color = 3;
|
||||
inline constexpr type reflectance = 4;
|
||||
}
|
||||
|
||||
enum class flags : std::uint8_t {
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
normal = 1 << indices::normal,
|
||||
tex_coord = 1 << indices::tex_coord,
|
||||
color = 1 << indices::color,
|
||||
reflectance = 1 << indices::reflectance
|
||||
};
|
||||
|
||||
using all = std::tuple<position, normal, tex_coord, color, reflectance>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::mesh_vertex
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::mesh_vertex::flags)
|
||||
36
include/assets/components/point_cloud_vertex_components.hpp
Executable file
36
include/assets/components/point_cloud_vertex_components.hpp
Executable file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include "util/enum_operators.hpp"
|
||||
|
||||
namespace components::point_cloud_vertex {
|
||||
|
||||
using position = std::array<float, 3>;
|
||||
using normal = std::array<float, 3>;
|
||||
using color = std::array<float, 3>;
|
||||
using reflectance = std::array<float, 1>;
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = std::size_t;
|
||||
inline constexpr type position = 0;
|
||||
inline constexpr type normal = 1;
|
||||
inline constexpr type color = 2;
|
||||
inline constexpr type reflectance = 3;
|
||||
} // namespace indices
|
||||
|
||||
enum class flags : std::uint8_t {
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
normal = 1 << indices::normal,
|
||||
color = 1 << indices::color,
|
||||
reflectance = 1 << indices::reflectance
|
||||
};
|
||||
|
||||
using all = std::tuple<position, normal, color, reflectance>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::point_cloud_vertex
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::point_cloud_vertex::flags)
|
||||
28
include/assets/components/texture_components.hpp
Normal file
28
include/assets/components/texture_components.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <cinttypes>
|
||||
#include "util/enum_operators.hpp"
|
||||
|
||||
namespace components::texture {
|
||||
|
||||
using red = std::uint8_t;
|
||||
using green = std::uint8_t;
|
||||
using blue = std::uint8_t;
|
||||
using luminance = std::uint8_t;
|
||||
|
||||
enum class flags : std::uint8_t {
|
||||
none = 0,
|
||||
luminance = 1 << 1,
|
||||
red = 1 << 2,
|
||||
green = 1 << 3,
|
||||
blue = 1 << 4,
|
||||
alpha = 1 << 5
|
||||
};
|
||||
|
||||
using all = std::tuple<red, green, blue, luminance>;
|
||||
constexpr inline auto count = std::tuple_size_v<all>;
|
||||
|
||||
} // namespace components::texture
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(components::texture::flags)
|
||||
11
include/assets/data/surface_properties.hpp
Normal file
11
include/assets/data/surface_properties.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
struct surface_properties
|
||||
{
|
||||
std::array<float, 3> ambient_filter{ 0.7f, 0.7f, 0.7f };
|
||||
std::array<float, 3> diffuse_filter{ 0.466f, 0.466f, 0.7922f };
|
||||
std::array<float, 3> specular_filter{ 0.5974f, 0.2084f, 0.2084f };
|
||||
float shininess{ 100.2237f };
|
||||
};
|
||||
30
include/assets/data_loaders/glsl_loader.hpp
Normal file
30
include/assets/data_loaders/glsl_loader.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/prefetch_lookups/mesh_prefetch_lookup.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_shader_buffer.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
struct glsl_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("glsl");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_shader_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
53
include/assets/data_loaders/kitti_loader.hpp
Normal file
53
include/assets/data_loaders/kitti_loader.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_point_cloud_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "glm/mat4x4.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
struct kitti_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("kitti");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_point_cloud_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
inline static constexpr auto frame_folder = "frames";
|
||||
|
||||
[[nodiscard]] static ztu::result<std::size_t> frame_id_from_filename(
|
||||
std::string_view filename
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load_point_file(
|
||||
const std::filesystem::path& filename,
|
||||
dynamic_point_cloud_buffer& point_cloud
|
||||
);
|
||||
|
||||
static void transform_point_cloud(
|
||||
std::span<components::point_cloud_vertex::position> points,
|
||||
const glm::mat4& pose
|
||||
);
|
||||
|
||||
[[nodiscard]] static ztu::result<std::string_view> parent_directory(std::string_view path);
|
||||
|
||||
|
||||
};
|
||||
37
include/assets/data_loaders/kitti_pose_loader.hpp
Normal file
37
include/assets/data_loaders/kitti_pose_loader.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_pose_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_pose_buffer.hpp"
|
||||
#include "assets/prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
|
||||
struct kitti_pose_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("kitti_pose");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_pose_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
static constexpr auto pose_filename = std::string_view{ "pose.txt" };
|
||||
|
||||
static std::error_code parse_pose(
|
||||
std::ifstream& in,
|
||||
dynamic_pose_buffer& pose
|
||||
);
|
||||
};
|
||||
56
include/assets/data_loaders/mtl_loader.hpp
Normal file
56
include/assets/data_loaders/mtl_loader.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_library_store.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
namespace mtl_loader_error {
|
||||
|
||||
enum class codes {
|
||||
ok = 0,
|
||||
mtl_cannot_open_file,
|
||||
mtl_cannot_open_texture,
|
||||
mtl_malformed_ambient_color,
|
||||
mtl_malformed_diffuse_color,
|
||||
mtl_malformed_specular_color,
|
||||
mtl_malformed_specular_exponent,
|
||||
mtl_malformed_dissolve,
|
||||
mlt_unknown_line_begin
|
||||
};
|
||||
|
||||
} // namespace mtl_loader_error
|
||||
|
||||
class mtl_loader {
|
||||
public:
|
||||
static constexpr auto name = std::string_view("mtl");
|
||||
|
||||
std::optional<dynamic_material_store::id_type> find_id(std::string_view name);
|
||||
|
||||
void clear_name_lookup();
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
// THis is not very elegant, but right now I do not see a better solution...
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_material_library_buffer& material_library_buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
ztu::string_lookup<dynamic_material_store::id_type> m_id_lookup;
|
||||
};
|
||||
42
include/assets/data_loaders/obj_loader.hpp
Executable file
42
include/assets/data_loaders/obj_loader.hpp
Executable file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <string_view>
|
||||
#include "assets/dynamic_data_loaders/dynamic_material_loader.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
|
||||
namespace obj_loader_error {
|
||||
|
||||
enum class codes {
|
||||
ok = 0,
|
||||
obj_cannot_open_file,
|
||||
obj_malformed_vertex,
|
||||
obj_malformed_texture_coordinate,
|
||||
obj_malformed_normal,
|
||||
obj_malformed_face,
|
||||
obj_face_index_out_of_range,
|
||||
obj_unknown_line_begin
|
||||
};
|
||||
|
||||
} // namespace obj_loader_error
|
||||
|
||||
struct obj_loader {
|
||||
|
||||
static constexpr auto name = std::string_view("obj");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
components::mesh_vertex::flags enabled_components,
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
30
include/assets/data_loaders/stl_loader.hpp
Normal file
30
include/assets/data_loaders/stl_loader.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <string_view>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
|
||||
struct stl_loader {
|
||||
|
||||
static constexpr auto name = std::string_view("stl");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
// space stuff that has to persist
|
||||
dynamic_mesh_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
};
|
||||
40
include/assets/data_loaders/threedtk_pose_loader.hpp
Normal file
40
include/assets/data_loaders/threedtk_pose_loader.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/dynamic_data_store.hpp"
|
||||
#include "assets/prefetch_lookup.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_pose_buffer.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
#include "util/result.hpp"
|
||||
#include "assets/prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
|
||||
struct threedtk_pose_loader
|
||||
{
|
||||
static constexpr auto name = std::string_view("3dtk_pose");
|
||||
|
||||
[[nodiscard]] static std::error_code prefetch(
|
||||
const file_dir_list& paths,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] static std::error_code load(
|
||||
dynamic_pose_buffer& buffer,
|
||||
const file_dir_list& paths,
|
||||
prefetch_lookup& id_lookup,
|
||||
dynamic_data_store& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
protected:
|
||||
static std::error_code parse_transform_info(
|
||||
std::ifstream& in,
|
||||
std::string& line,
|
||||
std::array<glm::vec3, 2>& transform_info
|
||||
);
|
||||
|
||||
static ztu::result<pose_prefetch_lookup::index_type> parse_index(
|
||||
std::string_view filename
|
||||
);
|
||||
};
|
||||
9
include/assets/data_loaders/uos_loader.hpp
Normal file
9
include/assets/data_loaders/uos_loader.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_loader : generic_3dtk_loader<false, false, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos");
|
||||
};
|
||||
|
||||
8
include/assets/data_loaders/uos_normal_loader.hpp
Normal file
8
include/assets/data_loaders/uos_normal_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_normal_loader : generic_3dtk_loader<true, false, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos_normal");
|
||||
};
|
||||
8
include/assets/data_loaders/uos_rgb_loader.hpp
Normal file
8
include/assets/data_loaders/uos_rgb_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uos_rgb_loader : generic_3dtk_loader<false, true, false>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uos_rgb");
|
||||
};
|
||||
8
include/assets/data_loaders/uosr_loader.hpp
Normal file
8
include/assets/data_loaders/uosr_loader.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_3dtk_loader.hpp"
|
||||
|
||||
struct uosr_loader : generic_3dtk_loader<false, false, true>
|
||||
{
|
||||
static constexpr auto name = std::string_view("uosr");
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_library_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_library_store.hpp"
|
||||
#include "assets/prefetch_lookups/material_library_prefetch_lookup.hpp"
|
||||
#include "generic/base_dynamic_loader.hpp"
|
||||
|
||||
#include "assets/data_loaders/mtl_loader.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
class dynamic_material_library_loader : public base_dynamic_loader<
|
||||
components::material::flags,
|
||||
mtl_loader
|
||||
> {
|
||||
public:
|
||||
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_material_library_store& store,
|
||||
dynamic_material_store& material_store,
|
||||
material_library_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
dynamic_material_library_buffer m_buffer{};
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "generic/base_dynamic_loader.hpp"
|
||||
|
||||
#include "assets/data_loaders/mtl_loader.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
#include "assets/prefetch_lookups/material_prefetch_lookup.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
class dynamic_material_loader : public base_dynamic_loader<
|
||||
components::material::flags
|
||||
// TODO no loaders
|
||||
> {
|
||||
public:
|
||||
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_material_store& store,
|
||||
material_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
dynamic_material_buffer m_buffer{};
|
||||
};
|
||||
35
include/assets/dynamic_data_loaders/dynamic_mesh_loader.hpp
Normal file
35
include/assets/dynamic_data_loaders/dynamic_mesh_loader.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/base_dynamic_loader.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
#include "assets/data_loaders/obj_loader.hpp"
|
||||
#include "assets/data_loaders/stl_loader.hpp"
|
||||
#include "assets/prefetch_lookups/mesh_prefetch_lookup.hpp"
|
||||
|
||||
|
||||
class dynamic_mesh_loader : public base_dynamic_loader<
|
||||
components::mesh_vertex::flags,
|
||||
obj_loader,
|
||||
stl_loader
|
||||
> {
|
||||
public:
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_mesh_store& store,
|
||||
mesh_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
dynamic_mesh_buffer m_buffer{};
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "generic/base_dynamic_loader.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_point_cloud_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
|
||||
#include "assets/data_loaders/kitti_loader.hpp"
|
||||
#include "assets/data_loaders/uos_loader.hpp"
|
||||
#include "assets/data_loaders/uos_normal_loader.hpp"
|
||||
#include "assets/data_loaders/uos_rgb_loader.hpp"
|
||||
#include "assets/data_loaders/uosr_loader.hpp"
|
||||
#include "assets/prefetch_lookups/point_cloud_prefetch_lookup.hpp"
|
||||
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
class dynamic_point_cloud_loader : public base_dynamic_loader<
|
||||
components::point_cloud_vertex::flags,
|
||||
kitti_loader,
|
||||
uos_loader,
|
||||
uos_normal_loader,
|
||||
uos_rgb_loader,
|
||||
uos_loader,
|
||||
uosr_loader
|
||||
> {
|
||||
public:
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_point_cloud_store& store,
|
||||
point_cloud_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
dynamic_point_cloud_buffer m_buffer{};
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <filesystem>
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
#include "assets/components/texture_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_texture_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_texture_store.hpp"
|
||||
#include "assets/dynamic_data_loader_ctx.hpp"
|
||||
#include "assets/prefetch_queue.hpp"
|
||||
#include "assets/prefetch_lookups/texture_prefetch_lookup.hpp"
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
/*
|
||||
* [[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_point_cloud_store& store,
|
||||
point_cloud_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
*/
|
||||
|
||||
class dynamic_texture_loader
|
||||
{
|
||||
public:
|
||||
using loader_id_type = ztu::id_type_for<dynamic_texture_loader, ztu::u8>;
|
||||
|
||||
explicit dynamic_texture_loader(components::texture::flags enabled_components);
|
||||
|
||||
[[nodiscard]] std::optional<loader_id_type> find_loader(const std::string_view& name);
|
||||
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
prefetch_queue& queue
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code load(
|
||||
loader_id_type loader_id,
|
||||
const ztu::string_list& directories,
|
||||
dynamic_texture_store& store,
|
||||
texture_prefetch_lookup& id_lookup,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
ztu::string_lookup<loader_id_type> m_loader_id_lookup{};
|
||||
components::texture::flags m_enabled_components{ components::texture::flags::none };
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
#include "assets/dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
#include "util/uix.hpp"
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
#include "util/result.hpp"
|
||||
|
||||
template<typename C, class... Loaders>
|
||||
class base_dynamic_loader
|
||||
{
|
||||
public:
|
||||
using loader_id_type = ztu::id_type_for<base_dynamic_loader, ztu::u32>;
|
||||
|
||||
explicit base_dynamic_loader(C enabled_components);
|
||||
|
||||
[[nodiscard]] std::optional<loader_id_type> find_loader(std::string_view name);
|
||||
|
||||
[[nodiscard]] static consteval std::optional<loader_id_type> find_loader_static(std::string_view name);
|
||||
|
||||
template<loader_id_type ID>
|
||||
auto& get_loader();
|
||||
|
||||
protected:
|
||||
|
||||
template<typename F>
|
||||
ztu::result<dynamic_point_cloud_store::id_type> invoke_with_matching_loader(loader_id_type loader_id, F&& f);
|
||||
|
||||
std::tuple<Loaders...> m_loaders{};
|
||||
ztu::string_lookup<loader_id_type> m_loader_id_lookup{};
|
||||
C m_enabled_components{ 0 };
|
||||
};
|
||||
|
||||
#define INCLUDE_BASE_DYNAMIC_LOADER_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_loaders/generic/base_dynamic_loader.ipp"
|
||||
#undef INCLUDE_BASE_DYNAMIC_LOADER_IMPLEMENTATION
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_library_buffer.hpp"
|
||||
|
||||
using dynamic_material_library_store = generic_dynamic_store<dynamic_material_library_buffer>;
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "dynamic_texture_store.hpp"
|
||||
#include "generic/generic_dynamic_component_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_buffer.hpp"
|
||||
|
||||
class dynamic_material_store {
|
||||
using store_type = generic_dynamic_component_store<
|
||||
components::material::flags,
|
||||
components::material::surface_properties,
|
||||
components::material::transparency,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type,
|
||||
dynamic_texture_store::id_type
|
||||
>;
|
||||
|
||||
public:
|
||||
using id_type = store_type::id_type;
|
||||
using iterator_type = store_type::iterator_type;
|
||||
using const_iterator = store_type::const_iterator;
|
||||
|
||||
id_type add(const dynamic_material_buffer& data);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
store_type m_store;
|
||||
};
|
||||
37
include/assets/dynamic_data_stores/dynamic_mesh_store.hpp
Normal file
37
include/assets/dynamic_data_stores/dynamic_mesh_store.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/dynamic_data_stores/generic/generic_dynamic_indexed_component_array_store.hpp"
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp"
|
||||
|
||||
class dynamic_mesh_store
|
||||
{
|
||||
using store_type = generic_dynamic_indexed_component_array_store<
|
||||
components::mesh_vertex::flags,
|
||||
ztu::u32,
|
||||
components::mesh_vertex::position,
|
||||
components::mesh_vertex::normal,
|
||||
components::mesh_vertex::tex_coord,
|
||||
components::mesh_vertex::color,
|
||||
components::mesh_vertex::reflectance
|
||||
>;
|
||||
|
||||
public:
|
||||
using id_type = store_type::id_type;
|
||||
using iterator_type = store_type::iterator_type;
|
||||
using const_iterator = store_type::const_iterator;
|
||||
|
||||
id_type add(const dynamic_mesh_buffer& mesh_buffer);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
store_type m_store;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/dynamic_data_stores/generic/generic_dynamic_component_array_store.hpp"
|
||||
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_point_cloud_buffer.hpp"
|
||||
|
||||
|
||||
class dynamic_point_cloud_store
|
||||
{
|
||||
using store_type = generic_dynamic_component_array_store<
|
||||
components::point_cloud_vertex::flags,
|
||||
components::point_cloud_vertex::position,
|
||||
components::point_cloud_vertex::normal,
|
||||
components::point_cloud_vertex::color,
|
||||
components::point_cloud_vertex::reflectance
|
||||
>;
|
||||
|
||||
public:
|
||||
using id_type = store_type::id_type;
|
||||
using iterator_type = store_type::iterator_type;
|
||||
using const_iterator = store_type::const_iterator;
|
||||
|
||||
id_type add(const dynamic_point_cloud_buffer& point_cloud_buffer);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
store_type m_store;
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "glm/mat4x4.hpp"
|
||||
|
||||
using dynamic_pose_store = generic_dynamic_store<glm::mat4>;
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "glm/mat4x4.hpp"
|
||||
|
||||
class dynamic_shader_store {
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "generic/generic_dynamic_store.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_texture_buffer.hpp"
|
||||
|
||||
using dynamic_texture_store = generic_dynamic_store<dynamic_texture_buffer>;
|
||||
37
include/assets/dynamic_data_stores/dynamic_vertex_store.hpp
Normal file
37
include/assets/dynamic_data_stores/dynamic_vertex_store.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <span>
|
||||
#include "util/id_type.hpp"
|
||||
#include "util/uix.hpp"
|
||||
|
||||
#include "GL/glew.h"
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class dynamic_vertex_store {
|
||||
public:
|
||||
using id_type = ztu::id_type_for<dynamic_vertex_store, ztu::u32>;
|
||||
|
||||
void add(
|
||||
C component_flags,
|
||||
std::span<const Ts>... components
|
||||
);
|
||||
|
||||
void build_vertex_buffer(
|
||||
std::vector<ztu::u8>& vertex_buffer,
|
||||
std::size_t& component_count,
|
||||
std::array<GLenum, sizeof...(Ts)>& component_types,
|
||||
std::array<GLint, sizeof...(Ts)>& component_lengths,
|
||||
GLsizei& stride
|
||||
) const;
|
||||
|
||||
protected:
|
||||
std::tuple<std::vector<Ts>...> m_component_buffers{};
|
||||
std::vector<std::size_t> vertex_counts;
|
||||
std::vector<C> m_components{ 0 };
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_MODEL_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_model_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_MODEL_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,149 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
|
||||
#include <tuple>
|
||||
#include <span>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class generic_dynamic_component_array_store;
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class component_array_iterator {
|
||||
public:
|
||||
using value_type = std::tuple<std::span<Ts>...>;
|
||||
using size_type = std::size_t;
|
||||
using count_type = ztu::u32;
|
||||
using flag_count_type = std::pair<C, count_type>;
|
||||
using component_array_pointer_type = std::tuple<std::add_pointer_t<Ts>...>;
|
||||
using flag_count_pointer_type = const flag_count_type*;
|
||||
using offsets_type = std::array<size_type, sizeof...(Ts)>;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type;
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
|
||||
private:
|
||||
friend generic_dynamic_component_array_store<C, Ts...>;
|
||||
|
||||
component_array_iterator(
|
||||
component_array_pointer_type components,
|
||||
flag_count_pointer_type flags,
|
||||
std::size_t index,
|
||||
const offsets_type& offsets
|
||||
);
|
||||
|
||||
public:
|
||||
constexpr component_array_iterator() noexcept = default;
|
||||
|
||||
constexpr component_array_iterator(const component_array_iterator&) noexcept = default;
|
||||
constexpr component_array_iterator(component_array_iterator&&) noexcept = default;
|
||||
|
||||
constexpr component_array_iterator& operator=(const component_array_iterator&) noexcept = default;
|
||||
constexpr component_array_iterator& operator=(component_array_iterator&&) noexcept = default;
|
||||
|
||||
reference operator*() const;
|
||||
|
||||
component_array_iterator& operator++();
|
||||
component_array_iterator operator++(int);
|
||||
component_array_iterator& operator--();
|
||||
component_array_iterator operator--(int);
|
||||
|
||||
component_array_iterator& operator+=(difference_type n);
|
||||
component_array_iterator& operator-=(difference_type n);
|
||||
component_array_iterator operator+(difference_type n) const;
|
||||
component_array_iterator operator-(difference_type n) const;
|
||||
difference_type operator-(const component_array_iterator& other) const;
|
||||
|
||||
reference operator[](difference_type n) const;
|
||||
|
||||
bool operator==(const component_array_iterator& other) const;
|
||||
bool operator!=(const component_array_iterator& other) const;
|
||||
bool operator<(const component_array_iterator& other) const;
|
||||
bool operator<=(const component_array_iterator& other) const;
|
||||
bool operator>(const component_array_iterator& other) const;
|
||||
bool operator>=(const component_array_iterator& other) const;
|
||||
|
||||
protected:
|
||||
template <std::size_t I>
|
||||
static bool is_component_enabled(C flag);
|
||||
|
||||
template <std::size_t... Is>
|
||||
void calc_offsets(std::index_sequence<Is...>, difference_type n);
|
||||
|
||||
template <std::size_t... Is>
|
||||
reference dereference(std::index_sequence<Is...>) const;
|
||||
|
||||
template <std::size_t N>
|
||||
std::tuple_element_t<N, value_type> get_span() const;
|
||||
|
||||
private:
|
||||
value_type m_components{};
|
||||
const flag_count_type* m_flag_counts{};
|
||||
size_type m_index{};
|
||||
offsets_type m_offsets{};
|
||||
};
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class generic_dynamic_component_array_store
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::id_type_for<generic_dynamic_component_array_store, ztu::u32>;
|
||||
using count_type = ztu::u32;
|
||||
using iterator_type = component_array_iterator<C, Ts...>;
|
||||
using const_iterator = component_array_iterator<C, std::add_const_t<Ts>...>;
|
||||
using view_type = std::ranges::subrange<iterator_type>;
|
||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
||||
|
||||
id_type add(const std::tuple<std::vector<Ts>...>& component_arrays);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
iterator_type begin();
|
||||
|
||||
iterator_type end();
|
||||
|
||||
const_iterator begin() const;
|
||||
|
||||
const_iterator end() const;
|
||||
|
||||
const_iterator cbegin() const;
|
||||
|
||||
const_iterator cend() const;
|
||||
|
||||
view_type view();
|
||||
|
||||
const_view_type view() const;
|
||||
|
||||
protected:
|
||||
std::tuple<std::add_pointer_t<Ts>...> data_ptrs();
|
||||
|
||||
std::tuple<std::add_pointer_t<std::add_const_t<Ts>>...> data_ptrs() const;
|
||||
|
||||
std::array<std::size_t, sizeof...(Ts)> data_counts() const;
|
||||
|
||||
private:
|
||||
std::tuple<std::vector<Ts>...> m_component_arrays;
|
||||
std::vector<std::pair<C, ztu::u32>> m_component_flag_counts;
|
||||
std::vector<id_type> m_ids;
|
||||
id_type m_next_data_id{ 1 };
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_DYNAMIC_COMPONENT_ARRAY_STORE_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_stores/generic/generic_dynamic_component_array_store.ipp"
|
||||
#undef INCLUDE_GENERIC_DYNAMIC_COMPONENT_ARRAY_STORE_IMPLEMENTATION
|
||||
@@ -0,0 +1,147 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
|
||||
#include <tuple>
|
||||
#include <span>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class generic_dynamic_component_store;
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class component_iterator {
|
||||
public:
|
||||
|
||||
|
||||
using value_type = std::tuple<std::add_pointer_t<Ts>...>;
|
||||
using size_type = std::size_t;
|
||||
using offsets_type = std::array<size_type, sizeof...(Ts)>;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type;
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
|
||||
private:
|
||||
friend generic_dynamic_component_store<C, Ts...>;
|
||||
|
||||
component_iterator(
|
||||
value_type components,
|
||||
const C* flags,
|
||||
std::size_t index,
|
||||
const offsets_type& offsets
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
constexpr component_iterator() noexcept = default;
|
||||
|
||||
constexpr component_iterator(const component_iterator&) noexcept = default;
|
||||
constexpr component_iterator(component_iterator&&) noexcept = default;
|
||||
|
||||
constexpr component_iterator& operator=(const component_iterator&) noexcept = default;
|
||||
constexpr component_iterator& operator=(component_iterator&&) noexcept = default;
|
||||
|
||||
reference operator*() const;
|
||||
|
||||
component_iterator& operator++();
|
||||
component_iterator operator++(int);
|
||||
component_iterator& operator--();
|
||||
component_iterator operator--(int);
|
||||
|
||||
component_iterator& operator+=(difference_type n);
|
||||
component_iterator& operator-=(difference_type n);
|
||||
component_iterator operator+(difference_type n) const;
|
||||
component_iterator operator-(difference_type n) const;
|
||||
difference_type operator-(const component_iterator& other) const;
|
||||
|
||||
reference operator[](difference_type n) const;
|
||||
|
||||
bool operator==(const component_iterator& other) const;
|
||||
bool operator!=(const component_iterator& other) const;
|
||||
bool operator<(const component_iterator& other) const;
|
||||
bool operator<=(const component_iterator& other) const;
|
||||
bool operator>(const component_iterator& other) const;
|
||||
bool operator>=(const component_iterator& other) const;
|
||||
|
||||
protected:
|
||||
template <std::size_t I>
|
||||
static bool is_component_enabled(C flag);
|
||||
|
||||
template <std::size_t... Is>
|
||||
void calc_offsets(std::index_sequence<Is...>, difference_type n);
|
||||
|
||||
template <std::size_t... Is>
|
||||
reference dereference(std::index_sequence<Is...>) const;
|
||||
|
||||
template <std::size_t N>
|
||||
std::tuple_element_t<N, value_type> get_pointer() const;
|
||||
|
||||
private:
|
||||
value_type m_components{};
|
||||
const C* m_flags{};
|
||||
size_type m_index{};
|
||||
offsets_type m_offsets{};
|
||||
};
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
class generic_dynamic_component_store
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::id_type_for<generic_dynamic_component_store, ztu::u32>;
|
||||
using iterator_type = component_iterator<C, Ts...>;
|
||||
using const_iterator = component_iterator<C, std::add_const_t<Ts>...>;
|
||||
using view_type = std::ranges::subrange<iterator_type>;
|
||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
||||
|
||||
id_type add(const std::tuple<std::optional<Ts>...>& data);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
iterator_type begin();
|
||||
|
||||
iterator_type end();
|
||||
|
||||
const_iterator begin() const;
|
||||
|
||||
const_iterator end() const;
|
||||
|
||||
const_iterator cbegin() const;
|
||||
|
||||
const_iterator cend() const;
|
||||
|
||||
view_type view();
|
||||
|
||||
const_view_type view() const;
|
||||
|
||||
protected:
|
||||
std::tuple<std::add_pointer_t<Ts>...> data_ptrs();
|
||||
|
||||
std::tuple<std::add_pointer_t<std::add_const_t<Ts>>...> data_ptrs() const;
|
||||
|
||||
std::array<std::size_t, sizeof...(Ts)> data_counts() const;
|
||||
|
||||
private:
|
||||
std::tuple<std::vector<Ts>...> m_components;
|
||||
std::vector<C> m_component_flags;
|
||||
std::vector<id_type> m_ids;
|
||||
id_type m_next_data_id{ 1 };
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_DYNAMIC_COMPONENT_STORE_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_stores/generic_dynamic_component_store.ipp"
|
||||
#undef INCLUDE_GENERIC_DYNAMIC_COMPONENT_STORE_IMPLEMENTATION
|
||||
@@ -0,0 +1,157 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
|
||||
#include <tuple>
|
||||
#include <span>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
|
||||
template<typename C, typename I, typename... Ts>
|
||||
class generic_dynamic_indexed_component_array_store;
|
||||
|
||||
template<typename C, typename I, typename... Ts>
|
||||
class indexed_component_array_iterator {
|
||||
public:
|
||||
using index_type = I;
|
||||
using value_type = std::tuple<std::span<I>, std::span<Ts>...>;
|
||||
using size_type = std::size_t;
|
||||
using count_type = ztu::u32;
|
||||
using flag_count_type = std::tuple<C, count_type, count_type>;
|
||||
using index_array_pointer_type = const index_type*;
|
||||
using component_array_pointer_type = std::tuple<std::add_pointer_t<Ts>...>;
|
||||
using flag_count_pointer_type = const flag_count_type*;
|
||||
|
||||
using offsets_type = std::array<size_type, 1 + sizeof...(Ts)>;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type;
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
|
||||
private:
|
||||
friend generic_dynamic_indexed_component_array_store<C, I, Ts...>;
|
||||
|
||||
indexed_component_array_iterator(
|
||||
index_array_pointer_type indices,
|
||||
const component_array_pointer_type& components,
|
||||
flag_count_pointer_type flag_counts,
|
||||
std::size_t index,
|
||||
const offsets_type& offsets
|
||||
);
|
||||
|
||||
public:
|
||||
constexpr indexed_component_array_iterator() noexcept = default;
|
||||
|
||||
constexpr indexed_component_array_iterator(const indexed_component_array_iterator&) noexcept = default;
|
||||
constexpr indexed_component_array_iterator(indexed_component_array_iterator&&) noexcept = default;
|
||||
|
||||
constexpr indexed_component_array_iterator& operator=(const indexed_component_array_iterator&) noexcept = default;
|
||||
constexpr indexed_component_array_iterator& operator=(indexed_component_array_iterator&&) noexcept = default;
|
||||
|
||||
reference operator*() const;
|
||||
|
||||
indexed_component_array_iterator& operator++();
|
||||
indexed_component_array_iterator operator++(int);
|
||||
indexed_component_array_iterator& operator--();
|
||||
indexed_component_array_iterator operator--(int);
|
||||
|
||||
indexed_component_array_iterator& operator+=(difference_type n);
|
||||
indexed_component_array_iterator& operator-=(difference_type n);
|
||||
indexed_component_array_iterator operator+(difference_type n) const;
|
||||
indexed_component_array_iterator operator-(difference_type n) const;
|
||||
difference_type operator-(const indexed_component_array_iterator& other) const;
|
||||
|
||||
reference operator[](difference_type n) const;
|
||||
|
||||
bool operator==(const indexed_component_array_iterator& other) const;
|
||||
bool operator!=(const indexed_component_array_iterator& other) const;
|
||||
bool operator<(const indexed_component_array_iterator& other) const;
|
||||
bool operator<=(const indexed_component_array_iterator& other) const;
|
||||
bool operator>(const indexed_component_array_iterator& other) const;
|
||||
bool operator>=(const indexed_component_array_iterator& other) const;
|
||||
|
||||
protected:
|
||||
template <std::size_t N>
|
||||
static bool is_component_enabled(C flag);
|
||||
|
||||
template <std::size_t... Is>
|
||||
void calc_offsets(std::index_sequence<Is...>, difference_type n);
|
||||
|
||||
template <std::size_t... Is>
|
||||
reference dereference(std::index_sequence<Is...>) const;
|
||||
|
||||
private:
|
||||
index_array_pointer_type m_indices{};
|
||||
component_array_pointer_type m_components{};
|
||||
flag_count_pointer_type m_flag_counts{};
|
||||
size_type m_index{};
|
||||
offsets_type m_offsets{};
|
||||
};
|
||||
|
||||
template<typename C, typename I, typename... Ts>
|
||||
class generic_dynamic_indexed_component_array_store
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::id_type_for<generic_dynamic_indexed_component_array_store, ztu::u32>;
|
||||
using count_type = ztu::u32;
|
||||
using iterator_type = indexed_component_array_iterator<C, I, Ts...>;
|
||||
using const_iterator = indexed_component_array_iterator<C, I, std::add_const_t<Ts>...>;
|
||||
using view_type = std::ranges::subrange<iterator_type>;
|
||||
using const_view_type = std::ranges::subrange<const_iterator>;
|
||||
|
||||
id_type add(
|
||||
std::span<const I> indices,
|
||||
const std::tuple<std::vector<Ts>...>& component_arrays
|
||||
);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
void remove(const iterator_type& it);
|
||||
|
||||
void clear();
|
||||
|
||||
iterator_type begin();
|
||||
|
||||
iterator_type end();
|
||||
|
||||
const_iterator begin() const;
|
||||
|
||||
const_iterator end() const;
|
||||
|
||||
const_iterator cbegin() const;
|
||||
|
||||
const_iterator cend() const;
|
||||
|
||||
view_type view();
|
||||
|
||||
const_view_type view() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
std::tuple<std::add_pointer_t<Ts>...> component_array_ptrs();
|
||||
|
||||
std::tuple<std::add_pointer_t<std::add_const_t<Ts>>...> component_array_ptrs() const;
|
||||
|
||||
std::array<std::size_t, 1 + sizeof...(Ts)> array_counts() const;
|
||||
|
||||
private:
|
||||
std::vector<I> m_indices;
|
||||
std::tuple<std::vector<Ts>...> m_component_arrays;
|
||||
std::vector<std::pair<C, ztu::u32>> m_component_flag_counts;
|
||||
std::vector<id_type> m_ids;
|
||||
id_type m_next_data_id{ 1 };
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_DYNAMIC_INDEXED_COMPONENT_ARRAY_STORE_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_stores/generic/generic_dynamic_indexed_component_array_store.ipp"
|
||||
#undef INCLUDE_GENERIC_DYNAMIC_INDEXED_COMPONENT_ARRAY_STORE_IMPLEMENTATION
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "util/id_type.hpp"
|
||||
|
||||
template<typename T>
|
||||
class generic_dynamic_store
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::id_type_for<generic_dynamic_store, ztu::u32>;
|
||||
using container_type = std::vector<T>;
|
||||
using iterator_type = typename container_type::iterator;
|
||||
using const_iterator = typename container_type::const_iterator;
|
||||
|
||||
id_type add(const T& data);
|
||||
|
||||
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
|
||||
|
||||
[[nodiscard]] std::pair<const_iterator, bool> find(id_type id) const;
|
||||
|
||||
[[nodiscard]] std::span<T> data();
|
||||
|
||||
[[nodiscard]] std::span<const T> data() const;
|
||||
|
||||
void remove(iterator_type it);
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
std::vector<T> m_data;
|
||||
std::vector<id_type> m_ids;
|
||||
id_type m_next_data_id{ 1 };
|
||||
};
|
||||
|
||||
#define INCLUDE_GENERIC_DYNAMIC_STORE_IMPLEMENTATION
|
||||
#include "assets/dynamic_data_stores/generic_dynamic_store.ipp"
|
||||
#undef INCLUDE_GENERIC_DYNAMIC_STORE_IMPLEMENTATION
|
||||
48
include/assets/dynamic_read_buffers/dynamic_material_buffer.hpp
Executable file
48
include/assets/dynamic_read_buffers/dynamic_material_buffer.hpp
Executable file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_texture_store.hpp"
|
||||
|
||||
struct dynamic_material_buffer {
|
||||
|
||||
dynamic_material_buffer() = default;
|
||||
|
||||
components::material::surface_properties& initialized_surface_properties();
|
||||
|
||||
[[nodiscard]] std::optional<components::material::surface_properties>& surface_properties();
|
||||
[[nodiscard]] std::optional<components::material::transparency>& transparency();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& ambient_color_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& diffuse_color_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& specular_color_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& shininess_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& alpha_texture_id();
|
||||
[[nodiscard]] std::optional<dynamic_texture_store::id_type>& bump_texture_id();
|
||||
|
||||
[[nodiscard]] const std::optional<components::material::surface_properties>& surface_properties() const;
|
||||
[[nodiscard]] const std::optional<components::material::transparency>& transparency() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& ambient_color_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& diffuse_color_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& specular_color_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& shininess_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& alpha_texture_id() const;
|
||||
[[nodiscard]] const std::optional<dynamic_texture_store::id_type>& bump_texture_id() const;
|
||||
|
||||
std::tuple<
|
||||
std::optional<components::material::surface_properties>,
|
||||
std::optional<components::material::transparency>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>,
|
||||
std::optional<dynamic_texture_store::id_type>
|
||||
> data{
|
||||
std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt
|
||||
};
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_MATERIAL_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_material_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_MATERIAL_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/string_lookup.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
|
||||
using dynamic_material_library_buffer = ztu::string_lookup<dynamic_material_store::id_type>;
|
||||
46
include/assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp
Normal file
46
include/assets/dynamic_read_buffers/dynamic_mesh_buffer.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/dynamic_read_buffers/dynamic_vertex_buffer.hpp"
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
|
||||
class dynamic_mesh_buffer : public dynamic_vertex_buffer<
|
||||
components::mesh_vertex::flags,
|
||||
components::mesh_vertex::position,
|
||||
components::mesh_vertex::normal,
|
||||
components::mesh_vertex::tex_coord,
|
||||
components::mesh_vertex::color,
|
||||
components::mesh_vertex::reflectance
|
||||
> {
|
||||
public:
|
||||
using index_type = ztu::u32;
|
||||
using triangle_type = std::array<index_type, 3>;
|
||||
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::position>& positions();
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::normal>& normals();
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::tex_coord>& tex_coords();
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::color>& colors();
|
||||
[[nodiscard]] std::vector<components::mesh_vertex::reflectance>& reflectances();
|
||||
[[nodiscard]] std::vector<triangle_type>& triangles();
|
||||
[[nodiscard]] auto& material_id();
|
||||
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::position>& positions() const;
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::normal>& normals() const;
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::tex_coord>& tex_coords() const;
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::color>& colors() const;
|
||||
[[nodiscard]] const std::vector<components::mesh_vertex::reflectance>& reflectances() const;
|
||||
[[nodiscard]] const std::vector<triangle_type>& triangles() const;
|
||||
[[nodiscard]] const auto& material_id() const;
|
||||
|
||||
private:
|
||||
std::vector<triangle_type> m_triangles{};
|
||||
dynamic_material_store::id_type m_material_id{};
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_MESH_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_mesh_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_MESH_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "assets/dynamic_read_buffers/dynamic_vertex_buffer.hpp"
|
||||
|
||||
class dynamic_point_cloud_buffer : public dynamic_vertex_buffer<
|
||||
components::point_cloud_vertex::flags,
|
||||
components::point_cloud_vertex::position,
|
||||
components::point_cloud_vertex::normal,
|
||||
components::point_cloud_vertex::color,
|
||||
components::point_cloud_vertex::reflectance
|
||||
> {
|
||||
public:
|
||||
[[nodiscard]] std::vector<components::point_cloud_vertex::position>& positions();
|
||||
[[nodiscard]] std::vector<components::point_cloud_vertex::normal>& normals();
|
||||
[[nodiscard]] std::vector<components::point_cloud_vertex::color>& colors();
|
||||
[[nodiscard]] std::vector<components::point_cloud_vertex::reflectance>& reflectances();
|
||||
|
||||
[[nodiscard]] const std::vector<components::point_cloud_vertex::position>& positions() const;
|
||||
[[nodiscard]] const std::vector<components::point_cloud_vertex::normal>& normals() const;
|
||||
[[nodiscard]] const std::vector<components::point_cloud_vertex::color>& colors() const;
|
||||
[[nodiscard]] const std::vector<components::point_cloud_vertex::reflectance>& reflectances() const;
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_point_cloud_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "glm/mat4x4.hpp"
|
||||
|
||||
using dynamic_pose_buffer = glm::mat4;
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "GL/glew.h"
|
||||
|
||||
struct dynamic_shader_buffer
|
||||
{
|
||||
std::vector<char> source{};
|
||||
GLenum type{ GL_INVALID_ENUM };
|
||||
};
|
||||
77
include/assets/dynamic_read_buffers/dynamic_texture_buffer.hpp
Executable file
77
include/assets/dynamic_read_buffers/dynamic_texture_buffer.hpp
Executable file
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <bit>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include "assets/components/texture_components.hpp"
|
||||
|
||||
class dynamic_texture_buffer {
|
||||
public:
|
||||
using value_type = std::uint8_t;
|
||||
using dim_type = std::int32_t;
|
||||
using size_type = std::make_signed_t<std::size_t>;
|
||||
using difference_type = size_type;
|
||||
using reference = value_type&;
|
||||
using const_reference = const value_type&;
|
||||
using pointer = std::uint8_t*;
|
||||
using const_pointer = const std::uint8_t*;
|
||||
using iterator = pointer;
|
||||
using const_iterator = const_pointer;
|
||||
|
||||
dynamic_texture_buffer() = default;
|
||||
|
||||
dynamic_texture_buffer(
|
||||
std::unique_ptr<value_type>&& data,
|
||||
dim_type width,
|
||||
dim_type height,
|
||||
components::texture::flags components
|
||||
);
|
||||
|
||||
dynamic_texture_buffer(const dynamic_texture_buffer&);
|
||||
|
||||
dynamic_texture_buffer(dynamic_texture_buffer&&) noexcept;
|
||||
|
||||
[[nodiscard]] dynamic_texture_buffer& operator=(const dynamic_texture_buffer&);
|
||||
|
||||
[[nodiscard]] dynamic_texture_buffer& operator=(dynamic_texture_buffer&&) noexcept;
|
||||
|
||||
[[nodiscard]] components::texture::flags components() const;
|
||||
|
||||
[[nodiscard]] dim_type width() const;
|
||||
|
||||
[[nodiscard]] dim_type height() const;
|
||||
|
||||
[[nodiscard]] std::pair<dim_type, dim_type> dimensions() const;
|
||||
|
||||
[[nodiscard]] size_type pixel_count() const;
|
||||
|
||||
[[nodiscard]] size_type component_count() const;
|
||||
|
||||
[[nodiscard]] size_type size() const;
|
||||
|
||||
[[nodiscard]] const_iterator begin() const;
|
||||
|
||||
[[nodiscard]] iterator begin();
|
||||
|
||||
[[nodiscard]] const_iterator end() const;
|
||||
|
||||
[[nodiscard]] iterator end();
|
||||
|
||||
[[nodiscard]] const_iterator cbegin() const;
|
||||
|
||||
[[nodiscard]] const_iterator cend() const;
|
||||
|
||||
[[nodiscard]] const_pointer data() const;
|
||||
|
||||
[[nodiscard]] pointer data();
|
||||
|
||||
private:
|
||||
std::unique_ptr<value_type[]> m_data{ nullptr };
|
||||
dim_type m_width{ 0 }, m_height{ 0 };
|
||||
components::texture::flags m_components{ components::texture::flags::none };
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_texture_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_TEXTURE_DATA_IMPLEMENTATION
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/uix.hpp"
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "GL/glew.h"
|
||||
|
||||
template<typename C, typename... Ts>
|
||||
struct dynamic_vertex_buffer {
|
||||
std::tuple<std::vector<Ts>...> vertices{};
|
||||
};
|
||||
|
||||
#define INCLUDE_DYNAMIC_MODEL_DATA_IMPLEMENTATION
|
||||
#include "assets/dynamic_read_buffers/dynamic_texture_buffer.ipp"
|
||||
#undef INCLUDE_DYNAMIC_MODEL_DATA_IMPLEMENTATION
|
||||
20
include/assets/prefetch_lookup.hpp
Normal file
20
include/assets/prefetch_lookup.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "prefetch_lookups/material_library_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/material_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/mesh_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/point_cloud_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/pose_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/shader_prefetch_lookup.hpp"
|
||||
#include "prefetch_lookups/texture_prefetch_lookup.hpp"
|
||||
|
||||
struct prefetch_lookup
|
||||
{
|
||||
texture_prefetch_lookup textures;
|
||||
material_library_prefetch_lookup material_libraries;
|
||||
material_prefetch_lookup materials;
|
||||
mesh_prefetch_lookup meshes;
|
||||
pose_prefetch_lookup poses;
|
||||
point_cloud_prefetch_lookup point_clouds;
|
||||
shader_prefetch_lookup shaders;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_material_library_store.hpp"
|
||||
|
||||
using material_library_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_material_library_store::id_type>;
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
|
||||
|
||||
using material_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_material_store::id_type>;
|
||||
7
include/assets/prefetch_lookups/mesh_prefetch_lookup.hpp
Normal file
7
include/assets/prefetch_lookups/mesh_prefetch_lookup.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_mesh_store.hpp"
|
||||
|
||||
using mesh_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_mesh_store::id_type>;
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_point_cloud_store.hpp"
|
||||
|
||||
using point_cloud_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_point_cloud_store::id_type>;
|
||||
58
include/assets/prefetch_lookups/pose_prefetch_lookup.hpp
Normal file
58
include/assets/prefetch_lookups/pose_prefetch_lookup.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "assets/dynamic_data_stores/dynamic_pose_store.hpp"
|
||||
#include "util/uix.hpp"
|
||||
|
||||
class pose_prefetch_lookup {
|
||||
public:
|
||||
using index_type = ztu::u32;
|
||||
using directory_lookup = std::unordered_map<std::filesystem::path, index_type>;
|
||||
using directory_iterator = std::pair<directory_lookup::iterator, index_type>;
|
||||
using index_lookup = std::vector<index_type>;
|
||||
using index_iterator = index_lookup::iterator;
|
||||
using lookup_type = std::vector<dynamic_pose_store::id_type>;
|
||||
using iterator = lookup_type::iterator;
|
||||
|
||||
void emplace(
|
||||
const std::filesystem::path& directory,
|
||||
index_type index,
|
||||
dynamic_pose_store::id_type id
|
||||
);
|
||||
|
||||
void emplace_hint_dir(
|
||||
directory_iterator directory_it,
|
||||
const std::filesystem::path& directory,
|
||||
index_type index,
|
||||
dynamic_pose_store::id_type id
|
||||
);
|
||||
|
||||
void emplace_hint_dir_index(
|
||||
directory_iterator directory_it,
|
||||
index_iterator index_it,
|
||||
index_type index,
|
||||
dynamic_pose_store::id_type id
|
||||
);
|
||||
|
||||
std::pair<directory_iterator, bool> find_directory(
|
||||
const std::filesystem::path& directory
|
||||
);
|
||||
|
||||
std::pair<index_iterator, dynamic_pose_store::id_type> find_index(
|
||||
directory_iterator directory_it,
|
||||
index_type index
|
||||
);
|
||||
|
||||
protected:
|
||||
directory_iterator emplace_dir(
|
||||
directory_iterator directory_it,
|
||||
const std::filesystem::path& directory
|
||||
);
|
||||
|
||||
private:
|
||||
directory_lookup m_directory_lookup;
|
||||
index_lookup m_directory_indices; // count before indices, indices sorted per dir
|
||||
lookup_type m_pose_ids; // offset by 1
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_shader_st
|
||||
|
||||
using texture_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_texture_store::id_type>;
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include "assets/dynamic_data_stores/dynamic_texture_store.hpp"
|
||||
|
||||
using texture_prefetch_lookup = std::unordered_map<std::filesystem::path, dynamic_texture_store::id_type>;
|
||||
28
include/assets/prefetch_queue.hpp
Normal file
28
include/assets/prefetch_queue.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/string_list.hpp"
|
||||
|
||||
struct file_dir_list
|
||||
{
|
||||
ztu::string_list files;
|
||||
ztu::string_list directories;
|
||||
};
|
||||
|
||||
struct prefetch_queue
|
||||
{
|
||||
file_dir_list obj_queue;
|
||||
file_dir_list stl_queue;
|
||||
|
||||
file_dir_list mtl_queue;
|
||||
|
||||
file_dir_list uosr_queue;
|
||||
file_dir_list uos_rgb_queue;
|
||||
file_dir_list uos_normal_queue;
|
||||
file_dir_list uos_queue;
|
||||
file_dir_list kitti_queue;
|
||||
|
||||
file_dir_list threedtk_pose_queue;
|
||||
file_dir_list kitti_pose_queue;
|
||||
|
||||
file_dir_list glsl_queue;
|
||||
};
|
||||
58
include/opengl/data/material_data.hpp
Normal file
58
include/opengl/data/material_data.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/data/texture.hpp"
|
||||
#include "assets/data/surface_properties.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
|
||||
#include "opengl/handles/material_handle.hpp"
|
||||
#include "opengl/data/texture_data.hpp"
|
||||
|
||||
#include <system_error>
|
||||
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
struct material_data
|
||||
{
|
||||
private:
|
||||
material_data(
|
||||
const std::optional<texture_handle>& texture_handle,
|
||||
const std::optional<surface_properties_handle>& surface_properties_handle,
|
||||
const std::optional<alpha_handle>& alpha_handle,
|
||||
std::optional<texture_data>&& texture_data,
|
||||
components::material::flags components
|
||||
);
|
||||
|
||||
public:
|
||||
material_data() = default;
|
||||
|
||||
[[nodiscard]] static std::error_code build_from(
|
||||
const std::optional<components::material::texture>& texture_opt,
|
||||
const std::optional<components::material::surface_properties>& surface_properties_opt,
|
||||
const std::optional<components::material::transparency>& transparency_opt,
|
||||
material_component::flags components,
|
||||
material_data& data
|
||||
);
|
||||
|
||||
material_data(const material_data& other) = delete;
|
||||
material_data& operator=(const material_data& other) = delete;
|
||||
|
||||
material_data(material_data&& other) noexcept;
|
||||
material_data& operator=(material_data&& other) noexcept;
|
||||
|
||||
[[nodiscard]] material_handle handle() const;
|
||||
|
||||
[[nodiscard]] material_component::flags components() const;
|
||||
|
||||
private:
|
||||
material_handle m_handle{};
|
||||
std::optional<texture_data> m_texture_data{ std::nullopt };
|
||||
material_component::flags m_component_types{
|
||||
material_component::flags::none
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#define INCLUDE_MATERIAL_DATA_IMPLEMENTATION
|
||||
#include "opengl/data/material_data.ipp"
|
||||
#undef INCLUDE_MATERIAL_DATA_IMPLEMENTATION
|
||||
68
include/opengl/data/mesh_data.hpp
Executable file
68
include/opengl/data/mesh_data.hpp
Executable file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/handles/mesh_handle.hpp"
|
||||
#include "util/uix.hpp"
|
||||
|
||||
#include <system_error>
|
||||
#include <span>
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "GL/glew.h"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
struct mesh_data
|
||||
{
|
||||
private:
|
||||
mesh_data(
|
||||
GLuint vertex_vbo_id,
|
||||
GLuint index_vbo_id,
|
||||
GLuint vao_id,
|
||||
ztu::u32 material_id,
|
||||
components::mesh_vertex::flags components,
|
||||
GLsizei index_count
|
||||
);
|
||||
|
||||
public:
|
||||
mesh_data() = default;
|
||||
|
||||
[[nodiscard]] static std::error_code build_from(
|
||||
std::span<const std::uint8_t> vertex_buffer,
|
||||
std::span<const GLenum> component_types,
|
||||
std::span<const GLint> component_lengths,
|
||||
GLsizei stride,
|
||||
std::span<const ztu::u32> index_buffer,
|
||||
ztu::u32 material_id,
|
||||
components::mesh_vertex::flags components,
|
||||
mesh_data& data
|
||||
);
|
||||
|
||||
mesh_data(const mesh_data& other) = delete;
|
||||
mesh_data& operator=(const mesh_data& other) = delete;
|
||||
|
||||
mesh_data(mesh_data&& other) noexcept;
|
||||
mesh_data& operator=(mesh_data&& other) noexcept;
|
||||
|
||||
~mesh_data();
|
||||
|
||||
[[nodiscard]] mesh_handle handle() const;
|
||||
|
||||
[[nodiscard]] components::mesh_vertex::flags components() const;
|
||||
|
||||
[[nodiscard]] ztu::u32 material_id() const;
|
||||
|
||||
|
||||
private:
|
||||
mesh_handle m_handle{};
|
||||
GLuint m_vertex_vbo_id{ 0 };
|
||||
GLuint m_index_vbo_id{ 0 };
|
||||
ztu::u32 m_material_id{ 0 };
|
||||
components::mesh_vertex::flags m_component_types{
|
||||
components::mesh_vertex::flags::none
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#define INCLUDE_MESH_DATA_IMPLEMENTATION
|
||||
#include "opengl/data/mesh_data.ipp"
|
||||
#undef INCLUDE_MESH_DATA_IMPLEMENTATION
|
||||
55
include/opengl/data/point_cloud_data.hpp
Normal file
55
include/opengl/data/point_cloud_data.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/uix.hpp"
|
||||
|
||||
#include <span>
|
||||
#include <system_error>
|
||||
#include "GL/glew.h"
|
||||
#include "opengl/handles/point_cloud_handle.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
|
||||
namespace zgl {
|
||||
struct point_cloud_data {
|
||||
private:
|
||||
point_cloud_data(
|
||||
GLuint vertex_buffer_id,
|
||||
GLuint vao_id,
|
||||
GLsizei point_count
|
||||
);
|
||||
|
||||
public:
|
||||
point_cloud_data() = default;
|
||||
|
||||
[[nodiscard]] static std::error_code build_from(
|
||||
std::span<const std::uint8_t> point_buffer,
|
||||
std::span<const GLenum> component_types,
|
||||
std::span<const GLint> component_lengths,
|
||||
GLsizei stride,
|
||||
point_cloud_data& data
|
||||
);
|
||||
|
||||
point_cloud_data(const point_cloud_data& other) = delete;
|
||||
point_cloud_data& operator=(const point_cloud_data& other) = delete;
|
||||
|
||||
point_cloud_data(point_cloud_data&& other) noexcept;
|
||||
point_cloud_data& operator=(point_cloud_data&& other) noexcept;
|
||||
|
||||
~point_cloud_data();
|
||||
|
||||
[[nodiscard]] point_cloud_handle handle() const;
|
||||
|
||||
[[nodiscard]] components::point_cloud_vertex::flags components() const;
|
||||
|
||||
private:
|
||||
point_cloud_handle m_handle{};
|
||||
GLuint m_vertex_vbo_id{ 0 };
|
||||
components::point_cloud_vertex::flags m_component_types{
|
||||
components::point_cloud_vertex::flags::none
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#define INCLUDE_POINT_CLOUD_DATA_IMPLEMENTATION
|
||||
#include "opengl/data/point_cloud_data.ipp"
|
||||
#undef INCLUDE_POINT_CLOUD_DATA_IMPLEMENTATION
|
||||
43
include/opengl/data/shader_data.hpp
Normal file
43
include/opengl/data/shader_data.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include "GL/glew.h"
|
||||
#include "opengl/handles/shader_handle.hpp"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
class shader_data
|
||||
{
|
||||
private:
|
||||
explicit shader_data(GLuint shader_id, GLenum type);
|
||||
|
||||
public:
|
||||
|
||||
shader_data() = default;
|
||||
|
||||
[[nodiscard]] static std::error_code build_from(
|
||||
GLenum type,
|
||||
const std::string& source,
|
||||
shader_data& data
|
||||
);
|
||||
|
||||
shader_data(const shader_data& other) = delete;
|
||||
shader_data& operator=(const shader_data& other) = delete;
|
||||
|
||||
shader_data(shader_data&& other) noexcept;
|
||||
shader_data& operator=(shader_data&& other) noexcept;
|
||||
|
||||
[[nodiscard]] shader_handle handle() const;
|
||||
|
||||
~shader_data();
|
||||
|
||||
private:
|
||||
shader_handle m_handle{};
|
||||
GLenum m_type{ GL_INVALID_ENUM };
|
||||
};
|
||||
}
|
||||
|
||||
#define INCLUDE_SHADER_DATA_IMPLEMENTATION
|
||||
#include "opengl/data/shader_data.ipp"
|
||||
#undef INCLUDE_SHADER_DATA_IMPLEMENTATION
|
||||
45
include/opengl/data/texture_data.hpp
Normal file
45
include/opengl/data/texture_data.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "GL/glew.h"
|
||||
#include "opengl/handles/texture_handle.hpp"
|
||||
|
||||
#include <span>
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
struct texture_data
|
||||
{
|
||||
private:
|
||||
explicit texture_data(GLuint texture_id);
|
||||
|
||||
public:
|
||||
texture_data() = default;
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] static std::error_code build_from(
|
||||
std::span<const T> buffer,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
texture_data& data
|
||||
);
|
||||
|
||||
texture_data(const texture_data&) = delete;
|
||||
texture_data& operator=(const texture_data&) = delete;
|
||||
|
||||
texture_data(texture_data&&) noexcept;
|
||||
texture_data& operator=(texture_data&&) noexcept;
|
||||
|
||||
~texture_data();
|
||||
|
||||
[[nodiscard]] texture_handle handle() const;
|
||||
|
||||
private:
|
||||
texture_handle m_handle{};
|
||||
};
|
||||
}
|
||||
|
||||
#define INCLUDE_TEXTURE_DATA_IMPLEMENTATION
|
||||
#include "opengl/data/texture_data.ipp"
|
||||
#undef INCLUDE_TEXTURE_DATA_IMPLEMENTATION
|
||||
84
include/opengl/data_uploaders/texture_data_uploader.hpp
Normal file
84
include/opengl/data_uploaders/texture_data_uploader.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../assets/dynamic_read_buffers"
|
||||
#include "assets/dynamic_data_stores/dynamic_texture_store.hpp"
|
||||
#include "opengl/data/texture_data.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
class texture_data_uploader
|
||||
{
|
||||
|
||||
void upload(
|
||||
std::span<const dynamic_texture_data> dynamic_data,
|
||||
std::span<const dynamic_texture_store::id_type> dynamic_data_ids
|
||||
) {
|
||||
|
||||
std::vector<GLuint> texture_ids;
|
||||
std::vector<GLuint> invalid_texture_ids;
|
||||
|
||||
texture_ids.resize(dynamic_data.size());
|
||||
|
||||
glGenTextures(texture_ids.size(), texture_ids.data());
|
||||
|
||||
auto texture_id_it = texture_ids.begin();
|
||||
|
||||
for (std::size_t i{}; i != dynamic_data.size(); ++i)
|
||||
{
|
||||
const auto& texture_id = *texture_id_it;
|
||||
const auto& texture = dynamic_data[i];
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture_id);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
GLenum format;
|
||||
switch (texture.components()) {
|
||||
using enum components::texture::flags;
|
||||
case luminance:
|
||||
format = GL_LUMINANCE;
|
||||
break;
|
||||
case luminance | alpha:
|
||||
format = GL_LUMINANCE_ALPHA;
|
||||
break;
|
||||
case red | green | blue:
|
||||
format = GL_RGB;
|
||||
break;
|
||||
case red | green | blue | alpha:
|
||||
format = GL_RGBA;
|
||||
break;
|
||||
default:
|
||||
format = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (format == GL_INVALID_ENUM)
|
||||
{
|
||||
invalid_texture_ids.push_back(texture_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0,
|
||||
GL_RGBA8,
|
||||
texture.width(),
|
||||
texture.height(),
|
||||
0,
|
||||
format,
|
||||
GL_UNSIGNED_BYTE,
|
||||
texture.data()
|
||||
);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glDeleteTextures(invalid_texture_ids.size(), invalid_texture_ids.data());
|
||||
}
|
||||
};
|
||||
}
|
||||
13
include/opengl/handles/shader_handle.hpp
Normal file
13
include/opengl/handles/shader_handle.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "GL/glew.h"
|
||||
|
||||
namespace zgl
|
||||
{
|
||||
struct shader_handle
|
||||
{
|
||||
constexpr bool operator==(const shader_handle&) const = default;
|
||||
|
||||
GLuint shader_id{ 0 };
|
||||
};
|
||||
}
|
||||
43
include/opengl/shader_program_lookup.hpp
Normal file
43
include/opengl/shader_program_lookup.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace zgl {
|
||||
class shader_program_lookup
|
||||
{
|
||||
public:
|
||||
void add(
|
||||
const shader_program_handle& shader_program_handle,
|
||||
std::span<const shader_program_variable> all_attributes,
|
||||
std::span<const shader_program_variable> all_uniforms
|
||||
);
|
||||
|
||||
[[nodiscard]] std::optional<shader_program_handle> find(
|
||||
shader_program_handle::attribute_support_type attributes,
|
||||
shader_program_handle::uniform_support_type uniforms,
|
||||
std::span<const shader_program_variable> all_attributes
|
||||
) const;
|
||||
|
||||
void print();
|
||||
|
||||
private:
|
||||
using attribute_locations_type = ztu::u32;
|
||||
|
||||
[[nodiscard]] static attribute_locations_type attribute_location_flags(
|
||||
shader_program_handle::attribute_support_type attributes,
|
||||
std::span<const shader_program_variable> all_attributes
|
||||
);
|
||||
|
||||
struct attribute_entry_type
|
||||
{
|
||||
shader_program_handle::attribute_support_type attributes;
|
||||
attribute_locations_type locations; // Do not go past location 31!!!
|
||||
};
|
||||
|
||||
std::vector<shader_program_handle::uniform_support_type> m_mesh_shader_program_uniforms;
|
||||
std::vector<attribute_entry_type> m_mesh_shader_program_attributes;
|
||||
std::vector<shader_program_handle> m_mesh_shader_programs;
|
||||
};
|
||||
}
|
||||
65
include/rendering/batch_renderers/mesh_batch_renderer.hpp
Normal file
65
include/rendering/batch_renderers/mesh_batch_renderer.hpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
#include "rendering/batches/mesh_batch.hpp"
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "opengl/handles/material_handle.hpp"
|
||||
#include <span>
|
||||
|
||||
#include "geometry/aabb.hpp"
|
||||
#include "rendering/modes/mesh_modes.hpp"
|
||||
#include "rendering/shader_program_lookups/mesh_lookup.hpp"
|
||||
#include "scene/lighting_setup.hpp"
|
||||
|
||||
namespace rendering
|
||||
{
|
||||
class mesh_batch_renderer
|
||||
{
|
||||
public:
|
||||
using batch_components_type = std::pair<
|
||||
components::mesh_vertex::flags,
|
||||
material_component::flags
|
||||
>;
|
||||
using batch_type = mesh_batch;
|
||||
using batch_index_type = ztu::u32;
|
||||
using batch_id_type = batch_index_type;
|
||||
using id_type = std::pair<batch_id_type, batch_type::id_type>;
|
||||
|
||||
explicit mesh_batch_renderer(int render_mode_count);
|
||||
|
||||
std::optional<id_type> add(
|
||||
const batch_components_type& batch_component,
|
||||
const zgl::mesh_handle& mesh,
|
||||
const aabb& bounding_box,
|
||||
const zgl::model_matrix_handle& transform,
|
||||
const zgl::material_handle& material,
|
||||
const shader_program_lookups::mesh_lookup& shader_program_lookup
|
||||
);
|
||||
|
||||
std::optional<aabb> bounding_box(id_type);
|
||||
|
||||
bool remove(id_type mesh_id);
|
||||
|
||||
void render(
|
||||
modes::mesh render_mode,
|
||||
const glm::mat4& vp_matrix,
|
||||
const glm::mat4& view_matrix,
|
||||
const glm::vec3& view_pos,
|
||||
const lighting_setup& lights
|
||||
);
|
||||
|
||||
protected:
|
||||
[[nodiscard]] std::pair<std::size_t, bool> lookup_batch(const batch_components_type& batch_components) const;
|
||||
|
||||
private:
|
||||
int m_render_mode_count;
|
||||
|
||||
std::vector<std::pair<batch_components_type, batch_index_type>> m_component_lookup{};
|
||||
std::vector<batch_id_type> m_id_lookup{};
|
||||
std::vector<std::pair<batch_type, batch_components_type>> m_batches{};
|
||||
std::vector<zgl::shader_program_handle> m_shader_programs{};
|
||||
|
||||
batch_id_type m_next_batch_id{ 0 };
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
#include "rendering/batches/point_cloud_batch.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "rendering/modes/point_cloud_modes.hpp"
|
||||
#include <optional>
|
||||
|
||||
#include "scene/lighting_setup.hpp"
|
||||
#include "rendering/shader_program_lookups/point_cloud_lookup.hpp"
|
||||
|
||||
namespace rendering
|
||||
{
|
||||
|
||||
class point_cloud_batch_renderer
|
||||
{
|
||||
public:
|
||||
using batch_components_type = components::point_cloud_vertex::flags;
|
||||
using batch_type = point_cloud_batch;
|
||||
using batch_index_type = ztu::u32;
|
||||
using batch_id_type = batch_index_type;
|
||||
using id_type = std::pair<batch_id_type, batch_type::id_type>;
|
||||
|
||||
explicit point_cloud_batch_renderer(int render_mode_count);
|
||||
|
||||
std::optional<id_type> add(
|
||||
batch_components_type batch_components,
|
||||
const zgl::point_cloud_handle& point_cloud,
|
||||
const aabb& bounding_box,
|
||||
const zgl::model_matrix_handle& transform,
|
||||
const shader_program_lookups::point_cloud_lookup& shader_program_lookup
|
||||
);
|
||||
|
||||
std::optional<aabb> bounding_box(id_type id);
|
||||
|
||||
bool remove(id_type id);
|
||||
|
||||
void render(
|
||||
modes::point_cloud render_mode,
|
||||
const glm::mat4& vp_matrix,
|
||||
const glm::vec3& camera_position,
|
||||
const lighting_setup&
|
||||
);
|
||||
|
||||
protected:
|
||||
[[nodiscard]] std::pair<std::size_t, bool> lookup_batch(const batch_components_type& batch_component) const;
|
||||
|
||||
private:
|
||||
int m_render_mode_count;
|
||||
|
||||
std::vector<std::pair<batch_components_type, batch_index_type>> m_component_lookup;
|
||||
std::vector<batch_id_type> m_id_lookup;
|
||||
std::vector<std::pair<batch_type, batch_components_type>> m_batches;
|
||||
std::vector<zgl::shader_program_handle> m_shader_programs;
|
||||
|
||||
batch_id_type m_next_batch_id{ 0 };
|
||||
};
|
||||
|
||||
}
|
||||
55
include/rendering/batches/mesh_batch.hpp
Normal file
55
include/rendering/batches/mesh_batch.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
#include "opengl/handles/mesh_handle.hpp"
|
||||
#include "opengl/handles/matrix_handles.hpp"
|
||||
#include "opengl/handles/texture_handle.hpp"
|
||||
#include "opengl/handles/mesh_handle.hpp"
|
||||
#include "opengl/handles/material_handle.hpp"
|
||||
#include "geometry/aabb.hpp"
|
||||
|
||||
class mesh_batch
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::u32;
|
||||
|
||||
inline id_type add(
|
||||
const zgl::mesh_handle& mesh,
|
||||
const aabb& bounding_box,
|
||||
const zgl::model_matrix_handle& transform,
|
||||
const zgl::material_handle& material
|
||||
);
|
||||
|
||||
inline std::optional<aabb> bounding_box(id_type id);
|
||||
|
||||
inline bool remove(id_type id);
|
||||
|
||||
[[nodiscard]] inline std::span<const zgl::mesh_handle> meshes() const;
|
||||
|
||||
[[nodiscard]] inline std::span<const aabb> bounding_boxes() const;
|
||||
|
||||
[[nodiscard]] inline std::span<const zgl::model_matrix_handle> transforms() const;
|
||||
|
||||
[[nodiscard]] inline std::span<const zgl::texture_handle> textures() const;
|
||||
|
||||
[[nodiscard]] inline std::span<const zgl::surface_properties_handle> surface_properties() const;
|
||||
|
||||
[[nodiscard]] inline std::span<const zgl::alpha_handle> alphas() const;
|
||||
|
||||
private:
|
||||
std::vector<zgl::mesh_handle> m_meshes{};
|
||||
std::vector<aabb> m_bounding_boxes{};
|
||||
std::vector<zgl::model_matrix_handle> m_transforms{};
|
||||
std::vector<zgl::texture_handle> m_textures{};
|
||||
std::vector<zgl::surface_properties_handle> m_surface_properties{};
|
||||
std::vector<zgl::alpha_handle> m_alphas{};
|
||||
|
||||
std::vector<id_type> m_id_lookup{};
|
||||
|
||||
id_type m_next_mesh_id{ 0 };
|
||||
};
|
||||
|
||||
#define INCLUDE_MESH_BATCH_IMPLEMENTATION
|
||||
#include "rendering/batches/mesh_batch.ipp"
|
||||
#undef INCLUDE_MESH_BATCH_IMPLEMENTATION
|
||||
46
include/rendering/batches/point_cloud_batch.hpp
Normal file
46
include/rendering/batches/point_cloud_batch.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "opengl/handles/point_cloud_handle.hpp"
|
||||
#include "opengl/handles/matrix_handles.hpp"
|
||||
#include <span>
|
||||
|
||||
#include "geometry/aabb.hpp"
|
||||
#include <optional>
|
||||
|
||||
class point_cloud_batch
|
||||
{
|
||||
public:
|
||||
using id_type = ztu::u32;
|
||||
|
||||
point_cloud_batch() = default;
|
||||
|
||||
inline id_type add(
|
||||
const zgl::point_cloud_handle& point_cloud,
|
||||
const aabb& bounding_box,
|
||||
const zgl::model_matrix_handle& transform
|
||||
);
|
||||
|
||||
inline std::optional<aabb> bounding_box(id_type id);
|
||||
|
||||
inline bool remove(id_type id);
|
||||
|
||||
[[nodiscard]] inline std::span<const zgl::point_cloud_handle> point_clouds() const;
|
||||
|
||||
[[nodiscard]] inline std::span<const zgl::model_matrix_handle> transforms() const;
|
||||
|
||||
[[nodiscard]] inline std::span<const aabb> bounding_boxes() const;
|
||||
|
||||
private:
|
||||
std::vector<zgl::point_cloud_handle> m_point_clouds{};
|
||||
std::vector<zgl::model_matrix_handle> m_transforms{};
|
||||
std::vector<aabb> m_bounding_boxes{};
|
||||
|
||||
std::vector<id_type> m_id_lookup{};
|
||||
|
||||
id_type m_next_id{ 0 };
|
||||
};
|
||||
|
||||
#define INCLUDE_POINT_CLOUD_BATCH_IMPLEMENTATION
|
||||
#include "rendering/batches/point_cloud_batch.ipp"
|
||||
#undef INCLUDE_POINT_CLOUD_BATCH_IMPLEMENTATION
|
||||
13
include/rendering/modes/mesh_modes.hpp
Normal file
13
include/rendering/modes/mesh_modes.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
namespace rendering::modes
|
||||
{
|
||||
enum class mesh
|
||||
{
|
||||
wire_frame,
|
||||
points,
|
||||
faces,
|
||||
lit_faces,
|
||||
count
|
||||
};
|
||||
};
|
||||
11
include/rendering/modes/point_cloud_modes.hpp
Normal file
11
include/rendering/modes/point_cloud_modes.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
namespace rendering::modes
|
||||
{
|
||||
enum class point_cloud
|
||||
{
|
||||
uniform_color,
|
||||
rainbow,
|
||||
count
|
||||
};
|
||||
}
|
||||
127
include/rendering/requirements/mesh_requirements.hpp
Normal file
127
include/rendering/requirements/mesh_requirements.hpp
Normal file
@@ -0,0 +1,127 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "shader_program/capabilities/mesh_capabilities.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace rendering::requirements::mesh
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
shader_program::capabilities::mesh::indices::type shader_program_requirement_index{};
|
||||
components::mesh_vertex::flags vertex_requirements{
|
||||
components::mesh_vertex::flags::none
|
||||
};
|
||||
material_component::flags material_requirements{
|
||||
material_component::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
enum class flags : int
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
lit = 1 << 1,
|
||||
textured = 1 << 2,
|
||||
uniform_color = 1 << 3,
|
||||
uniform_alpha = 1 << 4,
|
||||
point = 1 << 5
|
||||
};
|
||||
|
||||
constexpr inline auto position = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::mesh::indices::position,
|
||||
.vertex_requirements = components::mesh_vertex::flags::position
|
||||
};
|
||||
|
||||
constexpr inline auto lit = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::mesh::indices::lit,
|
||||
.vertex_requirements = components::mesh_vertex::flags::normal,
|
||||
.material_requirements = material_component::flags::surface_properties
|
||||
};
|
||||
|
||||
constexpr inline auto point = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::mesh::indices::point
|
||||
};
|
||||
|
||||
constexpr inline auto textured = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::mesh::indices::textured,
|
||||
.vertex_requirements = components::mesh_vertex::flags::tex_coord,
|
||||
.material_requirements = material_component::flags::texture,
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::mesh::indices::uniform_color
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_alpha = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::mesh::indices::uniform_alpha,
|
||||
.material_requirements = material_component::flags::transparency
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, lit, textured, uniform_color, uniform_alpha, point
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] constexpr rendering::requirements::mesh::flags operator|(
|
||||
const rendering::requirements::mesh::flags& a, const rendering::requirements::mesh::flags& b
|
||||
) {
|
||||
return static_cast<rendering::requirements::mesh::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr rendering::requirements::mesh::flags operator&(
|
||||
const rendering::requirements::mesh::flags& a, const rendering::requirements::mesh::flags& b
|
||||
) {
|
||||
return static_cast<rendering::requirements::mesh::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr rendering::requirements::mesh::flags operator^(
|
||||
const rendering::requirements::mesh::flags& a, const rendering::requirements::mesh::flags& b
|
||||
) {
|
||||
return static_cast<rendering::requirements::mesh::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr rendering::requirements::mesh::flags operator~(const rendering::requirements::mesh::flags& a) {
|
||||
return static_cast<rendering::requirements::mesh::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr rendering::requirements::mesh::flags& operator|=(rendering::requirements::mesh::flags& a, const rendering::requirements::mesh::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr rendering::requirements::mesh::flags& operator&=(rendering::requirements::mesh::flags& a, const rendering::requirements::mesh::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr rendering::requirements::mesh::flags& operator^=(rendering::requirements::mesh::flags& a, const rendering::requirements::mesh::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
rendering::requirements::mesh::flags lhs, rendering::requirements::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
rendering::requirements::mesh::flags lhs, rendering::requirements::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
rendering::requirements::mesh::flags lhs, rendering::requirements::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
rendering::requirements::mesh::flags lhs, rendering::requirements::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
122
include/rendering/requirements/point_cloud_requirements.hpp
Normal file
122
include/rendering/requirements/point_cloud_requirements.hpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "shader_program/capabilities/point_cloud_capabilities.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace rendering::requirements::point_cloud
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
shader_program::capabilities::point_cloud::indices::type shader_program_requirement_index{};
|
||||
components::point_cloud_vertex::flags vertex_requirements{
|
||||
components::point_cloud_vertex::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
enum class flags : int
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
vertex_color = 1 << 1,
|
||||
uniform_color = 1 << 2,
|
||||
normal = 1 << 3,
|
||||
reflectance = 1 << 4,
|
||||
rainbow = 1 << 5
|
||||
};
|
||||
|
||||
|
||||
constexpr inline auto position = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::point_cloud::indices::position,
|
||||
.vertex_requirements = components::point_cloud_vertex::flags::position
|
||||
};
|
||||
|
||||
constexpr inline auto rainbow = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::point_cloud::indices::rainbow
|
||||
};
|
||||
|
||||
constexpr inline auto vertex_color = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::point_cloud::indices::vertex_color,
|
||||
.vertex_requirements = components::point_cloud_vertex::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::point_cloud::indices::uniform_color
|
||||
};
|
||||
|
||||
constexpr inline auto normal = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::point_cloud::indices::normal,
|
||||
.vertex_requirements = components::point_cloud_vertex::flags::normal
|
||||
};
|
||||
|
||||
constexpr inline auto reflectance = type{
|
||||
.shader_program_requirement_index = shader_program::capabilities::point_cloud::indices::reflectance,
|
||||
.vertex_requirements = components::point_cloud_vertex::flags::reflectance
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, vertex_color, uniform_color, normal, reflectance, rainbow
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] constexpr rendering::requirements::point_cloud::flags operator|(
|
||||
const rendering::requirements::point_cloud::flags& a, const rendering::requirements::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<rendering::requirements::point_cloud::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr rendering::requirements::point_cloud::flags operator&(
|
||||
const rendering::requirements::point_cloud::flags& a, const rendering::requirements::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<rendering::requirements::point_cloud::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr rendering::requirements::point_cloud::flags operator^(
|
||||
const rendering::requirements::point_cloud::flags& a, const rendering::requirements::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<rendering::requirements::point_cloud::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr rendering::requirements::point_cloud::flags operator~(const rendering::requirements::point_cloud::flags& a) {
|
||||
return static_cast<rendering::requirements::point_cloud::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr rendering::requirements::point_cloud::flags& operator|=(rendering::requirements::point_cloud::flags& a, const rendering::requirements::point_cloud::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr rendering::requirements::point_cloud::flags& operator&=(rendering::requirements::point_cloud::flags& a, const rendering::requirements::point_cloud::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr rendering::requirements::point_cloud::flags& operator^=(rendering::requirements::point_cloud::flags& a, const rendering::requirements::point_cloud::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
rendering::requirements::point_cloud::flags lhs, rendering::requirements::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
rendering::requirements::point_cloud::flags lhs, rendering::requirements::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
rendering::requirements::point_cloud::flags lhs, rendering::requirements::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
rendering::requirements::point_cloud::flags lhs, rendering::requirements::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
27
include/rendering/shader_program_lookups/mesh_lookup.hpp
Normal file
27
include/rendering/shader_program_lookups/mesh_lookup.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_lookup.hpp"
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
#include "rendering/requirements/mesh_requirements.hpp"
|
||||
|
||||
namespace rendering::shader_program_lookups
|
||||
{
|
||||
|
||||
class mesh_lookup
|
||||
{
|
||||
public:
|
||||
void add(
|
||||
const zgl::shader_program_handle& shader_program_handle
|
||||
);
|
||||
|
||||
[[nodiscard]] std::optional<zgl::shader_program_handle> find(
|
||||
requirements::mesh::flags requirements
|
||||
) const;
|
||||
|
||||
void print();
|
||||
|
||||
private:
|
||||
zgl::shader_program_lookup m_shader_program_lookup;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_lookup.hpp"
|
||||
#include "opengl/handles/shader_program_handle.hpp"
|
||||
#include "rendering/requirements/point_cloud_requirements.hpp"
|
||||
|
||||
namespace rendering::shader_program_lookups
|
||||
{
|
||||
|
||||
class point_cloud_lookup
|
||||
{
|
||||
public:
|
||||
void add(
|
||||
const zgl::shader_program_handle& shader_program_handle
|
||||
);
|
||||
|
||||
[[nodiscard]] std::optional<zgl::shader_program_handle> find(
|
||||
requirements::point_cloud::flags requirements
|
||||
) const;
|
||||
|
||||
private:
|
||||
zgl::shader_program_lookup m_program_lookup;
|
||||
};
|
||||
|
||||
}
|
||||
21
include/scene/camera.hpp
Executable file
21
include/scene/camera.hpp
Executable file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "scene/camera_view.hpp"
|
||||
|
||||
class camera {
|
||||
public:
|
||||
virtual ~camera() = default;
|
||||
|
||||
virtual void update(
|
||||
float time_delta,
|
||||
glm::vec2 mouse_pos_delta,
|
||||
float mouse_wheel_delta,
|
||||
camera_view& view
|
||||
) = 0;
|
||||
|
||||
virtual void look_at(
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& target,
|
||||
camera_view& view
|
||||
) = 0;
|
||||
};
|
||||
30
include/scene/flying_camera.hpp
Executable file
30
include/scene/flying_camera.hpp
Executable file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "scene/camera.hpp"
|
||||
|
||||
|
||||
|
||||
class flying_camera : public camera {
|
||||
public:
|
||||
explicit flying_camera(float yaw, float pitch, float roll);
|
||||
|
||||
void update(
|
||||
float time_delta,
|
||||
glm::vec2 mouse_pos_delta,
|
||||
float mouse_wheel_delta,
|
||||
camera_view& view
|
||||
) override;
|
||||
|
||||
void look_at(
|
||||
const glm::vec3& origin,
|
||||
const glm::vec3& target,
|
||||
camera_view& view
|
||||
) override;
|
||||
|
||||
private:
|
||||
glm::vec3 m_velocity{ 0.0f, 0.0f, 0.0f };
|
||||
glm::mat3 m_world_rotation;
|
||||
glm::vec3 m_world_up;
|
||||
|
||||
float m_pitch, m_yaw, m_roll;
|
||||
};
|
||||
10
include/scene/lighting_setup.hpp
Normal file
10
include/scene/lighting_setup.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "glm/glm.hpp"
|
||||
|
||||
struct lighting_setup
|
||||
{
|
||||
glm::vec3 point_light_direction;
|
||||
glm::vec3 point_light_color;
|
||||
glm::vec3 ambient_light_color;
|
||||
};
|
||||
83
include/shader_program/attributes/mesh_attributes.hpp
Normal file
83
include/shader_program/attributes/mesh_attributes.hpp
Normal file
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace shader_program::attributes::mesh
|
||||
{
|
||||
|
||||
enum class flags : int {
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
normal = 1 << 1,
|
||||
tex_coord = 1 << 2
|
||||
};
|
||||
|
||||
constexpr inline auto position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 0 }, "vertex_position");
|
||||
constexpr inline auto normal = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "vertex_normal");
|
||||
constexpr inline auto tex_coord = zgl::shader_program_variable({ GL_FLOAT_VEC2, 2 }, "vertex_tex_coord");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, normal, tex_coord
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::mesh::flags operator|(
|
||||
const shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::mesh::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::mesh::flags operator&(
|
||||
const shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::mesh::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::mesh::flags operator^(
|
||||
const shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::mesh::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::mesh::flags operator~(const shader_program::attributes::mesh::flags& a) {
|
||||
return static_cast<shader_program::attributes::mesh::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::mesh::flags& operator|=(shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::mesh::flags& operator&=(shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::mesh::flags& operator^=(shader_program::attributes::mesh::flags& a, const shader_program::attributes::mesh::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
shader_program::attributes::mesh::flags lhs, shader_program::attributes::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
shader_program::attributes::mesh::flags lhs, shader_program::attributes::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
shader_program::attributes::mesh::flags lhs, shader_program::attributes::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
shader_program::attributes::mesh::flags lhs, shader_program::attributes::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
84
include/shader_program/attributes/point_cloud_attributes.hpp
Normal file
84
include/shader_program/attributes/point_cloud_attributes.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace shader_program::attributes::point_cloud
|
||||
{
|
||||
|
||||
enum class flags : int {
|
||||
none = 0,
|
||||
position = 1 << 0,
|
||||
normal = 1 << 1,
|
||||
color = 1 << 2,
|
||||
reflectance = 1 << 3
|
||||
};
|
||||
|
||||
constexpr inline auto position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 0 }, "vertex_position");
|
||||
constexpr inline auto normal = zgl::shader_program_variable({ GL_FLOAT_VEC3, 1 }, "vertex_normal");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 2 }, "vertex_color");
|
||||
constexpr inline auto reflectance = zgl::shader_program_variable({ GL_FLOAT, 2 }, "vertex_reflectance");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, normal, color, reflectance
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::point_cloud::flags operator|(
|
||||
const shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::point_cloud::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::point_cloud::flags operator&(
|
||||
const shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::point_cloud::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::point_cloud::flags operator^(
|
||||
const shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::attributes::point_cloud::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::attributes::point_cloud::flags operator~(const shader_program::attributes::point_cloud::flags& a) {
|
||||
return static_cast<shader_program::attributes::point_cloud::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::point_cloud::flags& operator|=(shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::point_cloud::flags& operator&=(shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr shader_program::attributes::point_cloud::flags& operator^=(shader_program::attributes::point_cloud::flags& a, const shader_program::attributes::point_cloud::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
shader_program::attributes::point_cloud::flags lhs, shader_program::attributes::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
shader_program::attributes::point_cloud::flags lhs, shader_program::attributes::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
shader_program::attributes::point_cloud::flags lhs, shader_program::attributes::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
shader_program::attributes::point_cloud::flags lhs, shader_program::attributes::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
85
include/shader_program/capabilities/mesh_capabilities.hpp
Normal file
85
include/shader_program/capabilities/mesh_capabilities.hpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
#include "assets/components/material_components.hpp"
|
||||
#include "shader_program/attributes/mesh_attributes.hpp"
|
||||
#include "shader_program/uniforms/mesh_uniforms.hpp"
|
||||
|
||||
namespace shader_program::capabilities::mesh
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
attributes::mesh::flags attributes{
|
||||
attributes::mesh::flags::none
|
||||
};
|
||||
uniforms::mesh::flags uniforms{
|
||||
uniforms::mesh::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = ztu::u8;
|
||||
constexpr inline type position = 0;
|
||||
constexpr inline type lit = 1;
|
||||
constexpr inline type textured = 2;
|
||||
constexpr inline type uniform_color = 3;
|
||||
constexpr inline type uniform_alpha = 4;
|
||||
constexpr inline type point = 5;
|
||||
}
|
||||
|
||||
enum class flags : int
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
lit = 1 << indices::lit,
|
||||
textured = 1 << indices::textured,
|
||||
uniform_color = 1 << indices::uniform_color,
|
||||
uniform_alpha = 1 << indices::uniform_alpha,
|
||||
point = 1 << indices::point
|
||||
};
|
||||
|
||||
constexpr inline auto position = type{
|
||||
.attributes = attributes::mesh::flags::position,
|
||||
.uniforms = uniforms::mesh::flags::mvp
|
||||
};
|
||||
|
||||
constexpr inline auto lit = type{
|
||||
.attributes = attributes::mesh::flags::normal,
|
||||
.uniforms = (
|
||||
uniforms::mesh::flags::model_matrix |
|
||||
uniforms::mesh::flags::view_pos |
|
||||
uniforms::mesh::flags::point_light_direction |
|
||||
uniforms::mesh::flags::point_light_color |
|
||||
uniforms::mesh::flags::ambient_light_color |
|
||||
uniforms::mesh::flags::ambient_filter |
|
||||
uniforms::mesh::flags::diffuse_filter |
|
||||
uniforms::mesh::flags::specular_filter |
|
||||
uniforms::mesh::flags::shininess
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto point = type{
|
||||
.uniforms = uniforms::mesh::flags::point_size
|
||||
};
|
||||
|
||||
constexpr inline auto textured = type{
|
||||
.attributes = attributes::mesh::flags::tex_coord,
|
||||
.uniforms = uniforms::mesh::flags::tex
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.uniforms = uniforms::mesh::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_alpha = type{
|
||||
.uniforms = uniforms::mesh::flags::alpha
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, lit, textured, uniform_color, uniform_alpha, point
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include "shader_program/attributes/point_cloud_attributes.hpp"
|
||||
#include "shader_program/uniforms/point_cloud_uniforms.hpp"
|
||||
|
||||
#include "assets/components/mesh_vertex_components.hpp"
|
||||
#include "assets/components/point_cloud_vertex_components.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace shader_program::capabilities::point_cloud
|
||||
{
|
||||
|
||||
struct type
|
||||
{
|
||||
attributes::point_cloud::flags attributes{
|
||||
attributes::point_cloud::flags::none
|
||||
};
|
||||
uniforms::point_cloud::flags uniforms{
|
||||
uniforms::point_cloud::flags::none
|
||||
};
|
||||
};
|
||||
|
||||
namespace indices
|
||||
{
|
||||
using type = ztu::u8;
|
||||
constexpr inline type position = 0;
|
||||
constexpr inline type vertex_color = 1;
|
||||
constexpr inline type uniform_color = 2;
|
||||
constexpr inline type normal = 3;
|
||||
constexpr inline type reflectance = 4;
|
||||
constexpr inline type rainbow = 5;
|
||||
}
|
||||
|
||||
enum class flags : int
|
||||
{
|
||||
none = 0,
|
||||
position = 1 << indices::position,
|
||||
vertex_color = 1 << indices::vertex_color,
|
||||
uniform_color = 1 << indices::uniform_color,
|
||||
normal = 1 << indices::normal,
|
||||
reflectance = 1 << indices::reflectance,
|
||||
rainbow = 1 << indices::rainbow
|
||||
};
|
||||
|
||||
constexpr inline auto position = type{
|
||||
.attributes = attributes::point_cloud::flags::position,
|
||||
.uniforms = uniforms::point_cloud::flags::mvp
|
||||
};
|
||||
|
||||
constexpr inline auto rainbow = type{};
|
||||
|
||||
constexpr inline auto vertex_color = type{
|
||||
.attributes = attributes::point_cloud::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto uniform_color = type{
|
||||
.uniforms = uniforms::point_cloud::flags::color
|
||||
};
|
||||
|
||||
constexpr inline auto normal = type{
|
||||
.attributes = attributes::point_cloud::flags::normal,
|
||||
.uniforms = (
|
||||
uniforms::point_cloud::flags::model |
|
||||
uniforms::point_cloud::flags::camera_position
|
||||
)
|
||||
};
|
||||
|
||||
constexpr inline auto reflectance = type{
|
||||
.attributes = attributes::point_cloud::flags::reflectance
|
||||
};
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
position, vertex_color, uniform_color, normal, reflectance, rainbow
|
||||
};
|
||||
|
||||
}
|
||||
117
include/shader_program/uniforms/mesh_uniforms.hpp
Normal file
117
include/shader_program/uniforms/mesh_uniforms.hpp
Normal file
@@ -0,0 +1,117 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace shader_program::uniforms::mesh
|
||||
{
|
||||
|
||||
enum class flags : int
|
||||
{
|
||||
none = 0,
|
||||
mvp = 1 << 0,
|
||||
model_matrix = 1 << 1,
|
||||
point_size = 1 << 2,
|
||||
color = 1 << 3,
|
||||
tex = 1 << 4,
|
||||
view_pos = 1 << 5,
|
||||
point_light_direction = 1 << 6,
|
||||
point_light_color = 1 << 7,
|
||||
ambient_light_color = 1 << 8,
|
||||
ambient_filter = 1 << 9,
|
||||
diffuse_filter = 1 << 10,
|
||||
specular_filter = 1 << 11,
|
||||
shininess = 1 << 12,
|
||||
alpha = 1 << 13
|
||||
};
|
||||
|
||||
constexpr inline auto mvp = zgl::shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp_matrix");
|
||||
constexpr inline auto model_matrix = zgl::shader_program_variable({ GL_FLOAT_MAT4, 1 }, "model_matrix");
|
||||
constexpr inline auto point_size = zgl::shader_program_variable({ GL_FLOAT, 2 }, "point_size");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC4, 3 }, "color");
|
||||
constexpr inline auto tex = zgl::shader_program_variable({ GL_SAMPLER_2D, 3 }, "tex");
|
||||
constexpr inline auto view_pos = zgl::shader_program_variable({ GL_FLOAT_VEC3, 4 }, "view_pos");
|
||||
constexpr inline auto point_light_direction = zgl::shader_program_variable({ GL_FLOAT_VEC3, 5 }, "point_light_direction");
|
||||
constexpr inline auto point_light_color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 6 }, "point_light_color");
|
||||
constexpr inline auto ambient_light_color = zgl::shader_program_variable({ GL_FLOAT_VEC3, 7 }, "ambient_light_color");
|
||||
constexpr inline auto ambient_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 8 }, "ambient_filter");
|
||||
constexpr inline auto diffuse_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 9 }, "diffuse_filter");
|
||||
constexpr inline auto specular_filter = zgl::shader_program_variable({ GL_FLOAT_VEC3, 10 }, "specular_filter");
|
||||
constexpr inline auto shininess = zgl::shader_program_variable({ GL_FLOAT, 11 }, "shininess");
|
||||
constexpr inline auto alpha = zgl::shader_program_variable({ GL_FLOAT, 12 }, "alpha");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
mvp,
|
||||
model_matrix,
|
||||
point_size,
|
||||
color,
|
||||
tex,
|
||||
view_pos,
|
||||
point_light_direction,
|
||||
point_light_color,
|
||||
ambient_light_color,
|
||||
ambient_filter,
|
||||
diffuse_filter,
|
||||
specular_filter,
|
||||
shininess,
|
||||
alpha
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::mesh::flags operator|(
|
||||
const shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::mesh::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::mesh::flags operator&(
|
||||
const shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::mesh::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::mesh::flags operator^(
|
||||
const shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::mesh::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::mesh::flags operator~(const shader_program::uniforms::mesh::flags& a) {
|
||||
return static_cast<shader_program::uniforms::mesh::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::mesh::flags& operator|=(shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::mesh::flags& operator&=(shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::mesh::flags& operator^=(shader_program::uniforms::mesh::flags& a, const shader_program::uniforms::mesh::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
shader_program::uniforms::mesh::flags lhs, shader_program::uniforms::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
shader_program::uniforms::mesh::flags lhs, shader_program::uniforms::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
shader_program::uniforms::mesh::flags lhs, shader_program::uniforms::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
shader_program::uniforms::mesh::flags lhs, shader_program::uniforms::mesh::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
97
include/shader_program/uniforms/point_cloud_uniforms.hpp
Normal file
97
include/shader_program/uniforms/point_cloud_uniforms.hpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include "opengl/shader_program_variable.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace shader_program::uniforms::point_cloud
|
||||
{
|
||||
|
||||
enum class flags : int
|
||||
{
|
||||
none = 0,
|
||||
mvp = 1 << 0,
|
||||
point_size = 1 << 1,
|
||||
color = 1 << 2,
|
||||
model = 1 << 3,
|
||||
camera_position = 1 << 4,
|
||||
rainbow_offset_y = 1 << 5,
|
||||
rainbow_scale_y = 1 << 6,
|
||||
};
|
||||
|
||||
constexpr inline auto mvp = zgl::shader_program_variable({ GL_FLOAT_MAT4, 0 }, "mvp");
|
||||
constexpr inline auto point_size = zgl::shader_program_variable({ GL_FLOAT, 2 }, "point_size");
|
||||
constexpr inline auto color = zgl::shader_program_variable({ GL_FLOAT_VEC4, 3 }, "color");
|
||||
constexpr inline auto model = zgl::shader_program_variable({ GL_FLOAT_MAT4, 4 }, "model");
|
||||
constexpr inline auto camera_position = zgl::shader_program_variable({ GL_FLOAT_VEC3, 5 }, "camera_position");
|
||||
constexpr inline auto rainbow_offset_y = zgl::shader_program_variable({ GL_FLOAT, 6 }, "rainbow_offset_y");
|
||||
constexpr inline auto rainbow_scale_y = zgl::shader_program_variable({ GL_FLOAT, 7 }, "rainbow_scale_y");
|
||||
|
||||
constexpr inline auto all = std::array{
|
||||
mvp,
|
||||
point_size,
|
||||
color,
|
||||
model,
|
||||
camera_position,
|
||||
rainbow_offset_y,
|
||||
rainbow_scale_y
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::point_cloud::flags operator|(
|
||||
const shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::point_cloud::flags>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::point_cloud::flags operator&(
|
||||
const shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::point_cloud::flags>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::point_cloud::flags operator^(
|
||||
const shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b
|
||||
) {
|
||||
return static_cast<shader_program::uniforms::point_cloud::flags>(static_cast<int>(a) ^ static_cast<int>(b));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr shader_program::uniforms::point_cloud::flags operator~(const shader_program::uniforms::point_cloud::flags& a) {
|
||||
return static_cast<shader_program::uniforms::point_cloud::flags>(~static_cast<int>(a));
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::point_cloud::flags& operator|=(shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b) {
|
||||
return a = a | b;
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::point_cloud::flags& operator&=(shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b) {
|
||||
return a = a & b;
|
||||
}
|
||||
|
||||
constexpr shader_program::uniforms::point_cloud::flags& operator^=(shader_program::uniforms::point_cloud::flags& a, const shader_program::uniforms::point_cloud::flags& b) {
|
||||
return a = a ^ b;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<(
|
||||
shader_program::uniforms::point_cloud::flags lhs, shader_program::uniforms::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) < static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator<=(
|
||||
shader_program::uniforms::point_cloud::flags lhs, shader_program::uniforms::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) <= static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>(
|
||||
shader_program::uniforms::point_cloud::flags lhs, shader_program::uniforms::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) > static_cast<int>(rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator>=(
|
||||
shader_program::uniforms::point_cloud::flags lhs, shader_program::uniforms::point_cloud::flags rhs
|
||||
) {
|
||||
return static_cast<int>(lhs) >= static_cast<int>(rhs);
|
||||
}
|
||||
285
include/util/arx.hpp
Executable file
285
include/util/arx.hpp
Executable file
@@ -0,0 +1,285 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <charconv>
|
||||
#include <functional>
|
||||
#include "util/uix.hpp"
|
||||
#include "util/pack.hpp"
|
||||
#include "util/function.hpp"
|
||||
#include "util/string_literal.hpp"
|
||||
#include "util/for_each.hpp"
|
||||
|
||||
|
||||
namespace ztu {
|
||||
|
||||
static constexpr char NO_SHORT_FLAG = '\0';
|
||||
|
||||
namespace arx_internal {
|
||||
|
||||
template<typename F, typename T>
|
||||
concept parsing_function = (
|
||||
ztu::callable<F, std::optional<T>, std::string_view> and
|
||||
(not std::is_class_v<F> or std::is_empty_v<F>)
|
||||
);
|
||||
|
||||
} // namespace arx_internal
|
||||
|
||||
template<
|
||||
char ShortName,
|
||||
ztu::string_literal LongName,
|
||||
typename T = bool,
|
||||
auto Parse = std::nullptr_t{}
|
||||
> requires (
|
||||
std::same_as<std::nullptr_t, decltype(Parse)> or
|
||||
arx_internal::parsing_function<decltype(Parse), T>
|
||||
)
|
||||
struct arx_flag {
|
||||
static constexpr auto short_name = ShortName;
|
||||
static constexpr auto long_name = LongName;
|
||||
using type = T;
|
||||
static constexpr auto parse = Parse;
|
||||
};
|
||||
|
||||
namespace arx_parsers {
|
||||
|
||||
template<std::integral Type = int, int Base = 10>
|
||||
requires (Base > 0)
|
||||
[[nodiscard]] inline std::optional<Type> integer(const std::string_view& str);
|
||||
|
||||
template<std::floating_point Type = float, std::chars_format Format = std::chars_format::general>
|
||||
[[nodiscard]] inline std::optional<Type> floating_point(const std::string_view& str);
|
||||
|
||||
} // namespace arx_parsers
|
||||
|
||||
namespace arx_internal {
|
||||
|
||||
template<ztu::string_literal LongName, class... Flags>
|
||||
struct flag_by_name {
|
||||
template<class Flag>
|
||||
struct pred : std::conditional_t<
|
||||
Flag::long_name == LongName,
|
||||
std::true_type,
|
||||
std::false_type
|
||||
> {
|
||||
};
|
||||
using type = ztu::find<pred, Flags...>;
|
||||
};
|
||||
|
||||
template<ztu::string_literal LongName, class... Flags>
|
||||
using flag_by_name_t = flag_by_name<LongName, Flags...>::type;
|
||||
|
||||
template<ztu::string_literal LongName, class... Flags>
|
||||
using flag_type_by_name_t = flag_by_name_t<LongName, Flags...>::type;
|
||||
|
||||
} // namespace arx_internal
|
||||
|
||||
|
||||
template<class... Flags>
|
||||
class arx {
|
||||
private:
|
||||
static constexpr auto short_flag_prefix = std::string_view{ "-" };
|
||||
static constexpr auto long_flag_prefix = std::string_view{ "--" };
|
||||
static constexpr auto UNBOUND_ARGUMENT = ztu::isize_max;
|
||||
|
||||
public:
|
||||
inline arx(int num_args, const char* const* args);
|
||||
|
||||
template<ztu::string_literal LongName>
|
||||
[[nodiscard]] inline std::optional<arx_internal::flag_type_by_name_t<LongName, Flags...>> get() const;
|
||||
|
||||
[[nodiscard]] inline std::optional<std::string_view> get(ztu::isize position) const;
|
||||
|
||||
[[nodiscard]] inline ztu::isize num_positional() const;
|
||||
|
||||
protected:
|
||||
[[nodiscard]] inline std::optional<std::string_view> find_flag_value(ztu::isize flag_index) const;
|
||||
|
||||
template<ztu::string_literal LongName>
|
||||
[[nodiscard]] inline std::optional<arx_internal::flag_type_by_name_t<LongName, Flags...>>
|
||||
parse_value(const std::string_view& value_str) const;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<ztu::isize, std::string_view>> m_arguments;
|
||||
ztu::isize m_unbound_begin;
|
||||
};
|
||||
|
||||
|
||||
namespace arx_parsers {
|
||||
|
||||
template<std::integral Type, int Base>
|
||||
requires (Base > 0)
|
||||
[[nodiscard]] inline std::optional<Type> integer(const std::string_view& str) {
|
||||
Type value{};
|
||||
const auto [ptr, ec] = std::from_chars(str.begin(), str.end(), value, Base);
|
||||
if (ec == std::errc() and ptr == str.end()) {
|
||||
return value;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template<std::floating_point Type, std::chars_format Format>
|
||||
[[nodiscard]] inline std::optional<Type> floating_point(const std::string_view& str) {
|
||||
Type value{};
|
||||
const auto [ptr, ec] = std::from_chars(str.begin(), str.end(), value, Format);
|
||||
if (ec == std::errc() and ptr == str.end()) {
|
||||
return value;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace arx_parsers
|
||||
|
||||
template<class... Flags>
|
||||
arx<Flags...>::arx(int num_args, const char* const* args) {
|
||||
|
||||
m_arguments.reserve(std::max(num_args - 1, 0));
|
||||
|
||||
for (int i = 1; i < num_args; i++) {
|
||||
const auto argument = std::string_view{ args[i] };
|
||||
|
||||
const auto found_match = for_each::indexed_type<Flags...>(
|
||||
[&]<auto Index, typename Flag>() {
|
||||
if ((
|
||||
Flag::short_name != NO_SHORT_FLAG and
|
||||
argument.length() == short_flag_prefix.length() + 1 and
|
||||
argument.starts_with(short_flag_prefix) and
|
||||
argument[short_flag_prefix.length()] == Flag::short_name
|
||||
) or (
|
||||
argument.length() == long_flag_prefix.length() + Flag::long_name.length() and
|
||||
argument.starts_with(long_flag_prefix) and
|
||||
argument.substr(long_flag_prefix.length()) == Flag::long_name
|
||||
)) {
|
||||
if constexpr (std::same_as<typename Flag::type, bool>) {
|
||||
m_arguments.emplace_back(Index, argument);
|
||||
} else {
|
||||
if (i + 1 < num_args) {
|
||||
const auto value = std::string_view{ args[++i] };
|
||||
m_arguments.emplace_back(Index, value);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
if (not found_match) {
|
||||
m_arguments.emplace_back(UNBOUND_ARGUMENT, argument);
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(
|
||||
m_arguments.begin(), m_arguments.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.first < b.first;
|
||||
}
|
||||
);
|
||||
|
||||
const auto first_unbound = std::find_if(
|
||||
m_arguments.begin(), m_arguments.end(), [](const auto& a) {
|
||||
return a.first == UNBOUND_ARGUMENT;
|
||||
}
|
||||
);
|
||||
|
||||
const auto num_bound = m_arguments.end() - first_unbound;
|
||||
|
||||
const auto last = std::unique(
|
||||
std::reverse_iterator(first_unbound), m_arguments.rend(), [](const auto& a, const auto& b) {
|
||||
return a.first == b.first;
|
||||
}
|
||||
).base();
|
||||
|
||||
m_arguments.erase(m_arguments.begin(), last);
|
||||
|
||||
m_unbound_begin = m_arguments.size() - num_bound;
|
||||
};
|
||||
|
||||
|
||||
template<class... Flags>
|
||||
std::optional<std::string_view> arx<Flags...>::find_flag_value(isize flag_index) const {
|
||||
const auto begin = m_arguments.begin();
|
||||
const auto end = begin + m_unbound_begin;
|
||||
const auto it = std::lower_bound(
|
||||
begin, end, flag_index, [](const auto& a, const auto& b) {
|
||||
return a.first < b;
|
||||
}
|
||||
);
|
||||
if (it != end and it->first == flag_index) {
|
||||
return { it->second };
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
template<class... Flags>
|
||||
template<string_literal LongName>
|
||||
std::optional<arx_internal::flag_type_by_name_t<LongName, Flags...>> arx<Flags...>::parse_value(
|
||||
const std::string_view& value_str
|
||||
) const {
|
||||
|
||||
using Flag = arx_internal::flag_by_name_t<LongName, Flags...>;
|
||||
using Type = Flag::type;
|
||||
using opt_t = std::optional<Type>;
|
||||
|
||||
opt_t ret;
|
||||
|
||||
// Use custom parser if provided and if not try using a default parser
|
||||
if constexpr (
|
||||
requires(const std::string_view str) {
|
||||
{
|
||||
std::invoke(Flag::parse, str)
|
||||
} -> std::same_as<opt_t>;
|
||||
}
|
||||
) {
|
||||
return std::invoke(Flag::parse, value_str);
|
||||
} else if constexpr (std::integral<Type> && not std::same_as<Type, bool>) {
|
||||
return arx_parsers::integer(value_str);
|
||||
} else if constexpr (std::floating_point<Type>) {
|
||||
return arx_parsers::floating_point(value_str);
|
||||
} else if constexpr (std::same_as<std::string_view, Type>) {
|
||||
return value_str;
|
||||
} else if constexpr (std::same_as<std::string, Type>) {
|
||||
return std::string(value_str);
|
||||
} else {
|
||||
Type::__cannot_parse_this_type;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
template<class... Flags>
|
||||
template<string_literal LongName>
|
||||
std::optional<arx_internal::flag_type_by_name_t<LongName, Flags...>> arx<Flags...>::get() const {
|
||||
using Flag = arx_internal::flag_by_name_t<LongName, Flags...>;
|
||||
static constexpr auto index = index_of<Flag, Flags...>;
|
||||
|
||||
if (index < sizeof...(Flags)) {
|
||||
const auto value_opt = find_flag_value(index);
|
||||
if constexpr (std::same_as<typename Flag::type, bool>) {
|
||||
return value_opt.has_value();
|
||||
} else if (value_opt) {
|
||||
return parse_value<LongName>(*value_opt);
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template<class... Flags>
|
||||
inline isize arx<Flags...>::num_positional() const {
|
||||
return m_arguments.size() - m_unbound_begin;
|
||||
}
|
||||
|
||||
template<class... Flags>
|
||||
std::optional<std::string_view> arx<Flags...>::get(isize position) const {
|
||||
if (0 <= position and position < num_positional()) {
|
||||
return { m_arguments[m_unbound_begin + position].second };
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace ztu
|
||||
|
||||
207
include/util/binary_ifstream.hpp
Normal file
207
include/util/binary_ifstream.hpp
Normal file
@@ -0,0 +1,207 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <span>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
class binary_ifstream {
|
||||
public:
|
||||
using char_type = char;
|
||||
using size_type = std::streamsize;
|
||||
|
||||
[[nodiscard]] inline std::error_code open(
|
||||
const std::filesystem::path& filename,
|
||||
bool check_file_before_open
|
||||
);
|
||||
|
||||
[[nodiscard]] inline std::error_code read(std::span<char_type> buffer);
|
||||
|
||||
template<std::endian E, std::integral T>
|
||||
[[nodiscard]] std::error_code read(T& integer);
|
||||
|
||||
template<std::endian E, std::floating_point T>
|
||||
[[nodiscard]] std::error_code read_ieee754(T& floating_point);
|
||||
|
||||
[[nodiscard]] inline std::error_code skip(size_type count);
|
||||
|
||||
template<std::integral T>
|
||||
[[nodiscard]] std::error_code skip();
|
||||
|
||||
template<std::floating_point T>
|
||||
[[nodiscard]] std::error_code skip();
|
||||
|
||||
inline void close();
|
||||
|
||||
protected:
|
||||
[[nodiscard]] inline static std::error_code check_file(
|
||||
const std::filesystem::path& filename
|
||||
);
|
||||
|
||||
[[nodiscard]] inline std::errc get_stream_error_code() const;
|
||||
|
||||
private:
|
||||
std::basic_ifstream<char_type> in{};
|
||||
};
|
||||
|
||||
inline std::errc binary_ifstream::get_stream_error_code() const {
|
||||
const auto state = in.rdstate();
|
||||
|
||||
auto code = std::errc{};
|
||||
|
||||
if (state != std::ios::goodbit)
|
||||
{
|
||||
code = std::errc::state_not_recoverable;
|
||||
|
||||
if (state & std::ios::failbit) // irrecoverable stream error
|
||||
{
|
||||
code = std::errc::state_not_recoverable;
|
||||
}
|
||||
else if (state & std::ios::badbit) // input/output operation failed
|
||||
{
|
||||
code = std::errc::io_error;
|
||||
}
|
||||
else if (state & std::ios::eofbit) // input sequence has reached end-of-file
|
||||
{
|
||||
code = std::errc::result_out_of_range;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
inline std::error_code binary_ifstream::check_file(const std::filesystem::path& filename)
|
||||
{
|
||||
auto error = std::error_code{};
|
||||
|
||||
const auto is_file = std::filesystem::exists(filename, error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
if (not is_file)
|
||||
{
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
|
||||
const auto files_exists = std::filesystem::exists(filename, error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
if (not files_exists)
|
||||
{
|
||||
return std::make_error_code(std::errc::no_such_file_or_directory);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline std::error_code binary_ifstream::open(
|
||||
const std::filesystem::path& filename,
|
||||
bool check_file_before_open
|
||||
) {
|
||||
if (check_file_before_open)
|
||||
{
|
||||
if (const auto error = check_file(filename))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
in = {};
|
||||
|
||||
// Turn of exceptions, as errors are handled via the stream state.
|
||||
in.exceptions(std::ios::goodbit);
|
||||
|
||||
in.open(filename, std::ios::binary | std::ios::in);
|
||||
|
||||
if (const auto error = std::make_error_code(get_stream_error_code()))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
if (not in.is_open())
|
||||
{
|
||||
// Unknown error, so 'state_not_recoverable' is assumed.
|
||||
return std::make_error_code(std::errc::state_not_recoverable);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline void binary_ifstream::close()
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
|
||||
inline std::error_code binary_ifstream::skip(size_type count)
|
||||
{
|
||||
in.ignore(count);
|
||||
return std::make_error_code(get_stream_error_code());
|
||||
}
|
||||
|
||||
template<std::floating_point T>
|
||||
std::error_code binary_ifstream::skip()
|
||||
{
|
||||
return skip(sizeof(T));
|
||||
}
|
||||
|
||||
template<std::integral T>
|
||||
std::error_code binary_ifstream::skip()
|
||||
{
|
||||
return skip(sizeof(T));
|
||||
}
|
||||
|
||||
inline std::error_code binary_ifstream::read(std::span<char_type> buffer)
|
||||
{
|
||||
in.read(buffer.data(), static_cast<size_type>(buffer.size()));
|
||||
return std::make_error_code(get_stream_error_code());
|
||||
}
|
||||
|
||||
template<std::endian E, std::integral T>
|
||||
std::error_code binary_ifstream::read(T& integer)
|
||||
{
|
||||
std::array<char_type, sizeof(T)> buffer;
|
||||
if (const auto error = read(buffer))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
if constexpr (std::endian::native != E)
|
||||
{
|
||||
std::reverse(buffer.begin(), buffer.end());
|
||||
}
|
||||
|
||||
// Use memcpy to avoid UB.
|
||||
std::memcpy(static_cast<void*>(&integer), buffer.data(), buffer.size());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template<std::endian E, std::floating_point T>
|
||||
std::error_code binary_ifstream::read_ieee754(T& floating_point)
|
||||
{
|
||||
static_assert(std::numeric_limits<T>::is_iec559);
|
||||
|
||||
std::array<char_type, sizeof(T)> buffer;
|
||||
if (const auto error = read(buffer))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
if constexpr (std::endian::native != E)
|
||||
{
|
||||
std::reverse(buffer.begin(), buffer.end());
|
||||
}
|
||||
|
||||
// Use memcpy to avoid UB.
|
||||
std::memcpy(static_cast<void*>(&floating_point), buffer.data(), buffer.size());
|
||||
|
||||
return {};
|
||||
}
|
||||
57
include/util/enum_operators.hpp
Normal file
57
include/util/enum_operators.hpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUM_TYPE) \
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator|( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) | \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator&( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) & \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator^( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) ^ \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator~(const ENUM_TYPE a) \
|
||||
{ \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
~static_cast<std::underlying_type_t<ENUM_TYPE>>(a) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator|=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs | rhs; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator&=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs & rhs; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator^=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs ^ rhs; \
|
||||
}
|
||||
28
include/util/extra_arx_parsers.hpp
Executable file
28
include/util/extra_arx_parsers.hpp
Executable file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include <optional>
|
||||
#include <charconv>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace extra_arx_parsers {
|
||||
|
||||
template<int Count, typename T, glm::qualifier Q>
|
||||
requires (Count > 0)
|
||||
[[nodiscard]] inline std::optional<glm::vec<Count, T>> glm_vec(const std::string_view& str) {
|
||||
glm::vec<Count, T, Q> vec{};
|
||||
auto it = str.cbegin();
|
||||
for (int i = 0; i < Count; i++) {
|
||||
const auto [ptr, ec] = std::from_chars(it, str.cend(), vec[i], std::chars_format::general);
|
||||
if (ec != std::errc()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
it = ptr + 1; // skip space in between components
|
||||
}
|
||||
if (it < str.cend()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
49
include/util/for_each.hpp
Executable file
49
include/util/for_each.hpp
Executable file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ztu::for_each {
|
||||
|
||||
template<typename... Types>
|
||||
inline constexpr bool type(auto &&f) {
|
||||
return (f.template operator()<Types>() || ...);
|
||||
}
|
||||
|
||||
template<auto... Values>
|
||||
inline constexpr bool value(auto &&f) {
|
||||
return (f.template operator()<Values>() || ...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline constexpr bool argument(auto &&f, Args&&... args) {
|
||||
return (f(std::forward<Args>(args)) || ...);
|
||||
}
|
||||
|
||||
template <auto Size>
|
||||
inline constexpr bool index(auto&& f) {
|
||||
return [&]<auto... Indices>(std::index_sequence<Indices...>) {
|
||||
return (f.template operator()<Indices>() || ...);
|
||||
}(std::make_index_sequence<Size>());
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
inline constexpr bool indexed_type(auto &&f) {
|
||||
return [&]<auto... Indices>(std::index_sequence<Indices...>) {
|
||||
return (f.template operator()<Indices, Types>() || ...);
|
||||
}(std::make_index_sequence<sizeof...(Types)>());
|
||||
}
|
||||
|
||||
template<auto... Values>
|
||||
inline constexpr bool indexed_value(auto &&f) {
|
||||
return [&]<auto... Indices>(std::index_sequence<Indices...>) {
|
||||
return (f.template operator()<Indices, Values>() || ...);
|
||||
}(std::make_index_sequence<sizeof...(Values)>());
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline constexpr bool indexed_argument(auto &&f, Args&&... args) {
|
||||
return [&]<auto... Indices>(std::index_sequence<Indices...>) {
|
||||
return (f.template operator()<Indices>(std::forward<Args>(args)) || ...);
|
||||
}(std::make_index_sequence<sizeof...(Args)>());
|
||||
}
|
||||
}
|
||||
63
include/util/function.hpp
Executable file
63
include/util/function.hpp
Executable file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <concepts>
|
||||
|
||||
namespace ztu {
|
||||
|
||||
template<typename F, typename R, typename... Args>
|
||||
concept callable = std::same_as<std::invoke_result_t<F, Args...>, R>;
|
||||
|
||||
template<typename T>
|
||||
concept runnable = callable<T, void>;
|
||||
|
||||
template<typename T, typename R>
|
||||
concept supplier = callable<T, R>;
|
||||
|
||||
template<typename T, typename... Args>
|
||||
concept consumer = callable<T, void, Args...>;
|
||||
|
||||
template<typename T, typename... Args>
|
||||
concept predicate = callable<T, bool, Args...>;
|
||||
|
||||
|
||||
template<typename>
|
||||
struct function_meta;
|
||||
|
||||
template<typename R, typename... Args>
|
||||
struct function_meta<R(*)(Args...)> {
|
||||
using ret_t = R;
|
||||
using args_t = std::tuple<Args...>;
|
||||
static constexpr bool is_const = false;
|
||||
};
|
||||
|
||||
template<class C, typename R, typename... Args>
|
||||
struct function_meta<R(C::*)(Args...)> {
|
||||
using class_t = C;
|
||||
using ret_t = R;
|
||||
using args_t = std::tuple<Args...>;
|
||||
static constexpr bool is_const = false;
|
||||
};
|
||||
|
||||
template<class C, typename R, typename... Args>
|
||||
struct function_meta<R(C::*)(Args...) const> {
|
||||
using class_t = C;
|
||||
using ret_t = R;
|
||||
using args_t = std::tuple<Args...>;
|
||||
static constexpr bool is_const = true;
|
||||
};
|
||||
|
||||
namespace function {
|
||||
template<typename F>
|
||||
using class_t = typename function_meta<F>::class_t;
|
||||
|
||||
template<typename F>
|
||||
using ret_t = typename function_meta<F>::ret_t;
|
||||
|
||||
template<typename F>
|
||||
using args_t = typename function_meta<F>::args_t;
|
||||
|
||||
template<typename F>
|
||||
constexpr bool is_const_v = function_meta<F>::is_const;
|
||||
}
|
||||
}
|
||||
25
include/util/id_type.hpp
Normal file
25
include/util/id_type.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
namespace ztu
|
||||
{
|
||||
template<class Parent, typename IndexType, int uuid = 0>
|
||||
class id_type_for
|
||||
{
|
||||
friend Parent;
|
||||
|
||||
using index_type = IndexType;
|
||||
|
||||
explicit constexpr id_type_for(index_type index) : index{ index } {}
|
||||
|
||||
index_type index{};
|
||||
|
||||
public:
|
||||
constexpr id_type_for() = default;
|
||||
constexpr auto operator<=>(const id_type_for&) const = default;
|
||||
|
||||
constexpr operator bool() const
|
||||
{
|
||||
return index == index_type{};
|
||||
}
|
||||
};
|
||||
}
|
||||
327
include/util/image.hpp
Executable file
327
include/util/image.hpp
Executable file
@@ -0,0 +1,327 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC system_header
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(push, 0)
|
||||
#endif
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_STATIC
|
||||
#include "stb_image.h"
|
||||
|
||||
|
||||
#define STBI_MSC_SECURE_CRT
|
||||
#define STB_IMAGE_WRITE_STATIC
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
namespace ztu {
|
||||
|
||||
template<typename C>
|
||||
class image {
|
||||
public:
|
||||
using value_type = C;
|
||||
using size_type = std::make_signed_t<std::size_t>;
|
||||
using difference_type = size_type;
|
||||
using reference = std::add_lvalue_reference_t<value_type>;
|
||||
using const_reference = std::add_const_t<reference>;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using iterator = pointer;
|
||||
using const_iterator = const_pointer;
|
||||
|
||||
public:
|
||||
[[nodiscard]] static std::error_code load(const char* filename, image& dst, bool flip = false);
|
||||
|
||||
[[nodiscard]] static image create(size_type width, size_type height, const value_type& color);
|
||||
|
||||
public:
|
||||
image() = default;
|
||||
|
||||
image(std::unique_ptr<value_type>&& data, size_type width, size_type height);
|
||||
|
||||
image(const image&);
|
||||
|
||||
image(image&&) noexcept;
|
||||
|
||||
[[nodiscard]] image& operator=(const image&);
|
||||
|
||||
[[nodiscard]] image& operator=(image&&) noexcept;
|
||||
|
||||
[[nodiscard]] value_type operator()(double x, double y) const;
|
||||
|
||||
[[nodiscard]] const_reference operator()(size_type x, size_type y) const;
|
||||
|
||||
[[nodiscard]] reference operator()(size_type x, size_type y);
|
||||
|
||||
[[nodiscard]] const_iterator operator[](size_type y) const;
|
||||
|
||||
[[nodiscard]] iterator operator[](size_type y);
|
||||
|
||||
[[nodiscard]] int save(const std::string& filename) const;
|
||||
|
||||
[[nodiscard]] bool contains(size_type x, size_type y) const;
|
||||
|
||||
[[nodiscard]] size_type width() const;
|
||||
|
||||
[[nodiscard]] size_type height() const;
|
||||
|
||||
[[nodiscard]] std::pair<size_type, size_type> size() const;
|
||||
|
||||
[[nodiscard]] size_type num_pixels() const;
|
||||
|
||||
[[nodiscard]] const_iterator begin() const;
|
||||
|
||||
[[nodiscard]] iterator begin();
|
||||
|
||||
[[nodiscard]] const_iterator end() const;
|
||||
|
||||
[[nodiscard]] iterator end();
|
||||
|
||||
[[nodiscard]] const_iterator cbegin() const;
|
||||
|
||||
[[nodiscard]] const_iterator cend() const;
|
||||
|
||||
[[nodiscard]] const_pointer data() const;
|
||||
|
||||
[[nodiscard]] pointer data();
|
||||
|
||||
private:
|
||||
std::unique_ptr<value_type[]> m_data{ nullptr };
|
||||
size_type m_width{ 0 }, m_height{ 0 };
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
image<C>::image(std::unique_ptr<value_type>&& data, const size_type width, const size_type height) :
|
||||
m_data{ std::move(data) }, m_width{ width }, m_height{ height } {
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
image<C>::image(const image& other) :
|
||||
m_data{ new C[other.m_width * other.m_height] },
|
||||
m_width{ other.m_width }, m_height{ other.m_height } {
|
||||
std::copy_n(other.m_data.get(), other.m_width * other.m_height, this->m_data.get());
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
image<C>::image(image&& other) noexcept :
|
||||
m_data{ std::move(other.m_data) },
|
||||
m_width{ other.m_width }, m_height{ other.m_height } {
|
||||
other.m_width = 0;
|
||||
other.m_height = 0;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
image<C>& image<C>::operator=(const image& other) {
|
||||
if (this != &other) {
|
||||
|
||||
const auto m_num_pixels = m_width * m_height;
|
||||
const auto o_num_pixels = other.m_width * other.m_height;
|
||||
|
||||
if (o_num_pixels > m_num_pixels) {
|
||||
this->~image();
|
||||
this->m_data = new C[o_num_pixels];
|
||||
}
|
||||
|
||||
std::copy_n(other.m_data, o_num_pixels, this->m_data);
|
||||
|
||||
this->m_width = other.m_width;
|
||||
this->m_height = other.m_height;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
image<C>& image<C>::operator=(image&& other) noexcept {
|
||||
if (this != &other) {
|
||||
this->~image();
|
||||
|
||||
this->m_data = std::move(other.m_data);
|
||||
this->m_width = other.m_width;
|
||||
this->m_height = other.m_height;
|
||||
|
||||
other.m_width = 0;
|
||||
other.m_height = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<typename C>
|
||||
std::error_code image<C>::load(const char* filename, image& dst, bool flip) {
|
||||
int width, height, channels;
|
||||
|
||||
stbi_set_flip_vertically_on_load(flip);
|
||||
|
||||
auto data = reinterpret_cast<pointer>(stbi_load(filename, &width, &height, &channels, sizeof(C)));
|
||||
|
||||
if (data == nullptr) {
|
||||
return std::make_error_code(std::errc::no_such_file_or_directory);
|
||||
}
|
||||
|
||||
dst.m_data.reset(data);
|
||||
dst.m_width = static_cast<size_type>(width);
|
||||
dst.m_height = static_cast<size_type>(height);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
image<C> image<C>::create(const size_type width, const size_type height, const C& color) {
|
||||
|
||||
const auto num_pixels = width * height;
|
||||
C* data = new C[num_pixels];
|
||||
|
||||
std::fill_n(data, num_pixels, color);
|
||||
|
||||
return image(data, width, height);
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::size_type image<C>::width() const {
|
||||
return m_width;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::size_type image<C>::height() const {
|
||||
return m_height;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
std::pair<typename image<C>::size_type, typename image<C>::size_type> image<C>::size() const {
|
||||
return { m_width, m_height };
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::size_type image<C>::num_pixels() const {
|
||||
return m_width * m_height;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
int image<C>::save(const std::string& filename) const {
|
||||
|
||||
std::string ext = filename.substr(filename.rfind('.') + 1, filename.length());
|
||||
std::transform(
|
||||
ext.begin(), ext.end(), ext.begin(), [](unsigned char c) {
|
||||
return std::tolower(c);
|
||||
}
|
||||
);
|
||||
|
||||
int status = -1;
|
||||
|
||||
if (ext == "png") {
|
||||
status = stbi_write_png(filename.c_str(), m_width, m_height, sizeof(C), m_data, m_width * sizeof(C));
|
||||
} else if (ext == "bmp") {
|
||||
status = stbi_write_bmp(filename.c_str(), m_width, m_height, sizeof(C), m_data);
|
||||
} else if (ext == "tga") {
|
||||
status = stbi_write_tga(filename.c_str(), m_width, m_height, sizeof(C), m_data);
|
||||
} else if (ext == "jpg" || ext == "jpeg") {
|
||||
status = stbi_write_jpg(filename.c_str(), m_width, m_height, sizeof(C), m_data, m_width * sizeof(C));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
bool image<C>::contains(size_type x, size_type y) const {
|
||||
return 0 <= x and x < m_width and 0 <= y and y < m_height;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::const_reference image<C>::operator()(size_type x, size_type y) const {
|
||||
const auto clamped_x = std::clamp(x, static_cast<size_type>(0), m_width - 1);
|
||||
const auto clamped_y = std::clamp(y, static_cast<size_type>(0), m_height - 1);
|
||||
return m_data[clamped_x + clamped_y * m_width];
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::reference image<C>::operator()(size_type x, size_type y) {
|
||||
const auto clamped_x = std::clamp(x, static_cast<size_type>(0), m_width - 1);
|
||||
const auto clamped_y = std::clamp(y, static_cast<size_type>(0), m_height - 1);
|
||||
return m_data[clamped_x + clamped_y * m_width];
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::value_type image<C>::operator()(double x, double y) const {
|
||||
auto min_x = static_cast<size_type>(std::floor(x));
|
||||
auto min_y = static_cast<size_type>(std::floor(y));
|
||||
const auto px00 = (*this)(min_x, min_y), px10 = (*this)(min_x + 1, min_y);
|
||||
const auto px01 = (*this)(min_x, min_y + 1), px11 = (*this)(min_x + 1, min_y + 1);
|
||||
const auto a_x = x - static_cast<double>(min_x), a_y = y - static_cast<double>(min_y);
|
||||
return std::lerp(
|
||||
std::lerp(px00, px10, a_x),
|
||||
std::lerp(px01, px11, a_x),
|
||||
a_y
|
||||
);
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::const_iterator image<C>::operator[](size_type y) const {
|
||||
return &m_data[y * m_width];
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::iterator image<C>::operator[](size_type y) {
|
||||
return &m_data[y * m_width];
|
||||
}
|
||||
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::const_iterator image<C>::begin() const {
|
||||
return m_data.get();
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::iterator image<C>::begin() {
|
||||
return m_data.get();
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::const_iterator image<C>::end() const {
|
||||
return m_data.get() + m_width * m_height;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::iterator image<C>::end() {
|
||||
return m_data.get() + m_width * m_height;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::const_iterator image<C>::cbegin() const {
|
||||
return const_cast<const_iterator>(begin());
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::const_iterator image<C>::cend() const {
|
||||
return const_cast<const_iterator>(begin());
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::const_pointer image<C>::data() const {
|
||||
return m_data.get();
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
typename image<C>::pointer image<C>::data() {
|
||||
return m_data.get();
|
||||
}
|
||||
|
||||
} // namespace ztu
|
||||
87
include/util/line_parser.hpp
Normal file
87
include/util/line_parser.hpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <istream>
|
||||
#include "util/for_each.hpp"
|
||||
|
||||
namespace ztu
|
||||
{
|
||||
template<bool Repeating, typename F>
|
||||
struct prefixed_line_parser {
|
||||
const std::string_view prefix;
|
||||
F parse;
|
||||
};
|
||||
|
||||
template<bool Repeating>
|
||||
struct line_repeating_type {};
|
||||
|
||||
static constexpr auto is_repeating = line_repeating_type<true>{};
|
||||
static constexpr auto is_not_repeating = line_repeating_type<false>{};
|
||||
|
||||
template<bool Repeating, typename F>
|
||||
prefixed_line_parser<Repeating, F> make_line_parser(std::string_view prefix, line_repeating_type<Repeating>, F&& f)
|
||||
{
|
||||
return { prefix, std::forward<F>(f) };
|
||||
}
|
||||
|
||||
template<typename E, bool... Rs, class... Fs>
|
||||
E parse_lines(std::istream& in, const bool pedantic, prefixed_line_parser<Rs, Fs>&&... parsers)
|
||||
{
|
||||
|
||||
auto ec = E{};
|
||||
|
||||
std::string line;
|
||||
while (std::getline(in, line)) [[likely]]
|
||||
{
|
||||
parse_current_line:
|
||||
|
||||
auto line_updated = false;
|
||||
|
||||
for_each::argument(
|
||||
[&]<bool R, typename F>(prefixed_line_parser<R, F>&& parser) -> bool
|
||||
{
|
||||
if (line.starts_with(parser.prefix))
|
||||
{
|
||||
const auto prefix_length = parser.prefix.length();
|
||||
ec = parser.parse(line.substr(prefix_length));
|
||||
|
||||
if constexpr (R)
|
||||
{
|
||||
while (std::getline(in, line))
|
||||
{
|
||||
if (line.starts_with(parser.prefix)) [[likely]]
|
||||
{
|
||||
ec = parser.parse(line.substr(prefix_length));
|
||||
}
|
||||
else [[unlikely]]
|
||||
{
|
||||
line_updated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
std::forward<prefixed_line_parser<Rs, Fs>>(parsers)...
|
||||
);
|
||||
|
||||
if (pedantic) {
|
||||
if (ec != E{}) [[unlikely]] {
|
||||
return ec;
|
||||
}
|
||||
}
|
||||
|
||||
if (line_updated)
|
||||
{
|
||||
goto parse_current_line;
|
||||
}
|
||||
}
|
||||
|
||||
return E{};
|
||||
}
|
||||
}
|
||||
1742
include/util/logger.hpp
Executable file
1742
include/util/logger.hpp
Executable file
File diff suppressed because it is too large
Load Diff
139
include/util/result.hpp
Normal file
139
include/util/result.hpp
Normal file
@@ -0,0 +1,139 @@
|
||||
#pragma once
|
||||
|
||||
#include <variant>
|
||||
#include <system_error>
|
||||
#include <expected>
|
||||
|
||||
namespace ztu {
|
||||
|
||||
template<typename T>
|
||||
using result = std::expected<T, std::error_code>;
|
||||
|
||||
/*
|
||||
template<typename T>
|
||||
class result {
|
||||
static constexpr auto value_index = 0;
|
||||
static constexpr auto error_index = 1;
|
||||
|
||||
public:
|
||||
constexpr result(T value);
|
||||
constexpr result(const std::error_code& error);
|
||||
|
||||
template<typename... Args>
|
||||
void emplace(Args&&... args);
|
||||
|
||||
[[nodiscard]] constexpr bool ok() const;
|
||||
|
||||
[[nodiscard]] constexpr std::error_code error() const;
|
||||
|
||||
[[nodiscard]] constexpr const T& value() const;
|
||||
|
||||
[[nodiscard]] constexpr T& value();
|
||||
|
||||
[[nodiscard]] constexpr T&& value() &&;
|
||||
|
||||
[[nodiscard]] operator bool() const;
|
||||
|
||||
[[nodiscard]] const T& operator*() const;
|
||||
|
||||
[[nodiscard]] T& operator*();
|
||||
|
||||
[[nodiscard]] T&& operator*() &&;
|
||||
|
||||
[[nodiscard]] bool operator==(const T& rhs) const;
|
||||
|
||||
[[nodiscard]] bool operator==(const std::error_code& rhs) const;
|
||||
|
||||
template<typename Func>
|
||||
auto map(Func&& func) const -> result<decltype(func(value()))>
|
||||
{
|
||||
if (ok()) return func(value());
|
||||
return error();
|
||||
}
|
||||
|
||||
private:
|
||||
std::variant<T, std::error_code> m_data;
|
||||
};
|
||||
|
||||
// Member function definitions
|
||||
|
||||
template<typename T>
|
||||
constexpr result<T>::result(T value)
|
||||
: m_data{ std::in_place_index_t<value_index>{}, std::move(value) }
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
constexpr result<T>::result(const std::error_code& error)
|
||||
: m_data{ std::in_place_index_t<error_index>{}, error }
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
template<typename... Args>
|
||||
void result<T>::emplace(Args&&... args) {
|
||||
m_data.template emplace<value_index>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename Func>
|
||||
auto result<T>::map(Func&& func) const -> result<decltype(func(value()))> {
|
||||
if (ok()) return func(value());
|
||||
return error();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr bool result<T>::ok() const {
|
||||
return m_data.index() == value_index;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr std::error_code result<T>::error() const {
|
||||
auto error_ptr = std::get_if<error_index>(m_data);
|
||||
return error_ptr ? *error_ptr : std::error_code{};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr const T& result<T>::value() const {
|
||||
return std::get<value_index>(m_data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T& result<T>::value() {
|
||||
return std::get<value_index>(m_data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T&& result<T>::value() && {
|
||||
return std::get<value_index>(std::move(m_data));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr result<T>::operator bool() const {
|
||||
return ok();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T& result<T>::operator*() const {
|
||||
return *std::get_if<value_index>(m_data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& result<T>::operator*() {
|
||||
return *std::get_if<value_index>(m_data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T&& result<T>::operator*() && {
|
||||
return *std::get_if<value_index>(std::move(m_data));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool result<T>::operator==(const T& rhs) const {
|
||||
return ok() and value() == rhs;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool result<T>::operator==(const std::error_code& rhs) const {
|
||||
return not ok() and error() == rhs;
|
||||
}*/
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user