19 #define KY_IntToPixelBitShift 7
20 #define KY_PixelSizeInIntCoord 128
21 #define KY_HalfPixelSizeInIntCoord 64
22 #define KY_PixelSizeInIntCoord_Float 128.0f
34 static inline KyInt32 NearestPixelCoord(
KyInt32 x) {
return IntToPixelCoord(x +
Kaim::Isel(x, KY_HalfPixelSizeInIntCoord-1, KY_HalfPixelSizeInIntCoord)); }
35 static inline KyInt32 NearestPixelCoord(
KyInt64 x) {
return IntToPixelCoord(x +
Kaim::Lsel(x, KY_HalfPixelSizeInIntCoord-1, KY_HalfPixelSizeInIntCoord)); }
37 static inline KyInt32 IntPixelSize() {
return KY_PixelSizeInIntCoord; }
39 static inline KyInt32 IntToPixelCoord(
KyInt32 intCoord) {
return intCoord >> KY_IntToPixelBitShift; }
40 static inline KyInt32 IntToPixelCoord(
KyInt64 intCoord) {
return (
KyInt32)(intCoord >> KY_IntToPixelBitShift); }
41 static inline KyInt32 PixelCoordToInt(
KyInt32 pixelCoord) {
return pixelCoord << KY_IntToPixelBitShift; }
44 static inline KyFloat32 IntegerPrecision(
KyFloat32 rasterPrecision) {
return rasterPrecision / KY_PixelSizeInIntCoord_Float; }
45 static inline KyFloat32 InvIntegerPrecision(
KyFloat32 rasterPrecision) {
return KY_PixelSizeInIntCoord_Float / rasterPrecision; }
50 return IntToNavigation(intDist, IntegerPrecision(rasterPrecision));
56 return NavigationToInt(dist, InvIntegerPrecision(rasterPrecision));
59 static inline void IntToNavigation_Pos(
const Vec2i& intPos, Vec2f& pos,
KyFloat32 rasterPrecision)
61 KyFloat32 integerPrecision = IntegerPrecision(rasterPrecision);
62 pos.x = IntToNavigation(intPos.x, integerPrecision);
63 pos.y = IntToNavigation(intPos.y, integerPrecision);
67 static inline void IntToNavigation_Pos(
const Vec3i& intPos, Vec3f& pos,
KyFloat32 rasterPrecision)
69 KyFloat32 integerPrecision = IntegerPrecision(rasterPrecision);
70 pos.x = IntToNavigation(intPos.x, integerPrecision);
71 pos.y = IntToNavigation(intPos.y, integerPrecision);
72 pos.z = IntToNavigation(intPos.z, integerPrecision);
76 static inline void PixelToNavigation_Pos(
const Vec3i& intPos, Vec3f& pos,
KyFloat32 integerPrecision)
78 pos.x = (
KyFloat32)(PixelCoordToInt(intPos.x) * integerPrecision);
79 pos.y = (
KyFloat32)(PixelCoordToInt(intPos.y) * integerPrecision);
80 pos.z = (
KyFloat32)(PixelCoordToInt(intPos.z) * integerPrecision);
84 static inline void NavigationToInt_Pos(
const Vec2f& pos, Vec2i& intPos,
KyFloat32 rasterPrecision)
86 KyFloat32 invIntegerPrecision = InvIntegerPrecision(rasterPrecision);
87 intPos.x = NavigationToInt(pos.x, invIntegerPrecision);
88 intPos.y = NavigationToInt(pos.y, invIntegerPrecision);
92 static inline void NavigationToInt_Pos(
const Vec3f& pos, Vec3i& intPos,
KyFloat32 rasterPrecision)
94 KyFloat32 invIntegerPrecision = InvIntegerPrecision(rasterPrecision);
95 intPos.x = NavigationToInt(pos.x, invIntegerPrecision);
96 intPos.y = NavigationToInt(pos.y, invIntegerPrecision);
97 intPos.z = NavigationToInt(pos.z, invIntegerPrecision);
104 return ((
KyFloat32)intDist) * integerPrecision;
109 return NearestInt(dist * invIntegerPrecision);
KyInt32 Isel(KyInt32 a, KyInt32 x, KyInt32 y)
If a is greater than 0, returns x.
Definition: fastmath.h:26
std::int64_t KyInt64
int64_t
Definition: types.h:25
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
float KyFloat32
float
Definition: types.h:32
KyInt64 Lsel(KyInt64 a, KyInt64 x, KyInt64 y)
If a is greater than 0, returns x.
Definition: fastmath.h:35