port(EterLib): GrpMath/GrpColor/GrpColorInstance verbatim
port.grp_math pins the 40250 conventions: D3DXVec3Rotation applies the inverse rotation, GetRotationFromMatrix returns negated Z*X*Y angles, and CGraphicColor defaults to opaque white. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
042bddf195
commit
c7bcb9bbbe
@@ -1,62 +1,78 @@
|
||||
// Platform skeleton for EterLib/GrpColor.h (40250 EterLib/GrpColor.cpp), generated by platform_stub.py.
|
||||
// Every MT_PLATFORM_STUB() body is unimplemented: replace it with the platform implementation.
|
||||
// 40250 EterLib/GrpColor.cpp, verbatim.
|
||||
#include "EterLib/StdAfx.h"
|
||||
#include "EterLib/GrpColor.h"
|
||||
|
||||
#include "../PlatformStub.h"
|
||||
|
||||
CGraphicColor::CGraphicColor(const CGraphicColor &)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
CGraphicColor::CGraphicColor(float, float, float, float)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
CGraphicColor::CGraphicColor(DWORD)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
CGraphicColor::CGraphicColor()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
Clear();
|
||||
}
|
||||
|
||||
CGraphicColor::CGraphicColor(const CGraphicColor& c_rSrcColor)
|
||||
{
|
||||
Set(c_rSrcColor);
|
||||
}
|
||||
|
||||
CGraphicColor::CGraphicColor(float r, float g, float b, float a)
|
||||
{
|
||||
Set(r, g, b, a);
|
||||
}
|
||||
|
||||
CGraphicColor::CGraphicColor(DWORD color)
|
||||
{
|
||||
Set(color);
|
||||
}
|
||||
|
||||
CGraphicColor::~CGraphicColor()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CGraphicColor::Clear() -> void
|
||||
void CGraphicColor::Clear()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
Set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
auto CGraphicColor::Set(float, float, float, float) -> void
|
||||
void CGraphicColor::Set(float r, float g, float b, float a)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_r=r;
|
||||
m_g=g;
|
||||
m_b=b;
|
||||
m_a=a;
|
||||
}
|
||||
|
||||
auto CGraphicColor::Set(const CGraphicColor &) -> void
|
||||
void CGraphicColor::Set(const CGraphicColor& c_rSrcColor)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_r=c_rSrcColor.m_r;
|
||||
m_g=c_rSrcColor.m_g;
|
||||
m_b=c_rSrcColor.m_b;
|
||||
m_a=c_rSrcColor.m_a;
|
||||
}
|
||||
|
||||
auto CGraphicColor::Set(DWORD) -> void
|
||||
void CGraphicColor::Blend(float p, const CGraphicColor& c_rSrcColor, const CGraphicColor& c_rDstColor)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
float q=1.0f-p;
|
||||
m_r=c_rSrcColor.m_r*q+c_rDstColor.m_r*p;
|
||||
m_g=c_rSrcColor.m_g*q+c_rDstColor.m_g*p;
|
||||
m_b=c_rSrcColor.m_b*q+c_rDstColor.m_b*p;
|
||||
m_a=c_rSrcColor.m_a*q+c_rDstColor.m_a*p;
|
||||
}
|
||||
|
||||
auto CGraphicColor::Blend(float, const CGraphicColor &, const CGraphicColor &) -> void
|
||||
void CGraphicColor::Set(DWORD pack)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_b = (pack & 0xff) / 255.0f; pack >>= 8;
|
||||
m_g = (pack & 0xff) / 255.0f; pack >>= 8;
|
||||
m_r = (pack & 0xff) / 255.0f; pack >>= 8;
|
||||
m_a = (pack) / 255.0f;
|
||||
}
|
||||
|
||||
auto CGraphicColor::GetPackValue() const -> DWORD
|
||||
DWORD CGraphicColor::GetPackValue() const
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<DWORD>();
|
||||
DWORD packValue=0;
|
||||
|
||||
packValue = int(255.0f * m_a);packValue <<= 8;
|
||||
packValue |= int(255.0f * m_r);packValue <<= 8;
|
||||
packValue |= int(255.0f * m_g);packValue <<= 8;
|
||||
packValue |= int(255.0f * m_b);
|
||||
|
||||
return packValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,48 +1,66 @@
|
||||
// Platform skeleton for EterLib/GrpColorInstance.h (40250 EterLib/GrpColorInstance.cpp), generated by platform_stub.py.
|
||||
// Every MT_PLATFORM_STUB() body is unimplemented: replace it with the platform implementation.
|
||||
// 40250 EterLib/GrpColorInstance.cpp, verbatim.
|
||||
#include "EterLib/StdAfx.h"
|
||||
#include "EterLib/GrpColorInstance.h"
|
||||
|
||||
#include "../PlatformStub.h"
|
||||
#include "EterBase/Timer.h"
|
||||
|
||||
CGraphicColorInstance::CGraphicColorInstance()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_baseTime=0;
|
||||
m_blendTime=0;
|
||||
}
|
||||
|
||||
CGraphicColorInstance::~CGraphicColorInstance()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CGraphicColorInstance::Clear() -> void
|
||||
void CGraphicColorInstance::Clear()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_srcColor.Clear();
|
||||
m_dstColor.Clear();
|
||||
m_curColor.Clear();
|
||||
|
||||
m_baseTime=0;
|
||||
m_blendTime=0;
|
||||
}
|
||||
|
||||
auto CGraphicColorInstance::SetColorReference(const CGraphicColor &) -> void
|
||||
void CGraphicColorInstance::SetColorReference(const CGraphicColor & c_rSrcColor)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_srcColor = c_rSrcColor;
|
||||
m_dstColor = c_rSrcColor;
|
||||
m_curColor = c_rSrcColor;
|
||||
}
|
||||
|
||||
auto CGraphicColorInstance::BlendColorReference(DWORD, const CGraphicColor &) -> void
|
||||
void CGraphicColorInstance::BlendColorReference(DWORD blendTime, const CGraphicColor& c_rDstColor)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_baseTime = GetCurrentTime();
|
||||
m_blendTime = blendTime;
|
||||
|
||||
m_srcColor = m_curColor;
|
||||
m_dstColor = c_rDstColor;
|
||||
}
|
||||
|
||||
auto CGraphicColorInstance::Update() -> void
|
||||
void CGraphicColorInstance::Update()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
DWORD curTime = GetCurrentTime();
|
||||
DWORD elapsedTime = curTime - m_baseTime;
|
||||
|
||||
if (elapsedTime < m_blendTime)
|
||||
{
|
||||
m_curColor.Blend(elapsedTime/float(m_blendTime), m_srcColor, m_dstColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_curColor=m_dstColor;
|
||||
}
|
||||
}
|
||||
|
||||
auto CGraphicColorInstance::GetCurrentColorReference() const -> const CGraphicColor &
|
||||
DWORD CGraphicColorInstance::GetCurrentTime()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<const CGraphicColor &>();
|
||||
return CTimer::Instance().GetCurrentMillisecond();
|
||||
}
|
||||
|
||||
auto CGraphicColorInstance::GetCurrentTime() -> DWORD
|
||||
const CGraphicColor& CGraphicColorInstance::GetCurrentColorReference() const
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<DWORD>();
|
||||
return m_curColor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +1,137 @@
|
||||
// Platform skeleton for EterLib/GrpMath.h (40250 EterLib/GrpMath.cpp), generated by platform_stub.py.
|
||||
// Every MT_PLATFORM_STUB() body is unimplemented: replace it with the platform implementation.
|
||||
// 40250 EterLib/GrpMath.cpp, verbatim.
|
||||
#include "EterLib/StdAfx.h"
|
||||
#include "EterLib/GrpMath.h"
|
||||
|
||||
#include "../PlatformStub.h"
|
||||
|
||||
auto CrossProduct2D(float, float, float, float) -> float
|
||||
float CrossProduct2D(float x1, float y1, float x2, float y2)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<float>();
|
||||
return x1*y2-y1*x2;
|
||||
}
|
||||
|
||||
auto IsInTriangle2D(float, float, float, float, float, float, float, float) -> bool
|
||||
bool IsInTriangle2D(float ax, float ay, float bx, float by, float cx, float cy, float tx, float ty)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<bool>();
|
||||
float c1 = CrossProduct2D(bx-ax, by-ay, tx-ax, ty-ay);
|
||||
float c2 = CrossProduct2D(cx-bx, cy-by, tx-bx, ty-by);
|
||||
float c3 = CrossProduct2D(ax-cx, ay-cy, tx-cx, ty-cy);
|
||||
|
||||
if (c1 * c2 > 0.0f && c1 * c3 > 0.0f)
|
||||
return true;
|
||||
|
||||
if (c1 * c2 * c3 == 0.0f)
|
||||
{
|
||||
if (tx < ax)
|
||||
if (tx < bx)
|
||||
if (tx < cx)
|
||||
return false;
|
||||
|
||||
if (tx > ax)
|
||||
if (tx > bx)
|
||||
if (tx > cx)
|
||||
return false;
|
||||
|
||||
if (ty < ay)
|
||||
if (ty < by)
|
||||
if (ty < cy)
|
||||
return false;
|
||||
|
||||
if (ty > ay)
|
||||
if (ty > by)
|
||||
if (ty > cy)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto D3DXVec3Rotation(D3DXVECTOR3 *, const D3DXVECTOR3 *, const D3DXQUATERNION *) -> D3DXVECTOR3 *
|
||||
D3DXVECTOR3* D3DXVec3Rotation(D3DXVECTOR3* pvtOut, const D3DXVECTOR3* c_pvtSrc, const D3DXQUATERNION* c_pqtRot)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<D3DXVECTOR3 *>();
|
||||
D3DXQUATERNION qtSrc(c_pvtSrc->x, c_pvtSrc->y, c_pvtSrc->z, 0);
|
||||
D3DXQUATERNION qtRet;
|
||||
D3DXQuaternionConjugate(&qtRet, c_pqtRot);
|
||||
D3DXQuaternionMultiply(&qtRet, &qtSrc, &qtRet);
|
||||
D3DXQuaternionMultiply(&qtRet, c_pqtRot, &qtRet);
|
||||
|
||||
pvtOut->x=qtRet.x;
|
||||
pvtOut->y=qtRet.y;
|
||||
pvtOut->z=qtRet.z;
|
||||
|
||||
return pvtOut;
|
||||
}
|
||||
|
||||
auto D3DXVec3Translation(D3DXVECTOR3 *, const D3DXVECTOR3 *, const D3DXVECTOR3 *) -> D3DXVECTOR3 *
|
||||
|
||||
|
||||
void GetRotationFromMatrix(D3DXVECTOR3 * pRotation, const D3DXMATRIX * c_pMatrix)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<D3DXVECTOR3 *>();
|
||||
float sx = c_pMatrix->_32;
|
||||
float cx = sqrtf(1.0f - sx * sx);
|
||||
|
||||
if (cx < 0.00001f)
|
||||
{
|
||||
if (sx > 0)
|
||||
pRotation->x = D3DX_PI / 2;
|
||||
else
|
||||
pRotation->x = -D3DX_PI / 2;
|
||||
|
||||
pRotation->y = atan2f(c_pMatrix->_31, c_pMatrix->_11);
|
||||
pRotation->z = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
pRotation->x = atan2f(sx, cx);
|
||||
pRotation->y = atan2f(-c_pMatrix->_31, c_pMatrix->_33);
|
||||
pRotation->z = atan2f(-c_pMatrix->_12, c_pMatrix->_22);
|
||||
}
|
||||
}
|
||||
|
||||
auto GetRotationFromMatrix(D3DXVECTOR3 *, const D3DXMATRIX *) -> void
|
||||
void GetPivotAndRotationFromMatrix(D3DXMATRIX * pMatrix, D3DXVECTOR3 * pPivot, D3DXVECTOR3 * pRotation)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
float sx = pMatrix->_32;
|
||||
float cx = sqrtf(1.0f - sx * sx);
|
||||
float x, y, z;
|
||||
|
||||
if (cx < 0.00001f)
|
||||
{
|
||||
if (sx > 0)
|
||||
x = D3DX_PI / 2;
|
||||
else
|
||||
x = -D3DX_PI / 2;
|
||||
|
||||
y = atan2f(pMatrix->_31, pMatrix->_11);
|
||||
z = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = atan2f(sx, cx);
|
||||
y = atan2f(-pMatrix->_31, pMatrix->_33);
|
||||
z = atan2f(-pMatrix->_12, pMatrix->_22);
|
||||
}
|
||||
|
||||
pRotation->x = x;
|
||||
pRotation->y = y;
|
||||
pRotation->z = z;
|
||||
|
||||
pPivot->x = pMatrix->_41;
|
||||
pPivot->y = pMatrix->_42;
|
||||
pPivot->z = pMatrix->_43;
|
||||
}
|
||||
|
||||
auto GetPivotAndRotationFromMatrix(D3DXMATRIX *, D3DXVECTOR3 *, D3DXVECTOR3 *) -> void
|
||||
// NOTE : must be optimized!
|
||||
void ExtractMovement(D3DXMATRIX * pTargetMatrix, D3DXMATRIX * pSourceMatrix)
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
D3DXVECTOR3 v3Pivot;
|
||||
D3DXVECTOR3 v3Rotation;
|
||||
GetPivotAndRotationFromMatrix(pSourceMatrix, &v3Pivot, &v3Rotation);
|
||||
|
||||
auto ExtractMovement(D3DXMATRIX *, D3DXMATRIX *) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
D3DXMATRIX matRotationX;
|
||||
D3DXMatrixRotationX(&matRotationX, v3Rotation.x);
|
||||
D3DXMATRIX matRotationY;
|
||||
D3DXMatrixRotationY(&matRotationY, v3Rotation.y);
|
||||
D3DXMATRIX matRotationZ;
|
||||
D3DXMatrixRotationZ(&matRotationZ, v3Rotation.z);
|
||||
|
||||
D3DXMATRIX matTranslation;
|
||||
D3DXMatrixTranslation(&matTranslation, v3Pivot.x, v3Pivot.y, v3Pivot.z);
|
||||
|
||||
*pTargetMatrix = matRotationX * matRotationY * matRotationZ * matTranslation;
|
||||
}
|
||||
|
||||
@@ -216,6 +216,9 @@ if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
|
||||
add_executable(port_file_loader_thread_test ${PROJECT_SOURCE_DIR}/tests/port/port_file_loader_thread_test.cpp)
|
||||
target_link_libraries(port_file_loader_thread_test PRIVATE port_platform)
|
||||
add_test(NAME port.file_loader_thread COMMAND $<TARGET_FILE:port_file_loader_thread_test>)
|
||||
add_executable(port_grp_math_test ${PROJECT_SOURCE_DIR}/tests/port/port_grp_math_test.cpp)
|
||||
target_link_libraries(port_grp_math_test PRIVATE port_platform)
|
||||
add_test(NAME port.grp_math COMMAND $<TARGET_FILE:port_grp_math_test>)
|
||||
|
||||
# EterBase/Debug.cpp: syserr.txt / log.txt (redirects its own stderr).
|
||||
add_executable(port_debug_log_test ${PROJECT_SOURCE_DIR}/tests/port/port_debug_log_test.cpp)
|
||||
|
||||
Reference in New Issue
Block a user