Skip to content

Commit

Permalink
DataFunc now equivalent (#456)
Browse files Browse the repository at this point in the history
* Force MSL_C++ files as C++ in clangd config

* A few DataFunc tweaks I've had stashed

* Tidy and match DataPackColor

* Tidy and match DataDo

* Match DataMin/Max/Clamp; better parameter names for Clamp/ClampEq
thanks LagoLunatic!

* Match DataForEachInt

* Match DataTime

* Match DataRandomElem

* Match DataNotifyBeta

* Tidy DataReverseInterp/InverseLerp
Tough match here

* Match DataMergeFilter ctor

* Implement and match DataFilterNotify

* Match DataReplaceObject

* Mark DataFunc as equivalent

* throwing this small thing in so it doesn't get forgotten lol
  • Loading branch information
TheNathannator authored Jan 8, 2025
1 parent 715b9b8 commit 7dd8f36
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 135 deletions.
13 changes: 13 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,16 @@ CompileFlags:
"--language=c++",
"-std=c++98",
]
---
# MSL_C++ is not C either
If:
PathMatch: .*/MSL_C\+\+/.*
CompileFlags:
Remove: [
"--language=",
"-std=",
]
Add: [
"--language=c++",
"-std=c++98",
]
2 changes: 1 addition & 1 deletion config/SZBE69_B8/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@

"system/obj/DataArray.cpp": "Equivalent",
"system/obj/DataFile.cpp": "NonMatching",
"system/obj/DataFunc.cpp": "NonMatching",
"system/obj/DataFunc.cpp": "Equivalent",
"system/obj/DataNode.cpp": "NonMatching",
"system/obj/DataUtl.cpp": {
"status": "LinkIssues",
Expand Down
1 change: 1 addition & 0 deletions src/decomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define DECOMP_FORCEACTIVE(module, ...)
#define DECOMP_FORCELITERAL(module, ...)
#define DECOMP_FORCEFUNC(module, decl, ...)
#define DECOMP_FORCEFUNC_TEMPL(module, cls, func, ...)
#define DECOMP_FORCEDTOR(module, cls)
#define DECOMP_FORCEBLOCK(module, ...)
// Compile with matching hacks.
Expand Down
44 changes: 26 additions & 18 deletions src/system/math/Utl.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ template<class T> inline T Max(T x, T y, T z){
return Max(x, Max(y, z));
}

template<class T> inline T Clamp(T x, T y, T z){
if(z > y) return y;
if(!(z < x)) return z;
return x;
template<class T> inline T Clamp(T min, T max, T value){
if(value > max) return max;
if(value < min) return min;
return value;
}

template<class T> inline bool ClampEq(T& x, const T& y, const T& z) {
T temp = y;
if (x < y) {
x = temp;
template<class T> inline bool ClampEq(T& value, const T& min, const T& max) {
T temp = min;
if (value < min) {
value = temp;
return true;
} else if (x > z) {
x = z;
} else if (value > max) {
value = max;
return true;
}
return false;
Expand Down Expand Up @@ -152,17 +152,25 @@ inline float ModRange(float f1, float f2, float f3){
}


inline float Interp(float a, float b, float c){
float delta = b - a;
return c * delta + a;
inline float Interp(float a, float b, float t){
return t * (b - a) + a;
}

inline void Interp(float f1, float f2, float f3, float& fres){
fres = f3 * (f2 - f1) + f1;
inline void Interp(float a, float b, float t, float& fres){
fres = t * (b - a) + a;
}

inline void Interp(bool b1, bool b2, float f, bool& bres){
bres = f < 1.0f ? b1 : b2;
inline void Interp(bool a, bool b, float t, bool& bres){
bres = t < 1.0f ? a : b;
}

inline float InverseLerp(float min, float max, float value) {
// Prevent divide-by-zero from zero-sized range
if (max != min) {
return (value - min) / (max - min);
} else {
return 1.0f;
}
}

inline bool PowerOf2(int num){
Expand All @@ -176,4 +184,4 @@ inline float Limit(float f1, float f2, float f3, int& i){
int floored = floor((f3 - f1) / fsub);
i = floored;
return -(floored * fsub - f3);
}
}
Loading

0 comments on commit 7dd8f36

Please sign in to comment.