[Core] Expose approximate equality methods to GDScript
This commit is contained in:
parent
b2e1c9c276
commit
7f7d97f536
|
@ -498,6 +498,17 @@
|
|||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_equal_approx">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="a" type="float">
|
||||
</argument>
|
||||
<argument index="1" name="b" type="float">
|
||||
</argument>
|
||||
<description>
|
||||
Returns True/False whether [code]a[/code] and [code]b[/code] are approximately equal to each other.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_inf">
|
||||
<return type="bool">
|
||||
</return>
|
||||
|
@ -525,6 +536,15 @@
|
|||
Returns whether [code]s[/code] is a NaN (Not-A-Number) value.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_zero_approx">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="s" type="float">
|
||||
</argument>
|
||||
<description>
|
||||
Returns True/False whether [code]s[/code] is zero or almost zero.
|
||||
</description>
|
||||
</method>
|
||||
<method name="len">
|
||||
<return type="int">
|
||||
</return>
|
||||
|
|
|
@ -68,6 +68,8 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
|
|||
"exp",
|
||||
"is_nan",
|
||||
"is_inf",
|
||||
"is_equal_approx",
|
||||
"is_zero_approx",
|
||||
"ease",
|
||||
"decimals",
|
||||
"stepify",
|
||||
|
@ -316,6 +318,17 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||
VALIDATE_ARG_NUM(0);
|
||||
r_ret = Math::is_inf((double)*p_args[0]);
|
||||
} break;
|
||||
case MATH_ISEQUALAPPROX: {
|
||||
VALIDATE_ARG_COUNT(2);
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
r_ret = Math::is_equal_approx((real_t)*p_args[0], (real_t)*p_args[1]);
|
||||
} break;
|
||||
case MATH_ISZEROAPPROX: {
|
||||
VALIDATE_ARG_COUNT(1);
|
||||
VALIDATE_ARG_NUM(0);
|
||||
r_ret = Math::is_zero_approx((real_t)*p_args[0]);
|
||||
} break;
|
||||
case MATH_EASE: {
|
||||
VALIDATE_ARG_COUNT(2);
|
||||
VALIDATE_ARG_NUM(0);
|
||||
|
@ -1596,6 +1609,16 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
|
|||
mi.return_val.type = Variant::BOOL;
|
||||
return mi;
|
||||
} break;
|
||||
case MATH_ISEQUALAPPROX: {
|
||||
MethodInfo mi("is_equal_approx", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
|
||||
mi.return_val.type = Variant::BOOL;
|
||||
return mi;
|
||||
} break;
|
||||
case MATH_ISZEROAPPROX: {
|
||||
MethodInfo mi("is_zero_approx", PropertyInfo(Variant::REAL, "s"));
|
||||
mi.return_val.type = Variant::BOOL;
|
||||
return mi;
|
||||
} break;
|
||||
case MATH_EASE: {
|
||||
MethodInfo mi("ease", PropertyInfo(Variant::REAL, "s"), PropertyInfo(Variant::REAL, "curve"));
|
||||
mi.return_val.type = Variant::REAL;
|
||||
|
|
|
@ -59,6 +59,8 @@ public:
|
|||
MATH_EXP,
|
||||
MATH_ISNAN,
|
||||
MATH_ISINF,
|
||||
MATH_ISEQUALAPPROX,
|
||||
MATH_ISZEROAPPROX,
|
||||
MATH_EASE,
|
||||
MATH_DECIMALS,
|
||||
MATH_STEPIFY,
|
||||
|
|
Loading…
Reference in New Issue