From c235524403db970148c4a1216e4e5682bea9af39 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Wed, 25 Dec 2024 08:28:42 +0800 Subject: [PATCH] fix: fix 2 issues - rename float to CKFLOAT in VxMatrix. - move CKLightData struct to CKDefine.hpp because it not a private struct used by CKLight, but a CKRasterizer struct. --- LibCmo/CK2/CKDefines.hpp | 22 ++++++++++++++++++++++ LibCmo/CK2/ObjImpls/CKLight.hpp | 15 --------------- LibCmo/VxMath/VxTypes.cpp | 26 +++++++++++++------------- LibCmo/VxMath/VxTypes.hpp | 8 ++++---- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/LibCmo/CK2/CKDefines.hpp b/LibCmo/CK2/CKDefines.hpp index fe667dc..3818fd9 100644 --- a/LibCmo/CK2/CKDefines.hpp +++ b/LibCmo/CK2/CKDefines.hpp @@ -141,6 +141,28 @@ namespace LibCmo::CK2 { CKFileExtension m_Ext; /**< File Extension of the image being described by this structure */ }; + /** + * @brief Light Structure passed to CKRasterizerContext::SetLight() + * @details + * This struct is a part of CKRasterizer. + * I put it in there just for the convenience of CKLight. + */ + struct CKLightData { + VxMath::VXLIGHT_TYPE m_Type; /**< Point, Spot, Directionnal */ + VxMath::VxColor m_Diffuse; /**< Diffuse Color */ + VxMath::VxColor m_Specular; /**< Specular Color (Unused...) */ + VxMath::VxColor m_Ambient; /**< Ambient Color (Unused...) */ + VxMath::VxVector3 m_Position; /**< World Position */ + VxMath::VxVector3 m_Direction; /**< Direction */ + CKFLOAT m_Range; /**< Range */ + CKFLOAT m_Falloff; + CKFLOAT m_Attenuation0; + CKFLOAT m_Attenuation1; + CKFLOAT m_Attenuation2; + CKFLOAT m_InnerSpotCone; /**< Only for spot lights */ + CKFLOAT m_OuterSpotCone; /**< Only for spot lights */ + }; + #pragma endregion diff --git a/LibCmo/CK2/ObjImpls/CKLight.hpp b/LibCmo/CK2/ObjImpls/CKLight.hpp index 765ca9b..7a887b3 100644 --- a/LibCmo/CK2/ObjImpls/CKLight.hpp +++ b/LibCmo/CK2/ObjImpls/CKLight.hpp @@ -60,21 +60,6 @@ namespace LibCmo::CK2::ObjImpls { void SetLightPower(CKFLOAT power = 1.0f); protected: - struct CKLightData { - VxMath::VXLIGHT_TYPE m_Type; - VxMath::VxColor m_Diffuse; - VxMath::VxColor m_Specular; - VxMath::VxColor m_Ambient; - VxMath::VxVector3 m_Position; - VxMath::VxVector3 m_Direction; - CKFLOAT m_Range; - CKFLOAT m_Falloff; - CKFLOAT m_Attenuation0; - CKFLOAT m_Attenuation1; - CKFLOAT m_Attenuation2; - CKFLOAT m_InnerSpotCone; - CKFLOAT m_OuterSpotCone; - }; enum class LightFlags : CKDWORD { None = 0, Active = 0x100u, /**< if set, this light is active. */ diff --git a/LibCmo/VxMath/VxTypes.cpp b/LibCmo/VxMath/VxTypes.cpp index 38a487a..f924b34 100644 --- a/LibCmo/VxMath/VxTypes.cpp +++ b/LibCmo/VxMath/VxTypes.cpp @@ -442,7 +442,7 @@ namespace LibCmo::VxMath { Clear(); m_Data[0][0] = m_Data[1][1] = m_Data[2][2] = m_Data[3][3] = 1.0f; } - void VxMatrix::Perspective(float Fov, float Aspect, float Near_plane, float Far_plane) { + void VxMatrix::Perspective(CKFLOAT Fov, CKFLOAT Aspect, CKFLOAT Near_plane, CKFLOAT Far_plane) { Clear(); m_Data[0][0] = std::cosf(Fov * 0.5f) / std::sinf(Fov * 0.5f); m_Data[1][1] = m_Data[0][0] * Aspect; @@ -450,10 +450,10 @@ namespace LibCmo::VxMath { m_Data[3][2] = -m_Data[2][2] * Near_plane; m_Data[2][3] = 1; } - void VxMatrix::PerspectiveRect(float Left, float Right, float Top, float Bottom, float Near_plane, float Far_plane) { + void VxMatrix::PerspectiveRect(CKFLOAT Left, CKFLOAT Right, CKFLOAT Top, CKFLOAT Bottom, CKFLOAT Near_plane, CKFLOAT Far_plane) { Clear(); - float RL = 1.0f / (Right - Left); - float TB = 1.0f / (Top - Bottom); + CKFLOAT RL = 1.0f / (Right - Left); + CKFLOAT TB = 1.0f / (Top - Bottom); m_Data[0][0] = 2.0f * Near_plane * RL; m_Data[1][1] = 2.0f * Near_plane * TB; m_Data[2][0] = -(Right + Left) * RL; @@ -462,20 +462,20 @@ namespace LibCmo::VxMath { m_Data[3][2] = -m_Data[2][2] * Near_plane; m_Data[2][3] = 1; } - void VxMatrix::Orthographic(float Zoom, float Aspect, float Near_plane, float Far_plane) { + void VxMatrix::Orthographic(CKFLOAT Zoom, CKFLOAT Aspect, CKFLOAT Near_plane, CKFLOAT Far_plane) { Clear(); - float iz = 1.0f / (Far_plane - Near_plane); + CKFLOAT iz = 1.0f / (Far_plane - Near_plane); m_Data[0][0] = Zoom; m_Data[1][1] = Zoom * Aspect; m_Data[2][2] = iz; m_Data[3][2] = -Near_plane * iz; m_Data[3][3] = 1.0f; } - void VxMatrix::OrthographicRect(float Left, float Right, float Top, float Bottom, float Near_plane, float Far_plane) { + void VxMatrix::OrthographicRect(CKFLOAT Left, CKFLOAT Right, CKFLOAT Top, CKFLOAT Bottom, CKFLOAT Near_plane, CKFLOAT Far_plane) { Clear(); - float ix = 1.0f / (Right - Left); - float iy = 1.0f / (Top - Bottom); - float iz = 1.0f / (Far_plane - Near_plane); + CKFLOAT ix = 1.0f / (Right - Left); + CKFLOAT iy = 1.0f / (Top - Bottom); + CKFLOAT iz = 1.0f / (Far_plane - Near_plane); m_Data[0][0] = 2.0f * ix; m_Data[1][1] = -2.0f * iy; m_Data[2][2] = iz; @@ -492,15 +492,15 @@ namespace LibCmo::VxMath { namespace NSVxVector { - float DotProduct(const VxVector2& lhs, const VxVector2& rhs) { + CKFLOAT DotProduct(const VxVector2& lhs, const VxVector2& rhs) { return lhs * rhs; } - float DotProduct(const VxVector3& lhs, const VxVector3& rhs) { + CKFLOAT DotProduct(const VxVector3& lhs, const VxVector3& rhs) { return lhs * rhs; } - float DotProduct(const VxVector4& lhs, const VxVector4& rhs) { + CKFLOAT DotProduct(const VxVector4& lhs, const VxVector4& rhs) { return lhs * rhs; } diff --git a/LibCmo/VxMath/VxTypes.hpp b/LibCmo/VxMath/VxTypes.hpp index 3ba142f..b021205 100644 --- a/LibCmo/VxMath/VxTypes.hpp +++ b/LibCmo/VxMath/VxTypes.hpp @@ -221,7 +221,7 @@ namespace LibCmo::VxMath { * * @see PerspectiveRect, Orthographic, OrthographicRect */ - void Perspective(float Fov, float Aspect, float Near_plane, float Far_plane); + void Perspective(CKFLOAT Fov, CKFLOAT Aspect, CKFLOAT Near_plane, CKFLOAT Far_plane); /** * @brief Constructs a perspective projection matrix given a view rectangle. * @param[in] Left Left clipping plane value. @@ -246,7 +246,7 @@ namespace LibCmo::VxMath { * * @see Perspective, Orthographic, OrthographicRect */ - void PerspectiveRect(float Left, float Right, float Top, float Bottom, float Near_plane, float Far_plane); + void PerspectiveRect(CKFLOAT Left, CKFLOAT Right, CKFLOAT Top, CKFLOAT Bottom, CKFLOAT Near_plane, CKFLOAT Far_plane); /** * @brief Constructs a orthographic projection matrix. * @param[in] Zoom Zoom factor. @@ -265,7 +265,7 @@ namespace LibCmo::VxMath { * * @see Perspective, OrthographicRect */ - void Orthographic(float Zoom, float Aspect, float Near_plane, float Far_plane); + void Orthographic(CKFLOAT Zoom, CKFLOAT Aspect, CKFLOAT Near_plane, CKFLOAT Far_plane); /** * @brief Constructs a orthographic projection matrix. * @param[in] Left Left clipping plane value. @@ -290,7 +290,7 @@ namespace LibCmo::VxMath { * * @see Perspective, Orthographic */ - void OrthographicRect(float Left, float Right, float Top, float Bottom, float Near_plane, float Far_plane); + void OrthographicRect(CKFLOAT Left, CKFLOAT Right, CKFLOAT Top, CKFLOAT Bottom, CKFLOAT Near_plane, CKFLOAT Far_plane); /* ===== END USER CUSTOM ===== */ };