LUS Cleanup: Utils.cpp is now in namespace Ship.

This commit is contained in:
Kenix3 2022-07-31 23:22:02 -04:00
parent c1659d3dcf
commit 1bf7771981
3 changed files with 15 additions and 14 deletions

View File

@ -1065,8 +1065,8 @@ static void gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *verti
dotx /= 127.0f; dotx /= 127.0f;
doty /= 127.0f; doty /= 127.0f;
dotx = math::clamp(dotx, -1.0f, 1.0f); dotx = Ship::Math::clamp(dotx, -1.0f, 1.0f);
doty = math::clamp(doty, -1.0f, 1.0f); doty = Ship::Math::clamp(doty, -1.0f, 1.0f);
if (rsp.geometry_mode & G_TEXTURE_GEN_LINEAR) { if (rsp.geometry_mode & G_TEXTURE_GEN_LINEAR) {
// Not sure exactly what formula we should use to get accurate values // Not sure exactly what formula we should use to get accurate values
@ -1118,7 +1118,7 @@ static void gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *verti
if (winv < 0.0f) winv = std::numeric_limits<int16_t>::max(); if (winv < 0.0f) winv = std::numeric_limits<int16_t>::max();
float fog_z = z * winv * rsp.fog_mul + rsp.fog_offset; float fog_z = z * winv * rsp.fog_mul + rsp.fog_offset;
fog_z = math::clamp(fog_z, 0.0f, 255.0f); fog_z = Ship::Math::clamp(fog_z, 0.0f, 255.0f);
d->color.a = fog_z; // Use alpha variable to store fog factor d->color.a = fog_z; // Use alpha variable to store fog factor
} else { } else {
d->color.a = v->cn[3]; d->color.a = v->cn[3];

View File

@ -5,14 +5,14 @@
#define strdup _strdup #define strdup _strdup
#endif #endif
namespace math { namespace Ship {
float clamp(float d, float min, float max) { namespace Math {
const float t = d < min ? min : d; float clamp(float d, float min, float max) {
return t > max ? max : t; const float t = d < min ? min : d;
return t > max ? max : t;
}
} }
}
namespace Utils {
std::vector<std::string> SplitText(const std::string text, char separator = ' ', bool keep_quotes = false) { std::vector<std::string> SplitText(const std::string text, char separator = ' ', bool keep_quotes = false) {
std::vector<std::string> args; std::vector<std::string> args;
char* input = strdup(text.c_str()); char* input = strdup(text.c_str());

View File

@ -3,10 +3,11 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace math { namespace Ship {
float clamp(float d, float min, float max);
} namespace Math {
float clamp(float d, float min, float max);
}
namespace Utils {
std::vector<std::string> SplitText(const std::string& text, char separator, bool keep_quotes); std::vector<std::string> SplitText(const std::string& text, char separator, bool keep_quotes);
} }