fix: fix VxMath part
This commit is contained in:
317
.clang-format
Normal file
317
.clang-format
Normal file
@@ -0,0 +1,317 @@
|
|||||||
|
# yaml-language-server: $schema=https://json.schemastore.org/clang-format.json
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveBitFields:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveDeclarations:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveMacros:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveShortCaseStatements:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCaseArrows: false
|
||||||
|
AlignCaseColons: false
|
||||||
|
AlignConsecutiveTableGenBreakingDAGArgColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveTableGenCondOperatorColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveTableGenDefinitionColons:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignEscapedNewlines: DontAlign
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowBreakBeforeNoexceptSpecifier: Never
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseExpressionOnASingleLine: true
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortCompoundRequirementOnASingleLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: false
|
||||||
|
SplitEmptyRecord: false
|
||||||
|
SplitEmptyNamespace: false
|
||||||
|
BreakAdjacentStringLiterals: true
|
||||||
|
BreakAfterAttributes: Leave
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakAfterReturnType: None
|
||||||
|
BreakArrays: true
|
||||||
|
BreakBeforeBinaryOperators: All
|
||||||
|
BreakBeforeConceptDeclarations: Always
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: AfterColon
|
||||||
|
BreakFunctionDefinitionParameters: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: false
|
||||||
|
BreakTemplateDeclarations: Yes
|
||||||
|
ColumnLimit: 140
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: true
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- forever
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<Q.*'
|
||||||
|
Priority: 200
|
||||||
|
SortPriority: 200
|
||||||
|
CaseSensitive: true
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentRequiresClause: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertBraces: false
|
||||||
|
InsertNewlineAtEOF: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
IntegerLiteralSeparator:
|
||||||
|
Binary: 0
|
||||||
|
BinaryMinDigits: 0
|
||||||
|
Decimal: 0
|
||||||
|
DecimalMinDigits: 0
|
||||||
|
Hex: 0
|
||||||
|
HexMinDigits: 0
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLines:
|
||||||
|
AtEndOfFile: false
|
||||||
|
AtStartOfBlock: false
|
||||||
|
AtStartOfFile: false
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
LineEnding: DeriveLF
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MainIncludeChar: Quote
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: All
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PackConstructorInitializers: BinPack
|
||||||
|
PenaltyBreakAssignment: 150
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 300
|
||||||
|
PenaltyBreakComment: 500
|
||||||
|
PenaltyBreakFirstLessLess: 400
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakScopeResolution: 500
|
||||||
|
PenaltyBreakString: 600
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 50
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 300
|
||||||
|
PointerAlignment: Right
|
||||||
|
PPIndentWidth: -1
|
||||||
|
QualifierAlignment: Leave
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: false
|
||||||
|
RemoveBracesLLVM: false
|
||||||
|
RemoveParentheses: Leave
|
||||||
|
RemoveSemicolon: false
|
||||||
|
RequiresClausePosition: OwnLine
|
||||||
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Leave
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SkipMacroDefinitionBody: false
|
||||||
|
SortIncludes: Never
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: Lexicographic
|
||||||
|
SpaceAfterCStyleCast: true
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeJsonColon: false
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: true
|
||||||
|
AfterForeachMacros: true
|
||||||
|
AfterFunctionDefinitionName: false
|
||||||
|
AfterFunctionDeclarationName: false
|
||||||
|
AfterIfMacros: true
|
||||||
|
AfterOverloadedOperator: false
|
||||||
|
AfterPlacementOperator: true
|
||||||
|
AfterRequiresInClause: false
|
||||||
|
AfterRequiresInExpression: false
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParens: Never
|
||||||
|
SpacesInParensOptions:
|
||||||
|
ExceptDoubleParentheses: false
|
||||||
|
InCStyleCasts: false
|
||||||
|
InConditionalStatements: false
|
||||||
|
InEmptyParentheses: false
|
||||||
|
Other: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
- emit
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
- Q_CLASSINFO
|
||||||
|
- Q_ENUM
|
||||||
|
- Q_ENUM_NS
|
||||||
|
- Q_FLAG
|
||||||
|
- Q_FLAG_NS
|
||||||
|
- Q_GADGET
|
||||||
|
- Q_GADGET_EXPORT
|
||||||
|
- Q_INTERFACES
|
||||||
|
- Q_LOGGING_CATEGORY
|
||||||
|
- Q_MOC_INCLUDE
|
||||||
|
- Q_NAMESPACE
|
||||||
|
- Q_NAMESPACE_EXPORT
|
||||||
|
- Q_OBJECT
|
||||||
|
- Q_PROPERTY
|
||||||
|
- Q_REVISION
|
||||||
|
- Q_DISABLE_COPY
|
||||||
|
- Q_DISABLE_COPY_MOVE
|
||||||
|
- Q_SET_OBJECT_NAME
|
||||||
|
- QT_BEGIN_NAMESPACE
|
||||||
|
- QT_END_NAMESPACE
|
||||||
|
- QML_ADDED_IN_MINOR_VERSION
|
||||||
|
- QML_ANONYMOUS
|
||||||
|
- QML_ATTACHED
|
||||||
|
- QML_DECLARE_TYPE
|
||||||
|
- QML_DECLARE_TYPEINFO
|
||||||
|
- QML_ELEMENT
|
||||||
|
- QML_EXTENDED
|
||||||
|
- QML_EXTENDED_NAMESPACE
|
||||||
|
- QML_EXTRA_VERSION
|
||||||
|
- QML_FOREIGN
|
||||||
|
- QML_FOREIGN_NAMESPACE
|
||||||
|
- QML_IMPLEMENTS_INTERFACES
|
||||||
|
- QML_INTERFACE
|
||||||
|
- QML_NAMED_ELEMENT
|
||||||
|
- QML_REMOVED_IN_MINOR_VERSION
|
||||||
|
- QML_SINGLETON
|
||||||
|
- QML_UNAVAILABLE
|
||||||
|
- QML_UNCREATABLE
|
||||||
|
- QML_VALUE_TYPE
|
||||||
|
- YYCC_DELETE_COPY
|
||||||
|
- YYCC_DELETE_MOVE
|
||||||
|
- YYCC_DELETE_COPY_MOVE
|
||||||
|
- YYCC_DEFAULT_COPY
|
||||||
|
- YYCC_DEFAULT_MOVE
|
||||||
|
- YYCC_DEFAULT_COPY_MOVE
|
||||||
|
- YYCC_DECL_COPY
|
||||||
|
- YYCC_DECL_MOVE
|
||||||
|
- YYCC_DECL_COPY_MOVE
|
||||||
|
TableGenBreakInsideDAGArg: DontBreak
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: ForIndentation
|
||||||
|
VerilogBreakBetweenInstancePorts: true
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- STRINGIZE
|
||||||
|
...
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ struct {{ sname }} {
|
|||||||
{{ sname }}({{- shared.argument_list_builder(svars) -}});
|
{{ sname }}({{- shared.argument_list_builder(svars) -}});
|
||||||
|
|
||||||
{#- Default copy ctor, move ctor, copy assigner, move assigner #}
|
{#- Default copy ctor, move ctor, copy assigner, move assigner #}
|
||||||
YYCC_DEFAULT_COPY_MOVE({{ sname }});
|
YYCC_DEFAULT_COPY_MOVE({{ sname }})
|
||||||
|
|
||||||
{#- Offset operator #}
|
{#- Offset operator #}
|
||||||
CKFLOAT& operator[](size_t i);
|
CKFLOAT& operator[](size_t i);
|
||||||
|
|||||||
@@ -159,14 +159,14 @@ namespace LibCmo::CK2 {
|
|||||||
if (!canSaveAlpha) {
|
if (!canSaveAlpha) {
|
||||||
// prepare alpha list
|
// prepare alpha list
|
||||||
CKDWORD pixelCount = slot->GetPixelCount();
|
CKDWORD pixelCount = slot->GetPixelCount();
|
||||||
std::unique_ptr<CKBYTE[]> alphabuf(new CKBYTE[pixelCount * VxMath::VxImageDescEx::ColorFactorSize]);
|
std::unique_ptr<CKBYTE[]> alphabuf(new CKBYTE[pixelCount * VxMath::VxImageDescEx::FACTOR_SIZE]);
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
pixelCount,
|
pixelCount,
|
||||||
alphabuf.get(),
|
alphabuf.get(),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
slot->GetImage() + 3 * VxMath::VxImageDescEx::ColorFactorSize, // move to A factor
|
slot->GetImage() + 3 * VxMath::VxImageDescEx::FACTOR_SIZE, // move to A factor
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
|
|
||||||
// check whether alpha are the same value
|
// check whether alpha are the same value
|
||||||
@@ -174,9 +174,9 @@ namespace LibCmo::CK2 {
|
|||||||
CKDWORD sameAlpha = 0;
|
CKDWORD sameAlpha = 0;
|
||||||
for (CKDWORD i = 0; i < pixelCount; ++i) {
|
for (CKDWORD i = 0; i < pixelCount; ++i) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
sameAlpha = static_cast<CKDWORD>(alphabuf[i * VxMath::VxImageDescEx::ColorFactorSize]);
|
sameAlpha = static_cast<CKDWORD>(alphabuf[i * VxMath::VxImageDescEx::FACTOR_SIZE]);
|
||||||
} else {
|
} else {
|
||||||
if (sameAlpha != static_cast<CKDWORD>(alphabuf[i * VxMath::VxImageDescEx::ColorFactorSize])) {
|
if (sameAlpha != static_cast<CKDWORD>(alphabuf[i * VxMath::VxImageDescEx::FACTOR_SIZE])) {
|
||||||
isSameAlpha = false;
|
isSameAlpha = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ namespace LibCmo::CK2 {
|
|||||||
if (isSameAlpha) {
|
if (isSameAlpha) {
|
||||||
chk->WriteStruct(sameAlpha);
|
chk->WriteStruct(sameAlpha);
|
||||||
} else {
|
} else {
|
||||||
chk->WriteBuffer(alphabuf.get(), pixelCount * VxMath::VxImageDescEx::ColorFactorSize);
|
chk->WriteBuffer(alphabuf.get(), pixelCount * VxMath::VxImageDescEx::FACTOR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// free alphabuf
|
// free alphabuf
|
||||||
@@ -240,7 +240,7 @@ namespace LibCmo::CK2 {
|
|||||||
// create 4 channel buf
|
// create 4 channel buf
|
||||||
// we always write alpha channel data.
|
// we always write alpha channel data.
|
||||||
CKDWORD pixelCount = slot->GetPixelCount();
|
CKDWORD pixelCount = slot->GetPixelCount();
|
||||||
CKDWORD bufSize = pixelCount * VxMath::VxImageDescEx::ColorFactorSize;
|
CKDWORD bufSize = pixelCount * VxMath::VxImageDescEx::FACTOR_SIZE;
|
||||||
std::unique_ptr<CKBYTE[]> redbuf(new CKBYTE[bufSize]);
|
std::unique_ptr<CKBYTE[]> redbuf(new CKBYTE[bufSize]);
|
||||||
std::unique_ptr<CKBYTE[]> greenbuf(new CKBYTE[bufSize]);
|
std::unique_ptr<CKBYTE[]> greenbuf(new CKBYTE[bufSize]);
|
||||||
std::unique_ptr<CKBYTE[]> bluebuf(new CKBYTE[bufSize]);
|
std::unique_ptr<CKBYTE[]> bluebuf(new CKBYTE[bufSize]);
|
||||||
@@ -251,37 +251,37 @@ namespace LibCmo::CK2 {
|
|||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
pixelCount,
|
pixelCount,
|
||||||
alphabuf.get(),
|
alphabuf.get(),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
slot->GetImage() + (3 * VxMath::VxImageDescEx::ColorFactorSize),
|
slot->GetImage() + (3 * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// copy r
|
// copy r
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
pixelCount,
|
pixelCount,
|
||||||
redbuf.get(),
|
redbuf.get(),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
slot->GetImage() + (2 * VxMath::VxImageDescEx::ColorFactorSize),
|
slot->GetImage() + (2 * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// copy g
|
// copy g
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
pixelCount,
|
pixelCount,
|
||||||
greenbuf.get(),
|
greenbuf.get(),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
slot->GetImage() + (1 * VxMath::VxImageDescEx::ColorFactorSize),
|
slot->GetImage() + (1 * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// copy b
|
// copy b
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
pixelCount,
|
pixelCount,
|
||||||
bluebuf.get(),
|
bluebuf.get(),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
slot->GetImage() + (0 * VxMath::VxImageDescEx::ColorFactorSize),
|
slot->GetImage() + (0 * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
|
|
||||||
// write 4 buf
|
// write 4 buf
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "../VTUtils.hpp"
|
#include "../VTUtils.hpp"
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#if defined(YYCC_OS_WINDOWS)
|
||||||
#define ZLIB_WINAPI
|
#define ZLIB_WINAPI
|
||||||
#endif
|
#endif
|
||||||
#include <zconf.h>
|
#include <zconf.h>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// MARK: for std-image size, we use `n * CKSizeof(CKBYTE)` to calc offset.
|
// MARK: for std-image size, we use `n * CKSizeof(CKBYTE)` to calc offset.
|
||||||
// for virtools size, we use `VxMath::VxImageDescEx::ColorFactorSize` and `VxMath::VxImageDescEx::PixelSize` to calc offset.
|
// for virtools size, we use `VxMath::VxImageDescEx::FACTOR_SIZE` and `VxMath::VxImageDescEx::PIXEL_SIZE` to calc offset.
|
||||||
|
|
||||||
static void ABGRToARGB(CKDWORD count, const void* _abgr, void* _argb) {
|
static void ABGRToARGB(CKDWORD count, const void* _abgr, void* _argb) {
|
||||||
const CKBYTE* abgr = static_cast<const CKBYTE*>(_abgr);
|
const CKBYTE* abgr = static_cast<const CKBYTE*>(_abgr);
|
||||||
@@ -24,36 +24,36 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
// copy R
|
// copy R
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
argb + (2u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (2u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize,
|
VxMath::VxImageDescEx::PIXEL_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
abgr + (0u * CKSizeof(CKBYTE)),
|
abgr + (0u * CKSizeof(CKBYTE)),
|
||||||
4u * CKSizeof(CKBYTE)
|
4u * CKSizeof(CKBYTE)
|
||||||
);
|
);
|
||||||
// copy G
|
// copy G
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
argb + (1u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (1u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize,
|
VxMath::VxImageDescEx::PIXEL_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
abgr + (1u * CKSizeof(CKBYTE)),
|
abgr + (1u * CKSizeof(CKBYTE)),
|
||||||
4u * CKSizeof(CKBYTE)
|
4u * CKSizeof(CKBYTE)
|
||||||
);
|
);
|
||||||
// copy B
|
// copy B
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
argb + (0u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (0u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize,
|
VxMath::VxImageDescEx::PIXEL_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
abgr + (2u * CKSizeof(CKBYTE)),
|
abgr + (2u * CKSizeof(CKBYTE)),
|
||||||
4u * CKSizeof(CKBYTE)
|
4u * CKSizeof(CKBYTE)
|
||||||
);
|
);
|
||||||
// copy A
|
// copy A
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
argb + (3u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (3u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize,
|
VxMath::VxImageDescEx::PIXEL_SIZE,
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
abgr + (3u * CKSizeof(CKBYTE)),
|
abgr + (3u * CKSizeof(CKBYTE)),
|
||||||
4u * CKSizeof(CKBYTE)
|
4u * CKSizeof(CKBYTE)
|
||||||
);
|
);
|
||||||
@@ -67,36 +67,36 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
count,
|
count,
|
||||||
abgr + (0u * CKSizeof(CKBYTE)),
|
abgr + (0u * CKSizeof(CKBYTE)),
|
||||||
4u * CKSizeof(CKBYTE),
|
4u * CKSizeof(CKBYTE),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
argb + (2u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (2u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// copy G
|
// copy G
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
abgr + (1u * CKSizeof(CKBYTE)),
|
abgr + (1u * CKSizeof(CKBYTE)),
|
||||||
4u * CKSizeof(CKBYTE),
|
4u * CKSizeof(CKBYTE),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
argb + (1u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (1u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// copy B
|
// copy B
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
abgr + (2u * CKSizeof(CKBYTE)),
|
abgr + (2u * CKSizeof(CKBYTE)),
|
||||||
4u * CKSizeof(CKBYTE),
|
4u * CKSizeof(CKBYTE),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
argb + (0u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (0u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// copy A
|
// copy A
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
abgr + (3u * CKSizeof(CKBYTE)),
|
abgr + (3u * CKSizeof(CKBYTE)),
|
||||||
4u * CKSizeof(CKBYTE),
|
4u * CKSizeof(CKBYTE),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
argb + (3u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (3u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,27 +108,27 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
count,
|
count,
|
||||||
bgr + (0u * CKSizeof(CKBYTE)),
|
bgr + (0u * CKSizeof(CKBYTE)),
|
||||||
3u * CKSizeof(CKBYTE),
|
3u * CKSizeof(CKBYTE),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
argb + (2u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (2u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// copy G
|
// copy G
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
bgr + (1u * CKSizeof(CKBYTE)),
|
bgr + (1u * CKSizeof(CKBYTE)),
|
||||||
3u * CKSizeof(CKBYTE),
|
3u * CKSizeof(CKBYTE),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
argb + (1u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (1u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// copy B
|
// copy B
|
||||||
VxMath::VxCopyStructure(
|
VxMath::VxCopyStructure(
|
||||||
count,
|
count,
|
||||||
bgr + (2u * CKSizeof(CKBYTE)),
|
bgr + (2u * CKSizeof(CKBYTE)),
|
||||||
3u * CKSizeof(CKBYTE),
|
3u * CKSizeof(CKBYTE),
|
||||||
VxMath::VxImageDescEx::ColorFactorSize,
|
VxMath::VxImageDescEx::FACTOR_SIZE,
|
||||||
argb + (0u * VxMath::VxImageDescEx::ColorFactorSize),
|
argb + (0u * VxMath::VxImageDescEx::FACTOR_SIZE),
|
||||||
VxMath::VxImageDescEx::PixelSize
|
VxMath::VxImageDescEx::PIXEL_SIZE
|
||||||
);
|
);
|
||||||
// skip A factor
|
// skip A factor
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
props.m_Format.Flags = static_cast<CKDWORD>(VxMath::VX_PIXELFORMAT::_32_ARGB8888);
|
props.m_Format.Flags = static_cast<CKDWORD>(VxMath::VX_PIXELFORMAT::_32_ARGB8888);
|
||||||
props.m_Format.Width = m_ImageHost.GetWidth();
|
props.m_Format.Width = m_ImageHost.GetWidth();
|
||||||
props.m_Format.Height = m_ImageHost.GetHeight();
|
props.m_Format.Height = m_ImageHost.GetHeight();
|
||||||
props.m_Format.BytesPerLine = VxMath::VxImageDescEx::PixelSize * props.m_Format.Width;
|
props.m_Format.BytesPerLine = VxMath::VxImageDescEx::PIXEL_SIZE * props.m_Format.Width;
|
||||||
props.m_Format.BitsPerPixel = 32;
|
props.m_Format.BitsPerPixel = 32;
|
||||||
|
|
||||||
props.m_Format.RedMask = 0x00FF0000;
|
props.m_Format.RedMask = 0x00FF0000;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace LibCmo::VxMath {
|
|||||||
|
|
||||||
// copy and swap data by line
|
// copy and swap data by line
|
||||||
CKDWORD height = dst->GetHeight(),
|
CKDWORD height = dst->GetHeight(),
|
||||||
rowsize = VxImageDescEx::PixelSize * dst->GetWidth();
|
rowsize = VxImageDescEx::PIXEL_SIZE * dst->GetWidth();
|
||||||
for (CKDWORD row = 0; row < height; ++row) {
|
for (CKDWORD row = 0; row < height; ++row) {
|
||||||
std::memcpy(
|
std::memcpy(
|
||||||
dst->GetMutableImage() + (row * rowsize),
|
dst->GetMutableImage() + (row * rowsize),
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
#include "VxMemoryMappedFile.hpp"
|
#include "VxMemoryMappedFile.hpp"
|
||||||
#include "../VTEncoding.hpp"
|
#include <yycc/num/safe_cast.hpp>
|
||||||
|
#if defined(YYCC_OS_WINDOWS)
|
||||||
|
#include <yycc/encoding/windows.hpp>
|
||||||
|
#else
|
||||||
|
#include <yycc/string/reinterpret.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace LibCmo::VxMath {
|
namespace LibCmo::VxMath {
|
||||||
|
|
||||||
VxMemoryMappedFile::VxMemoryMappedFile(CKSTRING u8_filepath) :
|
VxMemoryMappedFile::VxMemoryMappedFile(CKSTRING u8_filepath) :
|
||||||
// Initialize members
|
// Initialize members
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#if defined(YYCC_OS_WINDOWS)
|
||||||
// Initialize Windows specific.
|
// Initialize Windows specific.
|
||||||
m_hFile(NULL), m_hFileMapping(NULL), m_hFileMapView(NULL),
|
m_hFile(NULL), m_hFileMapping(NULL), m_hFileMapView(NULL),
|
||||||
m_dwFileSize(),
|
m_dwFileSize(),
|
||||||
@@ -22,12 +27,12 @@ namespace LibCmo::VxMath {
|
|||||||
m_szFilePath = u8_filepath;
|
m_szFilePath = u8_filepath;
|
||||||
|
|
||||||
// Do real mapping work according to different platform.
|
// Do real mapping work according to different platform.
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#if defined(YYCC_OS_WINDOWS)
|
||||||
|
|
||||||
// Parse file name to wchar_t
|
// Parse file name to wchar_t
|
||||||
std::wstring w_filename;
|
auto rv_w_filename = yycc::encoding::windows::to_wchar(m_szFilePath);
|
||||||
if (!YYCC::EncodingHelper::UTF8ToWchar(m_szFilePath, w_filename))
|
if (!rv_w_filename.has_value()) return;
|
||||||
return;
|
std::wstring w_filename = std::move(rv_w_filename.value());
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
this->m_hFile = ::CreateFileW(
|
this->m_hFile = ::CreateFileW(
|
||||||
@@ -85,7 +90,7 @@ namespace LibCmo::VxMath {
|
|||||||
// create file
|
// create file
|
||||||
// we do not need provide mode_t, because is served for new created file.
|
// we do not need provide mode_t, because is served for new created file.
|
||||||
// we are opening a existed file.
|
// we are opening a existed file.
|
||||||
this->m_hFile = open(YYCC::EncodingHelper::ToOrdinary(m_szFilePath.c_str()), O_RDONLY);
|
this->m_hFile = open(yycc::string::reinterpret::as_ordinary(m_szFilePath.c_str()), O_RDONLY);
|
||||||
if (m_hFile == -1) {
|
if (m_hFile == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -98,13 +103,15 @@ namespace LibCmo::VxMath {
|
|||||||
close(m_hFile);
|
close(m_hFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Setup size and check its range
|
// Setup size with checking its range
|
||||||
this->m_offFileSize = sb.st_size;
|
this->m_offFileSize = sb.st_size;
|
||||||
if (this->m_offFileSize > static_cast<off_t>(std::numeric_limits<CKDWORD>::max())) {
|
auto rv_cbFile = yycc::num::safe_cast::try_to<CKDWORD>(this->m_offFileSize);
|
||||||
|
if (rv_cbFile.has_value()) {
|
||||||
|
this->m_cbFile = rv_cbFile.value();
|
||||||
|
} else {
|
||||||
close(m_hFile);
|
close(m_hFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_cbFile = static_cast<CKDWORD>(this->m_offFileSize);
|
|
||||||
|
|
||||||
// map file
|
// map file
|
||||||
this->m_pFileAddr = mmap(
|
this->m_pFileAddr = mmap(
|
||||||
@@ -120,7 +127,7 @@ namespace LibCmo::VxMath {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set base address
|
// set base address
|
||||||
m_pMemoryMappedFileBase = m_pFileAddr;
|
this->m_pMemoryMappedFileBase = m_pFileAddr;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -135,7 +142,7 @@ namespace LibCmo::VxMath {
|
|||||||
m_cbFile = 0;
|
m_cbFile = 0;
|
||||||
m_pMemoryMappedFileBase = nullptr;
|
m_pMemoryMappedFileBase = nullptr;
|
||||||
|
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#if defined(YYCC_OS_WINDOWS)
|
||||||
UnmapViewOfFile(this->m_hFileMapView);
|
UnmapViewOfFile(this->m_hFileMapView);
|
||||||
CloseHandle(m_hFileMapping);
|
CloseHandle(m_hFileMapping);
|
||||||
CloseHandle(m_hFile);
|
CloseHandle(m_hFile);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../VTInternal.hpp"
|
#include "../VTInternal.hpp"
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#include <yycc/macro/class_copy_move.hpp>
|
||||||
#include <YYCC/WinImportPrefix.hpp>
|
#if defined(YYCC_OS_WINDOWS)
|
||||||
|
#include <yycc/windows/import_guard_head.hpp>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <YYCC/WinImportSuffix.hpp>
|
#include <yycc/windows/import_guard_tail.hpp>
|
||||||
#else
|
#else
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -24,7 +25,7 @@ namespace LibCmo::VxMath {
|
|||||||
*/
|
*/
|
||||||
class VxMemoryMappedFile {
|
class VxMemoryMappedFile {
|
||||||
private:
|
private:
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#if defined(YYCC_OS_WINDOWS)
|
||||||
HANDLE m_hFile;
|
HANDLE m_hFile;
|
||||||
LARGE_INTEGER m_dwFileSize;
|
LARGE_INTEGER m_dwFileSize;
|
||||||
HANDLE m_hFileMapping;
|
HANDLE m_hFileMapping;
|
||||||
@@ -48,7 +49,7 @@ namespace LibCmo::VxMath {
|
|||||||
*/
|
*/
|
||||||
VxMemoryMappedFile(CKSTRING u8_filepath);
|
VxMemoryMappedFile(CKSTRING u8_filepath);
|
||||||
~VxMemoryMappedFile();
|
~VxMemoryMappedFile();
|
||||||
YYCC_DEL_CLS_COPY_MOVE(VxMemoryMappedFile);
|
YYCC_DELETE_COPY_MOVE(VxMemoryMappedFile)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns a pointer to the mapped memory buffer.
|
* @brief Returns a pointer to the mapped memory buffer.
|
||||||
|
|||||||
@@ -9,22 +9,28 @@ namespace LibCmo::VxMath {
|
|||||||
VxVector2::VxVector2(CKFLOAT _x, CKFLOAT _y) : x(_x), y(_y) {}
|
VxVector2::VxVector2(CKFLOAT _x, CKFLOAT _y) : x(_x), y(_y) {}
|
||||||
CKFLOAT& VxVector2::operator[](size_t i) {
|
CKFLOAT& VxVector2::operator[](size_t i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return x;
|
case 0:
|
||||||
case 1: return y;
|
return x;
|
||||||
default: throw LogicException("Invalid index for VxVector2::operator[].");
|
case 1:
|
||||||
|
return y;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxVector2::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const CKFLOAT& VxVector2::operator[](size_t i) const {
|
const CKFLOAT& VxVector2::operator[](size_t i) const {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return x;
|
case 0:
|
||||||
case 1: return y;
|
return x;
|
||||||
default: throw LogicException("Invalid index for VxVector2::operator[].");
|
case 1:
|
||||||
|
return y;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxVector2::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool VxVector2::operator==(const VxVector2& rhs) const {
|
bool VxVector2::operator==(const VxVector2& rhs) const {
|
||||||
return (x == rhs.x && y == rhs.y);
|
return (x == rhs.x && y == rhs.y);
|
||||||
}
|
}
|
||||||
auto VxVector2::operator<=>(const VxVector2& rhs) const {
|
std::partial_ordering VxVector2::operator<=>(const VxVector2& rhs) const {
|
||||||
if (auto cmp = x <=> rhs.x; cmp != 0) return cmp;
|
if (auto cmp = x <=> rhs.x; cmp != 0) return cmp;
|
||||||
return y <=> rhs.y;
|
return y <=> rhs.y;
|
||||||
}
|
}
|
||||||
@@ -103,24 +109,32 @@ namespace LibCmo::VxMath {
|
|||||||
VxVector3::VxVector3(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z) : x(_x), y(_y), z(_z) {}
|
VxVector3::VxVector3(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z) : x(_x), y(_y), z(_z) {}
|
||||||
CKFLOAT& VxVector3::operator[](size_t i) {
|
CKFLOAT& VxVector3::operator[](size_t i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return x;
|
case 0:
|
||||||
case 1: return y;
|
return x;
|
||||||
case 2: return z;
|
case 1:
|
||||||
default: throw LogicException("Invalid index for VxVector3::operator[].");
|
return y;
|
||||||
|
case 2:
|
||||||
|
return z;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxVector3::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const CKFLOAT& VxVector3::operator[](size_t i) const {
|
const CKFLOAT& VxVector3::operator[](size_t i) const {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return x;
|
case 0:
|
||||||
case 1: return y;
|
return x;
|
||||||
case 2: return z;
|
case 1:
|
||||||
default: throw LogicException("Invalid index for VxVector3::operator[].");
|
return y;
|
||||||
|
case 2:
|
||||||
|
return z;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxVector3::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool VxVector3::operator==(const VxVector3& rhs) const {
|
bool VxVector3::operator==(const VxVector3& rhs) const {
|
||||||
return (x == rhs.x && y == rhs.y && z == rhs.z);
|
return (x == rhs.x && y == rhs.y && z == rhs.z);
|
||||||
}
|
}
|
||||||
auto VxVector3::operator<=>(const VxVector3& rhs) const {
|
std::partial_ordering VxVector3::operator<=>(const VxVector3& rhs) const {
|
||||||
if (auto cmp = x <=> rhs.x; cmp != 0) return cmp;
|
if (auto cmp = x <=> rhs.x; cmp != 0) return cmp;
|
||||||
if (auto cmp = y <=> rhs.y; cmp != 0) return cmp;
|
if (auto cmp = y <=> rhs.y; cmp != 0) return cmp;
|
||||||
return z <=> rhs.z;
|
return z <=> rhs.z;
|
||||||
@@ -205,26 +219,36 @@ namespace LibCmo::VxMath {
|
|||||||
VxVector4::VxVector4(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w) : x(_x), y(_y), z(_z), w(_w) {}
|
VxVector4::VxVector4(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w) : x(_x), y(_y), z(_z), w(_w) {}
|
||||||
CKFLOAT& VxVector4::operator[](size_t i) {
|
CKFLOAT& VxVector4::operator[](size_t i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return x;
|
case 0:
|
||||||
case 1: return y;
|
return x;
|
||||||
case 2: return z;
|
case 1:
|
||||||
case 3: return w;
|
return y;
|
||||||
default: throw LogicException("Invalid index for VxVector4::operator[].");
|
case 2:
|
||||||
|
return z;
|
||||||
|
case 3:
|
||||||
|
return w;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxVector4::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const CKFLOAT& VxVector4::operator[](size_t i) const {
|
const CKFLOAT& VxVector4::operator[](size_t i) const {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return x;
|
case 0:
|
||||||
case 1: return y;
|
return x;
|
||||||
case 2: return z;
|
case 1:
|
||||||
case 3: return w;
|
return y;
|
||||||
default: throw LogicException("Invalid index for VxVector4::operator[].");
|
case 2:
|
||||||
|
return z;
|
||||||
|
case 3:
|
||||||
|
return w;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxVector4::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool VxVector4::operator==(const VxVector4& rhs) const {
|
bool VxVector4::operator==(const VxVector4& rhs) const {
|
||||||
return (x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w);
|
return (x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w);
|
||||||
}
|
}
|
||||||
auto VxVector4::operator<=>(const VxVector4& rhs) const {
|
std::partial_ordering VxVector4::operator<=>(const VxVector4& rhs) const {
|
||||||
if (auto cmp = x <=> rhs.x; cmp != 0) return cmp;
|
if (auto cmp = x <=> rhs.x; cmp != 0) return cmp;
|
||||||
if (auto cmp = y <=> rhs.y; cmp != 0) return cmp;
|
if (auto cmp = y <=> rhs.y; cmp != 0) return cmp;
|
||||||
if (auto cmp = z <=> rhs.z; cmp != 0) return cmp;
|
if (auto cmp = z <=> rhs.z; cmp != 0) return cmp;
|
||||||
@@ -311,30 +335,40 @@ namespace LibCmo::VxMath {
|
|||||||
|
|
||||||
#pragma region VxQuaternion
|
#pragma region VxQuaternion
|
||||||
|
|
||||||
VxQuaternion::VxQuaternion() :x(0.0f), y(0.0f), z(0.0f), w(1.0f) {} // SET YOUR CUSTOM INIT
|
VxQuaternion::VxQuaternion() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {} // SET YOUR CUSTOM INIT
|
||||||
VxQuaternion::VxQuaternion(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w) : x(_x), y(_y), z(_z), w(_w) {}
|
VxQuaternion::VxQuaternion(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w) : x(_x), y(_y), z(_z), w(_w) {}
|
||||||
CKFLOAT& VxQuaternion::operator[](size_t i) {
|
CKFLOAT& VxQuaternion::operator[](size_t i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return x;
|
case 0:
|
||||||
case 1: return y;
|
return x;
|
||||||
case 2: return z;
|
case 1:
|
||||||
case 3: return w;
|
return y;
|
||||||
default: throw LogicException("Invalid index for VxQuaternion::operator[].");
|
case 2:
|
||||||
|
return z;
|
||||||
|
case 3:
|
||||||
|
return w;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxQuaternion::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const CKFLOAT& VxQuaternion::operator[](size_t i) const {
|
const CKFLOAT& VxQuaternion::operator[](size_t i) const {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return x;
|
case 0:
|
||||||
case 1: return y;
|
return x;
|
||||||
case 2: return z;
|
case 1:
|
||||||
case 3: return w;
|
return y;
|
||||||
default: throw LogicException("Invalid index for VxQuaternion::operator[].");
|
case 2:
|
||||||
|
return z;
|
||||||
|
case 3:
|
||||||
|
return w;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxQuaternion::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool VxQuaternion::operator==(const VxQuaternion& rhs) const {
|
bool VxQuaternion::operator==(const VxQuaternion& rhs) const {
|
||||||
return (x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w);
|
return (x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w);
|
||||||
}
|
}
|
||||||
auto VxQuaternion::operator<=>(const VxQuaternion& rhs) const {
|
std::partial_ordering VxQuaternion::operator<=>(const VxQuaternion& rhs) const {
|
||||||
if (auto cmp = x <=> rhs.x; cmp != 0) return cmp;
|
if (auto cmp = x <=> rhs.x; cmp != 0) return cmp;
|
||||||
if (auto cmp = y <=> rhs.y; cmp != 0) return cmp;
|
if (auto cmp = y <=> rhs.y; cmp != 0) return cmp;
|
||||||
if (auto cmp = z <=> rhs.z; cmp != 0) return cmp;
|
if (auto cmp = z <=> rhs.z; cmp != 0) return cmp;
|
||||||
@@ -348,30 +382,40 @@ namespace LibCmo::VxMath {
|
|||||||
|
|
||||||
#pragma region VxColor
|
#pragma region VxColor
|
||||||
|
|
||||||
VxColor::VxColor() :r(0.0f), g(0.0f), b(0.0f), a(1.0f) {} // SET YOUR CUSTOM INIT
|
VxColor::VxColor() : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {} // SET YOUR CUSTOM INIT
|
||||||
VxColor::VxColor(CKFLOAT _r, CKFLOAT _g, CKFLOAT _b, CKFLOAT _a) : r(_r), g(_g), b(_b), a(_a) {}
|
VxColor::VxColor(CKFLOAT _r, CKFLOAT _g, CKFLOAT _b, CKFLOAT _a) : r(_r), g(_g), b(_b), a(_a) {}
|
||||||
CKFLOAT& VxColor::operator[](size_t i) {
|
CKFLOAT& VxColor::operator[](size_t i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return r;
|
case 0:
|
||||||
case 1: return g;
|
return r;
|
||||||
case 2: return b;
|
case 1:
|
||||||
case 3: return a;
|
return g;
|
||||||
default: throw LogicException("Invalid index for VxColor::operator[].");
|
case 2:
|
||||||
|
return b;
|
||||||
|
case 3:
|
||||||
|
return a;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxColor::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const CKFLOAT& VxColor::operator[](size_t i) const {
|
const CKFLOAT& VxColor::operator[](size_t i) const {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return r;
|
case 0:
|
||||||
case 1: return g;
|
return r;
|
||||||
case 2: return b;
|
case 1:
|
||||||
case 3: return a;
|
return g;
|
||||||
default: throw LogicException("Invalid index for VxColor::operator[].");
|
case 2:
|
||||||
|
return b;
|
||||||
|
case 3:
|
||||||
|
return a;
|
||||||
|
default:
|
||||||
|
throw LogicException("Invalid index for VxColor::operator[].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool VxColor::operator==(const VxColor& rhs) const {
|
bool VxColor::operator==(const VxColor& rhs) const {
|
||||||
return (r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a);
|
return (r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a);
|
||||||
}
|
}
|
||||||
auto VxColor::operator<=>(const VxColor& rhs) const {
|
std::partial_ordering VxColor::operator<=>(const VxColor& rhs) const {
|
||||||
if (auto cmp = r <=> rhs.r; cmp != 0) return cmp;
|
if (auto cmp = r <=> rhs.r; cmp != 0) return cmp;
|
||||||
if (auto cmp = g <=> rhs.g; cmp != 0) return cmp;
|
if (auto cmp = g <=> rhs.g; cmp != 0) return cmp;
|
||||||
if (auto cmp = b <=> rhs.b; cmp != 0) return cmp;
|
if (auto cmp = b <=> rhs.b; cmp != 0) return cmp;
|
||||||
@@ -379,7 +423,9 @@ namespace LibCmo::VxMath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ===== BEGIN USER CUSTOM ===== */
|
/* ===== BEGIN USER CUSTOM ===== */
|
||||||
VxColor::VxColor(CKDWORD argb) { FromARGB(argb); }
|
VxColor::VxColor(CKDWORD argb) {
|
||||||
|
FromARGB(argb);
|
||||||
|
}
|
||||||
VxColor::VxColor(CKFLOAT _r, CKFLOAT _g, CKFLOAT _b) : r(_r), g(_g), b(_b), a(1.0f) {}
|
VxColor::VxColor(CKFLOAT _r, CKFLOAT _g, CKFLOAT _b) : r(_r), g(_g), b(_b), a(1.0f) {}
|
||||||
void VxColor::FromARGB(CKDWORD argb) {
|
void VxColor::FromARGB(CKDWORD argb) {
|
||||||
a = ((argb & 0xFF000000) >> 24) / 255.0f;
|
a = ((argb & 0xFF000000) >> 24) / 255.0f;
|
||||||
@@ -414,8 +460,12 @@ namespace LibCmo::VxMath {
|
|||||||
|
|
||||||
#pragma region VxMatrix
|
#pragma region VxMatrix
|
||||||
|
|
||||||
VxMatrix::VxMatrix() : m_Data() { SetIdentity(); }
|
VxMatrix::VxMatrix() : m_Data() {
|
||||||
VxMatrix::VxMatrix(CKFLOAT m[4][4]) : m_Data() { std::memcpy(m_Data, m, sizeof(m_Data)); }
|
SetIdentity();
|
||||||
|
}
|
||||||
|
VxMatrix::VxMatrix(CKFLOAT m[4][4]) : m_Data() {
|
||||||
|
std::memcpy(m_Data, m, sizeof(m_Data));
|
||||||
|
}
|
||||||
VxVector4& VxMatrix::operator[](size_t i) {
|
VxVector4& VxMatrix::operator[](size_t i) {
|
||||||
if (i >= 4) throw LogicException("Invalid index for VxMatrix::operator[].");
|
if (i >= 4) throw LogicException("Invalid index for VxMatrix::operator[].");
|
||||||
return *(reinterpret_cast<VxVector4*>(m_Data) + i);
|
return *(reinterpret_cast<VxVector4*>(m_Data) + i);
|
||||||
@@ -427,7 +477,7 @@ namespace LibCmo::VxMath {
|
|||||||
bool VxMatrix::operator==(const VxMatrix& rhs) const {
|
bool VxMatrix::operator==(const VxMatrix& rhs) const {
|
||||||
return ((*this)[0] == rhs[0] && (*this)[1] == rhs[1] && (*this)[2] == rhs[2] && (*this)[3] == rhs[3]);
|
return ((*this)[0] == rhs[0] && (*this)[1] == rhs[1] && (*this)[2] == rhs[2] && (*this)[3] == rhs[3]);
|
||||||
}
|
}
|
||||||
auto VxMatrix::operator<=>(const VxMatrix& rhs) const {
|
std::partial_ordering VxMatrix::operator<=>(const VxMatrix& rhs) const {
|
||||||
if (auto cmp = (*this)[0] <=> rhs[0]; cmp != 0) return cmp;
|
if (auto cmp = (*this)[0] <=> rhs[0]; cmp != 0) return cmp;
|
||||||
if (auto cmp = (*this)[1] <=> rhs[1]; cmp != 0) return cmp;
|
if (auto cmp = (*this)[1] <=> rhs[1]; cmp != 0) return cmp;
|
||||||
if (auto cmp = (*this)[2] <=> rhs[2]; cmp != 0) return cmp;
|
if (auto cmp = (*this)[2] <=> rhs[2]; cmp != 0) return cmp;
|
||||||
@@ -505,11 +555,7 @@ namespace LibCmo::VxMath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VxVector3 CrossProduct(const VxVector3& lhs, const VxVector3& rhs) {
|
VxVector3 CrossProduct(const VxVector3& lhs, const VxVector3& rhs) {
|
||||||
return VxVector3(
|
return VxVector3(lhs.y * rhs.z - lhs.z * rhs.y, lhs.z * rhs.x - lhs.x * rhs.z, lhs.x * rhs.y - lhs.y * rhs.x);
|
||||||
lhs.y * rhs.z - lhs.z * rhs.y,
|
|
||||||
lhs.z * rhs.x - lhs.x * rhs.z,
|
|
||||||
lhs.x * rhs.y - lhs.y * rhs.x
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Absolute(VxVector3& lhs) {
|
void Absolute(VxVector3& lhs) {
|
||||||
@@ -518,12 +564,10 @@ namespace LibCmo::VxMath {
|
|||||||
lhs.z = std::fabs(lhs.z);
|
lhs.z = std::fabs(lhs.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace NSVxVector
|
||||||
|
|
||||||
namespace NSVxMatrix {
|
namespace NSVxMatrix {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
}
|
} // namespace LibCmo::VxMath
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
#include "../VTUtils.hpp"
|
#include "../VTUtils.hpp"
|
||||||
#include "../CK2/CKTypes.hpp"
|
#include "../CK2/CKTypes.hpp"
|
||||||
|
#include <yycc/macro/class_copy_move.hpp>
|
||||||
#include "VxEnums.hpp"
|
#include "VxEnums.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
#include <compare>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VxMath part of LibCmo.
|
* @brief The VxMath part of LibCmo.
|
||||||
@@ -16,7 +18,6 @@ namespace LibCmo::VxMath {
|
|||||||
|
|
||||||
// ========== Type Definition ==========
|
// ========== Type Definition ==========
|
||||||
|
|
||||||
|
|
||||||
// ========== Class List ==========
|
// ========== Class List ==========
|
||||||
// Important classes
|
// Important classes
|
||||||
|
|
||||||
@@ -33,11 +34,11 @@ namespace LibCmo::VxMath {
|
|||||||
CKFLOAT x, y;
|
CKFLOAT x, y;
|
||||||
VxVector2();
|
VxVector2();
|
||||||
VxVector2(CKFLOAT _x, CKFLOAT _y);
|
VxVector2(CKFLOAT _x, CKFLOAT _y);
|
||||||
YYCC_DEF_CLS_COPY_MOVE(VxVector2);
|
YYCC_DEFAULT_COPY_MOVE(VxVector2)
|
||||||
CKFLOAT& operator[](size_t i);
|
CKFLOAT& operator[](size_t i);
|
||||||
const CKFLOAT& operator[](size_t i) const;
|
const CKFLOAT& operator[](size_t i) const;
|
||||||
bool operator==(const VxVector2& rhs) const;
|
bool operator==(const VxVector2& rhs) const;
|
||||||
auto operator<=>(const VxVector2& rhs) const;
|
std::partial_ordering operator<=>(const VxVector2& rhs) const;
|
||||||
VxVector2 operator+() const;
|
VxVector2 operator+() const;
|
||||||
VxVector2 operator-() const;
|
VxVector2 operator-() const;
|
||||||
VxVector2& operator+=(const VxVector2& rhs);
|
VxVector2& operator+=(const VxVector2& rhs);
|
||||||
@@ -67,11 +68,11 @@ namespace LibCmo::VxMath {
|
|||||||
CKFLOAT x, y, z;
|
CKFLOAT x, y, z;
|
||||||
VxVector3();
|
VxVector3();
|
||||||
VxVector3(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z);
|
VxVector3(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z);
|
||||||
YYCC_DEF_CLS_COPY_MOVE(VxVector3);
|
YYCC_DEFAULT_COPY_MOVE(VxVector3)
|
||||||
CKFLOAT& operator[](size_t i);
|
CKFLOAT& operator[](size_t i);
|
||||||
const CKFLOAT& operator[](size_t i) const;
|
const CKFLOAT& operator[](size_t i) const;
|
||||||
bool operator==(const VxVector3& rhs) const;
|
bool operator==(const VxVector3& rhs) const;
|
||||||
auto operator<=>(const VxVector3& rhs) const;
|
std::partial_ordering operator<=>(const VxVector3& rhs) const;
|
||||||
VxVector3 operator+() const;
|
VxVector3 operator+() const;
|
||||||
VxVector3 operator-() const;
|
VxVector3 operator-() const;
|
||||||
VxVector3& operator+=(const VxVector3& rhs);
|
VxVector3& operator+=(const VxVector3& rhs);
|
||||||
@@ -105,11 +106,11 @@ namespace LibCmo::VxMath {
|
|||||||
CKFLOAT x, y, z, w;
|
CKFLOAT x, y, z, w;
|
||||||
VxVector4();
|
VxVector4();
|
||||||
VxVector4(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w);
|
VxVector4(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w);
|
||||||
YYCC_DEF_CLS_COPY_MOVE(VxVector4);
|
YYCC_DEFAULT_COPY_MOVE(VxVector4)
|
||||||
CKFLOAT& operator[](size_t i);
|
CKFLOAT& operator[](size_t i);
|
||||||
const CKFLOAT& operator[](size_t i) const;
|
const CKFLOAT& operator[](size_t i) const;
|
||||||
bool operator==(const VxVector4& rhs) const;
|
bool operator==(const VxVector4& rhs) const;
|
||||||
auto operator<=>(const VxVector4& rhs) const;
|
std::partial_ordering operator<=>(const VxVector4& rhs) const;
|
||||||
VxVector4 operator+() const;
|
VxVector4 operator+() const;
|
||||||
VxVector4 operator-() const;
|
VxVector4 operator-() const;
|
||||||
VxVector4& operator+=(const VxVector4& rhs);
|
VxVector4& operator+=(const VxVector4& rhs);
|
||||||
@@ -144,11 +145,11 @@ namespace LibCmo::VxMath {
|
|||||||
CKFLOAT x, y, z, w;
|
CKFLOAT x, y, z, w;
|
||||||
VxQuaternion();
|
VxQuaternion();
|
||||||
VxQuaternion(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w);
|
VxQuaternion(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w);
|
||||||
YYCC_DEF_CLS_COPY_MOVE(VxQuaternion);
|
YYCC_DEFAULT_COPY_MOVE(VxQuaternion)
|
||||||
CKFLOAT& operator[](size_t i);
|
CKFLOAT& operator[](size_t i);
|
||||||
const CKFLOAT& operator[](size_t i) const;
|
const CKFLOAT& operator[](size_t i) const;
|
||||||
bool operator==(const VxQuaternion& rhs) const;
|
bool operator==(const VxQuaternion& rhs) const;
|
||||||
auto operator<=>(const VxQuaternion& rhs) const;
|
std::partial_ordering operator<=>(const VxQuaternion& rhs) const;
|
||||||
|
|
||||||
/* ===== BEGIN USER CUSTOM ===== */
|
/* ===== BEGIN USER CUSTOM ===== */
|
||||||
/* ===== END USER CUSTOM ===== */
|
/* ===== END USER CUSTOM ===== */
|
||||||
@@ -166,11 +167,11 @@ namespace LibCmo::VxMath {
|
|||||||
CKFLOAT r, g, b, a;
|
CKFLOAT r, g, b, a;
|
||||||
VxColor();
|
VxColor();
|
||||||
VxColor(CKFLOAT _r, CKFLOAT _g, CKFLOAT _b, CKFLOAT _a);
|
VxColor(CKFLOAT _r, CKFLOAT _g, CKFLOAT _b, CKFLOAT _a);
|
||||||
YYCC_DEF_CLS_COPY_MOVE(VxColor);
|
YYCC_DEFAULT_COPY_MOVE(VxColor)
|
||||||
CKFLOAT& operator[](size_t i);
|
CKFLOAT& operator[](size_t i);
|
||||||
const CKFLOAT& operator[](size_t i) const;
|
const CKFLOAT& operator[](size_t i) const;
|
||||||
bool operator==(const VxColor& rhs) const;
|
bool operator==(const VxColor& rhs) const;
|
||||||
auto operator<=>(const VxColor& rhs) const;
|
std::partial_ordering operator<=>(const VxColor& rhs) const;
|
||||||
|
|
||||||
/* ===== BEGIN USER CUSTOM ===== */
|
/* ===== BEGIN USER CUSTOM ===== */
|
||||||
VxColor(CKDWORD argb);
|
VxColor(CKDWORD argb);
|
||||||
@@ -190,14 +191,15 @@ namespace LibCmo::VxMath {
|
|||||||
struct VxMatrix {
|
struct VxMatrix {
|
||||||
private:
|
private:
|
||||||
CKFLOAT m_Data[4][4];
|
CKFLOAT m_Data[4][4];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VxMatrix();
|
VxMatrix();
|
||||||
VxMatrix(CKFLOAT m[4][4]);
|
VxMatrix(CKFLOAT m[4][4]);
|
||||||
YYCC_DEF_CLS_COPY_MOVE(VxMatrix);
|
YYCC_DEFAULT_COPY_MOVE(VxMatrix)
|
||||||
VxVector4& operator[](size_t i);
|
VxVector4& operator[](size_t i);
|
||||||
const VxVector4& operator[](size_t i) const;
|
const VxVector4& operator[](size_t i) const;
|
||||||
bool operator==(const VxMatrix& rhs) const;
|
bool operator==(const VxMatrix& rhs) const;
|
||||||
auto operator<=>(const VxMatrix& rhs) const;
|
std::partial_ordering operator<=>(const VxMatrix& rhs) const;
|
||||||
|
|
||||||
/* ===== BEGIN USER CUSTOM ===== */
|
/* ===== BEGIN USER CUSTOM ===== */
|
||||||
void Clear();
|
void Clear();
|
||||||
@@ -300,7 +302,8 @@ namespace LibCmo::VxMath {
|
|||||||
* @brief Structure for storage of strided data.
|
* @brief Structure for storage of strided data.
|
||||||
* @tparam _Ty The data pointer type this class stored.
|
* @tparam _Ty The data pointer type this class stored.
|
||||||
*/
|
*/
|
||||||
template<class _Ty, std::enable_if_t<std::is_pointer_v<_Ty>, int> = 0>
|
template<class T>
|
||||||
|
requires std::is_pointer_v<T>
|
||||||
class VxStridedData {
|
class VxStridedData {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -310,9 +313,7 @@ namespace LibCmo::VxMath {
|
|||||||
* If you set stride to the size of underlying type of pointer,
|
* If you set stride to the size of underlying type of pointer,
|
||||||
* this class will degenerate to the visitor of a plain data array.
|
* this class will degenerate to the visitor of a plain data array.
|
||||||
*/
|
*/
|
||||||
VxStridedData(_Ty ptr, CKDWORD stride) :
|
VxStridedData(T ptr, CKDWORD stride) : m_Ptr(reinterpret_cast<CKBYTE*>(ptr)), m_Stride(stride) {}
|
||||||
m_Ptr(reinterpret_cast<CKBYTE*>(ptr)),
|
|
||||||
m_Stride(stride) {}
|
|
||||||
~VxStridedData() {}
|
~VxStridedData() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,9 +321,7 @@ namespace LibCmo::VxMath {
|
|||||||
* @param[in] idx N-th
|
* @param[in] idx N-th
|
||||||
* @return The pointer to n-th data.
|
* @return The pointer to n-th data.
|
||||||
*/
|
*/
|
||||||
_Ty operator[](size_t idx) {
|
T operator[](size_t idx) { return reinterpret_cast<T>(m_Ptr + (m_Stride * idx)); }
|
||||||
return reinterpret_cast<_Ty>(m_Ptr + (m_Stride * idx));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CKBYTE* m_Ptr; /**< The pointer to first data. */
|
CKBYTE* m_Ptr; /**< The pointer to first data. */
|
||||||
@@ -340,32 +339,26 @@ namespace LibCmo::VxMath {
|
|||||||
*/
|
*/
|
||||||
class VxImageDescEx {
|
class VxImageDescEx {
|
||||||
public:
|
public:
|
||||||
static constexpr CKDWORD ColorFactorSize = 1u; /**< Single color factor (one of ARGB) occpied size in byte. */
|
static constexpr CKDWORD FACTOR_SIZE = 1u; /**< Single color factor (one of ARGB) occpied size in byte. */
|
||||||
static constexpr CKDWORD PixelSize = ColorFactorSize * 4u; /**< Single pixel occpied size in byte. */
|
static constexpr CKDWORD PIXEL_SIZE = FACTOR_SIZE * 4u; /**< Single pixel occpied size in byte. */
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a blank (invalid) image.
|
* @brief Create a blank (invalid) image.
|
||||||
*/
|
*/
|
||||||
VxImageDescEx() :
|
VxImageDescEx() : m_Width(0), m_Height(0), m_Image(nullptr) {}
|
||||||
m_Width(0), m_Height(0), m_Image(nullptr) {}
|
|
||||||
/**
|
/**
|
||||||
* @brief Create a image with given width and height.
|
* @brief Create a image with given width and height.
|
||||||
* @param[in] width The width of image.
|
* @param[in] width The width of image.
|
||||||
* @param[in] height The height of image.
|
* @param[in] height The height of image.
|
||||||
*/
|
*/
|
||||||
VxImageDescEx(CKDWORD width, CKDWORD height) :
|
VxImageDescEx(CKDWORD width, CKDWORD height) : m_Width(width), m_Height(height), m_Image(nullptr) { CreateImage(width, height); }
|
||||||
m_Width(width), m_Height(height), m_Image(nullptr) {
|
VxImageDescEx(const VxImageDescEx& rhs) : m_Width(rhs.m_Width), m_Height(rhs.m_Height), m_Image(nullptr) {
|
||||||
CreateImage(width, height);
|
|
||||||
}
|
|
||||||
VxImageDescEx(const VxImageDescEx& rhs) :
|
|
||||||
m_Width(rhs.m_Width), m_Height(rhs.m_Height), m_Image(nullptr) {
|
|
||||||
// copy image
|
// copy image
|
||||||
if (rhs.m_Image != nullptr) {
|
if (rhs.m_Image != nullptr) {
|
||||||
CreateImage(rhs.m_Width, rhs.m_Height, rhs.m_Image);
|
CreateImage(rhs.m_Width, rhs.m_Height, rhs.m_Image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VxImageDescEx(VxImageDescEx&& rhs) :
|
VxImageDescEx(VxImageDescEx&& rhs) noexcept : m_Width(rhs.m_Width), m_Height(rhs.m_Height), m_Image(rhs.m_Image) {
|
||||||
m_Width(rhs.m_Width), m_Height(rhs.m_Height), m_Image(rhs.m_Image) {
|
|
||||||
// move image
|
// move image
|
||||||
rhs.m_Height = 0;
|
rhs.m_Height = 0;
|
||||||
rhs.m_Width = 0;
|
rhs.m_Width = 0;
|
||||||
@@ -382,7 +375,7 @@ namespace LibCmo::VxMath {
|
|||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
VxImageDescEx& operator=(VxImageDescEx&& rhs) {
|
VxImageDescEx& operator=(VxImageDescEx&& rhs) noexcept {
|
||||||
FreeImage();
|
FreeImage();
|
||||||
|
|
||||||
m_Height = rhs.m_Height;
|
m_Height = rhs.m_Height;
|
||||||
@@ -394,9 +387,7 @@ namespace LibCmo::VxMath {
|
|||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
~VxImageDescEx() {
|
~VxImageDescEx() { FreeImage(); }
|
||||||
FreeImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create image with given width and height
|
* @brief Create image with given width and height
|
||||||
@@ -443,45 +434,33 @@ namespace LibCmo::VxMath {
|
|||||||
* @return The allocated memory size of image.
|
* @return The allocated memory size of image.
|
||||||
* Basically it is image width * height * (single pixel size).
|
* Basically it is image width * height * (single pixel size).
|
||||||
*/
|
*/
|
||||||
CKDWORD GetImageSize() const {
|
CKDWORD GetImageSize() const { return static_cast<CKDWORD>(PIXEL_SIZE * m_Width * m_Height); }
|
||||||
return static_cast<CKDWORD>(PixelSize * m_Width * m_Height);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a constant pointer to image in memory unit for viewing.
|
* @brief Get a constant pointer to image in memory unit for viewing.
|
||||||
* @return A constant pointer to image in memory unit.
|
* @return A constant pointer to image in memory unit.
|
||||||
*/
|
*/
|
||||||
const CKBYTE* GetImage() const {
|
const CKBYTE* GetImage() const { return m_Image; }
|
||||||
return m_Image;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a mutable pointer to image in memory unit for modifying.
|
* @brief Get a mutable pointer to image in memory unit for modifying.
|
||||||
* @return A mutable pointer to image in memory uint.
|
* @return A mutable pointer to image in memory uint.
|
||||||
*/
|
*/
|
||||||
CKBYTE* GetMutableImage() {
|
CKBYTE* GetMutableImage() { return m_Image; }
|
||||||
return m_Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the full count of pixel in image.
|
* @brief Get the full count of pixel in image.
|
||||||
* @return The count of image. Basically it is image width * height.
|
* @return The count of image. Basically it is image width * height.
|
||||||
*/
|
*/
|
||||||
CKDWORD GetPixelCount() const {
|
CKDWORD GetPixelCount() const { return static_cast<CKDWORD>(m_Width * m_Height); }
|
||||||
return static_cast<CKDWORD>(m_Width * m_Height);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a constant pointer to image in pixel unit for viewing.
|
* @brief Get a constant pointer to image in pixel unit for viewing.
|
||||||
* @return A constant pointer to image in pixel unit.
|
* @return A constant pointer to image in pixel unit.
|
||||||
*/
|
*/
|
||||||
const CKDWORD* GetPixels() const {
|
const CKDWORD* GetPixels() const { return reinterpret_cast<CKDWORD*>(m_Image); }
|
||||||
return reinterpret_cast<CKDWORD*>(m_Image);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a mutable pointer to image in pixel uint for modifying.
|
* @brief Get a mutable pointer to image in pixel uint for modifying.
|
||||||
* @return A mutable pointer to image in pixel uint.
|
* @return A mutable pointer to image in pixel uint.
|
||||||
*/
|
*/
|
||||||
CKDWORD* GetMutablePixels() {
|
CKDWORD* GetMutablePixels() { return reinterpret_cast<CKDWORD*>(m_Image); }
|
||||||
return reinterpret_cast<CKDWORD*>(m_Image);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the width of this image in pixel.
|
* @brief Get the width of this image in pixel.
|
||||||
@@ -499,17 +478,13 @@ namespace LibCmo::VxMath {
|
|||||||
* @details If one of width and height is zero, or underlying image pointer, this image is invalid.
|
* @details If one of width and height is zero, or underlying image pointer, this image is invalid.
|
||||||
* @return True if it is, otherwise false.
|
* @return True if it is, otherwise false.
|
||||||
*/
|
*/
|
||||||
bool IsValid() const {
|
bool IsValid() const { return (m_Width != 0u && m_Height != 0u && m_Image != nullptr); }
|
||||||
return (m_Width != 0u && m_Height != 0u && m_Image != nullptr);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Check whether the width and height of this image are equal to another image.
|
* @brief Check whether the width and height of this image are equal to another image.
|
||||||
* @param[in] rhs Another image for comparing.
|
* @param[in] rhs Another image for comparing.
|
||||||
* @return True if their width and height are equal, otherwise false.
|
* @return True if their width and height are equal, otherwise false.
|
||||||
*/
|
*/
|
||||||
bool IsHWEqual(const VxImageDescEx& rhs) const {
|
bool IsHWEqual(const VxImageDescEx& rhs) const { return (m_Width == rhs.m_Width && m_Height == rhs.m_Height); }
|
||||||
return (m_Width == rhs.m_Width && m_Height == rhs.m_Height);
|
|
||||||
}
|
|
||||||
// bool IsMaskEqual(const VxImageDescEx& rhs) const {
|
// bool IsMaskEqual(const VxImageDescEx& rhs) const {
|
||||||
// return (
|
// return (
|
||||||
// m_RedMask == rhs.m_RedMask &&
|
// m_RedMask == rhs.m_RedMask &&
|
||||||
@@ -579,7 +554,7 @@ namespace LibCmo::VxMath {
|
|||||||
*/
|
*/
|
||||||
void Absolute(VxVector3& lhs);
|
void Absolute(VxVector3& lhs);
|
||||||
|
|
||||||
}
|
} // namespace NSVxVector
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The patch namespace for VxMatrix classes
|
* @brief The patch namespace for VxMatrix classes
|
||||||
@@ -620,7 +595,6 @@ namespace LibCmo::VxMath {
|
|||||||
|
|
||||||
//void VxInverseProject(const VxMatrix& iProjection, const Vx2DVector& i2D, const float iZ, VxVector* o3D);
|
//void VxInverseProject(const VxMatrix& iProjection, const Vx2DVector& i2D, const float iZ, VxVector* o3D);
|
||||||
|
|
||||||
|
} // namespace NSVxMatrix
|
||||||
|
|
||||||
}
|
} // namespace LibCmo::VxMath
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user