fix: fix various issues.
- fix convertion loss in CKCamera. - bump up version to 0.3.0 - use CMake to generate version info header. - fix annotation about Dassault ComputeCRC error. - change member field initialization value in CKLight.
This commit is contained in:
parent
fe4a58e864
commit
c18ff8f2e3
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,6 +5,9 @@
|
|||||||
*.nms
|
*.nms
|
||||||
*.vmo
|
*.vmo
|
||||||
|
|
||||||
|
# Ignore CMake generated version header
|
||||||
|
LibCmo/VTVersion.hpp
|
||||||
|
|
||||||
# Ignore temporary Visual Studio files and folders
|
# Ignore temporary Visual Studio files and folders
|
||||||
temp/
|
temp/
|
||||||
out/
|
out/
|
||||||
|
6
CMake/VTVersion.hpp.in
Normal file
6
CMake/VTVersion.hpp.in
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define LIBCMO_VER_MAJOR @PROJECT_VERSION_MAJOR@
|
||||||
|
#define LIBCMO_VER_MINOR @PROJECT_VERSION_MINOR@
|
||||||
|
#define LIBCMO_VER_PATCH @PROJECT_VERSION_PATCH@
|
||||||
|
#define LIBCMO_VER_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"
|
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.23)
|
cmake_minimum_required(VERSION 3.23)
|
||||||
project(NeMo
|
project(NeMo
|
||||||
VERSION 0.2.0
|
VERSION 0.3.0
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -102,24 +102,27 @@ namespace LibCmo::CK2 {
|
|||||||
// This is a patch for Dassault stupid programmer.
|
// This is a patch for Dassault stupid programmer.
|
||||||
//
|
//
|
||||||
// After Virtools 4.0, Dassault use a new way to compute the CRC of file.
|
// After Virtools 4.0, Dassault use a new way to compute the CRC of file.
|
||||||
// Dassault introduce a new class called CKMemoryBufferWriter which use file and memory map to handle big file properly.
|
// Dassault introduces a new class called CKMemoryBufferWriter which use file and memory map to handle big file properly.
|
||||||
|
// This algorithm splits the whole data body into 8 MB chunks and calculate them one by one to avoid instantaneous memory occupation.
|
||||||
// However, there is a bug in virtual function CKMemoryBufferWriter::ComputeCRC.
|
// However, there is a bug in virtual function CKMemoryBufferWriter::ComputeCRC.
|
||||||
// It takes `PreviousCRC` as argument but never use it in function. In this function, the start value of CRC compution is hardcoded 0.
|
// It takes `PreviousCRC` as argument but never use it in function.
|
||||||
|
// In this function, the start value of CRC compution is hardcoded 0.
|
||||||
// So, although Dassault programmer try to compute CRC for file header, header part and daat part in code, it actually only compute CRC for data part!
|
// So, although Dassault programmer try to compute CRC for file header, header part and daat part in code, it actually only compute CRC for data part!
|
||||||
// I 100% sure this is the mistake of Dassault stupid programmer and this bug cause horrible result.
|
// I 100% sure this is the mistake of Dassault stupid programmer and this bug cause more horrible result.
|
||||||
//
|
//
|
||||||
// In Virtools 2.1, engine will check CRC of file first. If no matched CRC, engine will reject loading file.
|
// In Virtools 2.1, engine will check CRC of file first. If no matched CRC, engine will reject loading file.
|
||||||
// So the obvious result is that we can not load file saved by Virtools 4.0 in Virtools 2.1.
|
// So the obvious result is that we can not load file saved by Virtools 4.0 in Virtools 2.1.
|
||||||
// But this is not the point which makes me indignant.
|
// But this is not the point which makes me indignant.
|
||||||
// The real weird point is that we can use Virtools 3.5 to open file saved by Virtools 4.0 but why?
|
// The real weird point is that we can use Virtools 3.5 to open file saved by Virtools 4.0, but why?
|
||||||
// After some research, I found that the programmer of Dassault totally removed CRC check when loading file since some version which I don't know!
|
// After some researches, I found that the programmer of Dassault totally removed CRC check when loading file, since some version which I don't know, to suppress this bug!
|
||||||
// This is totally cheat and commercial-oriented behavior!
|
// This is totally cheat and commercial-oriented behavior!
|
||||||
// I guess Dassault programmer also find that they can not load new created file in old Virtools.
|
// I guess Dassault programmer also found that they can not load new created file in old Virtools.
|
||||||
// But they entirely don't know how to resolve it. So they just directly remove the whole of CRC checker!
|
// But they didn't find out what cause this bug, and just directly remove the whole of CRC checker to resolve this bug!
|
||||||
// That's the point which makes me indignant.
|
// I can't believe that this thing happens on such official software.
|
||||||
|
// This is the point which makes me indignant.
|
||||||
gotten_crc = CKComputeDataCRC(parser->GetPtr(), this->m_FileInfo.DataPackSize, 0u);
|
gotten_crc = CKComputeDataCRC(parser->GetPtr(), this->m_FileInfo.DataPackSize, 0u);
|
||||||
|
|
||||||
// Both CRC compute methods are failed, this file may be really broken.
|
// Both CRC compute methods are failed. This file may be really broken.
|
||||||
// Report exception directly.
|
// Report exception directly.
|
||||||
if (gotten_crc != this->m_FileInfo.Crc) {
|
if (gotten_crc != this->m_FileInfo.Crc) {
|
||||||
this->m_Ctx->OutputToConsole(u8"Virtools file CRC error.");
|
this->m_Ctx->OutputToConsole(u8"Virtools file CRC error.");
|
||||||
|
@ -128,7 +128,7 @@ SetObjectFlags(obj_flags); \
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CKCamera::ComputeProjectionMatrix(VxMath::VxMatrix& mat) const {
|
void CKCamera::ComputeProjectionMatrix(VxMath::VxMatrix& mat) const {
|
||||||
CKFLOAT aspect = m_Width / m_Height;
|
CKFLOAT aspect = static_cast<CKFLOAT>(m_Width) / m_Height;
|
||||||
if (m_ProjectType == CK_CAMERA_PROJECTION::CK_PERSPECTIVEPROJECTION) {
|
if (m_ProjectType == CK_CAMERA_PROJECTION::CK_PERSPECTIVEPROJECTION) {
|
||||||
mat.Perspective(m_Fov, aspect, m_FrontPlane, m_BackPlane);
|
mat.Perspective(m_Fov, aspect, m_FrontPlane, m_BackPlane);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "CKLight.hpp"
|
#include "CKLight.hpp"
|
||||||
#include "../CKStateChunk.hpp"
|
#include "../CKStateChunk.hpp"
|
||||||
|
#include <numbers>
|
||||||
|
|
||||||
namespace LibCmo::CK2::ObjImpls {
|
namespace LibCmo::CK2::ObjImpls {
|
||||||
|
|
||||||
@ -16,8 +17,8 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
m_LightData.m_Attenuation0 = 1.0f;
|
m_LightData.m_Attenuation0 = 1.0f;
|
||||||
m_LightData.m_Attenuation1 = 0.0f;
|
m_LightData.m_Attenuation1 = 0.0f;
|
||||||
m_LightData.m_Attenuation2 = 0.0f;
|
m_LightData.m_Attenuation2 = 0.0f;
|
||||||
m_LightData.m_InnerSpotCone = 0.69813174f; // MARK: Perhaps 40 deg in rad.
|
m_LightData.m_InnerSpotCone = 40.0f / 180.0f * std::numbers::pi_v<float>; // MARK: Original value is 0.69813174f. Perhaps 40 deg in rad.
|
||||||
m_LightData.m_OuterSpotCone = 0.78539819f; // MARK: Perhaps 45 deg in rad.
|
m_LightData.m_OuterSpotCone = 45.0f / 180.0f * std::numbers::pi_v<float>; // MARK: Original value is 0.78539819f. Perhaps 45 deg in rad.
|
||||||
}
|
}
|
||||||
|
|
||||||
CKLight::~CKLight() {}
|
CKLight::~CKLight() {}
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
# Configure version file
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/../CMake/VTVersion.hpp.in
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/VTVersion.hpp
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
# Create static library
|
# Create static library
|
||||||
add_library(LibCmo STATIC "")
|
add_library(LibCmo STATIC "")
|
||||||
# Setup static library sources
|
# Setup static library sources
|
||||||
@ -47,6 +54,7 @@ PUBLIC
|
|||||||
FILE_SET HEADERS
|
FILE_SET HEADERS
|
||||||
FILES
|
FILES
|
||||||
# Asststant header files
|
# Asststant header files
|
||||||
|
VTVersion.hpp
|
||||||
VTInternal.hpp
|
VTInternal.hpp
|
||||||
VTEncoding.hpp
|
VTEncoding.hpp
|
||||||
VTUtils.hpp
|
VTUtils.hpp
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
* They should use Virtools type anywhere, except that Virtools type can not fulfill their requirements.
|
* They should use Virtools type anywhere, except that Virtools type can not fulfill their requirements.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// The version info header of LibCmo
|
||||||
|
#include "VTVersion.hpp"
|
||||||
// The base header of LibCmo.
|
// The base header of LibCmo.
|
||||||
// It provides various convenient stuff, for example:
|
// It provides various convenient stuff, for example:
|
||||||
// - General LibCmo specific custom exception.
|
// - General LibCmo specific custom exception.
|
||||||
|
@ -362,8 +362,8 @@ namespace Unvirt::CmdHelper {
|
|||||||
throw std::invalid_argument("root node should not be inserted as child node.");
|
throw std::invalid_argument("root node should not be inserted as child node.");
|
||||||
// check conflict
|
// check conflict
|
||||||
const auto& new_node_set = new_node_ptr->GetConflictSet();
|
const auto& new_node_set = new_node_ptr->GetConflictSet();
|
||||||
for (auto& node : m_Nodes) {
|
for (auto& child_node : m_Nodes) {
|
||||||
const auto& node_set = node->GetConflictSet();
|
const auto& node_set = child_node->GetConflictSet();
|
||||||
if (new_node_set.IsConflictWith(node_set))
|
if (new_node_set.IsConflictWith(node_set))
|
||||||
throw std::invalid_argument("try to add a conflict node. please check your code.");
|
throw std::invalid_argument("try to add a conflict node. please check your code.");
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ namespace Unvirt::Context {
|
|||||||
YYCC::ConsoleHelper::EnableColorfulConsole();
|
YYCC::ConsoleHelper::EnableColorfulConsole();
|
||||||
|
|
||||||
// Show banner
|
// Show banner
|
||||||
YYCC::ConsoleHelper::WriteLine(YYCC_COLOR_LIGHT_YELLOW(u8"Unvirt 0.2.0") " built at " __DATE__ " " __TIME__);
|
YYCC::ConsoleHelper::WriteLine(YYCC_COLOR_LIGHT_YELLOW(u8"Unvirt") " (based on LibCmo " LIBCMO_VER_STR ") built at " __DATE__ " " __TIME__);
|
||||||
YYCC::ConsoleHelper::WriteLine(u8"Type 'help' for more infomation. Type 'exit' to quit.");
|
YYCC::ConsoleHelper::WriteLine(u8"Type 'help' for more infomation. Type 'exit' to quit.");
|
||||||
|
|
||||||
// start process loop
|
// start process loop
|
||||||
|
Loading…
Reference in New Issue
Block a user