2V2-e.5a: restore 40250 min-max helpers for camera update
This commit is contained in:
@@ -142,40 +142,40 @@ auto IsGlobalFileName(const char *) -> bool
|
||||
return mt_platform_stub_return<bool>();
|
||||
}
|
||||
|
||||
auto MIN(int, int) -> int
|
||||
auto MIN(int a, int b) -> int
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<int>();
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
auto MAX(int, int) -> int
|
||||
auto MAX(int a, int b) -> int
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<int>();
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
auto MINMAX(int, int, int) -> int
|
||||
auto MINMAX(int min, int value, int max) -> int
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<int>();
|
||||
if (max < min)
|
||||
return MAX(min, value);
|
||||
int tv;
|
||||
tv = (min > value ? min : value);
|
||||
return (max < tv) ? max : tv;
|
||||
}
|
||||
|
||||
auto fMIN(float, float) -> float
|
||||
auto fMIN(float a, float b) -> float
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<float>();
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
auto fMAX(float, float) -> float
|
||||
auto fMAX(float a, float b) -> float
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<float>();
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
auto fMINMAX(float, float, float) -> float
|
||||
auto fMINMAX(float min, float value, float max) -> float
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<float>();
|
||||
float tv;
|
||||
tv = (min > value ? min : value);
|
||||
return (max < tv) ? max : tv;
|
||||
}
|
||||
|
||||
auto MyCreateDirectory(const char *) -> void
|
||||
|
||||
@@ -155,6 +155,9 @@ add_dependencies(port_logic port_header_gate)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../platform ${CMAKE_CURRENT_BINARY_DIR}/../platform)
|
||||
|
||||
if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
|
||||
add_executable(port_utils_test ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/port_utils_test.cpp)
|
||||
target_link_libraries(port_utils_test PRIVATE port_platform)
|
||||
add_test(NAME port.utils COMMAND $<TARGET_FILE:port_utils_test>)
|
||||
add_executable(port_common_test ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/port_common_test.cpp)
|
||||
target_link_libraries(port_common_test PRIVATE port_logic)
|
||||
add_test(NAME port.common COMMAND $<TARGET_FILE:port_common_test>)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "EterBase/StdAfx.h"
|
||||
#include "EterBase/Utils.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
int main()
|
||||
{
|
||||
int failures = 0;
|
||||
auto check = [&failures](bool ok, const char *name) {
|
||||
if (!ok) {
|
||||
std::fprintf(stderr, "FAIL %s\n", name);
|
||||
++failures;
|
||||
}
|
||||
};
|
||||
check(MIN(-3, 8) == -3 && MIN(8, -3) == -3, "MIN order/sign");
|
||||
check(MAX(-3, 8) == 8 && MAX(8, -3) == 8, "MAX order/sign");
|
||||
check(MINMAX(2, -5, 9) == 2, "MINMAX lower");
|
||||
check(MINMAX(2, 20, 9) == 9, "MINMAX upper");
|
||||
check(MINMAX(9, 4, 2) == 9, "MINMAX reversed bounds");
|
||||
check(fMIN(-3.5f, 8.5f) == -3.5f, "fMIN sign");
|
||||
check(fMAX(200.0f, 0.0f) == 200.0f, "fMAX camera floor");
|
||||
check(fMINMAX(2.0f, -5.0f, 9.0f) == 2.0f, "fMINMAX lower");
|
||||
check(fMINMAX(2.0f, 20.0f, 9.0f) == 9.0f, "fMINMAX upper");
|
||||
return failures ? 1 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user