mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-26 13:47:12 +01:00
Renamed the Math singleton to PMath, as it causes too many issues when dealing with gdnatove / mono. It will also be eventually moved to a module, as it's only useful in some situations.
This commit is contained in:
parent
97f5037c8b
commit
e8bb085466
@ -1617,98 +1617,98 @@ _OS::_OS() {
|
|||||||
|
|
||||||
///////////////////// MATH
|
///////////////////// MATH
|
||||||
|
|
||||||
_Math *_Math::singleton = nullptr;
|
PMath *PMath::singleton = nullptr;
|
||||||
|
|
||||||
_Math *_Math::get_singleton() {
|
PMath *PMath::get_singleton() {
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
_Math::_Math() {
|
PMath::PMath() {
|
||||||
singleton = this;
|
singleton = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _Math::_bind_methods() {
|
void PMath::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("sin", "x"), &_Math::sin);
|
ClassDB::bind_method(D_METHOD("sin", "x"), &PMath::sin);
|
||||||
ClassDB::bind_method(D_METHOD("cos", "x"), &_Math::cos);
|
ClassDB::bind_method(D_METHOD("cos", "x"), &PMath::cos);
|
||||||
ClassDB::bind_method(D_METHOD("tan", "x"), &_Math::tan);
|
ClassDB::bind_method(D_METHOD("tan", "x"), &PMath::tan);
|
||||||
ClassDB::bind_method(D_METHOD("sinh", "x"), &_Math::sinh);
|
ClassDB::bind_method(D_METHOD("sinh", "x"), &PMath::sinh);
|
||||||
ClassDB::bind_method(D_METHOD("sinc", "x"), &_Math::sinc);
|
ClassDB::bind_method(D_METHOD("sinc", "x"), &PMath::sinc);
|
||||||
ClassDB::bind_method(D_METHOD("sincn", "x"), &_Math::sincn);
|
ClassDB::bind_method(D_METHOD("sincn", "x"), &PMath::sincn);
|
||||||
ClassDB::bind_method(D_METHOD("cosh", "x"), &_Math::cosh);
|
ClassDB::bind_method(D_METHOD("cosh", "x"), &PMath::cosh);
|
||||||
ClassDB::bind_method(D_METHOD("tanh", "x"), &_Math::tanh);
|
ClassDB::bind_method(D_METHOD("tanh", "x"), &PMath::tanh);
|
||||||
ClassDB::bind_method(D_METHOD("asin", "x"), &_Math::asin);
|
ClassDB::bind_method(D_METHOD("asin", "x"), &PMath::asin);
|
||||||
ClassDB::bind_method(D_METHOD("acos", "x"), &_Math::acos);
|
ClassDB::bind_method(D_METHOD("acos", "x"), &PMath::acos);
|
||||||
ClassDB::bind_method(D_METHOD("atan", "x"), &_Math::atan);
|
ClassDB::bind_method(D_METHOD("atan", "x"), &PMath::atan);
|
||||||
ClassDB::bind_method(D_METHOD("atan2", "y", "x"), &_Math::atan2);
|
ClassDB::bind_method(D_METHOD("atan2", "y", "x"), &PMath::atan2);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("sqrt", "x"), &_Math::sqrt);
|
ClassDB::bind_method(D_METHOD("sqrt", "x"), &PMath::sqrt);
|
||||||
ClassDB::bind_method(D_METHOD("fmod", "x", "y"), &_Math::fmod);
|
ClassDB::bind_method(D_METHOD("fmod", "x", "y"), &PMath::fmod);
|
||||||
ClassDB::bind_method(D_METHOD("floor", "x"), &_Math::floor);
|
ClassDB::bind_method(D_METHOD("floor", "x"), &PMath::floor);
|
||||||
ClassDB::bind_method(D_METHOD("floorf_int", "x"), &_Math::floorf_int);
|
ClassDB::bind_method(D_METHOD("floorf_int", "x"), &PMath::floorf_int);
|
||||||
ClassDB::bind_method(D_METHOD("ceil", "x"), &_Math::ceil);
|
ClassDB::bind_method(D_METHOD("ceil", "x"), &PMath::ceil);
|
||||||
ClassDB::bind_method(D_METHOD("pow", "x", "y"), &_Math::pow);
|
ClassDB::bind_method(D_METHOD("pow", "x", "y"), &PMath::pow);
|
||||||
ClassDB::bind_method(D_METHOD("log", "x"), &_Math::log);
|
ClassDB::bind_method(D_METHOD("log", "x"), &PMath::log);
|
||||||
ClassDB::bind_method(D_METHOD("log1p", "x"), &_Math::log1p);
|
ClassDB::bind_method(D_METHOD("log1p", "x"), &PMath::log1p);
|
||||||
ClassDB::bind_method(D_METHOD("log10", "x"), &_Math::log10);
|
ClassDB::bind_method(D_METHOD("log10", "x"), &PMath::log10);
|
||||||
ClassDB::bind_method(D_METHOD("log2", "x"), &_Math::log2);
|
ClassDB::bind_method(D_METHOD("log2", "x"), &PMath::log2);
|
||||||
ClassDB::bind_method(D_METHOD("exp", "x"), &_Math::exp);
|
ClassDB::bind_method(D_METHOD("exp", "x"), &PMath::exp);
|
||||||
ClassDB::bind_method(D_METHOD("erf", "x"), &_Math::erf);
|
ClassDB::bind_method(D_METHOD("erf", "x"), &PMath::erf);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("is_nan", "val"), &_Math::is_nan);
|
ClassDB::bind_method(D_METHOD("is_nan", "val"), &PMath::is_nan);
|
||||||
ClassDB::bind_method(D_METHOD("is_inf", "val"), &_Math::is_inf);
|
ClassDB::bind_method(D_METHOD("is_inf", "val"), &PMath::is_inf);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("abs", "g"), &_Math::abs);
|
ClassDB::bind_method(D_METHOD("abs", "g"), &PMath::abs);
|
||||||
ClassDB::bind_method(D_METHOD("absi", "g"), &_Math::absi);
|
ClassDB::bind_method(D_METHOD("absi", "g"), &PMath::absi);
|
||||||
ClassDB::bind_method(D_METHOD("fposmod", "x", "y"), &_Math::fposmod);
|
ClassDB::bind_method(D_METHOD("fposmod", "x", "y"), &PMath::fposmod);
|
||||||
ClassDB::bind_method(D_METHOD("fposmodp", "x", "y"), &_Math::fposmodp);
|
ClassDB::bind_method(D_METHOD("fposmodp", "x", "y"), &PMath::fposmodp);
|
||||||
ClassDB::bind_method(D_METHOD("posmod", "x", "y"), &_Math::posmod);
|
ClassDB::bind_method(D_METHOD("posmod", "x", "y"), &PMath::posmod);
|
||||||
ClassDB::bind_method(D_METHOD("deg2rad", "y"), &_Math::deg2rad);
|
ClassDB::bind_method(D_METHOD("deg2rad", "y"), &PMath::deg2rad);
|
||||||
ClassDB::bind_method(D_METHOD("rad2deg", "y"), &_Math::rad2deg);
|
ClassDB::bind_method(D_METHOD("rad2deg", "y"), &PMath::rad2deg);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("lerp", "from", "to", "weight"), &_Math::lerp);
|
ClassDB::bind_method(D_METHOD("lerp", "from", "to", "weight"), &PMath::lerp);
|
||||||
ClassDB::bind_method(D_METHOD("lerp_angle", "from", "to", "weight"), &_Math::lerp_angle);
|
ClassDB::bind_method(D_METHOD("lerp_angle", "from", "to", "weight"), &PMath::lerp_angle);
|
||||||
ClassDB::bind_method(D_METHOD("inverse_lerp", "from", "to", "value"), &_Math::inverse_lerp);
|
ClassDB::bind_method(D_METHOD("inverse_lerp", "from", "to", "value"), &PMath::inverse_lerp);
|
||||||
ClassDB::bind_method(D_METHOD("range_lerp", "value", "istart", "istop", "ostart", "ostop"), &_Math::range_lerp);
|
ClassDB::bind_method(D_METHOD("range_lerp", "value", "istart", "istop", "ostart", "ostop"), &PMath::range_lerp);
|
||||||
ClassDB::bind_method(D_METHOD("cubic_interpolate", "from", "to", "pre", "post", "weight"), &_Math::cubic_interpolate);
|
ClassDB::bind_method(D_METHOD("cubic_interpolate", "from", "to", "pre", "post", "weight"), &PMath::cubic_interpolate);
|
||||||
ClassDB::bind_method(D_METHOD("bezier_interpolate", "start", "control_1", "control_2", "end", "t"), &_Math::bezier_interpolate);
|
ClassDB::bind_method(D_METHOD("bezier_interpolate", "start", "control_1", "control_2", "end", "t"), &PMath::bezier_interpolate);
|
||||||
ClassDB::bind_method(D_METHOD("smoothstep", "from", "to", "s"), &_Math::smoothstep);
|
ClassDB::bind_method(D_METHOD("smoothstep", "from", "to", "s"), &PMath::smoothstep);
|
||||||
ClassDB::bind_method(D_METHOD("move_toward", "from", "to", "delta"), &_Math::move_toward);
|
ClassDB::bind_method(D_METHOD("move_toward", "from", "to", "delta"), &PMath::move_toward);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("linear2db", "linear"), &_Math::linear2db);
|
ClassDB::bind_method(D_METHOD("linear2db", "linear"), &PMath::linear2db);
|
||||||
ClassDB::bind_method(D_METHOD("db2linear", "db"), &_Math::db2linear);
|
ClassDB::bind_method(D_METHOD("db2linear", "db"), &PMath::db2linear);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("round", "val"), &_Math::round);
|
ClassDB::bind_method(D_METHOD("round", "val"), &PMath::round);
|
||||||
ClassDB::bind_method(D_METHOD("wrapi", "value", "min", "max"), &_Math::wrapi);
|
ClassDB::bind_method(D_METHOD("wrapi", "value", "min", "max"), &PMath::wrapi);
|
||||||
ClassDB::bind_method(D_METHOD("wrapf", "value", "min", "max"), &_Math::wrapf);
|
ClassDB::bind_method(D_METHOD("wrapf", "value", "min", "max"), &PMath::wrapf);
|
||||||
ClassDB::bind_method(D_METHOD("fract", "value"), &_Math::fract);
|
ClassDB::bind_method(D_METHOD("fract", "value"), &PMath::fract);
|
||||||
ClassDB::bind_method(D_METHOD("pingpong", "value", "length"), &_Math::pingpong);
|
ClassDB::bind_method(D_METHOD("pingpong", "value", "length"), &PMath::pingpong);
|
||||||
ClassDB::bind_method(D_METHOD("ease", "x", "c"), &_Math::ease);
|
ClassDB::bind_method(D_METHOD("ease", "x", "c"), &PMath::ease);
|
||||||
ClassDB::bind_method(D_METHOD("step_decimals", "step"), &_Math::step_decimals);
|
ClassDB::bind_method(D_METHOD("step_decimals", "step"), &PMath::step_decimals);
|
||||||
ClassDB::bind_method(D_METHOD("range_step_decimals", "step"), &_Math::range_step_decimals);
|
ClassDB::bind_method(D_METHOD("range_step_decimals", "step"), &PMath::range_step_decimals);
|
||||||
ClassDB::bind_method(D_METHOD("stepify", "value", "step"), &_Math::stepify);
|
ClassDB::bind_method(D_METHOD("stepify", "value", "step"), &PMath::stepify);
|
||||||
ClassDB::bind_method(D_METHOD("dectime", "value", "amount", "step"), &_Math::dectime);
|
ClassDB::bind_method(D_METHOD("dectime", "value", "amount", "step"), &PMath::dectime);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("larger_prime", "val"), &_Math::larger_prime);
|
ClassDB::bind_method(D_METHOD("larger_prime", "val"), &PMath::larger_prime);
|
||||||
ClassDB::bind_method(D_METHOD("seed", "x"), &_Math::seed);
|
ClassDB::bind_method(D_METHOD("seed", "x"), &PMath::seed);
|
||||||
ClassDB::bind_method(D_METHOD("randomize"), &_Math::randomize);
|
ClassDB::bind_method(D_METHOD("randomize"), &PMath::randomize);
|
||||||
ClassDB::bind_method(D_METHOD("rand"), &_Math::rand);
|
ClassDB::bind_method(D_METHOD("rand"), &PMath::rand);
|
||||||
ClassDB::bind_method(D_METHOD("randd"), &_Math::randd);
|
ClassDB::bind_method(D_METHOD("randd"), &PMath::randd);
|
||||||
ClassDB::bind_method(D_METHOD("randf"), &_Math::randf);
|
ClassDB::bind_method(D_METHOD("randf"), &PMath::randf);
|
||||||
ClassDB::bind_method(D_METHOD("randfn", "mean", "deviation"), &_Math::randfn);
|
ClassDB::bind_method(D_METHOD("randfn", "mean", "deviation"), &PMath::randfn);
|
||||||
ClassDB::bind_method(D_METHOD("random", "from", "to"), &_Math::random);
|
ClassDB::bind_method(D_METHOD("random", "from", "to"), &PMath::random);
|
||||||
ClassDB::bind_method(D_METHOD("randomi", "from", "to"), &_Math::randomi);
|
ClassDB::bind_method(D_METHOD("randomi", "from", "to"), &PMath::randomi);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("is_equal_approx_ratio", "a", "b", "epsilon", "min_epsilon"), &_Math::is_equal_approx_ratio, CMP_EPSILON, CMP_EPSILON);
|
ClassDB::bind_method(D_METHOD("is_equal_approx_ratio", "a", "b", "epsilon", "min_epsilon"), &PMath::is_equal_approx_ratio, CMP_EPSILON, CMP_EPSILON);
|
||||||
ClassDB::bind_method(D_METHOD("is_equal_approx", "a", "b"), &_Math::is_equal_approx);
|
ClassDB::bind_method(D_METHOD("is_equal_approx", "a", "b"), &PMath::is_equal_approx);
|
||||||
ClassDB::bind_method(D_METHOD("is_equal_approxt", "a", "b", "tolerance"), &_Math::is_equal_approxt);
|
ClassDB::bind_method(D_METHOD("is_equal_approxt", "a", "b", "tolerance"), &PMath::is_equal_approxt);
|
||||||
ClassDB::bind_method(D_METHOD("is_zero_approx", "s"), &_Math::is_zero_approx);
|
ClassDB::bind_method(D_METHOD("is_zero_approx", "s"), &PMath::is_zero_approx);
|
||||||
ClassDB::bind_method(D_METHOD("absd", "g"), &_Math::absd);
|
ClassDB::bind_method(D_METHOD("absd", "g"), &PMath::absd);
|
||||||
ClassDB::bind_method(D_METHOD("fast_ftoi", "a"), &_Math::fast_ftoi);
|
ClassDB::bind_method(D_METHOD("fast_ftoi", "a"), &PMath::fast_ftoi);
|
||||||
ClassDB::bind_method(D_METHOD("halfbits_to_floatbits", "h"), &_Math::halfbits_to_floatbits);
|
ClassDB::bind_method(D_METHOD("halfbits_to_floatbits", "h"), &PMath::halfbits_to_floatbits);
|
||||||
ClassDB::bind_method(D_METHOD("half_to_float", "h"), &_Math::half_to_float);
|
ClassDB::bind_method(D_METHOD("half_to_float", "h"), &PMath::half_to_float);
|
||||||
ClassDB::bind_method(D_METHOD("make_half_float", "f"), &_Math::make_half_float);
|
ClassDB::bind_method(D_METHOD("make_half_float", "f"), &PMath::make_half_float);
|
||||||
ClassDB::bind_method(D_METHOD("snap_scalar", "offset", "step", "target"), &_Math::snap_scalar);
|
ClassDB::bind_method(D_METHOD("snap_scalar", "offset", "step", "target"), &PMath::snap_scalar);
|
||||||
ClassDB::bind_method(D_METHOD("snap_scalar_separation", "offset", "step", "target", "separation"), &_Math::snap_scalar_separation);
|
ClassDB::bind_method(D_METHOD("snap_scalar_separation", "offset", "step", "target", "separation"), &PMath::snap_scalar_separation);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////// GEOMETRY
|
///////////////////// GEOMETRY
|
||||||
|
@ -434,8 +434,10 @@ VARIANT_ENUM_CAST(_OS::SystemDir);
|
|||||||
VARIANT_ENUM_CAST(_OS::ScreenOrientation);
|
VARIANT_ENUM_CAST(_OS::ScreenOrientation);
|
||||||
VARIANT_ENUM_CAST(_OS::HandleType);
|
VARIANT_ENUM_CAST(_OS::HandleType);
|
||||||
|
|
||||||
class _Math : public Object {
|
// TODO Move this to a module
|
||||||
GDCLASS(_Math, Object);
|
|
||||||
|
class PMath : public Object {
|
||||||
|
GDCLASS(PMath, Object);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_ALWAYS_INLINE_ real_t sin(real_t p_x) {
|
_ALWAYS_INLINE_ real_t sin(real_t p_x) {
|
||||||
@ -725,13 +727,13 @@ public:
|
|||||||
return Math::snap_scalar_separation(p_offset, p_step, p_target, p_separation);
|
return Math::snap_scalar_separation(p_offset, p_step, p_target, p_separation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static _Math *get_singleton();
|
static PMath *get_singleton();
|
||||||
|
|
||||||
_Math();
|
PMath();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
static _Math *singleton;
|
static PMath *singleton;
|
||||||
};
|
};
|
||||||
|
|
||||||
class _Geometry : public Object {
|
class _Geometry : public Object {
|
||||||
|
@ -100,7 +100,7 @@ static ThreadPool *thread_pool = NULL;
|
|||||||
|
|
||||||
static IP *ip = nullptr;
|
static IP *ip = nullptr;
|
||||||
|
|
||||||
static _Math *_math = nullptr;
|
static PMath *_math = nullptr;
|
||||||
static _Geometry *_geometry = nullptr;
|
static _Geometry *_geometry = nullptr;
|
||||||
|
|
||||||
extern Mutex _global_mutex;
|
extern Mutex _global_mutex;
|
||||||
@ -230,7 +230,7 @@ void register_core_types() {
|
|||||||
|
|
||||||
ip = IP::create();
|
ip = IP::create();
|
||||||
|
|
||||||
_math = memnew(_Math);
|
_math = memnew(PMath);
|
||||||
_geometry = memnew(_Geometry);
|
_geometry = memnew(_Geometry);
|
||||||
|
|
||||||
_resource_loader = memnew(_ResourceLoader);
|
_resource_loader = memnew(_ResourceLoader);
|
||||||
@ -263,7 +263,7 @@ void register_core_settings() {
|
|||||||
void register_core_singletons() {
|
void register_core_singletons() {
|
||||||
ClassDB::register_class<ProjectSettings>();
|
ClassDB::register_class<ProjectSettings>();
|
||||||
ClassDB::register_virtual_class<IP>();
|
ClassDB::register_virtual_class<IP>();
|
||||||
ClassDB::register_class<_Math>();
|
ClassDB::register_class<PMath>();
|
||||||
ClassDB::register_class<_Geometry>();
|
ClassDB::register_class<_Geometry>();
|
||||||
ClassDB::register_class<_ResourceLoader>();
|
ClassDB::register_class<_ResourceLoader>();
|
||||||
ClassDB::register_class<_ResourceSaver>();
|
ClassDB::register_class<_ResourceSaver>();
|
||||||
@ -284,7 +284,7 @@ void register_core_singletons() {
|
|||||||
|
|
||||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
|
Engine::get_singleton()->add_singleton(Engine::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
|
||||||
Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton()));
|
Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton()));
|
||||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Math", _Math::get_singleton()));
|
Engine::get_singleton()->add_singleton(Engine::Singleton("PMath", PMath::get_singleton()));
|
||||||
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry", _Geometry::get_singleton()));
|
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry", _Geometry::get_singleton()));
|
||||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
|
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
|
||||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
|
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
|
||||||
|
Loading…
Reference in New Issue
Block a user