fix: update YYCC dependency
- move EnumsHelper into YYCC because it is widely used. - rename all calling to EnumsHelper due to this modification. - add version checker in code to make sure that user use correct YYCC library to compile. - modify some include syntax because the include directory layout changes of YYCC. - update CMake script to resolve the bug that we can not export LibCmo (thanks doyaGu and BLumia).
This commit is contained in:
parent
73f1a1f829
commit
e72102496b
|
@ -18,8 +18,6 @@ FILES
|
||||||
target_include_directories(BMap
|
target_include_directories(BMap
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${CMAKE_CURRENT_LIST_DIR}"
|
"${CMAKE_CURRENT_LIST_DIR}"
|
||||||
YYCC::YYCCommonplace
|
|
||||||
LibCmo
|
|
||||||
)
|
)
|
||||||
# Setup linked library infomation
|
# Setup linked library infomation
|
||||||
target_link_libraries(BMap
|
target_link_libraries(BMap
|
||||||
|
@ -52,6 +50,6 @@ PRIVATE
|
||||||
|
|
||||||
# Install BMap only on Release mode
|
# Install BMap only on Release mode
|
||||||
install(TARGETS BMap
|
install(TARGETS BMap
|
||||||
CONFIGURATIONS Release
|
CONFIGURATIONS Release RelWithDebInfo MinSizeRel
|
||||||
RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH}
|
RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH}
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,6 +6,10 @@ endif()
|
||||||
|
|
||||||
# Find YYCC library
|
# Find YYCC library
|
||||||
# It will produce YYCC::YYCCommonplace target for including and linking.
|
# It will produce YYCC::YYCCommonplace target for including and linking.
|
||||||
find_package(YYCCommonplace REQUIRED
|
#
|
||||||
HINTS ${YYCC_PATH} NO_DEFAULT_PATH
|
# Please note we MUST set CMake variable YYCCommonplace_ROOT to make sure CMake can found YYCC in out given path.
|
||||||
)
|
# The cache status of YYCCommonplace_ROOT is doesn't matter.
|
||||||
|
# CMake will throw error if we use HINTS feature in find_package to find YYCC.
|
||||||
|
set(YYCCommonplace_ROOT ${YYCC_PATH} CACHE PATH
|
||||||
|
"The path to YYCC CMake distribution installation path.")
|
||||||
|
find_package(YYCCommonplace REQUIRED)
|
||||||
|
|
|
@ -14,5 +14,6 @@ add_custom_target (NeMoDocuments
|
||||||
|
|
||||||
# Install built documentation
|
# Install built documentation
|
||||||
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||||
|
CONFIGURATIONS Release RelWithDebInfo MinSizeRel
|
||||||
DESTINATION ${NEMO_INSTALL_DOC_PATH}
|
DESTINATION ${NEMO_INSTALL_DOC_PATH}
|
||||||
)
|
)
|
||||||
|
|
|
@ -521,7 +521,7 @@ namespace LibCmo::CK2 {
|
||||||
m_Slots.resize(count);
|
m_Slots.resize(count);
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
EnumsHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_INVALID);
|
YYCC::EnumHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_INVALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,8 +535,8 @@ namespace LibCmo::CK2 {
|
||||||
m_CurrentSlot = slot;
|
m_CurrentSlot = slot;
|
||||||
|
|
||||||
// NOTE: idk what the fuck this is. just interpter the IDA decompiled code.
|
// NOTE: idk what the fuck this is. just interpter the IDA decompiled code.
|
||||||
if (EnumsHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP)) {
|
if (YYCC::EnumHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP)) {
|
||||||
EnumsHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_FORCERESTORE);
|
YYCC::EnumHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_FORCERESTORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,14 +660,14 @@ namespace LibCmo::CK2 {
|
||||||
// but we decide split the flag settings and slot.
|
// but we decide split the flag settings and slot.
|
||||||
// User should set slot count manually.
|
// User should set slot count manually.
|
||||||
if (is_cube) {
|
if (is_cube) {
|
||||||
EnumsHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP);
|
YYCC::EnumHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP);
|
YYCC::EnumHelper::Remove(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKBitmapData::IsCubeMap() const {
|
bool CKBitmapData::IsCubeMap() const {
|
||||||
return EnumsHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP);
|
return YYCC::EnumHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CKBitmapProperties& CKBitmapData::GetSaveFormat() const {
|
const CKBitmapProperties& CKBitmapData::GetSaveFormat() const {
|
||||||
|
@ -688,14 +688,14 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
void CKBitmapData::SetTransparent(bool Transparency) {
|
void CKBitmapData::SetTransparent(bool Transparency) {
|
||||||
if (Transparency) {
|
if (Transparency) {
|
||||||
EnumsHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT);
|
YYCC::EnumHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT);
|
YYCC::EnumHelper::Remove(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKBitmapData::IsTransparent() const {
|
bool CKBitmapData::IsTransparent() const {
|
||||||
return EnumsHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT);
|
return YYCC::EnumHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKBitmapData::SetTransparentColor(CKDWORD col) {
|
void CKBitmapData::SetTransparentColor(CKDWORD col) {
|
||||||
|
|
|
@ -205,8 +205,8 @@ namespace LibCmo::CK2 {
|
||||||
std::string name_conv;
|
std::string name_conv;
|
||||||
|
|
||||||
// ========== compress feature process ==========
|
// ========== compress feature process ==========
|
||||||
if (EnumsHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) ||
|
if (YYCC::EnumHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) ||
|
||||||
EnumsHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) {
|
YYCC::EnumHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) {
|
||||||
|
|
||||||
void* decomp_buffer = CKUnPackData(this->m_FileInfo.DataUnPackSize, parser->GetPtr(), this->m_FileInfo.DataPackSize);
|
void* decomp_buffer = CKUnPackData(this->m_FileInfo.DataUnPackSize, parser->GetPtr(), this->m_FileInfo.DataPackSize);
|
||||||
if (decomp_buffer != nullptr) {
|
if (decomp_buffer != nullptr) {
|
||||||
|
|
|
@ -216,8 +216,8 @@ namespace LibCmo::CK2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// compress header if needed
|
// compress header if needed
|
||||||
if (EnumsHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) ||
|
if (YYCC::EnumHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) ||
|
||||||
EnumsHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) {
|
YYCC::EnumHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) {
|
||||||
|
|
||||||
CKDWORD comp_buf_size = 0;
|
CKDWORD comp_buf_size = 0;
|
||||||
void* comp_buffer = CKPackData(hdrparser->GetBase(), hdrparser->GetSize(), comp_buf_size, m_Ctx->GetCompressionLevel());
|
void* comp_buffer = CKPackData(hdrparser->GetBase(), hdrparser->GetSize(), comp_buf_size, m_Ctx->GetCompressionLevel());
|
||||||
|
@ -263,8 +263,8 @@ namespace LibCmo::CK2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// compress header if needed
|
// compress header if needed
|
||||||
if (EnumsHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) ||
|
if (YYCC::EnumHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) ||
|
||||||
EnumsHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) {
|
YYCC::EnumHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) {
|
||||||
|
|
||||||
CKDWORD comp_buf_size = 0;
|
CKDWORD comp_buf_size = 0;
|
||||||
void* comp_buffer = CKPackData(datparser->GetBase(), datparser->GetSize(), comp_buf_size, m_Ctx->GetCompressionLevel());
|
void* comp_buffer = CKPackData(datparser->GetBase(), datparser->GetSize(), comp_buf_size, m_Ctx->GetCompressionLevel());
|
||||||
|
|
|
@ -419,23 +419,23 @@ namespace LibCmo::CK2 {
|
||||||
std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize);
|
std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize);
|
||||||
bufpos += this->m_DataDwSize;
|
bufpos += this->m_DataDwSize;
|
||||||
}
|
}
|
||||||
if (!EnumsHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE)) {
|
if (!YYCC::EnumHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE)) {
|
||||||
// forced no bind file
|
// forced no bind file
|
||||||
this->m_BindFile = nullptr;
|
this->m_BindFile = nullptr;
|
||||||
}
|
}
|
||||||
if (EnumsHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS)) {
|
if (YYCC::EnumHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS)) {
|
||||||
this->m_ObjectList.resize(dwbuf[bufpos]);
|
this->m_ObjectList.resize(dwbuf[bufpos]);
|
||||||
bufpos += 1u;
|
bufpos += 1u;
|
||||||
std::memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size());
|
std::memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size());
|
||||||
bufpos += this->m_ObjectList.size();
|
bufpos += this->m_ObjectList.size();
|
||||||
}
|
}
|
||||||
if (EnumsHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN)) {
|
if (YYCC::EnumHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN)) {
|
||||||
this->m_ChunkList.resize(dwbuf[bufpos]);
|
this->m_ChunkList.resize(dwbuf[bufpos]);
|
||||||
bufpos += 1u;
|
bufpos += 1u;
|
||||||
std::memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size());
|
std::memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size());
|
||||||
bufpos += this->m_ChunkList.size();
|
bufpos += this->m_ChunkList.size();
|
||||||
}
|
}
|
||||||
if (EnumsHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN)) {
|
if (YYCC::EnumHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN)) {
|
||||||
this->m_ManagerList.resize(dwbuf[bufpos]);
|
this->m_ManagerList.resize(dwbuf[bufpos]);
|
||||||
bufpos += 1u;
|
bufpos += 1u;
|
||||||
std::memcpy(this->m_ManagerList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ManagerList.size());
|
std::memcpy(this->m_ManagerList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ManagerList.size());
|
||||||
|
@ -459,19 +459,19 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
if (!m_ObjectList.empty()) {
|
if (!m_ObjectList.empty()) {
|
||||||
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ObjectList.size()) + sizeof(CKDWORD);
|
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ObjectList.size()) + sizeof(CKDWORD);
|
||||||
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS);
|
YYCC::EnumHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS);
|
||||||
}
|
}
|
||||||
if (!m_ChunkList.empty()) {
|
if (!m_ChunkList.empty()) {
|
||||||
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ChunkList.size()) + sizeof(CKDWORD);
|
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ChunkList.size()) + sizeof(CKDWORD);
|
||||||
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN);
|
YYCC::EnumHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN);
|
||||||
}
|
}
|
||||||
if (!m_ManagerList.empty()) {
|
if (!m_ManagerList.empty()) {
|
||||||
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ManagerList.size()) + sizeof(CKDWORD);
|
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ManagerList.size()) + sizeof(CKDWORD);
|
||||||
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN);
|
YYCC::EnumHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->m_BindFile != nullptr) {
|
if (this->m_BindFile != nullptr) {
|
||||||
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE);
|
YYCC::EnumHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if buffer provided, write it
|
// if buffer provided, write it
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace LibCmo::CK2::MgrImpls {
|
||||||
|
|
||||||
// set to be deleted
|
// set to be deleted
|
||||||
CK_OBJECT_FLAGS objflag = obj->GetObjectFlags();
|
CK_OBJECT_FLAGS objflag = obj->GetObjectFlags();
|
||||||
EnumsHelper::Add(objflag, CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED);
|
YYCC::EnumHelper::Add(objflag, CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED);
|
||||||
obj->SetObjectFlags(objflag);
|
obj->SetObjectFlags(objflag);
|
||||||
|
|
||||||
// collect class id
|
// collect class id
|
||||||
|
|
|
@ -9,12 +9,12 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
CKRenderObject(ctx, ckid, name),
|
CKRenderObject(ctx, ckid, name),
|
||||||
m_PotentialMeshes(), m_CurrentMesh(nullptr),
|
m_PotentialMeshes(), m_CurrentMesh(nullptr),
|
||||||
m_WorldMatrix(), m_ZOrder(0),
|
m_WorldMatrix(), m_ZOrder(0),
|
||||||
m_MoveableFlags(EnumsHelper::Merge({
|
m_MoveableFlags(YYCC::EnumHelper::Merge(
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_PICKABLE,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_PICKABLE,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERCHANNELS,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERCHANNELS,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INVERSEWORLDMATVALID
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INVERSEWORLDMATVALID
|
||||||
})),
|
)),
|
||||||
m_3dEntityFlags(static_cast<CK_3DENTITY_FLAGS>(0)) {}
|
m_3dEntityFlags(static_cast<CK_3DENTITY_FLAGS>(0)) {}
|
||||||
|
|
||||||
CK3dEntity::~CK3dEntity() {}
|
CK3dEntity::~CK3dEntity() {}
|
||||||
|
@ -53,15 +53,15 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
// regulate self flag again
|
// regulate self flag again
|
||||||
// MARK: originally we should check parent here.
|
// MARK: originally we should check parent here.
|
||||||
// but we do not support parent and hierarchy feature, so we simply remove flag
|
// but we do not support parent and hierarchy feature, so we simply remove flag
|
||||||
EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID);
|
YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID);
|
||||||
// MARK: originally we should check grouped into CKPlace here.
|
// MARK: originally we should check grouped into CKPlace here.
|
||||||
// but we do not support CKPlace, so we simply remove this flag
|
// but we do not support CKPlace, so we simply remove this flag
|
||||||
EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID);
|
YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID);
|
||||||
// check z-order, if not zero, save it
|
// check z-order, if not zero, save it
|
||||||
if (m_ZOrder != 0) {
|
if (m_ZOrder != 0) {
|
||||||
EnumsHelper::Add(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID);
|
YYCC::EnumHelper::Add(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID);
|
YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write 2 flags
|
// write 2 flags
|
||||||
|
@ -94,7 +94,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
if (!suc) return false;
|
if (!suc) return false;
|
||||||
|
|
||||||
// backup moveable flags
|
// backup moveable flags
|
||||||
bool hasWorldAligned = EnumsHelper::Has(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED);
|
bool hasWorldAligned = YYCC::EnumHelper::Has(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED);
|
||||||
|
|
||||||
// MARK: object animation is skipped
|
// MARK: object animation is skipped
|
||||||
|
|
||||||
|
@ -132,11 +132,11 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
chunk->ReadStruct(m_3dEntityFlags);
|
chunk->ReadStruct(m_3dEntityFlags);
|
||||||
chunk->ReadStruct(m_MoveableFlags);
|
chunk->ReadStruct(m_MoveableFlags);
|
||||||
// remove some properties
|
// remove some properties
|
||||||
EnumsHelper::Rm(m_3dEntityFlags, EnumsHelper::Merge({
|
YYCC::EnumHelper::Remove(m_3dEntityFlags,
|
||||||
CK_3DENTITY_FLAGS::CK_3DENTITY_UPDATELASTFRAME,
|
CK_3DENTITY_FLAGS::CK_3DENTITY_UPDATELASTFRAME,
|
||||||
CK_3DENTITY_FLAGS::CK_3DENTITY_RESERVED0
|
CK_3DENTITY_FLAGS::CK_3DENTITY_RESERVED0
|
||||||
}));
|
);
|
||||||
EnumsHelper::Rm(m_MoveableFlags, EnumsHelper::Merge({
|
YYCC::EnumHelper::Remove(m_MoveableFlags,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RESERVED2,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RESERVED2,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_STENCILONLY,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_STENCILONLY,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_DONTUPDATEFROMPARENT,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_DONTUPDATEFROMPARENT,
|
||||||
|
@ -145,13 +145,13 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_BOXVALID,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_BOXVALID,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_USERBOX,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_USERBOX,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_UPTODATE
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_UPTODATE
|
||||||
}));
|
);
|
||||||
if (hasWorldAligned) {
|
if (hasWorldAligned) {
|
||||||
EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED);
|
YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if order render first
|
// if order render first
|
||||||
if (EnumsHelper::Has(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERFIRST)) {
|
if (YYCC::EnumHelper::Has(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERFIRST)) {
|
||||||
m_ZOrder = 10000;
|
m_ZOrder = 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,47 +171,47 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
VxMath::VxVector3 crossProduct = VxMath::NSVxVector::CrossProduct(col0, col1);
|
VxMath::VxVector3 crossProduct = VxMath::NSVxVector::CrossProduct(col0, col1);
|
||||||
CKFLOAT dotProduct = VxMath::NSVxVector::DotProduct(crossProduct, col2);
|
CKFLOAT dotProduct = VxMath::NSVxVector::DotProduct(crossProduct, col2);
|
||||||
if (dotProduct >= 0.0f) {
|
if (dotProduct >= 0.0f) {
|
||||||
EnumsHelper::Rm(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX);
|
YYCC::EnumHelper::Remove(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX);
|
YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy visible data
|
// copy visible data
|
||||||
// process direct visible
|
// process direct visible
|
||||||
if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) {
|
if (YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) {
|
||||||
EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE);
|
YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE);
|
YYCC::EnumHelper::Remove(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE);
|
||||||
}
|
}
|
||||||
// process indirect visible
|
// process indirect visible
|
||||||
if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) {
|
if (YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) {
|
||||||
EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE);
|
YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE);
|
YYCC::EnumHelper::Remove(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read associated CKPlace
|
// read associated CKPlace
|
||||||
if (EnumsHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID)) {
|
if (YYCC::EnumHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID)) {
|
||||||
// MARK: we drop the support of CKPlace.
|
// MARK: we drop the support of CKPlace.
|
||||||
// so we just read it and skip it.
|
// so we just read it and skip it.
|
||||||
CK_ID placeid;
|
CK_ID placeid;
|
||||||
chunk->ReadObjectID(placeid);
|
chunk->ReadObjectID(placeid);
|
||||||
// and remove this flag
|
// and remove this flag
|
||||||
EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID);
|
YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read parent
|
// read parent
|
||||||
if (EnumsHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID)) {
|
if (YYCC::EnumHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID)) {
|
||||||
// MAKR: we drop the support of parent and the whole 3dentity hierarchy system
|
// MAKR: we drop the support of parent and the whole 3dentity hierarchy system
|
||||||
// we ignore this field.
|
// we ignore this field.
|
||||||
CK_ID parentid;
|
CK_ID parentid;
|
||||||
chunk->ReadObjectID(parentid);
|
chunk->ReadObjectID(parentid);
|
||||||
// and remove this flag
|
// and remove this flag
|
||||||
EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID);
|
YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read priority (non-zero zorder)
|
// read priority (non-zero zorder)
|
||||||
if (EnumsHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID)) {
|
if (YYCC::EnumHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID)) {
|
||||||
chunk->ReadStruct(m_ZOrder);
|
chunk->ReadStruct(m_ZOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,16 +227,16 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
void CK3dEntity::Show(CK_OBJECT_SHOWOPTION show) {
|
void CK3dEntity::Show(CK_OBJECT_SHOWOPTION show) {
|
||||||
CKObject::Show(show);
|
CKObject::Show(show);
|
||||||
|
|
||||||
EnumsHelper::Rm(m_MoveableFlags, EnumsHelper::Merge({
|
YYCC::EnumHelper::Remove(m_MoveableFlags,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE,
|
||||||
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE,
|
VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE
|
||||||
}));
|
);
|
||||||
switch (show) {
|
switch (show) {
|
||||||
case CK_OBJECT_SHOWOPTION::CKSHOW:
|
case CK_OBJECT_SHOWOPTION::CKSHOW:
|
||||||
EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE);
|
YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE);
|
||||||
break;
|
break;
|
||||||
case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE:
|
case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE:
|
||||||
EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE);
|
YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE);
|
||||||
break;
|
break;
|
||||||
case CK_OBJECT_SHOWOPTION::CKHIDE:
|
case CK_OBJECT_SHOWOPTION::CKHIDE:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -21,12 +21,12 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
m_LineCount(0),
|
m_LineCount(0),
|
||||||
m_LineIndices(),
|
m_LineIndices(),
|
||||||
// init flags
|
// init flags
|
||||||
m_Flags(EnumsHelper::Merge({
|
m_Flags(YYCC::EnumHelper::Merge(
|
||||||
VxMath::VXMESH_FLAGS::VXMESH_VISIBLE,
|
VxMath::VXMESH_FLAGS::VXMESH_VISIBLE,
|
||||||
VxMath::VXMESH_FLAGS::VXMESH_RENDERCHANNELS
|
VxMath::VXMESH_FLAGS::VXMESH_RENDERCHANNELS
|
||||||
})) {
|
)) {
|
||||||
// set visible in default
|
// set visible in default
|
||||||
EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
YYCC::EnumHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
CKMesh::~CKMesh() {}
|
CKMesh::~CKMesh() {}
|
||||||
|
@ -145,7 +145,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
rawbuf += CKSizeof(CKDWORD);
|
rawbuf += CKSizeof(CKDWORD);
|
||||||
|
|
||||||
// write vertex position
|
// write vertex position
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::NoPos)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoPos)) {
|
||||||
CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vtxCount;
|
CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vtxCount;
|
||||||
std::memcpy(rawbuf, m_VertexPosition.data(), consumed);
|
std::memcpy(rawbuf, m_VertexPosition.data(), consumed);
|
||||||
rawbuf += consumed;
|
rawbuf += consumed;
|
||||||
|
@ -154,7 +154,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
// write color and specular color
|
// write color and specular color
|
||||||
{
|
{
|
||||||
CKDWORD consumed = 0;
|
CKDWORD consumed = 0;
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleColor)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleColor)) {
|
||||||
consumed = CKSizeof(CKDWORD) * vtxCount;
|
consumed = CKSizeof(CKDWORD) * vtxCount;
|
||||||
} else {
|
} else {
|
||||||
consumed = CKSizeof(CKDWORD);
|
consumed = CKSizeof(CKDWORD);
|
||||||
|
@ -165,7 +165,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CKDWORD consumed = 0;
|
CKDWORD consumed = 0;
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleSpecularColor)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleSpecularColor)) {
|
||||||
consumed = CKSizeof(CKDWORD) * vtxCount;
|
consumed = CKSizeof(CKDWORD) * vtxCount;
|
||||||
} else {
|
} else {
|
||||||
consumed = CKSizeof(CKDWORD);
|
consumed = CKSizeof(CKDWORD);
|
||||||
|
@ -176,7 +176,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write normal
|
// write normal
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::NoNormal)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoNormal)) {
|
||||||
CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vtxCount;
|
CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vtxCount;
|
||||||
std::memcpy(rawbuf, m_VertexNormal.data(), consumed);
|
std::memcpy(rawbuf, m_VertexNormal.data(), consumed);
|
||||||
rawbuf += consumed;
|
rawbuf += consumed;
|
||||||
|
@ -185,7 +185,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
// write uv
|
// write uv
|
||||||
{
|
{
|
||||||
CKDWORD consumed = 0;
|
CKDWORD consumed = 0;
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleUV)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleUV)) {
|
||||||
consumed = CKSizeof(VxMath::VxVector2) * vtxCount;
|
consumed = CKSizeof(VxMath::VxVector2) * vtxCount;
|
||||||
} else {
|
} else {
|
||||||
consumed = CKSizeof(VxMath::VxVector2);
|
consumed = CKSizeof(VxMath::VxVector2);
|
||||||
|
@ -229,13 +229,13 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
// read flag
|
// read flag
|
||||||
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_MESH::CK_STATESAVE_MESHFLAGS)) {
|
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_MESH::CK_STATESAVE_MESHFLAGS)) {
|
||||||
chunk->ReadStruct(m_Flags);
|
chunk->ReadStruct(m_Flags);
|
||||||
EnumsHelper::Mask(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_ALLFLAGS);
|
YYCC::EnumHelper::Mask(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_ALLFLAGS);
|
||||||
|
|
||||||
// I don't know why, just interpter the IDA code.
|
// I don't know why, just interpter the IDA code.
|
||||||
EnumsHelper::Rm(m_Flags, EnumsHelper::Merge({
|
YYCC::EnumHelper::Remove(m_Flags,
|
||||||
VxMath::VXMESH_FLAGS::VXMESH_BOUNDINGUPTODATE,
|
VxMath::VXMESH_FLAGS::VXMESH_BOUNDINGUPTODATE,
|
||||||
VxMath::VXMESH_FLAGS::VXMESH_OPTIMIZED
|
VxMath::VXMESH_FLAGS::VXMESH_OPTIMIZED
|
||||||
}));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read material slots
|
// read material slots
|
||||||
|
@ -285,14 +285,14 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
const CKBYTE* rawbuf = static_cast<const CKBYTE*>(buf.get());
|
const CKBYTE* rawbuf = static_cast<const CKBYTE*>(buf.get());
|
||||||
|
|
||||||
// copy position if it have
|
// copy position if it have
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::NoPos)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoPos)) {
|
||||||
CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vertexCount;
|
CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vertexCount;
|
||||||
std::memcpy(m_VertexPosition.data(), rawbuf, consumed);
|
std::memcpy(m_VertexPosition.data(), rawbuf, consumed);
|
||||||
rawbuf += consumed;
|
rawbuf += consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy color or apply single color
|
// copy color or apply single color
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleColor)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleColor)) {
|
||||||
CKDWORD consumed = CKSizeof(CKDWORD) * vertexCount;
|
CKDWORD consumed = CKSizeof(CKDWORD) * vertexCount;
|
||||||
std::memcpy(m_VertexColor.data(), rawbuf, consumed);
|
std::memcpy(m_VertexColor.data(), rawbuf, consumed);
|
||||||
rawbuf += consumed;
|
rawbuf += consumed;
|
||||||
|
@ -309,7 +309,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy specular color or apply a single color
|
// copy specular color or apply a single color
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleSpecularColor)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleSpecularColor)) {
|
||||||
CKDWORD consumed = CKSizeof(CKDWORD) * vertexCount;
|
CKDWORD consumed = CKSizeof(CKDWORD) * vertexCount;
|
||||||
std::memcpy(m_VertexSpecularColor.data(), rawbuf, consumed);
|
std::memcpy(m_VertexSpecularColor.data(), rawbuf, consumed);
|
||||||
rawbuf += consumed;
|
rawbuf += consumed;
|
||||||
|
@ -326,14 +326,14 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy normals if it has
|
// copy normals if it has
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::NoNormal)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoNormal)) {
|
||||||
CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vertexCount;
|
CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vertexCount;
|
||||||
std::memcpy(m_VertexNormal.data(), rawbuf, consumed);
|
std::memcpy(m_VertexNormal.data(), rawbuf, consumed);
|
||||||
rawbuf += consumed;
|
rawbuf += consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy uv or apply single uv
|
// copy uv or apply single uv
|
||||||
if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleUV)) {
|
if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleUV)) {
|
||||||
CKDWORD consumed = CKSizeof(VxMath::VxVector2) * vertexCount;
|
CKDWORD consumed = CKSizeof(VxMath::VxVector2) * vertexCount;
|
||||||
std::memcpy(m_VertexUV.data(), rawbuf, consumed);
|
std::memcpy(m_VertexUV.data(), rawbuf, consumed);
|
||||||
rawbuf += consumed;
|
rawbuf += consumed;
|
||||||
|
@ -407,7 +407,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
}
|
}
|
||||||
|
|
||||||
// build normals
|
// build normals
|
||||||
if (EnumsHelper::Has(saveflags, VertexSaveFlags::NoNormal)) {
|
if (YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoNormal)) {
|
||||||
BuildNormals();
|
BuildNormals();
|
||||||
} else {
|
} else {
|
||||||
BuildFaceNormals();
|
BuildFaceNormals();
|
||||||
|
@ -425,9 +425,9 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
CKObject::Show(show);
|
CKObject::Show(show);
|
||||||
|
|
||||||
if (show == CK_OBJECT_SHOWOPTION::CKSHOW) {
|
if (show == CK_OBJECT_SHOWOPTION::CKSHOW) {
|
||||||
EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE);
|
YYCC::EnumHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE);
|
YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,15 +449,15 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
m_Flags = flags;
|
m_Flags = flags;
|
||||||
|
|
||||||
// sync visibility to CKObject layer.
|
// sync visibility to CKObject layer.
|
||||||
if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE)) {
|
if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE)) {
|
||||||
EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
YYCC::EnumHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
YYCC::EnumHelper::Remove(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VxMath::VXMESH_LITMODE CKMesh::GetLitMode() const {
|
VxMath::VXMESH_LITMODE CKMesh::GetLitMode() const {
|
||||||
if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE)) {
|
if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE)) {
|
||||||
return VxMath::VXMESH_LITMODE::VX_PRELITMESH;
|
return VxMath::VXMESH_LITMODE::VX_PRELITMESH;
|
||||||
} else {
|
} else {
|
||||||
return VxMath::VXMESH_LITMODE::VX_LITMESH;
|
return VxMath::VXMESH_LITMODE::VX_LITMESH;
|
||||||
|
@ -467,10 +467,10 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
void CKMesh::SetLitMode(VxMath::VXMESH_LITMODE mode) {
|
void CKMesh::SetLitMode(VxMath::VXMESH_LITMODE mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case VxMath::VXMESH_LITMODE::VX_PRELITMESH:
|
case VxMath::VXMESH_LITMODE::VX_PRELITMESH:
|
||||||
EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE);
|
YYCC::EnumHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE);
|
||||||
break;
|
break;
|
||||||
case VxMath::VXMESH_LITMODE::VX_LITMESH:
|
case VxMath::VXMESH_LITMODE::VX_LITMESH:
|
||||||
EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE);
|
YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -478,51 +478,51 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
VxMath::VXTEXTURE_WRAPMODE CKMesh::GetWrapMode() const {
|
VxMath::VXTEXTURE_WRAPMODE CKMesh::GetWrapMode() const {
|
||||||
VxMath::VXTEXTURE_WRAPMODE ret = VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_NONE;
|
VxMath::VXTEXTURE_WRAPMODE ret = VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_NONE;
|
||||||
|
|
||||||
if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU)) {
|
if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU)) {
|
||||||
EnumsHelper::Add(ret, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U);
|
YYCC::EnumHelper::Add(ret, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U);
|
||||||
}
|
}
|
||||||
if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV)) {
|
if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV)) {
|
||||||
EnumsHelper::Add(ret, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V);
|
YYCC::EnumHelper::Add(ret, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKMesh::SetWrapMode(VxMath::VXTEXTURE_WRAPMODE mode) {
|
void CKMesh::SetWrapMode(VxMath::VXTEXTURE_WRAPMODE mode) {
|
||||||
if (EnumsHelper::Has(mode, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U)) {
|
if (YYCC::EnumHelper::Has(mode, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U)) {
|
||||||
EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU);
|
YYCC::EnumHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU);
|
YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EnumsHelper::Has(mode, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V)) {
|
if (YYCC::EnumHelper::Has(mode, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V)) {
|
||||||
EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV);
|
YYCC::EnumHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV);
|
||||||
} else {
|
} else {
|
||||||
EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV);
|
YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CKMesh::VertexSaveFlags CKMesh::GenerateSaveFlags() {
|
CKMesh::VertexSaveFlags CKMesh::GenerateSaveFlags() {
|
||||||
// set to initial status
|
// set to initial status
|
||||||
VertexSaveFlags saveflags = EnumsHelper::Merge({
|
VertexSaveFlags saveflags = YYCC::EnumHelper::Merge(
|
||||||
VertexSaveFlags::SingleColor,
|
VertexSaveFlags::SingleColor,
|
||||||
VertexSaveFlags::SingleSpecularColor,
|
VertexSaveFlags::SingleSpecularColor,
|
||||||
VertexSaveFlags::NoNormal,
|
VertexSaveFlags::NoNormal,
|
||||||
VertexSaveFlags::SingleUV
|
VertexSaveFlags::SingleUV
|
||||||
});
|
);
|
||||||
|
|
||||||
// check no pos
|
// check no pos
|
||||||
// if position is generated, skip saving position
|
// if position is generated, skip saving position
|
||||||
if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS)) {
|
if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS)) {
|
||||||
EnumsHelper::Add(saveflags, VertexSaveFlags::NoPos);
|
YYCC::EnumHelper::Add(saveflags, VertexSaveFlags::NoPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check uv
|
// check uv
|
||||||
// if uv is not generated and all uv are not the same value, remove single uv
|
// if uv is not generated and all uv are not the same value, remove single uv
|
||||||
if (!EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALUV)) {
|
if (!YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALUV)) {
|
||||||
for (const auto& uv : m_VertexUV) {
|
for (const auto& uv : m_VertexUV) {
|
||||||
if (uv != m_VertexUV.front()) {
|
if (uv != m_VertexUV.front()) {
|
||||||
EnumsHelper::Rm(saveflags, VertexSaveFlags::SingleUV);
|
YYCC::EnumHelper::Remove(saveflags, VertexSaveFlags::SingleUV);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,19 +532,19 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
// if all color are not the same value, remove single color
|
// if all color are not the same value, remove single color
|
||||||
for (const auto& col : m_VertexColor) {
|
for (const auto& col : m_VertexColor) {
|
||||||
if (col != m_VertexColor.front()) {
|
if (col != m_VertexColor.front()) {
|
||||||
EnumsHelper::Rm(saveflags, VertexSaveFlags::SingleColor);
|
YYCC::EnumHelper::Remove(saveflags, VertexSaveFlags::SingleColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto& col : m_VertexSpecularColor) {
|
for (const auto& col : m_VertexSpecularColor) {
|
||||||
if (col != m_VertexSpecularColor.front()) {
|
if (col != m_VertexSpecularColor.front()) {
|
||||||
EnumsHelper::Rm(saveflags, VertexSaveFlags::SingleSpecularColor);
|
YYCC::EnumHelper::Remove(saveflags, VertexSaveFlags::SingleSpecularColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if normal not changed, and position is not generated, we should consider whether we need save normal (step into if)
|
// if normal not changed, and position is not generated, we should consider whether we need save normal (step into if)
|
||||||
if (!EnumsHelper::Has(m_Flags, EnumsHelper::Merge({ VxMath::VXMESH_FLAGS::VXMESH_NORMAL_CHANGED, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS }))) {
|
if (!YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_NORMAL_CHANGED, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS)) {
|
||||||
// MARK: we should build face normal first
|
// MARK: we should build face normal first
|
||||||
// then we build vertex normal like BuildNormals.
|
// then we build vertex normal like BuildNormals.
|
||||||
// then, we compare the difference between the generated normals and user specified normals, by simply using operator- (userNml - generatedNml) and abs the result.
|
// then, we compare the difference between the generated normals and user specified normals, by simply using operator- (userNml - generatedNml) and abs the result.
|
||||||
|
@ -581,7 +581,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
accnml /= static_cast<CKFLOAT>(m_VertexCount);
|
accnml /= static_cast<CKFLOAT>(m_VertexCount);
|
||||||
if (accnml.Length() > 0.001f) {
|
if (accnml.Length() > 0.001f) {
|
||||||
// too large difference, we need save normal
|
// too large difference, we need save normal
|
||||||
EnumsHelper::Rm(saveflags, VertexSaveFlags::NoNormal);
|
YYCC::EnumHelper::Remove(saveflags, VertexSaveFlags::NoNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
m_ObjectFlags = flags;
|
m_ObjectFlags = flags;
|
||||||
}
|
}
|
||||||
bool CKObject::IsToBeDeleted() const {
|
bool CKObject::IsToBeDeleted() const {
|
||||||
return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED);
|
return YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED);
|
||||||
}
|
}
|
||||||
CKContext* CKObject::GetCKContext() const {
|
CKContext* CKObject::GetCKContext() const {
|
||||||
return m_Context;
|
return m_Context;
|
||||||
|
@ -51,10 +51,10 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
void CKObject::PreSave(CKFileVisitor* file, CKDWORD flags) {}
|
void CKObject::PreSave(CKFileVisitor* file, CKDWORD flags) {}
|
||||||
|
|
||||||
bool CKObject::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) {
|
bool CKObject::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) {
|
||||||
if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) {
|
if (YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) {
|
||||||
// if hierarchy hidden
|
// if hierarchy hidden
|
||||||
chunk->WriteIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIERAHIDDEN);
|
chunk->WriteIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIERAHIDDEN);
|
||||||
} else if (!EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) {
|
} else if (!YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) {
|
||||||
// if really hidden
|
// if really hidden
|
||||||
chunk->WriteIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIDDEN);
|
chunk->WriteIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIDDEN);
|
||||||
}
|
}
|
||||||
|
@ -65,18 +65,20 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
|
|
||||||
bool CKObject::Load(CKStateChunk* chunk, CKFileVisitor* file) {
|
bool CKObject::Load(CKStateChunk* chunk, CKFileVisitor* file) {
|
||||||
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIDDEN)) {
|
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIDDEN)) {
|
||||||
EnumsHelper::Rm(this->m_ObjectFlags,
|
YYCC::EnumHelper::Remove(this->m_ObjectFlags,
|
||||||
EnumsHelper::Merge({ CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE }));
|
CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE,
|
||||||
|
CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIERAHIDDEN)) {
|
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIERAHIDDEN)) {
|
||||||
// != 0
|
// != 0
|
||||||
EnumsHelper::Rm(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
YYCC::EnumHelper::Remove(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||||
EnumsHelper::Add(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE);
|
YYCC::EnumHelper::Add(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// == 0
|
// == 0
|
||||||
EnumsHelper::Add(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
YYCC::EnumHelper::Add(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||||
EnumsHelper::Rm(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE);
|
YYCC::EnumHelper::Remove(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,17 +91,17 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
|
|
||||||
void CKObject::Show(CK_OBJECT_SHOWOPTION show) {
|
void CKObject::Show(CK_OBJECT_SHOWOPTION show) {
|
||||||
// clear all visible data of object flags
|
// clear all visible data of object flags
|
||||||
EnumsHelper::Rm(m_ObjectFlags, EnumsHelper::Merge({
|
YYCC::EnumHelper::Remove(m_ObjectFlags,
|
||||||
CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE,
|
CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE,
|
||||||
CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE
|
CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE
|
||||||
}));
|
);
|
||||||
|
|
||||||
switch (show) {
|
switch (show) {
|
||||||
case CK_OBJECT_SHOWOPTION::CKSHOW:
|
case CK_OBJECT_SHOWOPTION::CKSHOW:
|
||||||
EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
YYCC::EnumHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||||
break;
|
break;
|
||||||
case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE:
|
case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE:
|
||||||
EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE);
|
YYCC::EnumHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE);
|
||||||
break;
|
break;
|
||||||
case CK_OBJECT_SHOWOPTION::CKHIDE:
|
case CK_OBJECT_SHOWOPTION::CKHIDE:
|
||||||
return;
|
return;
|
||||||
|
@ -107,7 +109,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKObject::IsVisible() const {
|
bool CKObject::IsVisible() const {
|
||||||
return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
return YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -86,19 +86,15 @@ target_include_directories(LibCmo
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
PRIVATE
|
|
||||||
YYCC::YYCCommonplace
|
|
||||||
ZLIB::ZLIB
|
|
||||||
stb::stb-image
|
|
||||||
)
|
)
|
||||||
target_link_libraries(LibCmo
|
target_link_libraries(LibCmo
|
||||||
PRIVATE
|
PUBLIC
|
||||||
YYCC::YYCCommonplace
|
YYCC::YYCCommonplace
|
||||||
|
PRIVATE
|
||||||
ZLIB::ZLIB
|
ZLIB::ZLIB
|
||||||
stb::stb-image
|
stb::stb-image
|
||||||
)
|
)
|
||||||
if (NOT WIN32)
|
if (NOT WIN32)
|
||||||
target_include_directories(LibCmo PRIVATE Iconv::Iconv)
|
|
||||||
target_link_libraries(LibCmo PRIVATE Iconv::Iconv)
|
target_link_libraries(LibCmo PRIVATE Iconv::Iconv)
|
||||||
endif ()
|
endif ()
|
||||||
# Setup C++ standard
|
# Setup C++ standard
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||||
#include <WinImportPrefix.hpp>
|
#include <YYCC/WinImportPrefix.hpp>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <fileapi.h>
|
#include <fileapi.h>
|
||||||
#include <WinImportSuffix.hpp>
|
#include <YYCC/WinImportSuffix.hpp>
|
||||||
#else
|
#else
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
#error "You must define ONE of LIBCMO_BUILD_DEBUG and LIBCMO_BUILD_RELEASE to indicate build type!"
|
#error "You must define ONE of LIBCMO_BUILD_DEBUG and LIBCMO_BUILD_RELEASE to indicate build type!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Include YYCC helper library
|
// Include YYCC helper library and check its version
|
||||||
#include <YYCCommonplace.hpp>
|
#include <YYCCommonplace.hpp>
|
||||||
|
#if YYCC_VERCMP_NE(YYCC_VER_MAJOR, YYCC_VER_MINOR, YYCC_VER_PATCH, 1, 3, 0)
|
||||||
|
#error "YYCC library version is not matched with our expected version. Please check your library configuration."
|
||||||
|
#endif
|
||||||
|
|
||||||
// Header for this namespace implementation
|
// Header for this namespace implementation
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
|
||||||
#include <initializer_list>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The core namespace of LibCmo project.
|
* @brief The core namespace of LibCmo project.
|
||||||
|
@ -69,91 +70,4 @@ namespace LibCmo {
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The namespace for convenient C++ enum class logic operations.
|
|
||||||
* @details
|
|
||||||
* C++ enum class statement is a modern way to declare enum in C++.
|
|
||||||
* But it lack essential logic operations which is commonly used by programmer.
|
|
||||||
* So we create this helper to resolve this issue.
|
|
||||||
*/
|
|
||||||
namespace EnumsHelper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Merge given enum flags like performing <TT>e1 | e2 | ... | en</TT>
|
|
||||||
* @tparam TEnum Enum type for processing.
|
|
||||||
* @param[in] il The list of enum flags to be merged.
|
|
||||||
* @return The merged enum flag.
|
|
||||||
*/
|
|
||||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
|
||||||
constexpr TEnum Merge(std::initializer_list<TEnum> il) {
|
|
||||||
using ut = std::underlying_type_t<TEnum>;
|
|
||||||
ut result = 0;
|
|
||||||
for (auto it = il.begin(); it != il.end(); ++it) {
|
|
||||||
result |= static_cast<ut>(*it);
|
|
||||||
}
|
|
||||||
return static_cast<TEnum>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Reverse given enum flags like performing <TT>~(e)</TT>
|
|
||||||
* @tparam TEnum Enum type for processing.
|
|
||||||
* @param[in] e The list of enum flags to be inversed.
|
|
||||||
* @return The inversed enum flag.
|
|
||||||
*/
|
|
||||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
|
||||||
constexpr TEnum Inv(TEnum e) {
|
|
||||||
using ut = std::underlying_type_t<TEnum>;
|
|
||||||
return static_cast<TEnum>(~(static_cast<ut>(e)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Remove specified enum flags from given enum flags like performing <TT>e1 &= (~e2)</TT>
|
|
||||||
* @tparam TEnum Enum type for processing.
|
|
||||||
* @param[in,out] e1 The enum flags to be processed.
|
|
||||||
* @param[in] e2 The enum flag to be removed.
|
|
||||||
*/
|
|
||||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
|
||||||
constexpr void Rm(TEnum& e1, TEnum e2) {
|
|
||||||
using ut = std::underlying_type_t<TEnum>;
|
|
||||||
e1 = static_cast<TEnum>(static_cast<ut>(e1) & static_cast<ut>(Inv(e2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Use specified enum flags to mask given enum flags like performing <TT>e1 &= e2</TT>
|
|
||||||
* @tparam TEnum Enum type for processing.
|
|
||||||
* @param[in,out] e1 The enum flags to be masked.
|
|
||||||
* @param[in] e2 The mask enum flag.
|
|
||||||
*/
|
|
||||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
|
||||||
constexpr void Mask(TEnum& e1, TEnum e2) {
|
|
||||||
using ut = std::underlying_type_t<TEnum>;
|
|
||||||
e1 = static_cast<TEnum>(static_cast<ut>(e1) & static_cast<ut>(e2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Add specified enum flags to given enum flags like performing <TT>e1 |= e2</TT>
|
|
||||||
* @tparam TEnum Enum type for processing.
|
|
||||||
* @param[in,out] e1 The enum flags to be processed.
|
|
||||||
* @param[in] e2 The enum flag to be added.
|
|
||||||
*/
|
|
||||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
|
||||||
constexpr void Add(TEnum& e1, TEnum e2) {
|
|
||||||
using ut = std::underlying_type_t<TEnum>;
|
|
||||||
e1 = static_cast<TEnum>(static_cast<ut>(e1) | static_cast<ut>(e2));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check whether given enum flags has specified enum flag like performing <TT>bool(e & probe)</TT>
|
|
||||||
* @tparam TEnum Enum type for processing.
|
|
||||||
* @param[in] e1 The enum flags to be checked.
|
|
||||||
* @param[in] e2 The enum flag for checking.
|
|
||||||
* @return True if it has, otherwise false.
|
|
||||||
*/
|
|
||||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
|
||||||
constexpr bool Has(TEnum e1, TEnum e2) {
|
|
||||||
using ut = std::underlying_type_t<TEnum>;
|
|
||||||
return static_cast<bool>(static_cast<ut>(e1) & static_cast<ut>(e2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include "../VTInternal.hpp"
|
#include "../VTInternal.hpp"
|
||||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||||
#include <WinImportPrefix.hpp>
|
#include <YYCC/WinImportPrefix.hpp>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <WinImportSuffix.hpp>
|
#include <YYCC/WinImportSuffix.hpp>
|
||||||
#else
|
#else
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Unvirt {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check flag match
|
// check flag match
|
||||||
if (LibCmo::EnumsHelper::Has(val, item.first)) {
|
if (YYCC::EnumHelper::Has(val, item.first)) {
|
||||||
// add splittor if it not the first entry
|
// add splittor if it not the first entry
|
||||||
if (strl.size() != 0u && splitor != nullptr) {
|
if (strl.size() != 0u && splitor != nullptr) {
|
||||||
strl += splitor;
|
strl += splitor;
|
||||||
|
|
|
@ -23,8 +23,6 @@ FILES
|
||||||
target_include_directories(Unvirt
|
target_include_directories(Unvirt
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${CMAKE_CURRENT_LIST_DIR}"
|
"${CMAKE_CURRENT_LIST_DIR}"
|
||||||
YYCC::YYCCommonplace
|
|
||||||
LibCmo
|
|
||||||
)
|
)
|
||||||
# Setup linked library infomation
|
# Setup linked library infomation
|
||||||
target_link_libraries(Unvirt
|
target_link_libraries(Unvirt
|
||||||
|
@ -53,6 +51,6 @@ PRIVATE
|
||||||
|
|
||||||
# Install Unvirt only on Release mode
|
# Install Unvirt only on Release mode
|
||||||
install(TARGETS Unvirt
|
install(TARGETS Unvirt
|
||||||
CONFIGURATIONS Release
|
CONFIGURATIONS Release RelWithDebInfo MinSizeRel
|
||||||
RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH}
|
RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user