-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
756cd5a
commit 8b46507
Showing
35 changed files
with
2,683 additions
and
1,935 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
libs/RVL_SDK/src/revolution/hbm/include/nw4hbm/lyt/lyt_resourceAccessor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
#pragma once | ||
|
||
#include "nw4hbm/types_nw4hbm.h" | ||
#include "nw4hbm/ut/ut_Font.h" | ||
#ifndef NW4HBM_LYT_RESOURCE_ACCESSOR_H | ||
#define NW4HBM_LYT_RESOURCE_ACCESSOR_H | ||
#include "types_nw4hbm.h" | ||
#include "ut_Font.h" | ||
|
||
namespace nw4hbm | ||
{ | ||
namespace lyt | ||
{ | ||
struct ResourceAccessor | ||
class ResourceAccessor | ||
{ | ||
public: | ||
ResourceAccessor(); | ||
virtual ~ResourceAccessor(); | ||
virtual void GetResource(u32, const char *, u32 *) = 0; | ||
virtual ut::Font * GetFont(const char *); | ||
virtual ~ResourceAccessor(); // at 0x8 | ||
virtual UNKTYPE * GetResource(u32, const char *, u32 *) = 0; // at 0xC | ||
virtual ut::Font * GetFont(const char *); // at 0x10 | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef NW4HBM_PUBLIC_MATH_H | ||
#define NW4HBM_PUBLIC_MATH_H | ||
|
||
#include <nw4hbm/math/math_arithmetic.h> | ||
#include <nw4hbm/math/math_geometry.h> | ||
#include <nw4hbm/math/math_triangular.h> | ||
#include <nw4hbm/math/math_types.h> | ||
|
||
#endif |
129 changes: 129 additions & 0 deletions
129
libs/RVL_SDK/src/revolution/hbm/include/nw4hbm/math/math_arithmetic.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#ifndef NW4HBM_MATH_ARITHMETIC_H | ||
#define NW4HBM_MATH_ARITHMETIC_H | ||
#include <cmath> | ||
#include <nw4hbm/types_nw4hbm.h> | ||
#include <revolution/OS.h> | ||
|
||
#define NW4R_MATH_QNAN (-(0.0f / 0.0f)) | ||
#define NW4R_MATH_FLT_MAX 3.402823466e+38f | ||
|
||
namespace nw4hbm { | ||
namespace math { | ||
namespace detail { | ||
|
||
f32 FExp(f32 x); | ||
f32 FLog(f32 x); | ||
|
||
} // namespace detail | ||
|
||
f32 FrSqrt(f32 x); | ||
|
||
inline f32 FAbs(register f32 x) { | ||
// clang-format off | ||
asm { | ||
fabs x, x | ||
} | ||
// clang-format on | ||
|
||
return x; | ||
} | ||
|
||
inline f32 FCeil(f32 x) { return std::ceilf(x); } | ||
|
||
inline f32 FExp(f32 x) { return detail::FExp(x); } | ||
|
||
inline f32 FFloor(f32 x) { return std::floorf(x); } | ||
|
||
inline f32 FInv(register f32 x) { | ||
register f32 work0, work1, work2, work3; | ||
|
||
// clang-format off | ||
asm { | ||
fmr work1, x // x | ||
fres work0, work1 // 1/x | ||
|
||
// Refine estimate | ||
ps_add work2, work0, work0 // 2/x | ||
ps_mul work3, work0, work0 // 1/x^2 | ||
ps_nmsub work0, work1, work3, work2 // -(x * 1/x^2 - 2/x) | ||
} | ||
// clang-format on | ||
|
||
return work0; | ||
} | ||
|
||
inline f32 FMod(f32 x, f32 y) { return std::fmodf(x, y); } | ||
|
||
inline f32 FModf(f32 x, f32* y) { return std::modff(x, y); } | ||
|
||
inline f32 FSqrt(f32 x) { | ||
if (x < 0.0f) { | ||
return 0.0f; | ||
} | ||
|
||
return x * FrSqrt(x); | ||
} | ||
|
||
inline f32 FLog(f32 x) { | ||
if (x >= 0.0f) { | ||
return detail::FLog(x); | ||
} | ||
|
||
return NW4R_MATH_QNAN; | ||
} | ||
|
||
inline f32 FSelect(register f32 value, register f32 ge_zero, | ||
register f32 lt_zero) { | ||
register f32 ret; | ||
|
||
// clang-format off | ||
asm { | ||
fsel ret, value, ge_zero, lt_zero | ||
} | ||
// clang-format on | ||
|
||
return ret; | ||
} | ||
|
||
inline f32 U16ToF32(u16 arg) { | ||
f32 ret; | ||
OSu16tof32(&arg, &ret); | ||
return ret; | ||
} | ||
|
||
inline u16 F32ToU16(f32 arg) { | ||
u16 ret; | ||
OSf32tou16(&arg, &ret); | ||
return ret; | ||
} | ||
|
||
inline f32 S16ToF32(s16 arg) { | ||
f32 ret; | ||
OSs16tof32(&arg, &ret); | ||
return ret; | ||
} | ||
|
||
inline s16 F32ToS16(f32 arg) { | ||
s16 ret; | ||
OSf32tos16(&arg, &ret); | ||
return ret; | ||
} | ||
|
||
inline u32 F32AsU32(f32 arg) { return *reinterpret_cast<u32*>(&arg); } | ||
|
||
inline f32 U32AsF32(u32 arg) { return *reinterpret_cast<f32*>(&arg); } | ||
|
||
inline s32 FGetExpPart(f32 x) { | ||
s32 s = F32AsU32(x); | ||
return ((s >> 23) & 0xFF) - 0x7F; | ||
} | ||
|
||
inline f32 FGetMantPart(f32 x) { | ||
u32 u = F32AsU32(x); | ||
return U32AsF32((u & 0x807FFFFF) | 0x3F800000); | ||
} | ||
|
||
} // namespace math | ||
} // namespace nw4hbm | ||
|
||
#endif |
93 changes: 93 additions & 0 deletions
93
libs/RVL_SDK/src/revolution/hbm/include/nw4hbm/math/math_geometry.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#ifndef NW4HBM_MATH_GEOMETRY_H | ||
#define NW4HBM_MATH_GEOMETRY_H | ||
#include <nw4hbm/math/math_types.h> | ||
#include <nw4hbm/types_nw4hbm.h> | ||
|
||
namespace nw4hbm { | ||
namespace math { | ||
|
||
enum IntersectionResult { | ||
INTERSECTION_NONE, | ||
INTERSECTION_1, | ||
INTERSECTION_2, | ||
|
||
INTERSECTION_LINE3_ON_PLANE = INTERSECTION_2, | ||
INTERSECTION_RAY3_ON_PLANE = INTERSECTION_2, | ||
INTERSECTION_SEGMENT3_ON_PLANE = INTERSECTION_2, | ||
|
||
INTERSECTION_OUTSIDE = 0, | ||
INTERSECTION_INSIDE, | ||
INTERSECTION_INTERSECT | ||
}; | ||
|
||
struct PLANE { | ||
PLANE() {} | ||
|
||
f32 Test(const VEC3& point) const { return d + VEC3Dot(&n, &point); } | ||
void Set(const VEC3* p0, const VEC3* p1, const VEC3* p2); | ||
|
||
VEC3 n; // at 0x0 | ||
f32 d; // at 0xC | ||
}; | ||
|
||
struct AABB { | ||
AABB() {} | ||
|
||
void Set(const VEC3* points, unsigned int num); | ||
void Set(const AABB* box, const MTX34* mtx); | ||
|
||
VEC3 min; // at 0x0 | ||
VEC3 max; // at 0xC | ||
}; | ||
|
||
class FRUSTUM { | ||
private: | ||
enum Point { | ||
POINT_NEAR_TL, | ||
POINT_NEAR_TR, | ||
POINT_NEAR_BR, | ||
POINT_NEAR_BL, | ||
|
||
POINT_FAR_TL, | ||
POINT_FAR_TR, | ||
POINT_FAR_BR, | ||
POINT_FAR_BL, | ||
|
||
POINT_MAX | ||
}; | ||
|
||
enum Plane { | ||
PLANE_L, | ||
PLANE_R, | ||
PLANE_N, | ||
PLANE_F, | ||
PLANE_T, | ||
PLANE_B, | ||
|
||
PLANE_MAX | ||
}; | ||
|
||
public: | ||
void Set(f32 fovy, f32 aspect, f32 n, f32 f, const MTX34& cam); | ||
void Set(f32 t, f32 b, f32 l, f32 r, f32 n, f32 f, const MTX34& cam); | ||
|
||
IntersectionResult IntersectAABB_Ex(const AABB* box) const; | ||
|
||
private: | ||
MTX34 mCamMtx; // at 0x0 | ||
PLANE mPlaneL; // at 0x30 | ||
PLANE mPlaneR; // at 0x40 | ||
PLANE mPlaneT; // at 0x50 | ||
PLANE mPlaneB; // at 0x60 | ||
f32 mNearZ; // at 0x70 | ||
f32 mFarZ; // at 0x74 | ||
AABB mBox; // at 0x78 | ||
PLANE mPlanes[PLANE_MAX]; // at 0x90 | ||
}; | ||
|
||
bool IntersectionAABB(const AABB* a, const AABB* b); | ||
|
||
} // namespace math | ||
} // namespace nw4hbm | ||
|
||
#endif |
Oops, something went wrong.