2017-03-05 14:47:28 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* visual_script_builtin_funcs.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2016-08-02 22:11:05 +00:00
|
|
|
#include "visual_script_builtin_funcs.h"
|
2017-03-05 14:47:28 +00:00
|
|
|
|
2016-08-06 01:46:45 +00:00
|
|
|
#include "math_funcs.h"
|
2017-01-16 07:04:19 +00:00
|
|
|
#include "class_db.h"
|
2016-08-06 01:46:45 +00:00
|
|
|
#include "reference.h"
|
|
|
|
#include "func_ref.h"
|
|
|
|
#include "os/os.h"
|
|
|
|
#include "variant_parser.h"
|
|
|
|
#include "io/marshalls.h"
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
const char* VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX]={
|
|
|
|
"sin",
|
|
|
|
"cos",
|
|
|
|
"tan",
|
|
|
|
"sinh",
|
|
|
|
"cosh",
|
|
|
|
"tanh",
|
|
|
|
"asin",
|
|
|
|
"acos",
|
|
|
|
"atan",
|
|
|
|
"atan2",
|
|
|
|
"sqrt",
|
|
|
|
"fmod",
|
|
|
|
"fposmod",
|
|
|
|
"floor",
|
|
|
|
"ceil",
|
|
|
|
"round",
|
|
|
|
"abs",
|
|
|
|
"sign",
|
|
|
|
"pow",
|
|
|
|
"log",
|
|
|
|
"exp",
|
|
|
|
"is_nan",
|
|
|
|
"is_inf",
|
|
|
|
"ease",
|
|
|
|
"decimals",
|
|
|
|
"stepify",
|
|
|
|
"lerp",
|
|
|
|
"dectime",
|
|
|
|
"randomize",
|
|
|
|
"randi",
|
|
|
|
"randf",
|
|
|
|
"rand_range",
|
|
|
|
"seed",
|
|
|
|
"rand_seed",
|
|
|
|
"deg2rad",
|
|
|
|
"rad2deg",
|
|
|
|
"linear2db",
|
|
|
|
"db2linear",
|
|
|
|
"max",
|
|
|
|
"min",
|
|
|
|
"clamp",
|
|
|
|
"nearest_po2",
|
|
|
|
"weakref",
|
|
|
|
"funcref",
|
|
|
|
"convert",
|
|
|
|
"typeof",
|
|
|
|
"type_exists",
|
2016-10-03 16:17:54 +00:00
|
|
|
"char",
|
2016-08-02 22:11:05 +00:00
|
|
|
"str",
|
|
|
|
"print",
|
|
|
|
"printerr",
|
|
|
|
"printraw",
|
|
|
|
"var2str",
|
|
|
|
"str2var",
|
|
|
|
"var2bytes",
|
|
|
|
"bytes2var",
|
2016-11-10 21:06:00 +00:00
|
|
|
"color_named",
|
2016-08-02 22:11:05 +00:00
|
|
|
};
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::find_function(const String& p_string) {
|
|
|
|
|
|
|
|
for(int i=0;i<FUNC_MAX;i++) {
|
|
|
|
if (p_string==func_name[i])
|
|
|
|
return BuiltinFunc(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FUNC_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptBuiltinFunc::get_func_name(BuiltinFunc p_func) {
|
|
|
|
|
|
|
|
ERR_FAIL_INDEX_V(p_func,FUNC_MAX,String());
|
|
|
|
return func_name[p_func];
|
|
|
|
}
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
int VisualScriptBuiltinFunc::get_output_sequence_port_count() const {
|
|
|
|
|
2016-08-31 02:44:14 +00:00
|
|
|
return has_input_sequence_port() ? 1 : 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool VisualScriptBuiltinFunc::has_input_sequence_port() const{
|
|
|
|
|
2016-08-31 02:44:14 +00:00
|
|
|
switch(func) {
|
|
|
|
|
|
|
|
case MATH_RANDOMIZE:
|
|
|
|
case TEXT_PRINT:
|
|
|
|
case TEXT_PRINTERR:
|
|
|
|
case TEXT_PRINTRAW:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
switch(p_func) {
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
case MATH_RANDOMIZE:
|
|
|
|
case MATH_RAND:
|
|
|
|
case MATH_RANDF:
|
|
|
|
return 0;
|
|
|
|
case MATH_SIN:
|
|
|
|
case MATH_COS:
|
|
|
|
case MATH_TAN:
|
|
|
|
case MATH_SINH:
|
|
|
|
case MATH_COSH:
|
|
|
|
case MATH_TANH:
|
|
|
|
case MATH_ASIN:
|
|
|
|
case MATH_ACOS:
|
|
|
|
case MATH_ATAN:
|
|
|
|
case MATH_SQRT:
|
|
|
|
case MATH_FLOOR:
|
|
|
|
case MATH_CEIL:
|
|
|
|
case MATH_ROUND:
|
|
|
|
case MATH_ABS:
|
|
|
|
case MATH_SIGN:
|
|
|
|
case MATH_LOG:
|
|
|
|
case MATH_EXP:
|
|
|
|
case MATH_ISNAN:
|
|
|
|
case MATH_ISINF:
|
|
|
|
case MATH_DECIMALS:
|
|
|
|
case MATH_SEED:
|
|
|
|
case MATH_RANDSEED:
|
|
|
|
case MATH_DEG2RAD:
|
|
|
|
case MATH_RAD2DEG:
|
|
|
|
case MATH_LINEAR2DB:
|
|
|
|
case MATH_DB2LINEAR:
|
|
|
|
case LOGIC_NEAREST_PO2:
|
|
|
|
case OBJ_WEAKREF:
|
|
|
|
case TYPE_OF:
|
2016-10-03 16:17:54 +00:00
|
|
|
case TEXT_CHAR:
|
2016-08-02 22:11:05 +00:00
|
|
|
case TEXT_STR:
|
|
|
|
case TEXT_PRINT:
|
|
|
|
case TEXT_PRINTERR:
|
|
|
|
case TEXT_PRINTRAW:
|
|
|
|
case VAR_TO_STR:
|
|
|
|
case STR_TO_VAR:
|
|
|
|
case VAR_TO_BYTES:
|
|
|
|
case BYTES_TO_VAR:
|
|
|
|
case TYPE_EXISTS:
|
|
|
|
return 1;
|
|
|
|
case MATH_ATAN2:
|
|
|
|
case MATH_FMOD:
|
|
|
|
case MATH_FPOSMOD:
|
|
|
|
case MATH_POW:
|
|
|
|
case MATH_EASE:
|
|
|
|
case MATH_STEPIFY:
|
|
|
|
case MATH_RANDOM:
|
|
|
|
case LOGIC_MAX:
|
|
|
|
case LOGIC_MIN:
|
|
|
|
case FUNC_FUNCREF:
|
|
|
|
case TYPE_CONVERT:
|
2016-11-10 21:06:00 +00:00
|
|
|
case COLORN:
|
2016-08-02 22:11:05 +00:00
|
|
|
return 2;
|
|
|
|
case MATH_LERP:
|
|
|
|
case MATH_DECTIME:
|
|
|
|
case LOGIC_CLAMP:
|
|
|
|
return 3;
|
|
|
|
case FUNC_MAX:{}
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-09-06 22:12:28 +00:00
|
|
|
|
|
|
|
int VisualScriptBuiltinFunc::get_input_value_port_count() const{
|
|
|
|
|
|
|
|
return get_func_argument_count(func);
|
|
|
|
}
|
2016-08-02 22:11:05 +00:00
|
|
|
int VisualScriptBuiltinFunc::get_output_value_port_count() const{
|
|
|
|
|
|
|
|
switch(func) {
|
|
|
|
case MATH_RANDOMIZE:
|
|
|
|
case TEXT_PRINT:
|
|
|
|
case TEXT_PRINTERR:
|
|
|
|
case TEXT_PRINTRAW:
|
|
|
|
case MATH_SEED:
|
|
|
|
return 0;
|
|
|
|
case MATH_RANDSEED:
|
|
|
|
return 2;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptBuiltinFunc::get_output_sequence_port_text(int p_port) const {
|
|
|
|
|
|
|
|
return String();
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const{
|
|
|
|
|
|
|
|
switch(func) {
|
|
|
|
|
|
|
|
case MATH_SIN:
|
|
|
|
case MATH_COS:
|
|
|
|
case MATH_TAN:
|
|
|
|
case MATH_SINH:
|
|
|
|
case MATH_COSH:
|
|
|
|
case MATH_TANH:
|
|
|
|
case MATH_ASIN:
|
|
|
|
case MATH_ACOS:
|
|
|
|
case MATH_ATAN:
|
|
|
|
case MATH_ATAN2:
|
|
|
|
case MATH_SQRT: {
|
|
|
|
return PropertyInfo(Variant::REAL,"num");
|
|
|
|
} break;
|
|
|
|
case MATH_FMOD:
|
|
|
|
case MATH_FPOSMOD: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"x");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"y");
|
|
|
|
} break;
|
|
|
|
case MATH_FLOOR:
|
|
|
|
case MATH_CEIL:
|
|
|
|
case MATH_ROUND:
|
|
|
|
case MATH_ABS:
|
|
|
|
case MATH_SIGN: {
|
|
|
|
return PropertyInfo(Variant::REAL,"num");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MATH_POW: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"x");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"y");
|
|
|
|
} break;
|
|
|
|
case MATH_LOG:
|
|
|
|
case MATH_EXP:
|
|
|
|
case MATH_ISNAN:
|
|
|
|
case MATH_ISINF: {
|
|
|
|
return PropertyInfo(Variant::REAL,"num");
|
|
|
|
} break;
|
|
|
|
case MATH_EASE: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"s");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"curve");
|
|
|
|
} break;
|
|
|
|
case MATH_DECIMALS: {
|
|
|
|
return PropertyInfo(Variant::REAL,"step");
|
|
|
|
} break;
|
|
|
|
case MATH_STEPIFY: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"s");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"steps");
|
|
|
|
} break;
|
|
|
|
case MATH_LERP: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"from");
|
|
|
|
else if (p_idx==1)
|
|
|
|
return PropertyInfo(Variant::REAL,"to");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"weight");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MATH_DECTIME: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"value");
|
|
|
|
else if (p_idx==1)
|
|
|
|
return PropertyInfo(Variant::REAL,"amount");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"step");
|
|
|
|
} break;
|
|
|
|
case MATH_RANDOMIZE: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MATH_RAND: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MATH_RANDF: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MATH_RANDOM: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"from");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"to");
|
|
|
|
} break;
|
|
|
|
case MATH_SEED: {
|
|
|
|
return PropertyInfo(Variant::INT,"seed");
|
|
|
|
} break;
|
|
|
|
case MATH_RANDSEED: {
|
|
|
|
return PropertyInfo(Variant::INT,"seed");
|
|
|
|
} break;
|
|
|
|
case MATH_DEG2RAD: {
|
|
|
|
return PropertyInfo(Variant::REAL,"deg");
|
|
|
|
} break;
|
|
|
|
case MATH_RAD2DEG: {
|
|
|
|
return PropertyInfo(Variant::REAL,"rad");
|
|
|
|
} break;
|
|
|
|
case MATH_LINEAR2DB: {
|
|
|
|
return PropertyInfo(Variant::REAL,"nrg");
|
|
|
|
} break;
|
|
|
|
case MATH_DB2LINEAR: {
|
|
|
|
return PropertyInfo(Variant::REAL,"db");
|
|
|
|
} break;
|
|
|
|
case LOGIC_MAX: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"a");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"b");
|
|
|
|
} break;
|
|
|
|
case LOGIC_MIN: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"a");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"b");
|
|
|
|
} break;
|
|
|
|
case LOGIC_CLAMP: {
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::REAL,"a");
|
2017-03-02 22:13:01 +00:00
|
|
|
else if (p_idx==0) // FIXME: is it ok to test p_idx == 0 twice?
|
2016-08-02 22:11:05 +00:00
|
|
|
return PropertyInfo(Variant::REAL,"min");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"max");
|
|
|
|
} break;
|
|
|
|
case LOGIC_NEAREST_PO2: {
|
|
|
|
return PropertyInfo(Variant::INT,"num");
|
|
|
|
} break;
|
|
|
|
case OBJ_WEAKREF: {
|
|
|
|
|
|
|
|
return PropertyInfo(Variant::OBJECT,"source");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case FUNC_FUNCREF: {
|
|
|
|
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::OBJECT,"instance");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::STRING,"funcname");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TYPE_CONVERT: {
|
|
|
|
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::NIL,"what");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::STRING,"type");
|
|
|
|
} break;
|
|
|
|
case TYPE_OF: {
|
|
|
|
return PropertyInfo(Variant::NIL,"what");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TYPE_EXISTS: {
|
|
|
|
|
|
|
|
return PropertyInfo(Variant::STRING,"type");
|
|
|
|
|
2016-10-03 16:17:54 +00:00
|
|
|
} break;
|
|
|
|
case TEXT_CHAR: {
|
|
|
|
|
|
|
|
return PropertyInfo(Variant::INT,"ascii");
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
} break;
|
|
|
|
case TEXT_STR: {
|
|
|
|
|
|
|
|
return PropertyInfo(Variant::NIL,"value");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TEXT_PRINT: {
|
|
|
|
|
|
|
|
return PropertyInfo(Variant::NIL,"value");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TEXT_PRINTERR: {
|
|
|
|
return PropertyInfo(Variant::NIL,"value");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TEXT_PRINTRAW: {
|
|
|
|
|
|
|
|
return PropertyInfo(Variant::NIL,"value");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case VAR_TO_STR: {
|
|
|
|
return PropertyInfo(Variant::NIL,"var");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case STR_TO_VAR: {
|
|
|
|
|
|
|
|
return PropertyInfo(Variant::STRING,"string");
|
|
|
|
} break;
|
|
|
|
case VAR_TO_BYTES: {
|
|
|
|
return PropertyInfo(Variant::NIL,"var");
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case BYTES_TO_VAR: {
|
|
|
|
|
2017-01-11 03:52:51 +00:00
|
|
|
return PropertyInfo(Variant::POOL_BYTE_ARRAY,"bytes");
|
2016-08-02 22:11:05 +00:00
|
|
|
} break;
|
2016-11-10 21:06:00 +00:00
|
|
|
case COLORN: {
|
|
|
|
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::STRING,"name");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::REAL,"alpha");
|
|
|
|
|
|
|
|
} break;
|
2016-08-02 22:11:05 +00:00
|
|
|
case FUNC_MAX:{}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PropertyInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) const{
|
|
|
|
|
|
|
|
Variant::Type t=Variant::NIL;
|
|
|
|
switch(func) {
|
|
|
|
|
|
|
|
case MATH_SIN:
|
|
|
|
case MATH_COS:
|
|
|
|
case MATH_TAN:
|
|
|
|
case MATH_SINH:
|
|
|
|
case MATH_COSH:
|
|
|
|
case MATH_TANH:
|
|
|
|
case MATH_ASIN:
|
|
|
|
case MATH_ACOS:
|
|
|
|
case MATH_ATAN:
|
|
|
|
case MATH_ATAN2:
|
|
|
|
case MATH_SQRT:
|
|
|
|
case MATH_FMOD:
|
|
|
|
case MATH_FPOSMOD:
|
|
|
|
case MATH_FLOOR:
|
2016-08-04 01:06:39 +00:00
|
|
|
case MATH_CEIL: {
|
2016-08-02 22:11:05 +00:00
|
|
|
t=Variant::REAL;
|
2016-08-04 01:06:39 +00:00
|
|
|
} break;
|
2016-08-02 22:11:05 +00:00
|
|
|
case MATH_ROUND: {
|
|
|
|
t=Variant::INT;
|
|
|
|
} break;
|
|
|
|
case MATH_ABS: {
|
|
|
|
t=Variant::NIL;
|
|
|
|
} break;
|
|
|
|
case MATH_SIGN: {
|
|
|
|
t=Variant::NIL;
|
|
|
|
} break;
|
|
|
|
case MATH_POW:
|
|
|
|
case MATH_LOG:
|
|
|
|
case MATH_EXP: {
|
|
|
|
t=Variant::REAL;
|
|
|
|
} break;
|
|
|
|
case MATH_ISNAN:
|
|
|
|
case MATH_ISINF: {
|
|
|
|
t=Variant::BOOL;
|
|
|
|
} break;
|
|
|
|
case MATH_EASE: {
|
|
|
|
t=Variant::REAL;
|
|
|
|
} break;
|
|
|
|
case MATH_DECIMALS: {
|
|
|
|
t=Variant::INT;
|
|
|
|
} break;
|
|
|
|
case MATH_STEPIFY:
|
|
|
|
case MATH_LERP:
|
|
|
|
case MATH_DECTIME: {
|
|
|
|
t=Variant::REAL;
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MATH_RANDOMIZE: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MATH_RAND: {
|
|
|
|
|
|
|
|
t=Variant::INT;
|
|
|
|
} break;
|
|
|
|
case MATH_RANDF:
|
|
|
|
case MATH_RANDOM: {
|
|
|
|
t=Variant::REAL;
|
|
|
|
} break;
|
|
|
|
case MATH_SEED: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MATH_RANDSEED: {
|
|
|
|
|
|
|
|
if (p_idx==0)
|
|
|
|
return PropertyInfo(Variant::INT,"rnd");
|
|
|
|
else
|
|
|
|
return PropertyInfo(Variant::INT,"seed");
|
|
|
|
} break;
|
|
|
|
case MATH_DEG2RAD:
|
|
|
|
case MATH_RAD2DEG:
|
|
|
|
case MATH_LINEAR2DB:
|
|
|
|
case MATH_DB2LINEAR: {
|
|
|
|
t=Variant::REAL;
|
|
|
|
} break;
|
|
|
|
case LOGIC_MAX:
|
|
|
|
case LOGIC_MIN:
|
|
|
|
case LOGIC_CLAMP: {
|
|
|
|
|
|
|
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case LOGIC_NEAREST_PO2: {
|
|
|
|
t=Variant::NIL;
|
|
|
|
} break;
|
|
|
|
case OBJ_WEAKREF: {
|
|
|
|
|
|
|
|
t=Variant::OBJECT;
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case FUNC_FUNCREF: {
|
|
|
|
|
|
|
|
t=Variant::OBJECT;
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TYPE_CONVERT: {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TYPE_OF: {
|
|
|
|
t=Variant::INT;
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TYPE_EXISTS: {
|
|
|
|
|
|
|
|
t=Variant::BOOL;
|
|
|
|
|
|
|
|
} break;
|
2016-10-03 16:17:54 +00:00
|
|
|
case TEXT_CHAR:
|
2016-08-02 22:11:05 +00:00
|
|
|
case TEXT_STR: {
|
|
|
|
|
|
|
|
t=Variant::STRING;
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TEXT_PRINT: {
|
|
|
|
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TEXT_PRINTERR: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case TEXT_PRINTRAW: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case VAR_TO_STR: {
|
|
|
|
t=Variant::STRING;
|
|
|
|
} break;
|
|
|
|
case STR_TO_VAR: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case VAR_TO_BYTES: {
|
2017-01-11 03:52:51 +00:00
|
|
|
t=Variant::POOL_BYTE_ARRAY;
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case BYTES_TO_VAR: {
|
|
|
|
|
|
|
|
|
2016-11-10 21:06:00 +00:00
|
|
|
} break;
|
|
|
|
case COLORN: {
|
|
|
|
t=Variant::COLOR;
|
2016-08-02 22:11:05 +00:00
|
|
|
} break;
|
|
|
|
case FUNC_MAX:{}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PropertyInfo(t,"");
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptBuiltinFunc::get_caption() const {
|
|
|
|
|
|
|
|
return "BuiltinFunc";
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptBuiltinFunc::get_text() const {
|
|
|
|
|
|
|
|
return func_name[func];
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptBuiltinFunc::set_func(BuiltinFunc p_which) {
|
|
|
|
|
|
|
|
ERR_FAIL_INDEX(p_which,FUNC_MAX);
|
|
|
|
func=p_which;
|
|
|
|
_change_notify();
|
2016-08-04 01:06:39 +00:00
|
|
|
ports_changed_notify();
|
2016-08-02 22:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::get_func() {
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-06 01:46:45 +00:00
|
|
|
#define VALIDATE_ARG_NUM(m_arg) \
|
|
|
|
if (!p_inputs[m_arg]->is_num()) {\
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;\
|
|
|
|
r_error.argument=m_arg;\
|
|
|
|
r_error.expected=Variant::REAL;\
|
2016-09-06 22:12:28 +00:00
|
|
|
return;\
|
2016-08-06 01:46:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inputs,Variant* r_return,Variant::CallError& r_error,String& r_error_str) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
switch(p_func) {
|
|
|
|
case VisualScriptBuiltinFunc::MATH_SIN: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::sin((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_COS: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::cos((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_TAN: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::tan((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_SINH: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::sinh((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_COSH: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::cosh((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_TANH: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::tanh((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_ASIN: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::asin((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_ACOS: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::acos((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_ATAN: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::atan((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_ATAN2: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::atan2((double)*p_inputs[0],(double)*p_inputs[1]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_SQRT: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::sqrt((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_FMOD: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::fmod((double)*p_inputs[0],(double)*p_inputs[1]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_FPOSMOD: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::fposmod((double)*p_inputs[0],(double)*p_inputs[1]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_FLOOR: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::floor((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_CEIL: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::ceil((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_ROUND: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::round((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_ABS: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
if (p_inputs[0]->get_type()==Variant::INT) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
int64_t i = *p_inputs[0];
|
|
|
|
*r_return=ABS(i);
|
|
|
|
} else if (p_inputs[0]->get_type()==Variant::REAL) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
real_t r = *p_inputs[0];
|
|
|
|
*r_return=Math::abs(r);
|
|
|
|
} else {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
|
|
|
r_error.expected=Variant::REAL;
|
|
|
|
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_SIGN: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
if (p_inputs[0]->get_type()==Variant::INT) {
|
|
|
|
|
|
|
|
int64_t i = *p_inputs[0];
|
2016-09-06 22:12:28 +00:00
|
|
|
*r_return= i < 0 ? -1 : ( i > 0 ? +1 : 0);
|
2016-08-06 01:46:45 +00:00
|
|
|
} else if (p_inputs[0]->get_type()==Variant::REAL) {
|
|
|
|
|
|
|
|
real_t r = *p_inputs[0];
|
2016-09-06 22:12:28 +00:00
|
|
|
*r_return= r < 0.0 ? -1.0 : ( r > 0.0 ? +1.0 : 0.0);
|
2016-08-06 01:46:45 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
|
|
|
r_error.expected=Variant::REAL;
|
|
|
|
|
|
|
|
}
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_POW: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::pow((double)*p_inputs[0],(double)*p_inputs[1]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_LOG: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::log((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_EXP: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::exp((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_ISNAN: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::is_nan((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_ISINF: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::is_inf((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_EASE: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::ease((double)*p_inputs[0],(double)*p_inputs[1]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_DECIMALS: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::step_decimals((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_STEPIFY: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::stepify((double)*p_inputs[0],(double)*p_inputs[1]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_LERP: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
|
|
|
VALIDATE_ARG_NUM(2);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::lerp((double)*p_inputs[0],(double)*p_inputs[1],(double)*p_inputs[2]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_DECTIME: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
|
|
|
VALIDATE_ARG_NUM(2);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::dectime((double)*p_inputs[0],(double)*p_inputs[1],(double)*p_inputs[2]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_RANDOMIZE: {
|
|
|
|
Math::randomize();
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_RAND: {
|
|
|
|
*r_return=Math::rand();
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_RANDF: {
|
|
|
|
*r_return=Math::randf();
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_RANDOM: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::random((double)*p_inputs[0],(double)*p_inputs[1]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_SEED: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-15 05:34:51 +00:00
|
|
|
uint64_t seed=*p_inputs[0];
|
2016-09-06 22:12:28 +00:00
|
|
|
Math::seed(seed);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_RANDSEED: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-15 05:34:51 +00:00
|
|
|
uint64_t seed=*p_inputs[0];
|
2016-09-06 22:12:28 +00:00
|
|
|
int ret = Math::rand_from_seed(&seed);
|
|
|
|
Array reta;
|
|
|
|
reta.push_back(ret);
|
|
|
|
reta.push_back(seed);
|
|
|
|
*r_return=reta;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_DEG2RAD: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::deg2rad((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_RAD2DEG: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::rad2deg((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_LINEAR2DB: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::linear2db((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::MATH_DB2LINEAR: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2017-01-14 20:35:39 +00:00
|
|
|
*r_return=Math::db2linear((double)*p_inputs[0]);
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::LOGIC_MAX: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
if (p_inputs[0]->get_type()==Variant::INT && p_inputs[1]->get_type()==Variant::INT) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
int64_t a = *p_inputs[0];
|
|
|
|
int64_t b = *p_inputs[1];
|
|
|
|
*r_return=MAX(a,b);
|
|
|
|
} else {
|
2016-08-06 01:46:45 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(1);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
real_t a = *p_inputs[0];
|
|
|
|
real_t b = *p_inputs[1];
|
|
|
|
|
|
|
|
*r_return=MAX(a,b);
|
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::LOGIC_MIN: {
|
|
|
|
|
|
|
|
if (p_inputs[0]->get_type()==Variant::INT && p_inputs[1]->get_type()==Variant::INT) {
|
|
|
|
|
|
|
|
int64_t a = *p_inputs[0];
|
|
|
|
int64_t b = *p_inputs[1];
|
|
|
|
*r_return=MIN(a,b);
|
|
|
|
} else {
|
2016-08-06 01:46:45 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(1);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
real_t a = *p_inputs[0];
|
|
|
|
real_t b = *p_inputs[1];
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
*r_return=MIN(a,b);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::LOGIC_CLAMP: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
if (p_inputs[0]->get_type()==Variant::INT && p_inputs[1]->get_type()==Variant::INT && p_inputs[2]->get_type()==Variant::INT) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
int64_t a = *p_inputs[0];
|
|
|
|
int64_t b = *p_inputs[1];
|
|
|
|
int64_t c = *p_inputs[2];
|
|
|
|
*r_return=CLAMP(a,b,c);
|
|
|
|
} else {
|
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
VALIDATE_ARG_NUM(1);
|
|
|
|
VALIDATE_ARG_NUM(2);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
real_t a = *p_inputs[0];
|
|
|
|
real_t b = *p_inputs[1];
|
|
|
|
real_t c = *p_inputs[2];
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
*r_return=CLAMP(a,b,c);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::LOGIC_NEAREST_PO2: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(0);
|
|
|
|
int64_t num = *p_inputs[0];
|
|
|
|
*r_return = nearest_power_of_2(num);
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::OBJ_WEAKREF: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
if (p_inputs[0]->get_type()!=Variant::OBJECT) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
|
|
|
r_error.expected=Variant::OBJECT;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
return;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
if (p_inputs[0]->is_ref()) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
REF r = *p_inputs[0];
|
|
|
|
if (!r.is_valid()) {
|
|
|
|
|
|
|
|
return;
|
2016-08-06 01:46:45 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
Ref<WeakRef> wref = memnew( WeakRef );
|
|
|
|
wref->set_ref(r);
|
|
|
|
*r_return=wref;
|
|
|
|
} else {
|
|
|
|
Object *obj = *p_inputs[0];
|
|
|
|
if (!obj) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
Ref<WeakRef> wref = memnew( WeakRef );
|
|
|
|
wref->set_obj(obj);
|
|
|
|
*r_return=wref;
|
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::FUNC_FUNCREF: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
if (p_inputs[0]->get_type()!=Variant::OBJECT) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
|
|
|
r_error.expected=Variant::OBJECT;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
return;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
}
|
|
|
|
if (p_inputs[1]->get_type()!=Variant::STRING && p_inputs[1]->get_type()!=Variant::NODE_PATH) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=1;
|
|
|
|
r_error.expected=Variant::STRING;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
return;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
Ref<FuncRef> fr = memnew( FuncRef);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
fr->set_instance(*p_inputs[0]);
|
|
|
|
fr->set_function(*p_inputs[1]);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
*r_return=fr;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::TYPE_CONVERT: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VALIDATE_ARG_NUM(1);
|
|
|
|
int type=*p_inputs[1];
|
|
|
|
if (type<0 || type>=Variant::VARIANT_MAX) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
r_error_str=RTR("Invalid type argument to convert(), use TYPE_* constants.");
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
|
|
|
r_error.expected=Variant::INT;
|
|
|
|
return;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} else {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
*r_return=Variant::construct(Variant::Type(type),p_inputs,1,r_error);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::TYPE_OF: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
*r_return = p_inputs[0]->get_type();
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::TYPE_EXISTS: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2017-01-03 02:03:46 +00:00
|
|
|
*r_return = ClassDB::class_exists(*p_inputs[0]);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-10-03 16:17:54 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::TEXT_CHAR: {
|
|
|
|
|
|
|
|
CharType result[2] = {*p_inputs[0], 0};
|
|
|
|
|
|
|
|
*r_return=String(result);
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::TEXT_STR: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
String str = *p_inputs[0];
|
|
|
|
|
|
|
|
*r_return=str;
|
2016-08-02 22:11:05 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::TEXT_PRINT: {
|
2016-08-02 22:11:05 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
String str = *p_inputs[0];
|
|
|
|
print_line(str);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
case VisualScriptBuiltinFunc::TEXT_PRINTERR: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
String str = *p_inputs[0];
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
//str+="\n";
|
|
|
|
OS::get_singleton()->printerr("%s\n",str.utf8().get_data());
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::TEXT_PRINTRAW: {
|
|
|
|
String str = *p_inputs[0];
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
//str+="\n";
|
|
|
|
OS::get_singleton()->print("%s",str.utf8().get_data());
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::VAR_TO_STR: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
String vars;
|
|
|
|
VariantWriter::write_to_string(*p_inputs[0],vars);
|
|
|
|
*r_return=vars;
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::STR_TO_VAR: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
if (p_inputs[0]->get_type()!=Variant::STRING) {
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
|
|
|
r_error.expected=Variant::STRING;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VariantParser::StreamString ss;
|
|
|
|
ss.s=*p_inputs[0];
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
String errs;
|
|
|
|
int line;
|
|
|
|
Error err = VariantParser::parse(&ss,*r_return,errs,line);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
if (err!=OK) {
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
|
|
|
r_error.expected=Variant::STRING;
|
|
|
|
*r_return="Parse error at line "+itos(line)+": "+errs;
|
|
|
|
return;
|
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::VAR_TO_BYTES: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2017-01-11 03:52:51 +00:00
|
|
|
PoolByteArray barr;
|
2016-09-06 22:12:28 +00:00
|
|
|
int len;
|
|
|
|
Error err = encode_variant(*p_inputs[0],NULL,len);
|
|
|
|
if (err) {
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
|
|
|
r_error.expected=Variant::NIL;
|
|
|
|
r_error_str="Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).";
|
|
|
|
return;
|
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
barr.resize(len);
|
|
|
|
{
|
2017-01-11 03:52:51 +00:00
|
|
|
PoolByteArray::Write w = barr.write();
|
2016-09-06 22:12:28 +00:00
|
|
|
encode_variant(*p_inputs[0],w.ptr(),len);
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
}
|
|
|
|
*r_return=barr;
|
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::BYTES_TO_VAR: {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2017-01-11 03:52:51 +00:00
|
|
|
if (p_inputs[0]->get_type()!=Variant::POOL_BYTE_ARRAY) {
|
2016-09-06 22:12:28 +00:00
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
2017-01-11 03:52:51 +00:00
|
|
|
r_error.expected=Variant::POOL_BYTE_ARRAY;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2017-01-11 03:52:51 +00:00
|
|
|
PoolByteArray varr=*p_inputs[0];
|
2016-09-06 22:12:28 +00:00
|
|
|
Variant ret;
|
|
|
|
{
|
2017-01-11 03:52:51 +00:00
|
|
|
PoolByteArray::Read r=varr.read();
|
2016-09-06 22:12:28 +00:00
|
|
|
Error err = decode_variant(ret,r.ptr(),varr.size(),NULL);
|
2016-08-06 01:46:45 +00:00
|
|
|
if (err!=OK) {
|
2016-09-06 22:12:28 +00:00
|
|
|
r_error_str=RTR("Not enough bytes for decoding bytes, or invalid format.");
|
2016-08-06 01:46:45 +00:00
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
|
|
|
r_error.argument=0;
|
2017-01-11 03:52:51 +00:00
|
|
|
r_error.expected=Variant::POOL_BYTE_ARRAY;
|
2016-09-06 22:12:28 +00:00
|
|
|
return;
|
2016-08-06 01:46:45 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
*r_return=ret;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-11-10 21:06:00 +00:00
|
|
|
} break;
|
|
|
|
case VisualScriptBuiltinFunc::COLORN: {
|
|
|
|
|
|
|
|
VALIDATE_ARG_NUM(1);
|
|
|
|
|
|
|
|
Color color = Color::named(*p_inputs[0]);
|
|
|
|
color.a=*p_inputs[1];
|
|
|
|
|
|
|
|
*r_return=String(color);
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
} break;
|
|
|
|
default: {}
|
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
}
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
class VisualScriptNodeInstanceBuiltinFunc : public VisualScriptNodeInstance {
|
|
|
|
public:
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VisualScriptBuiltinFunc *node;
|
|
|
|
VisualScriptInstance *instance;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VisualScriptBuiltinFunc::BuiltinFunc func;
|
2016-08-06 01:46:45 +00:00
|
|
|
|
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
//virtual int get_working_memory_size() const { return 0; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
|
|
|
|
|
|
|
virtual int step(const Variant** p_inputs,Variant** p_outputs,StartMode p_start_mode,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-09-06 22:12:28 +00:00
|
|
|
VisualScriptBuiltinFunc::exec_func(func,p_inputs,p_outputs[0],r_error,r_error_str);
|
2016-08-06 01:46:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
VisualScriptNodeInstance* VisualScriptBuiltinFunc::instance(VisualScriptInstance* p_instance) {
|
|
|
|
|
|
|
|
VisualScriptNodeInstanceBuiltinFunc * instance = memnew(VisualScriptNodeInstanceBuiltinFunc );
|
|
|
|
instance->node=this;
|
|
|
|
instance->instance=p_instance;
|
|
|
|
instance->func=func;
|
|
|
|
return instance;
|
2016-08-02 22:11:05 +00:00
|
|
|
}
|
|
|
|
|
2016-08-06 01:46:45 +00:00
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
void VisualScriptBuiltinFunc::_bind_methods() {
|
|
|
|
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_func","which"),&VisualScriptBuiltinFunc::set_func);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_func"),&VisualScriptBuiltinFunc::get_func);
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
String cc;
|
|
|
|
|
|
|
|
for(int i=0;i<FUNC_MAX;i++) {
|
|
|
|
|
|
|
|
if (i>0)
|
|
|
|
cc+=",";
|
|
|
|
cc+=func_name[i];
|
|
|
|
}
|
2017-02-12 00:11:37 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT,"function",PROPERTY_HINT_ENUM,cc),"set_func","get_func");
|
2016-08-02 22:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VisualScriptBuiltinFunc::VisualScriptBuiltinFunc() {
|
|
|
|
|
|
|
|
func=MATH_SIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<VisualScriptBuiltinFunc::BuiltinFunc func>
|
|
|
|
static Ref<VisualScriptNode> create_builtin_func_node(const String& p_name) {
|
|
|
|
|
|
|
|
Ref<VisualScriptBuiltinFunc> node;
|
|
|
|
node.instance();
|
|
|
|
node->set_func(func);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
void register_visual_script_builtin_func_node() {
|
|
|
|
|
|
|
|
|
2016-08-06 01:46:45 +00:00
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sin",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SIN>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/cos",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_COS>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/tan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_TAN>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sinh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SINH>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/cosh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_COSH>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/tanh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_TANH>);
|
|
|
|
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/asin",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ASIN>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/acos",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ACOS>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/atan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ATAN>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/atan2",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ATAN2>);
|
|
|
|
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sqrt",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SQRT>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/fmod",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FMOD>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/fposmod",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FPOSMOD>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/floor",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FLOOR>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/ceil",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_CEIL>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/round",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ROUND>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/abs",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ABS>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sign",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SIGN>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/pow",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_POW>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/log",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LOG>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/exp",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_EXP>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/isnan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ISNAN>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/isinf",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ISINF>);
|
|
|
|
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/ease",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_EASE>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/decimals",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DECIMALS>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/stepify",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_STEPIFY>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/lerp",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/dectime",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DECTIME>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/randomize",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDOMIZE>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/rand",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RAND>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/randf",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDF>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/random",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDOM>);
|
|
|
|
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/seed",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SEED>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/randseed",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDSEED>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/deg2rad",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DEG2RAD>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/rad2deg",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RAD2DEG>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/linear2db",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LINEAR2DB>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/db2linear",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DB2LINEAR>);
|
|
|
|
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/max",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_MAX>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/min",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_MIN>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/clamp",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_CLAMP>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/nearest_po2",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_NEAREST_PO2>);
|
|
|
|
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/weakref",create_builtin_func_node<VisualScriptBuiltinFunc::OBJ_WEAKREF>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/funcref",create_builtin_func_node<VisualScriptBuiltinFunc::FUNC_FUNCREF>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/convert",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_CONVERT>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/typeof",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_OF>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/type_exists",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_EXISTS>);
|
2016-10-03 16:17:54 +00:00
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/char",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_CHAR>);
|
2016-08-06 01:46:45 +00:00
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/str",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_STR>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/print",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/printerr",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTERR>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/printraw",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTRAW>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/var2str",create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_STR>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/str2var",create_builtin_func_node<VisualScriptBuiltinFunc::STR_TO_VAR>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/var2bytes",create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_BYTES>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/bytes2var",create_builtin_func_node<VisualScriptBuiltinFunc::BYTES_TO_VAR>);
|
2016-11-10 21:06:00 +00:00
|
|
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/color_named",create_builtin_func_node<VisualScriptBuiltinFunc::COLORN>);
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
}
|