create BMap project and copy-paste previous mesh convertion code
This commit is contained in:
parent
f07ff1f246
commit
5671d7d7e6
9
BMap/BMExports.cpp
Normal file
9
BMap/BMExports.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "BMExports.hpp"
|
||||
|
||||
void BMInit() {
|
||||
|
||||
}
|
||||
|
||||
void BMDispose() {
|
||||
|
||||
}
|
21
BMap/BMExports.hpp
Normal file
21
BMap/BMExports.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include "BMap.hpp"
|
||||
|
||||
#pragma region Init / Dispose
|
||||
|
||||
LIBCMO_EXPORT void BMInit();
|
||||
LIBCMO_EXPORT void BMDispose();
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region BMapFile Life Time Manager
|
||||
|
||||
//LIBCMO_EXPORT BMap::BMFile* BMFile_Load(const char* file_name, const char* temp_folder, const char* texture_folder, const char* encoding);
|
||||
//LIBCMO_EXPORT BMap::BMFile* BMFile_Create();
|
||||
//LIBCMO_EXPORT bool BMFile_Save(BMap::BMFile* map_file, const char* file_name, int compreess_level);
|
||||
//LIBCMO_EXPORT void BMFile_Free(BMap::BMFile* map_file);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
173
BMap/BMap.cpp
Normal file
173
BMap/BMap.cpp
Normal file
|
@ -0,0 +1,173 @@
|
|||
#include "BMap.hpp"
|
||||
|
||||
namespace BMap {
|
||||
|
||||
#pragma region BMMeshTransition
|
||||
|
||||
BMMeshTransition::TransitionVertex::TransitionVertex(
|
||||
const LibCmo::VxMath::VxVector3& vec,
|
||||
const LibCmo::VxMath::VxVector3& norm,
|
||||
const LibCmo::VxMath::VxVector2& uv) :
|
||||
m_Vertex(vec), m_Norm(norm), m_UV(uv) {}
|
||||
|
||||
BMMeshTransition::TransitionFace::TransitionFace(uint32_t _i1, uint32_t _i2, uint32_t _i3, uint32_t mtl_id) :
|
||||
m_Idx1(_i1), m_Idx2(_i2), m_Idx3(_i3), m_MtlSlotIdx(mtl_id) {}
|
||||
|
||||
bool BMMeshTransition::TransitionVertexCompare::operator()(const TransitionVertex& lhs, const TransitionVertex& rhs) const {
|
||||
if (auto cmp = std::memcmp(&lhs.m_Vertex, &rhs.m_Vertex, sizeof(LibCmo::VxMath::VxVector3)); cmp != 0) return cmp < 0;
|
||||
if (auto cmp = std::memcmp(&lhs.m_Norm, &rhs.m_Norm, sizeof(LibCmo::VxMath::VxVector3)); cmp != 0) return cmp < 0;
|
||||
return std::memcmp(&lhs.m_UV, &rhs.m_UV, sizeof(LibCmo::VxMath::VxVector2)) < 0;
|
||||
}
|
||||
|
||||
BMMeshTransition::BMMeshTransition() :
|
||||
m_IsVertexOK(false), m_IsNormalOK(false), m_IsUVOK(false), m_IsFaceOK(false), m_IsMtlSlotOK(false),
|
||||
m_IsParsed(false),
|
||||
m_Vertexs(), m_Normals(), m_UVs(),
|
||||
m_MtlSlots(),
|
||||
m_FaceVertexs(), m_FaceNormals(), m_FaceUVs(), m_FaceMtlSlotIdxs(),
|
||||
m_ProcVertexs(), m_ProcFaces(), m_ProcDupRemover() {}
|
||||
|
||||
BMMeshTransition::~BMMeshTransition() {}
|
||||
|
||||
void BMMeshTransition::PrepareVertexCount(uint32_t count) {
|
||||
if (m_IsParsed) return;
|
||||
m_Vertexs.resize(count);
|
||||
m_IsVertexOK = true;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareVertex(uint32_t index, float x, float y, float z) {
|
||||
if (m_IsParsed || index >= m_Vertexs.size()) return;
|
||||
m_Vertexs[index].x = x;
|
||||
m_Vertexs[index].y = y;
|
||||
m_Vertexs[index].z = z;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareNormalCount(uint32_t count) {
|
||||
if (m_IsParsed) return;
|
||||
m_Normals.resize(count);
|
||||
m_IsNormalOK = true;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareNormal(uint32_t index, float x, float y, float z) {
|
||||
if (m_IsParsed || index >= m_Normals.size()) return;
|
||||
m_Normals[index].x = x;
|
||||
m_Normals[index].y = y;
|
||||
m_Normals[index].z = z;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareUVCount(uint32_t count) {
|
||||
if (m_IsParsed) return;
|
||||
m_UVs.resize(count);
|
||||
m_IsUVOK = true;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareUV(uint32_t index, float u, float v) {
|
||||
if (m_IsParsed || index >= m_UVs.size()) return;
|
||||
m_UVs[index].x = u;
|
||||
m_UVs[index].y = v;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareMtlSlotCount(uint32_t count) {
|
||||
if (m_IsParsed) return;
|
||||
m_MtlSlots.resize(count, nullptr);
|
||||
m_IsMtlSlotOK = true;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareMtlSlot(uint32_t index, BMMaterial* mtl) {
|
||||
if (m_IsParsed || index >= m_MtlSlots.size()) return;
|
||||
m_MtlSlots[index] = mtl;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareFaceCount(uint32_t count) {
|
||||
if (m_IsParsed) return;
|
||||
m_FaceVertexs.resize(count * 3);
|
||||
m_FaceNormals.resize(count * 3);
|
||||
m_FaceUVs.resize(count * 3);
|
||||
m_FaceMtlSlotIdxs.resize(count);
|
||||
m_IsFaceOK = true;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareFaceVertexIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3) {
|
||||
index *= 3;
|
||||
if (m_IsParsed || index >= m_FaceVertexs.size()) return;
|
||||
m_FaceVertexs[index] = indice1;
|
||||
m_FaceVertexs[index + 1] = indice2;
|
||||
m_FaceVertexs[index + 2] = indice3;
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareFaceNormalIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3) {
|
||||
index *= 3;
|
||||
if (m_IsParsed || index >= m_FaceNormals.size()) return;
|
||||
m_FaceNormals[index] = indice1;
|
||||
m_FaceNormals[index + 1] = indice2;
|
||||
m_FaceNormals[index + 2] = indice3;
|
||||
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareFaceUVIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3) {
|
||||
index *= 3;
|
||||
if (m_IsParsed || index >= m_FaceUVs.size()) return;
|
||||
m_FaceUVs[index] = indice1;
|
||||
m_FaceUVs[index + 1] = indice2;
|
||||
m_FaceUVs[index + 2] = indice3;
|
||||
|
||||
}
|
||||
|
||||
void BMMeshTransition::PrepareFaceMtlSlot(uint32_t index, uint32_t mtl_slot) {
|
||||
if (m_IsParsed || index >= m_FaceMtlSlotIdxs.size()) return;
|
||||
m_FaceMtlSlotIdxs[index] = mtl_slot;
|
||||
}
|
||||
|
||||
bool BMMeshTransition::Parse(BMMesh* write_into_mesh) {
|
||||
if (m_IsParsed || write_into_mesh == nullptr) return false;
|
||||
if (!m_IsVertexOK || !m_IsNormalOK || !m_IsUVOK || !m_IsFaceOK || !m_IsMtlSlotOK) return false;
|
||||
|
||||
DoRealParse();
|
||||
ApplyToMesh(write_into_mesh);
|
||||
|
||||
m_IsParsed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void BMMeshTransition::DoRealParse() {
|
||||
// reserve vector to prevent extra mem alloc
|
||||
// use the most bad situation to reserve
|
||||
size_t face_size = m_FaceMtlSlotIdxs.size();
|
||||
m_ProcVertexs.reserve(face_size * 3);
|
||||
m_ProcFaces.reserve(face_size);
|
||||
|
||||
// iterate face
|
||||
for (size_t faceid = 0; faceid < face_size; ++faceid) {
|
||||
uint32_t idx[3];
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
// create one first
|
||||
TransitionVertex tvec(
|
||||
m_Vertexs[m_FaceVertexs[faceid * 3 + j]],
|
||||
m_Normals[m_FaceVertexs[faceid * 3 + j]],
|
||||
m_UVs[m_FaceVertexs[faceid * 3 + j]]
|
||||
);
|
||||
|
||||
// try insert it
|
||||
auto insert_result = m_ProcDupRemover.try_emplace(tvec, static_cast<uint32_t>(m_ProcVertexs.size()));
|
||||
// get the new inserted index or existed index.
|
||||
idx[j] = insert_result.first->second;
|
||||
// if insert successfully, append to proc vertexs
|
||||
if (insert_result.second) {
|
||||
m_ProcVertexs.emplace_back(tvec);
|
||||
}
|
||||
}
|
||||
|
||||
// create face
|
||||
m_ProcFaces.emplace_back(idx[0], idx[1], idx[2], m_FaceMtlSlotIdxs[faceid]);
|
||||
}
|
||||
}
|
||||
|
||||
void BMMeshTransition::ApplyToMesh(BMMesh* write_into_mesh) {
|
||||
// todo: apply to mesh
|
||||
}
|
||||
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
}
|
129
BMap/BMap.hpp
Normal file
129
BMap/BMap.hpp
Normal file
|
@ -0,0 +1,129 @@
|
|||
#pragma once
|
||||
|
||||
#include <VTUserAll.hpp>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <cinttypes>
|
||||
|
||||
namespace BMap {
|
||||
|
||||
class BMGroup {
|
||||
public:
|
||||
BMGroup(LibCmo::CK2::ObjImpls::CKGroup* ptr);
|
||||
~BMGroup();
|
||||
LIBCMO_DEFAULT_COPY_MOVE(BMGroup);
|
||||
|
||||
LibCmo::CK2::ObjImpls::CKGroup* m_NativePtr;
|
||||
};
|
||||
|
||||
class BMTexture {
|
||||
public:
|
||||
BMTexture(LibCmo::CK2::ObjImpls::CKTexture* ptr);
|
||||
~BMTexture();
|
||||
LIBCMO_DEFAULT_COPY_MOVE(BMTexture);
|
||||
|
||||
LibCmo::CK2::ObjImpls::CKTexture* m_NativePtr;
|
||||
};
|
||||
|
||||
class BMMaterial {
|
||||
public:
|
||||
BMMaterial(LibCmo::CK2::ObjImpls::CKMaterial* ptr);
|
||||
~BMMaterial();
|
||||
LIBCMO_DEFAULT_COPY_MOVE(BMMaterial);
|
||||
|
||||
LibCmo::CK2::ObjImpls::CKMaterial* m_NativePtr;
|
||||
};
|
||||
|
||||
class BMMesh {
|
||||
public:
|
||||
BMMesh(LibCmo::CK2::ObjImpls::CKMesh* ptr);
|
||||
~BMMesh();
|
||||
LIBCMO_DEFAULT_COPY_MOVE(BMMesh);
|
||||
|
||||
LibCmo::CK2::ObjImpls::CKMesh* m_NativePtr;
|
||||
};
|
||||
|
||||
class BM3dEntity {
|
||||
public:
|
||||
BM3dEntity(LibCmo::CK2::ObjImpls::CK3dEntity* ptr);
|
||||
~BM3dEntity();
|
||||
LIBCMO_DEFAULT_COPY_MOVE(BM3dEntity);
|
||||
|
||||
LibCmo::CK2::ObjImpls::CK3dEntity* m_NativePtr;
|
||||
};
|
||||
|
||||
class BMMeshTransition {
|
||||
private:
|
||||
struct TransitionVertex {
|
||||
TransitionVertex(
|
||||
const LibCmo::VxMath::VxVector3& vec,
|
||||
const LibCmo::VxMath::VxVector3& norm,
|
||||
const LibCmo::VxMath::VxVector2& uv);
|
||||
LibCmo::VxMath::VxVector3 m_Vertex;
|
||||
LibCmo::VxMath::VxVector3 m_Norm;
|
||||
LibCmo::VxMath::VxVector2 m_UV;
|
||||
};
|
||||
struct TransitionFace {
|
||||
TransitionFace(uint32_t _i1, uint32_t _i2, uint32_t _i3, uint32_t mtl_id);
|
||||
uint32_t m_Idx1, m_Idx2, m_Idx3;
|
||||
uint32_t m_MtlSlotIdx;
|
||||
};
|
||||
struct TransitionVertexCompare {
|
||||
bool operator()(const TransitionVertex& lhs, const TransitionVertex& rhs) const;
|
||||
};
|
||||
|
||||
public:
|
||||
BMMeshTransition();
|
||||
~BMMeshTransition();
|
||||
|
||||
void PrepareVertexCount(uint32_t count);
|
||||
void PrepareVertex(uint32_t index, float x, float y, float z);
|
||||
void PrepareNormalCount(uint32_t count);
|
||||
void PrepareNormal(uint32_t index, float x, float y, float z);
|
||||
void PrepareUVCount(uint32_t count);
|
||||
void PrepareUV(uint32_t index, float u, float v);
|
||||
void PrepareMtlSlotCount(uint32_t count);
|
||||
void PrepareMtlSlot(uint32_t index, BMMaterial* mtl);
|
||||
void PrepareFaceCount(uint32_t count);
|
||||
void PrepareFaceVertexIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3);
|
||||
void PrepareFaceNormalIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3);
|
||||
void PrepareFaceUVIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3);
|
||||
void PrepareFaceMtlSlot(uint32_t index, uint32_t mtl_slot);
|
||||
|
||||
bool Parse(BMMesh* write_into_mesh);
|
||||
|
||||
private:
|
||||
void DoRealParse();
|
||||
void ApplyToMesh(BMMesh* write_into_mesh);
|
||||
|
||||
bool m_IsVertexOK, m_IsNormalOK, m_IsUVOK, m_IsFaceOK, m_IsMtlSlotOK;
|
||||
bool m_IsParsed;
|
||||
|
||||
std::vector<LibCmo::VxMath::VxVector3> m_Vertexs, m_Normals;
|
||||
std::vector<LibCmo::VxMath::VxVector2> m_UVs;
|
||||
std::vector<uint32_t> m_FaceVertexs, m_FaceNormals, m_FaceUVs;
|
||||
std::vector<uint32_t> m_FaceMtlSlotIdxs;
|
||||
std::vector<BMMaterial*> m_MtlSlots;
|
||||
|
||||
std::vector<TransitionVertex> m_ProcVertexs;
|
||||
std::vector<TransitionFace> m_ProcFaces;
|
||||
// unordered_map have performance problem when dealing with massive data (in this case, big mesh)
|
||||
// so we use map to get stable time cost.
|
||||
std::map<TransitionVertex, uint32_t, TransitionVertexCompare> m_ProcDupRemover;
|
||||
};
|
||||
|
||||
class BMFile {
|
||||
public:
|
||||
BMFile();
|
||||
~BMFile();
|
||||
|
||||
private:
|
||||
LibCmo::CK2::CKContext* m_Context;
|
||||
std::vector<LibCmo::CK2::ObjImpls::CKGroup*> m_ObjGroups;
|
||||
std::vector<LibCmo::CK2::ObjImpls::CK3dObject*> m_Obj3dObjects;
|
||||
std::vector<LibCmo::CK2::ObjImpls::CKMesh*> m_ObjMeshs;
|
||||
std::vector<LibCmo::CK2::ObjImpls::CKMaterial*> m_ObjMaterials;
|
||||
std::vector<LibCmo::CK2::ObjImpls::CKTexture*> m_ObjTextures;
|
||||
};
|
||||
|
||||
}
|
188
BMap/BMap.vcxproj
Normal file
188
BMap/BMap.vcxproj
Normal file
|
@ -0,0 +1,188 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{0f0a8b98-35d7-4b8e-af0a-041b1bd80fd2}</ProjectGuid>
|
||||
<RootNamespace>BMap</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\LibRef.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\LibRef.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\LibRef.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\LibRef.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>LIBCMO_EXPORTING;LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ZLIB_PATH);../LibCmo;../IronPad;$(STB_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>zlibwapi.lib;LibCmo.lib;IronPad.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x86\ZlibDllReleaseWithoutAsm;$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SolutionDir)out\$(Platform)\$(Configuration)\IronPad;</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>LIBCMO_EXPORTING;LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ZLIB_PATH);../LibCmo;../IronPad;$(STB_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>zlibwapi.lib;LibCmo.lib;IronPad.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x86\ZlibDllReleaseWithoutAsm;$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SolutionDir)out\$(Platform)\$(Configuration)\IronPad;</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>LIBCMO_EXPORTING;LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ZLIB_PATH);../LibCmo;../IronPad;$(STB_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>zlibwapi.lib;LibCmo.lib;IronPad.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x64\ZlibDllReleaseWithoutAsm;$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SolutionDir)out\$(Platform)\$(Configuration)\IronPad;</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>LIBCMO_EXPORTING;LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ZLIB_PATH);../LibCmo;../IronPad;$(STB_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>zlibwapi.lib;LibCmo.lib;IronPad.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x64\ZlibDllReleaseWithoutAsm;$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SolutionDir)out\$(Platform)\$(Configuration)\IronPad;</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BMap.hpp" />
|
||||
<ClInclude Include="BMExports.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="BMap.cpp" />
|
||||
<ClCompile Include="BMExports.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
33
BMap/BMap.vcxproj.filters
Normal file
33
BMap/BMap.vcxproj.filters
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Sources">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Headers">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resources">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BMap.hpp">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BMExports.hpp">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="BMap.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BMExports.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -83,9 +83,13 @@ def GetTmplOperDiv(sname: str, svars: tuple[str]) -> str:
|
|||
def GetTmplOperEqual(sname: str, svars: tuple[str]) -> str:
|
||||
return f"""\tbool operator==(const {sname}& rhs) const {{
|
||||
\t\treturn ({' && '.join(map(lambda x: f'{x} == rhs.{x}', svars))});
|
||||
\t}}
|
||||
\tbool operator!=(const {sname}& rhs) const {{
|
||||
\t\treturn !(*this == rhs);
|
||||
\t}}"""
|
||||
|
||||
def GetTmplOperSpaceship(sname: str, svars: tuple[str]) -> str:
|
||||
sp: str = '\n\t\t'
|
||||
return f"""\tauto operator<=>(const {sname}& rhs) const {{
|
||||
\t\t{sp.join(map(lambda x: f'if (auto cmp = {x} <=> rhs.{x}; cmp != 0) return cmp;', svars[:-1]))}
|
||||
\t\treturn {svars[-1]} <=> rhs.{svars[-1]};
|
||||
\t}}"""
|
||||
|
||||
def GetTmplLength(sname: str, svars: tuple[str]) -> str:
|
||||
|
|
|
@ -26,6 +26,18 @@ namespace IronPad {
|
|||
|
||||
#pragma region Exception Handler Detail
|
||||
|
||||
|
||||
static HMODULE GetCurrentModule() {
|
||||
// Reference: https://stackoverflow.com/questions/557081/how-do-i-get-the-hmodule-for-the-currently-executing-code
|
||||
HMODULE hModule = NULL;
|
||||
GetModuleHandleExW(
|
||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, // get address and do not inc ref counter.
|
||||
(LPCWSTR)GetCurrentModule,
|
||||
&hModule);
|
||||
|
||||
return hModule;
|
||||
}
|
||||
|
||||
static const char* UExceptionGetCodeName(DWORD code) {
|
||||
switch (code) {
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
|
@ -68,8 +80,9 @@ namespace IronPad {
|
|||
return "one instruction has been executed";
|
||||
case EXCEPTION_STACK_OVERFLOW:
|
||||
return "stack overflow";
|
||||
default:
|
||||
return "unknown exception";
|
||||
}
|
||||
return "unknown exception";
|
||||
}
|
||||
|
||||
static void UExceptionFormat(std::FILE* fs, const char* fmt, ...) {
|
||||
|
@ -207,7 +220,7 @@ namespace IronPad {
|
|||
std::filesystem::path ironpad_path;
|
||||
WCHAR module_path[MAX_PATH];
|
||||
std::memset(module_path, 0, sizeof(module_path));
|
||||
if (GetModuleFileNameW(NULL, module_path, MAX_PATH) == 0) {
|
||||
if (GetModuleFileNameW(GetCurrentModule(), module_path, MAX_PATH) == 0) {
|
||||
goto failed;
|
||||
}
|
||||
ironpad_path = module_path;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#endif
|
||||
|
||||
// Debug IronPad used. Force enable IronPad.
|
||||
#define IRONPAD_ENABLED 1
|
||||
//#define IRONPAD_ENABLED 1
|
||||
|
||||
namespace IronPad {
|
||||
|
||||
|
|
|
@ -418,9 +418,7 @@ namespace LibCmo::CK2 {
|
|||
}
|
||||
|
||||
auto operator<=>(const CKGUID& rhs) const {
|
||||
auto cmp = this->d1 <=> rhs.d1;
|
||||
if (cmp != 0)
|
||||
return cmp;
|
||||
if (auto cmp = this->d1 <=> rhs.d1; cmp != 0) return cmp;
|
||||
return this->d2 <=> rhs.d2;
|
||||
}
|
||||
bool operator==(const CKGUID& rhs) const {
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
#endif
|
||||
|
||||
// https://stackoverflow.com/questions/2164827/explicitly-exporting-shared-library-functions-in-linux
|
||||
// generate import export macro
|
||||
// generate import export macro.
|
||||
// these macro is not used by LibCmo because LibCmo is static library
|
||||
// these macro may used by other project such as BMap.
|
||||
#if defined(_MSC_VER)
|
||||
// Microsoft
|
||||
#define LIBCMO_RAW_EXPORT __declspec(dllexport)
|
||||
|
@ -22,7 +24,7 @@
|
|||
// do nothing and hope for the best?
|
||||
#define LIBCMO_RAW_EXPORT
|
||||
#define LIBCMO_RAW_IMPORT
|
||||
#pragma warning Unknown dynamic link import/export semantics.
|
||||
#pragma warning "Unknown dynamic link import/export semantics."
|
||||
#endif
|
||||
|
||||
// choosee proper style
|
||||
|
|
14
libcmo21.sln
14
libcmo21.sln
|
@ -16,6 +16,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IronPad", "IronPad\IronPad.
|
|||
{70F64F8D-099C-4C21-B29C-0A8F1E22FB2E} = {70F64F8D-099C-4C21-B29C-0A8F1E22FB2E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BMap", "BMap\BMap.vcxproj", "{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{A6454164-2153-45AE-BDB8-19C77014E0CC} = {A6454164-2153-45AE-BDB8-19C77014E0CC}
|
||||
{70F64F8D-099C-4C21-B29C-0A8F1E22FB2E} = {70F64F8D-099C-4C21-B29C-0A8F1E22FB2E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
|
@ -48,6 +54,14 @@ Global
|
|||
{A6454164-2153-45AE-BDB8-19C77014E0CC}.Release|x64.Build.0 = Release|x64
|
||||
{A6454164-2153-45AE-BDB8-19C77014E0CC}.Release|x86.ActiveCfg = Release|Win32
|
||||
{A6454164-2153-45AE-BDB8-19C77014E0CC}.Release|x86.Build.0 = Release|Win32
|
||||
{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}.Debug|x64.Build.0 = Debug|x64
|
||||
{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}.Debug|x86.Build.0 = Debug|Win32
|
||||
{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}.Release|x64.ActiveCfg = Release|x64
|
||||
{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}.Release|x64.Build.0 = Release|x64
|
||||
{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}.Release|x86.ActiveCfg = Release|Win32
|
||||
{0F0A8B98-35D7-4B8E-AF0A-041B1BD80FD2}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Reference in New Issue
Block a user