summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/math/camera_matrix.cpp2
-rw-r--r--core/variant.h4
-rw-r--r--core/variant_op.cpp1665
-rw-r--r--doc/classes/@GDScript.xml150
-rw-r--r--doc/classes/RigidBody.xml35
-rw-r--r--doc/classes/RigidBody2D.xml27
-rw-r--r--editor/code_editor.cpp6
-rw-r--r--editor/editor_node.cpp18
-rw-r--r--editor/editor_themes.cpp50
-rw-r--r--editor/import/resource_importer_scene.cpp14
-rw-r--r--editor/import/resource_importer_scene.h6
-rw-r--r--editor/script_editor_debugger.cpp2
-rw-r--r--main/main.cpp2
-rw-r--r--modules/gdscript/gd_compiler.cpp4
-rw-r--r--modules/gdscript/gd_editor.cpp2
-rw-r--r--modules/gdscript/gd_parser.cpp2
-rw-r--r--modules/visual_script/visual_script_expression.cpp4
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp2
-rw-r--r--modules/visual_script/visual_script_nodes.cpp2
-rw-r--r--platform/osx/crash_handler_osx.mm2
-rw-r--r--platform/windows/crash_handler_win.cpp4
-rw-r--r--platform/windows/godot_win.cpp38
-rw-r--r--platform/x11/crash_handler_x11.cpp2
-rw-r--r--scene/gui/scroll_bar.cpp8
-rw-r--r--scene/gui/text_edit.cpp4
-rw-r--r--scene/gui/text_edit.h2
26 files changed, 1195 insertions, 862 deletions
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 7132b6573e..2c587762e8 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -577,7 +577,7 @@ real_t CameraMatrix::get_fov() const {
if ((matrix[8] == 0) && (matrix[9] == 0)) {
return Math::rad2deg(Math::acos(Math::abs(right_plane.normal.x))) * 2.0;
} else {
- // our frustum is asymetrical need to calculate the left planes angle seperately..
+ // our frustum is asymmetrical need to calculate the left planes angle separately..
Plane left_plane = Plane(matrix[3] + matrix[0],
matrix[7] + matrix[4],
matrix[11] + matrix[8],
diff --git a/core/variant.h b/core/variant.h
index e77e2e93c4..edc86dedd4 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -70,6 +70,7 @@ typedef PoolVector<Color> PoolColorArray;
class Variant {
public:
+ // If this changes the table in variant_op must be updated
enum Type {
NIL,
@@ -288,6 +289,7 @@ public:
Variant(const IP_Address &p_address);
+ // If this changes the table in variant_op must be updated
enum Operator {
//comparation
@@ -299,7 +301,7 @@ public:
OP_GREATER_EQUAL,
//mathematic
OP_ADD,
- OP_SUBSTRACT,
+ OP_SUBTRACT,
OP_MULTIPLY,
OP_DIVIDE,
OP_NEGATE,
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index a11169eb8f..142919337d 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -33,6 +33,114 @@
#include "object.h"
#include "script_language.h"
+#define CASE_TYPE_ALL(PREFIX, OP) \
+ CASE_TYPE(PREFIX, OP, INT) \
+ CASE_TYPE_ALL_BUT_INT(PREFIX, OP)
+
+#define CASE_TYPE_ALL_BUT_INT(PREFIX, OP) \
+ CASE_TYPE(PREFIX, OP, NIL) \
+ CASE_TYPE(PREFIX, OP, BOOL) \
+ CASE_TYPE(PREFIX, OP, REAL) \
+ CASE_TYPE(PREFIX, OP, STRING) \
+ CASE_TYPE(PREFIX, OP, VECTOR2) \
+ CASE_TYPE(PREFIX, OP, RECT2) \
+ CASE_TYPE(PREFIX, OP, VECTOR3) \
+ CASE_TYPE(PREFIX, OP, TRANSFORM2D) \
+ CASE_TYPE(PREFIX, OP, PLANE) \
+ CASE_TYPE(PREFIX, OP, QUAT) \
+ CASE_TYPE(PREFIX, OP, RECT3) \
+ CASE_TYPE(PREFIX, OP, BASIS) \
+ CASE_TYPE(PREFIX, OP, TRANSFORM) \
+ CASE_TYPE(PREFIX, OP, COLOR) \
+ CASE_TYPE(PREFIX, OP, NODE_PATH) \
+ CASE_TYPE(PREFIX, OP, _RID) \
+ CASE_TYPE(PREFIX, OP, OBJECT) \
+ CASE_TYPE(PREFIX, OP, DICTIONARY) \
+ CASE_TYPE(PREFIX, OP, ARRAY) \
+ CASE_TYPE(PREFIX, OP, POOL_BYTE_ARRAY) \
+ CASE_TYPE(PREFIX, OP, POOL_INT_ARRAY) \
+ CASE_TYPE(PREFIX, OP, POOL_REAL_ARRAY) \
+ CASE_TYPE(PREFIX, OP, POOL_STRING_ARRAY) \
+ CASE_TYPE(PREFIX, OP, POOL_VECTOR2_ARRAY) \
+ CASE_TYPE(PREFIX, OP, POOL_VECTOR3_ARRAY) \
+ CASE_TYPE(PREFIX, OP, POOL_COLOR_ARRAY)
+
+#ifdef __GNUC__
+#define TYPE(PREFIX, OP, TYPE) &&PREFIX##_##OP##_##TYPE
+
+/* clang-format off */
+#define TYPES(PREFIX, OP) { \
+ TYPE(PREFIX, OP, NIL), \
+ TYPE(PREFIX, OP, BOOL), \
+ TYPE(PREFIX, OP, INT), \
+ TYPE(PREFIX, OP, REAL), \
+ TYPE(PREFIX, OP, STRING), \
+ TYPE(PREFIX, OP, VECTOR2), \
+ TYPE(PREFIX, OP, RECT2), \
+ TYPE(PREFIX, OP, VECTOR3), \
+ TYPE(PREFIX, OP, TRANSFORM2D), \
+ TYPE(PREFIX, OP, PLANE), \
+ TYPE(PREFIX, OP, QUAT), \
+ TYPE(PREFIX, OP, RECT3), \
+ TYPE(PREFIX, OP, BASIS), \
+ TYPE(PREFIX, OP, TRANSFORM), \
+ TYPE(PREFIX, OP, COLOR), \
+ TYPE(PREFIX, OP, NODE_PATH), \
+ TYPE(PREFIX, OP, _RID), \
+ TYPE(PREFIX, OP, OBJECT), \
+ TYPE(PREFIX, OP, DICTIONARY), \
+ TYPE(PREFIX, OP, ARRAY), \
+ TYPE(PREFIX, OP, POOL_BYTE_ARRAY), \
+ TYPE(PREFIX, OP, POOL_INT_ARRAY), \
+ TYPE(PREFIX, OP, POOL_REAL_ARRAY), \
+ TYPE(PREFIX, OP, POOL_STRING_ARRAY), \
+ TYPE(PREFIX, OP, POOL_VECTOR2_ARRAY), \
+ TYPE(PREFIX, OP, POOL_VECTOR3_ARRAY), \
+ TYPE(PREFIX, OP, POOL_COLOR_ARRAY), \
+}
+/* clang-format on */
+
+#define CASES(PREFIX) static void *switch_table_##PREFIX[25][27] = { \
+ TYPES(PREFIX, OP_EQUAL), \
+ TYPES(PREFIX, OP_NOT_EQUAL), \
+ TYPES(PREFIX, OP_LESS), \
+ TYPES(PREFIX, OP_LESS_EQUAL), \
+ TYPES(PREFIX, OP_GREATER), \
+ TYPES(PREFIX, OP_GREATER_EQUAL), \
+ TYPES(PREFIX, OP_ADD), \
+ TYPES(PREFIX, OP_SUBTRACT), \
+ TYPES(PREFIX, OP_MULTIPLY), \
+ TYPES(PREFIX, OP_DIVIDE), \
+ TYPES(PREFIX, OP_NEGATE), \
+ TYPES(PREFIX, OP_POSITIVE), \
+ TYPES(PREFIX, OP_MODULE), \
+ TYPES(PREFIX, OP_STRING_CONCAT), \
+ TYPES(PREFIX, OP_SHIFT_LEFT), \
+ TYPES(PREFIX, OP_SHIFT_RIGHT), \
+ TYPES(PREFIX, OP_BIT_AND), \
+ TYPES(PREFIX, OP_BIT_OR), \
+ TYPES(PREFIX, OP_BIT_XOR), \
+ TYPES(PREFIX, OP_BIT_NEGATE), \
+ TYPES(PREFIX, OP_AND), \
+ TYPES(PREFIX, OP_OR), \
+ TYPES(PREFIX, OP_XOR), \
+ TYPES(PREFIX, OP_NOT), \
+ TYPES(PREFIX, OP_IN), \
+}
+
+#define SWITCH(PREFIX, op, val) goto *switch_table_##PREFIX[op][val];
+#define SWITCH_OP(PREFIX, OP, val)
+#define CASE_TYPE(PREFIX, OP, TYPE) PREFIX##_##OP##_##TYPE:
+
+#else
+#define CASES(PREFIX)
+#define SWITCH(PREFIX, op, val) switch (op)
+#define SWITCH_OP(PREFIX, OP, val) \
+ case OP: \
+ switch (val)
+#define CASE_TYPE(PREFIX, OP, TYPE) case TYPE:
+#endif
+
Variant::operator bool() const {
bool b;
@@ -43,11 +151,16 @@ bool Variant::booleanize(bool &r_valid) const {
r_valid = true;
switch (type) {
- case NIL: return false;
- case BOOL: return _data._bool;
- case INT: return _data._int;
- case REAL: return _data._real;
- case STRING: return (*reinterpret_cast<const String *>(_data._mem)) != "";
+ case NIL:
+ return false;
+ case BOOL:
+ return _data._bool;
+ case INT:
+ return _data._int;
+ case REAL:
+ return _data._real;
+ case STRING:
+ return (*reinterpret_cast<const String *>(_data._mem)) != "";
case VECTOR2:
case RECT2:
case TRANSFORM2D:
@@ -58,9 +171,12 @@ bool Variant::booleanize(bool &r_valid) const {
case BASIS:
case TRANSFORM:
case COLOR:
- case _RID: return (*reinterpret_cast<const RID *>(_data._mem)).is_valid();
- case OBJECT: return _get_obj().obj;
- case NODE_PATH: return (*reinterpret_cast<const NodePath *>(_data._mem)) != NodePath();
+ case _RID:
+ return (*reinterpret_cast<const RID *>(_data._mem)).is_valid();
+ case OBJECT:
+ return _get_obj().obj;
+ case NODE_PATH:
+ return (*reinterpret_cast<const NodePath *>(_data._mem)) != NodePath();
case DICTIONARY:
case ARRAY:
case POOL_BYTE_ARRAY:
@@ -72,7 +188,8 @@ bool Variant::booleanize(bool &r_valid) const {
case POOL_COLOR_ARRAY:
r_valid = false;
return false;
- default: {}
+ default: {
+ }
}
return false;
@@ -84,10 +201,15 @@ bool Variant::booleanize(bool &r_valid) const {
return; \
}
-#define DEFAULT_OP_NUM(m_op, m_name, m_type) \
- case m_name: { \
+#define _RETURN_FAIL \
+ { \
+ r_valid = false; \
+ return; \
+ }
+
+#define DEFAULT_OP_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
switch (p_b.type) { \
- case BOOL: _RETURN(p_a._data.m_type m_op p_b._data._bool); \
case INT: _RETURN(p_a._data.m_type m_op p_b._data._int); \
case REAL: _RETURN(p_a._data.m_type m_op p_b._data._real); \
default: {} \
@@ -96,22 +218,55 @@ bool Variant::booleanize(bool &r_valid) const {
return; \
};
-#define DEFAULT_OP_NUM_NEG(m_name, m_type) \
- case m_name: { \
- \
- _RETURN(-p_a._data.m_type); \
+#ifdef DEBUG_ENABLED
+#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ switch (p_b.type) { \
+ case INT: { \
+ if (p_b._data._int == 0) { \
+ r_valid = false; \
+ _RETURN("Division By Zero"); \
+ } \
+ _RETURN(p_a._data.m_type / p_b._data._int); \
+ } \
+ case REAL: { \
+ if (p_b._data._real == 0) { \
+ r_valid = false; \
+ _RETURN("Division By Zero"); \
+ } \
+ _RETURN(p_a._data.m_type / p_b._data._real); \
+ } \
+ default: {} \
+ } \
+ r_valid = false; \
+ return; \
+ };
+#else
+#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ switch (p_b.type) { \
+ case INT: _RETURN(p_a._data.m_type / p_b._data._int); \
+ case REAL: _RETURN(p_a._data.m_type / p_b._data._real); \
+ default: {} \
+ } \
+ r_valid = false; \
+ return; \
+ };
+#endif
+
+#define DEFAULT_OP_NUM_NEG(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ _RETURN(-p_a._data.m_type); \
};
-#define DEFAULT_OP_NUM_POS(m_name, m_type) \
- case m_name: { \
- \
- _RETURN(p_a._data.m_type); \
+#define DEFAULT_OP_NUM_POS(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ _RETURN(p_a._data.m_type); \
};
-#define DEFAULT_OP_NUM_VEC(m_op, m_name, m_type) \
- case m_name: { \
+#define DEFAULT_OP_NUM_VEC(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
switch (p_b.type) { \
- case BOOL: _RETURN(p_a._data.m_type m_op p_b._data._bool); \
case INT: _RETURN(p_a._data.m_type m_op p_b._data._int); \
case REAL: _RETURN(p_a._data.m_type m_op p_b._data._real); \
case VECTOR2: _RETURN(p_a._data.m_type m_op *reinterpret_cast<const Vector2 *>(p_b._data._mem)); \
@@ -122,8 +277,19 @@ bool Variant::booleanize(bool &r_valid) const {
return; \
};
-#define DEFAULT_OP_STR(m_op, m_name, m_type) \
- case m_name: { \
+#define DEFAULT_OP_STR_REV(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ switch (p_b.type) { \
+ case STRING: _RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const String *>(p_a._data._mem)); \
+ case NODE_PATH: _RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const NodePath *>(p_a._data._mem)); \
+ default: {} \
+ } \
+ r_valid = false; \
+ return; \
+ };
+
+#define DEFAULT_OP_STR(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
switch (p_b.type) { \
case STRING: _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const String *>(p_b._data._mem)); \
case NODE_PATH: _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const NodePath *>(p_b._data._mem)); \
@@ -133,31 +299,36 @@ bool Variant::booleanize(bool &r_valid) const {
return; \
};
-#define DEFAULT_OP_LOCALMEM(m_op, m_name, m_type) \
- case m_name: { \
- switch (p_b.type) { \
- case m_name: _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const m_type *>(p_b._data._mem)); \
- default: {} \
- } \
- r_valid = false; \
- return; \
- }
+#define DEFAULT_OP_LOCALMEM_REV(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ if (p_b.type == m_name) \
+ _RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const m_type *>(p_a._data._mem)); \
+ r_valid = false; \
+ return; \
+ };
+
+#define DEFAULT_OP_LOCALMEM(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ if (p_b.type == m_name) \
+ _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const m_type *>(p_b._data._mem)); \
+ r_valid = false; \
+ return; \
+ };
-#define DEFAULT_OP_LOCALMEM_NEG(m_name, m_type) \
- case m_name: { \
+#define DEFAULT_OP_LOCALMEM_NEG(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
_RETURN(-*reinterpret_cast<const m_type *>(p_a._data._mem)); \
}
-#define DEFAULT_OP_LOCALMEM_POS(m_name, m_type) \
- case m_name: { \
- _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem)); \
+#define DEFAULT_OP_LOCALMEM_POS(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem)); \
}
-#define DEFAULT_OP_LOCALMEM_NUM(m_op, m_name, m_type) \
- case m_name: { \
+#define DEFAULT_OP_LOCALMEM_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
switch (p_b.type) { \
case m_name: _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const m_type *>(p_b._data._mem)); \
- case BOOL: _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._bool); \
case INT: _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._int); \
case REAL: _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._real); \
default: {} \
@@ -176,50 +347,51 @@ bool Variant::booleanize(bool &r_valid) const {
return; \
}
-#define DEFAULT_OP_PTRREF(m_op, m_name, m_sub) \
- case m_name: { \
- switch (p_b.type) { \
- case m_name: _RETURN(*p_a._data.m_sub m_op *p_b._data.m_sub); \
- default: {} \
- } \
- r_valid = false; \
- return; \
+#define DEFAULT_OP_PTRREF(m_prefix, m_op_name, m_name, m_op, m_sub) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ if (p_b.type == m_name) \
+ _RETURN(*p_a._data.m_sub m_op *p_b._data.m_sub); \
+ r_valid = false; \
+ return; \
}
-#define DEFAULT_OP_ARRAY_EQ(m_name, m_type) \
- DEFAULT_OP_ARRAY_OP(m_name, m_type, !=, !=, true, false, false)
-
-#define DEFAULT_OP_ARRAY_LT(m_name, m_type) \
- DEFAULT_OP_ARRAY_OP(m_name, m_type, <, !=, false, a_len < array_b.size(), true)
-
-#define DEFAULT_OP_ARRAY_OP(m_name, m_type, m_opa, m_opb, m_ret_def, m_ret_s, m_ret_f) \
- case m_name: { \
- if (p_a.type != p_b.type) { \
- r_valid = false; \
- return; \
- } \
- const PoolVector<m_type> &array_a = *reinterpret_cast<const PoolVector<m_type> *>(p_a._data._mem); \
- const PoolVector<m_type> &array_b = *reinterpret_cast<const PoolVector<m_type> *>(p_b._data._mem); \
- \
- int a_len = array_a.size(); \
- if (a_len m_opa array_b.size()) { \
- _RETURN(m_ret_s); \
- } else { \
- \
- PoolVector<m_type>::Read ra = array_a.read(); \
- PoolVector<m_type>::Read rb = array_b.read(); \
- \
- for (int i = 0; i < a_len; i++) { \
- if (ra[i] m_opb rb[i]) \
- _RETURN(m_ret_f); \
- } \
- \
- _RETURN(m_ret_def); \
- } \
+#define DEFAULT_OP_ARRAY_EQ(m_prefix, m_op_name, m_name, m_type) \
+ DEFAULT_OP_ARRAY_OP(m_prefix, m_op_name, m_name, m_type, !=, !=, true, false, false)
+
+#define DEFAULT_OP_ARRAY_LT(m_prefix, m_op_name, m_name, m_type) \
+ DEFAULT_OP_ARRAY_OP(m_prefix, m_op_name, m_name, m_type, <, !=, false, a_len < array_b.size(), true)
+
+#define DEFAULT_OP_ARRAY_GT(m_prefix, m_op_name, m_name, m_type) \
+ DEFAULT_OP_ARRAY_OP(m_prefix, m_op_name, m_name, m_type, >, !=, false, a_len < array_b.size(), true)
+
+#define DEFAULT_OP_ARRAY_OP(m_prefix, m_op_name, m_name, m_type, m_opa, m_opb, m_ret_def, m_ret_s, m_ret_f) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ if (p_a.type != p_b.type) { \
+ r_valid = false; \
+ return; \
+ } \
+ const PoolVector<m_type> &array_a = *reinterpret_cast<const PoolVector<m_type> *>(p_a._data._mem); \
+ const PoolVector<m_type> &array_b = *reinterpret_cast<const PoolVector<m_type> *>(p_b._data._mem); \
+ \
+ int a_len = array_a.size(); \
+ if (a_len m_opa array_b.size()) { \
+ _RETURN(m_ret_s); \
+ } else { \
+ \
+ PoolVector<m_type>::Read ra = array_a.read(); \
+ PoolVector<m_type>::Read rb = array_b.read(); \
+ \
+ for (int i = 0; i < a_len; i++) { \
+ if (ra[i] m_opb rb[i]) \
+ _RETURN(m_ret_f); \
+ } \
+ \
+ _RETURN(m_ret_def); \
+ } \
}
-#define DEFAULT_OP_ARRAY_ADD(m_name, m_type) \
- case m_name: { \
+#define DEFAULT_OP_ARRAY_ADD(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
if (p_a.type != p_b.type) { \
r_valid = false; \
_RETURN(NIL); \
@@ -237,589 +409,654 @@ bool Variant::booleanize(bool &r_valid) const {
return; \
}
-void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b, Variant &r_ret, bool &r_valid) {
+void Variant::evaluate(const Operator &p_op, const Variant &p_a,
+ const Variant &p_b, Variant &r_ret, bool &r_valid) {
+ CASES(math);
r_valid = true;
- switch (p_op) {
-
- case OP_EQUAL: {
-
- if ((int(p_a.type) * int(p_b.type)) == 0) {
- //null case is an exception, one of both is null
- if (p_a.type == p_b.type) //null against null is true
- _RETURN(true);
- //only against object is allowed
- if (p_a.type == Variant::OBJECT) {
- _RETURN(p_a._get_obj().obj == NULL);
- } else if (p_b.type == Variant::OBJECT) {
+ SWITCH(math, p_op, p_a.type) {
+ SWITCH_OP(math, OP_EQUAL, p_a.type) {
+ CASE_TYPE(math, OP_EQUAL, NIL) {
+ if (p_b.type == NIL) _RETURN(true);
+ if (p_b.type == OBJECT)
_RETURN(p_b._get_obj().obj == NULL);
- }
- //otherwise, always false
_RETURN(false);
}
- switch (p_a.type) {
+ CASE_TYPE(math, OP_EQUAL, BOOL) {
+ if (p_b.type != BOOL) _RETURN(false);
+ _RETURN(p_a._data._bool == p_b._data._bool);
+ }
- case NIL: {
+ CASE_TYPE(math, OP_EQUAL, OBJECT) {
+ if (p_b.type == OBJECT)
+ _RETURN((p_a._get_obj().obj == p_b._get_obj().obj));
+ if (p_b.type == NIL)
+ _RETURN(p_a._get_obj().obj == NULL);
+ }
- _RETURN(p_b.type == NIL || (p_b.type == Variant::OBJECT && !p_b._get_obj().obj));
- } break;
+ CASE_TYPE(math, OP_EQUAL, DICTIONARY) {
+ if (p_b.type != DICTIONARY)
+ _RETURN(false);
- DEFAULT_OP_NUM(==, BOOL, _bool);
- DEFAULT_OP_NUM(==, INT, _int);
- DEFAULT_OP_NUM(==, REAL, _real);
- DEFAULT_OP_STR(==, STRING, String);
- DEFAULT_OP_LOCALMEM(==, VECTOR2, Vector2);
- DEFAULT_OP_LOCALMEM(==, RECT2, Rect2);
- DEFAULT_OP_PTRREF(==, TRANSFORM2D, _transform2d);
- DEFAULT_OP_LOCALMEM(==, VECTOR3, Vector3);
- DEFAULT_OP_LOCALMEM(==, PLANE, Plane);
- DEFAULT_OP_LOCALMEM(==, QUAT, Quat);
- DEFAULT_OP_PTRREF(==, RECT3, _rect3);
- DEFAULT_OP_PTRREF(==, BASIS, _basis);
- DEFAULT_OP_PTRREF(==, TRANSFORM, _transform);
+ const Dictionary *arr_a = reinterpret_cast<const Dictionary *>(p_a._data._mem);
+ const Dictionary *arr_b = reinterpret_cast<const Dictionary *>(p_b._data._mem);
- DEFAULT_OP_LOCALMEM(==, COLOR, Color);
- DEFAULT_OP_STR(==, NODE_PATH, NodePath);
- DEFAULT_OP_LOCALMEM(==, _RID, RID);
- case OBJECT: {
+ _RETURN(*arr_a == *arr_b);
+ }
- if (p_b.type == OBJECT)
- _RETURN((p_a._get_obj().obj == p_b._get_obj().obj));
- if (p_b.type == NIL)
- _RETURN(!p_a._get_obj().obj);
- } break;
+ CASE_TYPE(math, OP_EQUAL, ARRAY) {
+ if (p_b.type != ARRAY)
+ _RETURN(false);
- case DICTIONARY: {
+ const Array *arr_a = reinterpret_cast<const Array *>(p_a._data._mem);
+ const Array *arr_b = reinterpret_cast<const Array *>(p_b._data._mem);
- if (p_b.type != DICTIONARY)
+ int l = arr_a->size();
+ if (arr_b->size() != l)
+ _RETURN(false);
+ for (int i = 0; i < l; i++) {
+ if (!((*arr_a)[i] == (*arr_b)[i])) {
_RETURN(false);
+ }
+ }
- const Dictionary *arr_a = reinterpret_cast<const Dictionary *>(p_a._data._mem);
- const Dictionary *arr_b = reinterpret_cast<const Dictionary *>(p_b._data._mem);
+ _RETURN(true);
+ }
+
+ DEFAULT_OP_NUM(math, OP_EQUAL, INT, ==, _int);
+ DEFAULT_OP_NUM(math, OP_EQUAL, REAL, ==, _real);
+ DEFAULT_OP_STR(math, OP_EQUAL, STRING, ==, String);
+ DEFAULT_OP_LOCALMEM(math, OP_EQUAL, VECTOR2, ==, Vector2);
+ DEFAULT_OP_LOCALMEM(math, OP_EQUAL, RECT2, ==, Rect2);
+ DEFAULT_OP_PTRREF(math, OP_EQUAL, TRANSFORM2D, ==, _transform2d);
+ DEFAULT_OP_LOCALMEM(math, OP_EQUAL, VECTOR3, ==, Vector3);
+ DEFAULT_OP_LOCALMEM(math, OP_EQUAL, PLANE, ==, Plane);
+ DEFAULT_OP_LOCALMEM(math, OP_EQUAL, QUAT, ==, Quat);
+ DEFAULT_OP_PTRREF(math, OP_EQUAL, RECT3, ==, _rect3);
+ DEFAULT_OP_PTRREF(math, OP_EQUAL, BASIS, ==, _basis);
+ DEFAULT_OP_PTRREF(math, OP_EQUAL, TRANSFORM, ==, _transform);
+ DEFAULT_OP_LOCALMEM(math, OP_EQUAL, COLOR, ==, Color);
+ DEFAULT_OP_STR(math, OP_EQUAL, NODE_PATH, ==, NodePath);
+ DEFAULT_OP_LOCALMEM(math, OP_EQUAL, _RID, ==, RID);
+
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR2_ARRAY, Vector2);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_COLOR_ARRAY, Color);
+ }
- _RETURN(*arr_a == *arr_b);
+ SWITCH_OP(math, OP_NOT_EQUAL, p_a.type) {
+ CASE_TYPE(math, OP_NOT_EQUAL, NIL) {
+ if (p_b.type == NIL) _RETURN(false);
+ if (p_b.type == OBJECT)
+ _RETURN(p_b._get_obj().obj != NULL);
+ _RETURN(true);
+ }
- } break;
- case ARRAY: {
+ CASE_TYPE(math, OP_NOT_EQUAL, BOOL) {
+ if (p_b.type != BOOL) _RETURN(true);
+ _RETURN(p_a._data._bool != p_b._data._bool);
+ }
- if (p_b.type != ARRAY)
- _RETURN(false);
+ CASE_TYPE(math, OP_NOT_EQUAL, OBJECT) {
+ if (p_b.type == OBJECT)
+ _RETURN((p_a._get_obj().obj != p_b._get_obj().obj));
+ if (p_b.type == NIL)
+ _RETURN(p_a._get_obj().obj != NULL);
+ }
+
+ CASE_TYPE(math, OP_NOT_EQUAL, DICTIONARY) {
+ if (p_b.type != DICTIONARY)
+ _RETURN(true);
+
+ const Dictionary *arr_a = reinterpret_cast<const Dictionary *>(p_a._data._mem);
+ const Dictionary *arr_b = reinterpret_cast<const Dictionary *>(p_b._data._mem);
+
+ _RETURN((*arr_a == *arr_b) == false);
+ }
+
+ CASE_TYPE(math, OP_NOT_EQUAL, ARRAY) {
+ if (p_b.type != ARRAY)
+ _RETURN(true);
- const Array *arr_a = reinterpret_cast<const Array *>(p_a._data._mem);
- const Array *arr_b = reinterpret_cast<const Array *>(p_b._data._mem);
+ const Array *arr_a = reinterpret_cast<const Array *>(p_a._data._mem);
+ const Array *arr_b = reinterpret_cast<const Array *>(p_b._data._mem);
- int l = arr_a->size();
- if (arr_b->size() != l)
+ int l = arr_a->size();
+ if (arr_b->size() != l)
+ _RETURN(true);
+ for (int i = 0; i < l; i++) {
+ if (((*arr_a)[i] == (*arr_b)[i])) {
_RETURN(false);
- for (int i = 0; i < l; i++) {
- if (!((*arr_a)[i] == (*arr_b)[i])) {
- _RETURN(false);
- }
}
+ }
- _RETURN(true);
+ _RETURN(true);
+ }
+
+ DEFAULT_OP_NUM(math, OP_NOT_EQUAL, INT, !=, _int);
+ DEFAULT_OP_NUM(math, OP_NOT_EQUAL, REAL, !=, _real);
+ DEFAULT_OP_STR(math, OP_NOT_EQUAL, STRING, !=, String);
+ DEFAULT_OP_LOCALMEM(math, OP_NOT_EQUAL, VECTOR2, !=, Vector2);
+ DEFAULT_OP_LOCALMEM(math, OP_NOT_EQUAL, RECT2, !=, Rect2);
+ DEFAULT_OP_PTRREF(math, OP_NOT_EQUAL, TRANSFORM2D, !=, _transform2d);
+ DEFAULT_OP_LOCALMEM(math, OP_NOT_EQUAL, VECTOR3, !=, Vector3);
+ DEFAULT_OP_LOCALMEM(math, OP_NOT_EQUAL, PLANE, !=, Plane);
+ DEFAULT_OP_LOCALMEM(math, OP_NOT_EQUAL, QUAT, !=, Quat);
+ DEFAULT_OP_PTRREF(math, OP_NOT_EQUAL, RECT3, !=, _rect3);
+ DEFAULT_OP_PTRREF(math, OP_NOT_EQUAL, BASIS, !=, _basis);
+ DEFAULT_OP_PTRREF(math, OP_NOT_EQUAL, TRANSFORM, !=, _transform);
+ DEFAULT_OP_LOCALMEM(math, OP_NOT_EQUAL, COLOR, !=, Color);
+ DEFAULT_OP_STR(math, OP_NOT_EQUAL, NODE_PATH, !=, NodePath);
+ DEFAULT_OP_LOCALMEM(math, OP_NOT_EQUAL, _RID, !=, RID);
+
+ CASE_TYPE(math, OP_NOT_EQUAL, POOL_BYTE_ARRAY);
+ CASE_TYPE(math, OP_NOT_EQUAL, POOL_INT_ARRAY);
+ CASE_TYPE(math, OP_NOT_EQUAL, POOL_REAL_ARRAY);
+ CASE_TYPE(math, OP_NOT_EQUAL, POOL_STRING_ARRAY);
+ CASE_TYPE(math, OP_NOT_EQUAL, POOL_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_NOT_EQUAL, POOL_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_NOT_EQUAL, POOL_COLOR_ARRAY);
+ _RETURN_FAIL;
+ }
- } break;
+ SWITCH_OP(math, OP_LESS, p_a.type) {
+ CASE_TYPE(math, OP_LESS, BOOL) {
+ if (p_b.type != BOOL)
+ _RETURN_FAIL;
- DEFAULT_OP_ARRAY_EQ(POOL_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_EQ(POOL_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_EQ(POOL_REAL_ARRAY, real_t);
- DEFAULT_OP_ARRAY_EQ(POOL_STRING_ARRAY, String);
- DEFAULT_OP_ARRAY_EQ(POOL_VECTOR2_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_EQ(POOL_VECTOR3_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_EQ(POOL_COLOR_ARRAY, Color);
+ if (p_a._data._bool == p_b._data._bool)
+ _RETURN(false);
- case VARIANT_MAX: {
- r_valid = false;
- return;
+ if (p_a._data._bool && !p_b._data._bool)
+ _RETURN(false);
- } break;
+ _RETURN(true);
}
- } break;
- case OP_NOT_EQUAL: {
- Variant res;
- evaluate(OP_EQUAL, p_a, p_b, res, r_valid);
- if (!r_valid)
- return;
- if (res.type == BOOL)
- res._data._bool = !res._data._bool;
- _RETURN(res);
-
- } break;
- case OP_LESS: {
-
- switch (p_a.type) {
-
- DEFAULT_OP_FAIL(NIL);
- DEFAULT_OP_NUM(<, BOOL, _bool);
- DEFAULT_OP_NUM(<, INT, _int);
- DEFAULT_OP_NUM(<, REAL, _real);
- DEFAULT_OP_STR(<, STRING, String);
- DEFAULT_OP_LOCALMEM(<, VECTOR2, Vector2);
- DEFAULT_OP_FAIL(RECT2);
- DEFAULT_OP_FAIL(TRANSFORM2D);
- DEFAULT_OP_LOCALMEM(<, VECTOR3, Vector3);
- DEFAULT_OP_FAIL(PLANE);
- DEFAULT_OP_FAIL(QUAT);
- DEFAULT_OP_FAIL(RECT3);
- DEFAULT_OP_FAIL(BASIS);
- DEFAULT_OP_FAIL(TRANSFORM);
-
- DEFAULT_OP_FAIL(COLOR);
-
- DEFAULT_OP_FAIL(NODE_PATH);
- DEFAULT_OP_LOCALMEM(<, _RID, RID);
- case OBJECT: {
-
- if (p_b.type == OBJECT)
- _RETURN((p_a._get_obj().obj < p_b._get_obj().obj));
- } break;
- DEFAULT_OP_FAIL(DICTIONARY);
- case ARRAY: {
-
- if (p_b.type != ARRAY)
- _RETURN(false);
-
- const Array *arr_a = reinterpret_cast<const Array *>(p_a._data._mem);
- const Array *arr_b = reinterpret_cast<const Array *>(p_b._data._mem);
- int l = arr_a->size();
- if (arr_b->size() < l)
- _RETURN(false);
- for (int i = 0; i < l; i++) {
- if (!((*arr_a)[i] < (*arr_b)[i])) {
- _RETURN(true);
- }
- }
+ CASE_TYPE(math, OP_LESS, OBJECT) {
+ if (p_b.type == OBJECT)
+ _RETURN((p_a._get_obj().obj < p_b._get_obj().obj));
+ }
+ CASE_TYPE(math, OP_LESS, ARRAY) {
+ if (p_b.type != ARRAY)
_RETURN(false);
- } break;
- DEFAULT_OP_ARRAY_LT(POOL_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_LT(POOL_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_LT(POOL_REAL_ARRAY, real_t);
- DEFAULT_OP_ARRAY_LT(POOL_STRING_ARRAY, String);
- DEFAULT_OP_ARRAY_LT(POOL_VECTOR2_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_LT(POOL_VECTOR3_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_LT(POOL_COLOR_ARRAY, Color);
- case VARIANT_MAX: {
- r_valid = false;
- return;
+ const Array *arr_a = reinterpret_cast<const Array *>(p_a._data._mem);
+ const Array *arr_b = reinterpret_cast<const Array *>(p_b._data._mem);
- } break;
- }
-
- } break;
- case OP_LESS_EQUAL: {
-
- switch (p_a.type) {
-
- DEFAULT_OP_FAIL(NIL);
- DEFAULT_OP_NUM(<=, BOOL, _bool);
- DEFAULT_OP_NUM(<=, INT, _int);
- DEFAULT_OP_NUM(<=, REAL, _real);
- DEFAULT_OP_STR(<=, STRING, String);
- DEFAULT_OP_LOCALMEM(<=, VECTOR2, Vector2);
- DEFAULT_OP_FAIL(RECT2);
- DEFAULT_OP_FAIL(TRANSFORM2D);
- DEFAULT_OP_LOCALMEM(<=, VECTOR3, Vector3);
- DEFAULT_OP_FAIL(PLANE);
- DEFAULT_OP_FAIL(QUAT);
- DEFAULT_OP_FAIL(RECT3);
- DEFAULT_OP_FAIL(BASIS);
- DEFAULT_OP_FAIL(TRANSFORM);
-
- DEFAULT_OP_FAIL(COLOR);
-
- DEFAULT_OP_FAIL(NODE_PATH);
- DEFAULT_OP_LOCALMEM(<=, _RID, RID);
- case OBJECT: {
-
- if (p_b.type == OBJECT)
- _RETURN((p_a._get_obj().obj <= p_b._get_obj().obj));
- } break;
- DEFAULT_OP_FAIL(DICTIONARY);
- DEFAULT_OP_FAIL(ARRAY);
- DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
- DEFAULT_OP_FAIL(POOL_INT_ARRAY);
- DEFAULT_OP_FAIL(POOL_REAL_ARRAY);
- DEFAULT_OP_FAIL(POOL_STRING_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR2_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR3_ARRAY);
- DEFAULT_OP_FAIL(POOL_COLOR_ARRAY);
- case VARIANT_MAX: {
- r_valid = false;
- return;
+ int l = arr_a->size();
+ if (arr_b->size() < l)
+ _RETURN(false);
+ for (int i = 0; i < l; i++) {
+ if (!((*arr_a)[i] < (*arr_b)[i])) {
+ _RETURN(true);
+ }
+ }
- } break;
+ _RETURN(false);
}
- } break;
- case OP_GREATER: {
+ DEFAULT_OP_NUM(math, OP_LESS, INT, <, _int);
+ DEFAULT_OP_NUM(math, OP_LESS, REAL, <, _real);
+ DEFAULT_OP_STR(math, OP_LESS, STRING, <, String);
+ DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR2, <, Vector2);
+ DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR3, <, Vector3);
+ DEFAULT_OP_LOCALMEM(math, OP_LESS, _RID, <, RID);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR2_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_COLOR_ARRAY, Color);
+
+ CASE_TYPE(math, OP_LESS, NIL)
+ CASE_TYPE(math, OP_LESS, RECT2)
+ CASE_TYPE(math, OP_LESS, TRANSFORM2D)
+ CASE_TYPE(math, OP_LESS, PLANE)
+ CASE_TYPE(math, OP_LESS, QUAT)
+ CASE_TYPE(math, OP_LESS, RECT3)
+ CASE_TYPE(math, OP_LESS, BASIS)
+ CASE_TYPE(math, OP_LESS, TRANSFORM)
+ CASE_TYPE(math, OP_LESS, COLOR)
+ CASE_TYPE(math, OP_LESS, NODE_PATH)
+ CASE_TYPE(math, OP_LESS, DICTIONARY)
+ _RETURN_FAIL;
+ }
- Variant res;
- evaluate(OP_LESS, p_b, p_a, res, r_valid);
- if (!r_valid)
- return;
- _RETURN(res);
+ SWITCH_OP(math, OP_LESS_EQUAL, p_a.type) {
+ CASE_TYPE(math, OP_LESS_EQUAL, OBJECT) {
+ if (p_b.type == OBJECT)
+ _RETURN((p_a._get_obj().obj <= p_b._get_obj().obj));
+ }
+
+ DEFAULT_OP_NUM(math, OP_LESS_EQUAL, INT, <=, _int);
+ DEFAULT_OP_NUM(math, OP_LESS_EQUAL, REAL, <=, _real);
+ DEFAULT_OP_STR(math, OP_LESS_EQUAL, STRING, <=, String);
+ DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR2, <=, Vector2);
+ DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR3, <=, Vector3);
+ DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, _RID, <=, RID);
+
+ CASE_TYPE(math, OP_LESS_EQUAL, NIL)
+ CASE_TYPE(math, OP_LESS_EQUAL, BOOL)
+ CASE_TYPE(math, OP_LESS_EQUAL, RECT2)
+ CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM2D)
+ CASE_TYPE(math, OP_LESS_EQUAL, PLANE)
+ CASE_TYPE(math, OP_LESS_EQUAL, QUAT)
+ CASE_TYPE(math, OP_LESS_EQUAL, RECT3)
+ CASE_TYPE(math, OP_LESS_EQUAL, BASIS)
+ CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM)
+ CASE_TYPE(math, OP_LESS_EQUAL, COLOR)
+ CASE_TYPE(math, OP_LESS_EQUAL, NODE_PATH)
+ CASE_TYPE(math, OP_LESS_EQUAL, DICTIONARY)
+ CASE_TYPE(math, OP_LESS_EQUAL, ARRAY)
+ CASE_TYPE(math, OP_LESS_EQUAL, POOL_BYTE_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, POOL_INT_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, POOL_REAL_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, POOL_STRING_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, POOL_COLOR_ARRAY);
+ _RETURN_FAIL;
+ }
- } break;
- case OP_GREATER_EQUAL: {
+ SWITCH_OP(math, OP_GREATER, p_a.type) {
+ CASE_TYPE(math, OP_GREATER, BOOL) {
+ if (p_b.type != BOOL)
+ _RETURN_FAIL;
- Variant res;
- evaluate(OP_LESS_EQUAL, p_b, p_a, res, r_valid);
- if (!r_valid)
- return;
- _RETURN(res);
- } break;
- //mathematic
- case OP_ADD: {
- switch (p_a.type) {
-
- DEFAULT_OP_FAIL(NIL);
- DEFAULT_OP_NUM(+, BOOL, _bool);
- DEFAULT_OP_NUM(+, INT, _int);
- DEFAULT_OP_NUM(+, REAL, _real);
- DEFAULT_OP_STR(+, STRING, String);
- DEFAULT_OP_LOCALMEM(+, VECTOR2, Vector2);
- DEFAULT_OP_FAIL(RECT2);
- DEFAULT_OP_FAIL(TRANSFORM2D);
- DEFAULT_OP_LOCALMEM(+, VECTOR3, Vector3);
- DEFAULT_OP_FAIL(PLANE);
- DEFAULT_OP_LOCALMEM(+, QUAT, Quat);
- DEFAULT_OP_FAIL(RECT3);
- DEFAULT_OP_FAIL(BASIS);
- DEFAULT_OP_FAIL(TRANSFORM);
-
- DEFAULT_OP_LOCALMEM(+, COLOR, Color);
-
- DEFAULT_OP_FAIL(NODE_PATH);
- DEFAULT_OP_FAIL(_RID);
- DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(DICTIONARY);
-
- case ARRAY: {
- if (p_a.type != p_b.type) {
- r_valid = false;
- return;
- }
- const Array &array_a = *reinterpret_cast<const Array *>(p_a._data._mem);
- const Array &array_b = *reinterpret_cast<const Array *>(p_b._data._mem);
- Array sum;
- int asize = array_a.size();
- int bsize = array_b.size();
- sum.resize(asize + bsize);
- for (int i = 0; i < asize; i++)
- sum[i] = array_a[i];
- for (int i = 0; i < bsize; i++)
- sum[i + asize] = array_b[i];
- _RETURN(sum);
- }
- DEFAULT_OP_ARRAY_ADD(POOL_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_ADD(POOL_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_ADD(POOL_REAL_ARRAY, real_t);
- DEFAULT_OP_ARRAY_ADD(POOL_STRING_ARRAY, String);
- DEFAULT_OP_ARRAY_ADD(POOL_VECTOR2_ARRAY, Vector2);
- DEFAULT_OP_ARRAY_ADD(POOL_VECTOR3_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_ADD(POOL_COLOR_ARRAY, Color);
- case VARIANT_MAX: {
- r_valid = false;
- return;
+ if (p_a._data._bool == p_b._data._bool)
+ _RETURN(false);
- } break;
- }
- } break;
- case OP_SUBSTRACT: {
- switch (p_a.type) {
-
- DEFAULT_OP_FAIL(NIL);
- DEFAULT_OP_NUM(-, BOOL, _bool);
- DEFAULT_OP_NUM(-, INT, _int);
- DEFAULT_OP_NUM(-, REAL, _real);
- DEFAULT_OP_FAIL(STRING);
- DEFAULT_OP_LOCALMEM(-, VECTOR2, Vector2);
- DEFAULT_OP_FAIL(RECT2);
- DEFAULT_OP_FAIL(TRANSFORM2D);
- DEFAULT_OP_LOCALMEM(-, VECTOR3, Vector3);
- DEFAULT_OP_FAIL(PLANE);
- DEFAULT_OP_LOCALMEM(-, QUAT, Quat);
- DEFAULT_OP_FAIL(RECT3);
- DEFAULT_OP_FAIL(BASIS);
- DEFAULT_OP_FAIL(TRANSFORM);
-
- DEFAULT_OP_LOCALMEM(-, COLOR, Color);
-
- DEFAULT_OP_FAIL(NODE_PATH);
- DEFAULT_OP_FAIL(_RID);
- DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(DICTIONARY);
- DEFAULT_OP_FAIL(ARRAY);
- DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
- DEFAULT_OP_FAIL(POOL_INT_ARRAY);
- DEFAULT_OP_FAIL(POOL_REAL_ARRAY);
- DEFAULT_OP_FAIL(POOL_STRING_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR2_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR3_ARRAY);
- DEFAULT_OP_FAIL(POOL_COLOR_ARRAY);
- case VARIANT_MAX: {
- r_valid = false;
- return;
+ if (!p_a._data._bool && p_b._data._bool)
+ _RETURN(false);
- } break;
+ _RETURN(true);
}
- } break;
- case OP_MULTIPLY: {
- switch (p_a.type) {
- DEFAULT_OP_FAIL(NIL);
- DEFAULT_OP_NUM(*, BOOL, _bool);
- DEFAULT_OP_NUM_VEC(*, INT, _int);
- DEFAULT_OP_NUM_VEC(*, REAL, _real);
- DEFAULT_OP_FAIL(STRING);
- DEFAULT_OP_LOCALMEM_NUM(*, VECTOR2, Vector2);
- DEFAULT_OP_FAIL(RECT2);
- case TRANSFORM2D: {
+ CASE_TYPE(math, OP_GREATER, OBJECT) {
+ if (p_b.type == OBJECT)
+ _RETURN((p_a._get_obj().obj > p_b._get_obj().obj));
+ }
- if (p_b.type == TRANSFORM2D) {
- _RETURN(*p_a._data._transform2d * *p_b._data._transform2d);
- };
- if (p_b.type == VECTOR2) {
- _RETURN(p_a._data._transform2d->xform(*(const Vector2 *)p_b._data._mem));
- };
- r_valid = false;
- return;
- } break;
- DEFAULT_OP_LOCALMEM_NUM(*, VECTOR3, Vector3);
- DEFAULT_OP_FAIL(PLANE);
- case QUAT: {
-
- switch (p_b.type) {
- case VECTOR3: {
-
- _RETURN(reinterpret_cast<const Quat *>(p_a._data._mem)->xform(*(const Vector3 *)p_b._data._mem));
- } break;
- case QUAT: {
-
- _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * *reinterpret_cast<const Quat *>(p_b._data._mem));
- } break;
- case REAL: {
- _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * p_b._data._real);
- } break;
- default: {}
- };
- r_valid = false;
- return;
- } break;
- DEFAULT_OP_FAIL(RECT3);
- case BASIS: {
+ CASE_TYPE(math, OP_GREATER, ARRAY) {
+ if (p_b.type != ARRAY)
+ _RETURN(false);
- switch (p_b.type) {
- case VECTOR3: {
+ const Array *arr_a = reinterpret_cast<const Array *>(p_a._data._mem);
+ const Array *arr_b = reinterpret_cast<const Array *>(p_b._data._mem);
- _RETURN(p_a._data._basis->xform(*(const Vector3 *)p_b._data._mem));
- };
- case BASIS: {
+ int l = arr_a->size();
+ if (arr_b->size() > l)
+ _RETURN(false);
+ for (int i = 0; i < l; i++) {
+ if (((*arr_a)[i] < (*arr_b)[i])) {
+ _RETURN(false);
+ }
+ }
- _RETURN(*p_a._data._basis * *p_b._data._basis);
- };
- default: {}
- };
+ _RETURN(true);
+ }
+
+ DEFAULT_OP_NUM(math, OP_GREATER, INT, >, _int);
+ DEFAULT_OP_NUM(math, OP_GREATER, REAL, >, _real);
+ DEFAULT_OP_STR_REV(math, OP_GREATER, STRING, <, String);
+ DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR2, <, Vector2);
+ DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR3, <, Vector3);
+ DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, _RID, <, RID);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR2_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_COLOR_ARRAY, Color);
+
+ CASE_TYPE(math, OP_GREATER, NIL)
+ CASE_TYPE(math, OP_GREATER, RECT2)
+ CASE_TYPE(math, OP_GREATER, TRANSFORM2D)
+ CASE_TYPE(math, OP_GREATER, PLANE)
+ CASE_TYPE(math, OP_GREATER, QUAT)
+ CASE_TYPE(math, OP_GREATER, RECT3)
+ CASE_TYPE(math, OP_GREATER, BASIS)
+ CASE_TYPE(math, OP_GREATER, TRANSFORM)
+ CASE_TYPE(math, OP_GREATER, COLOR)
+ CASE_TYPE(math, OP_GREATER, NODE_PATH)
+ CASE_TYPE(math, OP_GREATER, DICTIONARY)
+ _RETURN_FAIL;
+ }
+
+ SWITCH_OP(math, OP_GREATER_EQUAL, p_a.type) {
+ CASE_TYPE(math, OP_GREATER_EQUAL, OBJECT) {
+ if (p_b.type == OBJECT)
+ _RETURN((p_a._get_obj().obj >= p_b._get_obj().obj));
+ }
+
+ DEFAULT_OP_NUM(math, OP_GREATER_EQUAL, INT, >=, _int);
+ DEFAULT_OP_NUM(math, OP_GREATER_EQUAL, REAL, >=, _real);
+ DEFAULT_OP_STR_REV(math, OP_GREATER_EQUAL, STRING, <=, String);
+ DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR2, <=, Vector2);
+ DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR3, <=, Vector3);
+ DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, _RID, <=, RID);
+
+ CASE_TYPE(math, OP_GREATER_EQUAL, NIL)
+ CASE_TYPE(math, OP_GREATER_EQUAL, BOOL)
+ CASE_TYPE(math, OP_GREATER_EQUAL, RECT2)
+ CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM2D)
+ CASE_TYPE(math, OP_GREATER_EQUAL, PLANE)
+ CASE_TYPE(math, OP_GREATER_EQUAL, QUAT)
+ CASE_TYPE(math, OP_GREATER_EQUAL, RECT3)
+ CASE_TYPE(math, OP_GREATER_EQUAL, BASIS)
+ CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM)
+ CASE_TYPE(math, OP_GREATER_EQUAL, COLOR)
+ CASE_TYPE(math, OP_GREATER_EQUAL, NODE_PATH)
+ CASE_TYPE(math, OP_GREATER_EQUAL, DICTIONARY)
+ CASE_TYPE(math, OP_GREATER_EQUAL, ARRAY)
+ CASE_TYPE(math, OP_GREATER_EQUAL, POOL_BYTE_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, POOL_INT_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, POOL_REAL_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, POOL_STRING_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, POOL_COLOR_ARRAY);
+ _RETURN_FAIL;
+ }
+
+ SWITCH_OP(math, OP_ADD, p_a.type) {
+ CASE_TYPE(math, OP_ADD, ARRAY) {
+ if (p_a.type != p_b.type) {
r_valid = false;
return;
- } break;
- case TRANSFORM: {
+ }
+ const Array &array_a = *reinterpret_cast<const Array *>(p_a._data._mem);
+ const Array &array_b = *reinterpret_cast<const Array *>(p_b._data._mem);
+ Array sum;
+ int asize = array_a.size();
+ int bsize = array_b.size();
+ sum.resize(asize + bsize);
+ for (int i = 0; i < asize; i++)
+ sum[i] = array_a[i];
+ for (int i = 0; i < bsize; i++)
+ sum[i + asize] = array_b[i];
+ _RETURN(sum);
+ }
+
+ DEFAULT_OP_NUM(math, OP_ADD, INT, +, _int);
+ DEFAULT_OP_NUM(math, OP_ADD, REAL, +, _real);
+ DEFAULT_OP_STR(math, OP_ADD, STRING, +, String);
+ DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR2, +, Vector2);
+ DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR3, +, Vector3);
+ DEFAULT_OP_LOCALMEM(math, OP_ADD, QUAT, +, Quat);
+ DEFAULT_OP_LOCALMEM(math, OP_ADD, COLOR, +, Color);
+
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR2_ARRAY, Vector2);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_COLOR_ARRAY, Color);
+
+ CASE_TYPE(math, OP_ADD, NIL)
+ CASE_TYPE(math, OP_ADD, BOOL)
+ CASE_TYPE(math, OP_ADD, RECT2)
+ CASE_TYPE(math, OP_ADD, TRANSFORM2D)
+ CASE_TYPE(math, OP_ADD, PLANE)
+ CASE_TYPE(math, OP_ADD, RECT3)
+ CASE_TYPE(math, OP_ADD, BASIS)
+ CASE_TYPE(math, OP_ADD, TRANSFORM)
+ CASE_TYPE(math, OP_ADD, NODE_PATH)
+ CASE_TYPE(math, OP_ADD, _RID)
+ CASE_TYPE(math, OP_ADD, OBJECT)
+ CASE_TYPE(math, OP_ADD, DICTIONARY)
+ _RETURN_FAIL;
+ }
- switch (p_b.type) {
- case VECTOR3: {
+ SWITCH_OP(math, OP_SUBTRACT, p_a.type) {
+ DEFAULT_OP_NUM(math, OP_SUBTRACT, INT, -, _int);
+ DEFAULT_OP_NUM(math, OP_SUBTRACT, REAL, -, _real);
+ DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR2, -, Vector2);
+ DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR3, -, Vector3);
+ DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, QUAT, -, Quat);
+ DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, COLOR, -, Color);
+
+ CASE_TYPE(math, OP_SUBTRACT, NIL)
+ CASE_TYPE(math, OP_SUBTRACT, BOOL)
+ CASE_TYPE(math, OP_SUBTRACT, STRING)
+ CASE_TYPE(math, OP_SUBTRACT, RECT2)
+ CASE_TYPE(math, OP_SUBTRACT, TRANSFORM2D)
+ CASE_TYPE(math, OP_SUBTRACT, PLANE)
+ CASE_TYPE(math, OP_SUBTRACT, RECT3)
+ CASE_TYPE(math, OP_SUBTRACT, BASIS)
+ CASE_TYPE(math, OP_SUBTRACT, TRANSFORM)
+ CASE_TYPE(math, OP_SUBTRACT, NODE_PATH)
+ CASE_TYPE(math, OP_SUBTRACT, _RID)
+ CASE_TYPE(math, OP_SUBTRACT, OBJECT)
+ CASE_TYPE(math, OP_SUBTRACT, DICTIONARY)
+ CASE_TYPE(math, OP_SUBTRACT, ARRAY)
+ CASE_TYPE(math, OP_SUBTRACT, POOL_BYTE_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, POOL_INT_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, POOL_REAL_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, POOL_STRING_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, POOL_COLOR_ARRAY);
+ _RETURN_FAIL;
+ }
- _RETURN(p_a._data._transform->xform(*(const Vector3 *)p_b._data._mem));
- };
- case TRANSFORM: {
+ SWITCH_OP(math, OP_MULTIPLY, p_a.type) {
+ CASE_TYPE(math, OP_MULTIPLY, TRANSFORM2D) {
+ if (p_b.type == TRANSFORM2D) {
+ _RETURN(*p_a._data._transform2d * *p_b._data._transform2d);
+ };
+ if (p_b.type == VECTOR2) {
+ _RETURN(p_a._data._transform2d->xform(*(const Vector2 *)p_b._data._mem));
+ };
+ r_valid = false;
+ return;
+ }
+
+ CASE_TYPE(math, OP_MULTIPLY, QUAT) {
+ switch (p_b.type) {
+ case VECTOR3: {
+
+ _RETURN(reinterpret_cast<const Quat *>(p_a._data._mem)->xform(*(const Vector3 *)p_b._data._mem));
+ } break;
+ case QUAT: {
- _RETURN(*p_a._data._transform * *p_b._data._transform);
- };
- default: {}
+ _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * *reinterpret_cast<const Quat *>(p_b._data._mem));
+ } break;
+ case REAL: {
+ _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * p_b._data._real);
+ } break;
+ default: {}
+ };
+ r_valid = false;
+ return;
+ }
+
+ CASE_TYPE(math, OP_MULTIPLY, BASIS) {
+ switch (p_b.type) {
+ case VECTOR3: {
+
+ _RETURN(p_a._data._basis->xform(*(const Vector3 *)p_b._data._mem));
};
- r_valid = false;
- return;
- } break;
- DEFAULT_OP_LOCALMEM_NUM(*, COLOR, Color);
-
- DEFAULT_OP_FAIL(NODE_PATH);
- DEFAULT_OP_FAIL(_RID);
- DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(DICTIONARY);
- DEFAULT_OP_FAIL(ARRAY);
- DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
- DEFAULT_OP_FAIL(POOL_INT_ARRAY);
- DEFAULT_OP_FAIL(POOL_REAL_ARRAY);
- DEFAULT_OP_FAIL(POOL_STRING_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR2_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR3_ARRAY);
- DEFAULT_OP_FAIL(POOL_COLOR_ARRAY);
- case VARIANT_MAX: {
- r_valid = false;
- return;
+ case BASIS: {
- } break;
+ _RETURN(*p_a._data._basis * *p_b._data._basis);
+ };
+ default: {}
+ };
+ r_valid = false;
+ return;
}
- } break;
- case OP_DIVIDE: {
- switch (p_a.type) {
- DEFAULT_OP_FAIL(NIL);
- DEFAULT_OP_NUM(/, BOOL, _bool);
- case INT: {
- switch (p_b.type) {
- case BOOL: {
- int64_t b = p_b._data._bool;
- if (b == 0) {
+ CASE_TYPE(math, OP_MULTIPLY, TRANSFORM) {
+ switch (p_b.type) {
+ case VECTOR3: {
- r_valid = false;
- _RETURN("Division By False");
- }
- _RETURN(p_a._data._int / b);
+ _RETURN(p_a._data._transform->xform(*(const Vector3 *)p_b._data._mem));
+ };
+ case TRANSFORM: {
- } break;
- case INT: {
- int64_t b = p_b._data._int;
- if (b == 0) {
+ _RETURN(*p_a._data._transform * *p_b._data._transform);
+ };
+ default: {}
+ };
+ r_valid = false;
+ return;
+ }
- r_valid = false;
- _RETURN("Division By Zero");
- }
- _RETURN(p_a._data._int / b);
+ DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, INT, *, _int);
+ DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, REAL, *, _real);
+ DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR2, *, Vector2);
+ DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR3, *, Vector3);
+ DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, COLOR, *, Color);
+
+ CASE_TYPE(math, OP_MULTIPLY, NIL)
+ CASE_TYPE(math, OP_MULTIPLY, BOOL)
+ CASE_TYPE(math, OP_MULTIPLY, STRING)
+ CASE_TYPE(math, OP_MULTIPLY, RECT2)
+ CASE_TYPE(math, OP_MULTIPLY, PLANE)
+ CASE_TYPE(math, OP_MULTIPLY, RECT3)
+ CASE_TYPE(math, OP_MULTIPLY, NODE_PATH)
+ CASE_TYPE(math, OP_MULTIPLY, _RID)
+ CASE_TYPE(math, OP_MULTIPLY, OBJECT)
+ CASE_TYPE(math, OP_MULTIPLY, DICTIONARY)
+ CASE_TYPE(math, OP_MULTIPLY, ARRAY)
+ CASE_TYPE(math, OP_MULTIPLY, POOL_BYTE_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, POOL_INT_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, POOL_REAL_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, POOL_STRING_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, POOL_COLOR_ARRAY);
+ _RETURN_FAIL;
+ }
- } break;
- case REAL: _RETURN(p_a._data._int / p_b._data._real);
- default: {}
- }
+ SWITCH_OP(math, OP_DIVIDE, p_a.type) {
+ CASE_TYPE(math, OP_DIVIDE, QUAT) {
+ if (p_b.type != REAL) {
r_valid = false;
return;
- };
- DEFAULT_OP_NUM(/, REAL, _real);
- DEFAULT_OP_FAIL(STRING);
- DEFAULT_OP_LOCALMEM_NUM(/, VECTOR2, Vector2);
- DEFAULT_OP_FAIL(RECT2);
- DEFAULT_OP_FAIL(TRANSFORM2D);
- DEFAULT_OP_LOCALMEM_NUM(/, VECTOR3, Vector3);
- DEFAULT_OP_FAIL(PLANE);
- case QUAT: {
- if (p_b.type != REAL) {
- r_valid = false;
- return;
- }
- _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) / p_b._data._real);
- } break;
- DEFAULT_OP_FAIL(RECT3);
- DEFAULT_OP_FAIL(BASIS);
- DEFAULT_OP_FAIL(TRANSFORM);
-
- DEFAULT_OP_LOCALMEM_NUM(/, COLOR, Color);
-
- DEFAULT_OP_FAIL(NODE_PATH);
- DEFAULT_OP_FAIL(_RID);
- DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(DICTIONARY);
- DEFAULT_OP_FAIL(ARRAY);
- DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
- DEFAULT_OP_FAIL(POOL_INT_ARRAY);
- DEFAULT_OP_FAIL(POOL_REAL_ARRAY);
- DEFAULT_OP_FAIL(POOL_STRING_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR2_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR3_ARRAY);
- DEFAULT_OP_FAIL(POOL_COLOR_ARRAY);
- case VARIANT_MAX: {
+ }
+#ifdef DEBUG_ENABLED
+ if (p_b._data._real == 0) {
r_valid = false;
- return;
+ _RETURN("Division By Zero");
+ }
+#endif
+ _RETURN(
+ *reinterpret_cast<const Quat *>(p_a._data._mem) / p_b._data._real);
+ }
+
+ DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, INT, _int);
+ DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, REAL, _real);
+ DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR2, /, Vector2);
+ DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR3, /, Vector3);
+ DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, COLOR, /, Color);
+
+ CASE_TYPE(math, OP_DIVIDE, NIL)
+ CASE_TYPE(math, OP_DIVIDE, BOOL)
+ CASE_TYPE(math, OP_DIVIDE, STRING)
+ CASE_TYPE(math, OP_DIVIDE, RECT2)
+ CASE_TYPE(math, OP_DIVIDE, TRANSFORM2D)
+ CASE_TYPE(math, OP_DIVIDE, PLANE)
+ CASE_TYPE(math, OP_DIVIDE, RECT3)
+ CASE_TYPE(math, OP_DIVIDE, BASIS)
+ CASE_TYPE(math, OP_DIVIDE, TRANSFORM)
+ CASE_TYPE(math, OP_DIVIDE, NODE_PATH)
+ CASE_TYPE(math, OP_DIVIDE, _RID)
+ CASE_TYPE(math, OP_DIVIDE, OBJECT)
+ CASE_TYPE(math, OP_DIVIDE, DICTIONARY)
+ CASE_TYPE(math, OP_DIVIDE, ARRAY)
+ CASE_TYPE(math, OP_DIVIDE, POOL_BYTE_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, POOL_INT_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, POOL_REAL_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, POOL_STRING_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, POOL_COLOR_ARRAY);
+ _RETURN_FAIL;
+ }
- } break;
- }
-
- } break;
- case OP_POSITIVE: {
- // Simple case when user defines variable as +value.
- switch (p_a.type) {
-
- DEFAULT_OP_FAIL(NIL);
- DEFAULT_OP_FAIL(STRING);
- DEFAULT_OP_FAIL(RECT2);
- DEFAULT_OP_FAIL(TRANSFORM2D);
- DEFAULT_OP_FAIL(RECT3);
- DEFAULT_OP_FAIL(BASIS);
- DEFAULT_OP_FAIL(TRANSFORM);
- DEFAULT_OP_NUM_POS(BOOL, _bool);
- DEFAULT_OP_NUM_POS(INT, _int);
- DEFAULT_OP_NUM_POS(REAL, _real);
- DEFAULT_OP_LOCALMEM_POS(VECTOR3, Vector3);
- DEFAULT_OP_LOCALMEM_POS(PLANE, Plane);
- DEFAULT_OP_LOCALMEM_POS(QUAT, Quat);
- DEFAULT_OP_LOCALMEM_POS(VECTOR2, Vector2);
-
- DEFAULT_OP_FAIL(COLOR);
-
- DEFAULT_OP_FAIL(NODE_PATH);
- DEFAULT_OP_FAIL(_RID);
- DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(DICTIONARY);
- DEFAULT_OP_FAIL(ARRAY);
- DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
- DEFAULT_OP_FAIL(POOL_INT_ARRAY);
- DEFAULT_OP_FAIL(POOL_REAL_ARRAY);
- DEFAULT_OP_FAIL(POOL_STRING_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR2_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR3_ARRAY);
- DEFAULT_OP_FAIL(POOL_COLOR_ARRAY);
- case VARIANT_MAX: {
- r_valid = false;
- return;
+ SWITCH_OP(math, OP_POSITIVE, p_a.type) {
+ DEFAULT_OP_NUM_POS(math, OP_POSITIVE, INT, _int);
+ DEFAULT_OP_NUM_POS(math, OP_POSITIVE, REAL, _real);
+ DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR3, Vector3);
+ DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, PLANE, Plane);
+ DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, QUAT, Quat);
+ DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR2, Vector2);
+
+ CASE_TYPE(math, OP_POSITIVE, NIL)
+ CASE_TYPE(math, OP_POSITIVE, BOOL)
+ CASE_TYPE(math, OP_POSITIVE, STRING)
+ CASE_TYPE(math, OP_POSITIVE, RECT2)
+ CASE_TYPE(math, OP_POSITIVE, TRANSFORM2D)
+ CASE_TYPE(math, OP_POSITIVE, RECT3)
+ CASE_TYPE(math, OP_POSITIVE, BASIS)
+ CASE_TYPE(math, OP_POSITIVE, TRANSFORM)
+ CASE_TYPE(math, OP_POSITIVE, COLOR)
+ CASE_TYPE(math, OP_POSITIVE, NODE_PATH)
+ CASE_TYPE(math, OP_POSITIVE, _RID)
+ CASE_TYPE(math, OP_POSITIVE, OBJECT)
+ CASE_TYPE(math, OP_POSITIVE, DICTIONARY)
+ CASE_TYPE(math, OP_POSITIVE, ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, POOL_BYTE_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, POOL_INT_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, POOL_REAL_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, POOL_STRING_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR2_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR3_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, POOL_COLOR_ARRAY)
+ _RETURN_FAIL;
+ }
- } break;
- }
- } break;
- case OP_NEGATE: {
- switch (p_a.type) {
-
- DEFAULT_OP_FAIL(NIL);
- DEFAULT_OP_NUM_NEG(BOOL, _bool);
- DEFAULT_OP_NUM_NEG(INT, _int);
- DEFAULT_OP_NUM_NEG(REAL, _real);
- DEFAULT_OP_FAIL(STRING);
- DEFAULT_OP_LOCALMEM_NEG(VECTOR2, Vector2);
- DEFAULT_OP_FAIL(RECT2);
- DEFAULT_OP_FAIL(TRANSFORM2D);
- DEFAULT_OP_LOCALMEM_NEG(VECTOR3, Vector3);
- DEFAULT_OP_LOCALMEM_NEG(PLANE, Plane);
- DEFAULT_OP_LOCALMEM_NEG(QUAT, Quat);
- DEFAULT_OP_FAIL(RECT3);
- DEFAULT_OP_FAIL(BASIS);
- DEFAULT_OP_FAIL(TRANSFORM);
-
- DEFAULT_OP_LOCALMEM_NEG(COLOR, Color);
-
- DEFAULT_OP_FAIL(NODE_PATH);
- DEFAULT_OP_FAIL(_RID);
- DEFAULT_OP_FAIL(OBJECT);
- DEFAULT_OP_FAIL(DICTIONARY);
- DEFAULT_OP_FAIL(ARRAY);
- DEFAULT_OP_FAIL(POOL_BYTE_ARRAY);
- DEFAULT_OP_FAIL(POOL_INT_ARRAY);
- DEFAULT_OP_FAIL(POOL_REAL_ARRAY);
- DEFAULT_OP_FAIL(POOL_STRING_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR2_ARRAY);
- DEFAULT_OP_FAIL(POOL_VECTOR3_ARRAY);
- DEFAULT_OP_FAIL(POOL_COLOR_ARRAY);
- case VARIANT_MAX: {
- r_valid = false;
- return;
+ SWITCH_OP(math, OP_NEGATE, p_a.type) {
+ DEFAULT_OP_NUM_NEG(math, OP_NEGATE, INT, _int);
+ DEFAULT_OP_NUM_NEG(math, OP_NEGATE, REAL, _real);
+
+ DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR2, Vector2);
+ DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR3, Vector3);
+ DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, PLANE, Plane);
+ DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, QUAT, Quat);
+ DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, COLOR, Color);
+
+ CASE_TYPE(math, OP_NEGATE, NIL)
+ CASE_TYPE(math, OP_NEGATE, BOOL)
+ CASE_TYPE(math, OP_NEGATE, STRING)
+ CASE_TYPE(math, OP_NEGATE, RECT2)
+ CASE_TYPE(math, OP_NEGATE, TRANSFORM2D)
+ CASE_TYPE(math, OP_NEGATE, RECT3)
+ CASE_TYPE(math, OP_NEGATE, BASIS)
+ CASE_TYPE(math, OP_NEGATE, TRANSFORM)
+ CASE_TYPE(math, OP_NEGATE, NODE_PATH)
+ CASE_TYPE(math, OP_NEGATE, _RID)
+ CASE_TYPE(math, OP_NEGATE, OBJECT)
+ CASE_TYPE(math, OP_NEGATE, DICTIONARY)
+ CASE_TYPE(math, OP_NEGATE, ARRAY)
+ CASE_TYPE(math, OP_NEGATE, POOL_BYTE_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, POOL_INT_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, POOL_REAL_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, POOL_STRING_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, POOL_VECTOR2_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, POOL_VECTOR3_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, POOL_COLOR_ARRAY)
+ _RETURN_FAIL;
+ }
- } break;
- }
- } break;
- case OP_MODULE: {
- if (p_a.type == INT && p_b.type == INT) {
+ SWITCH_OP(math, OP_MODULE, p_a.type) {
+ CASE_TYPE(math, OP_MODULE, INT) {
+ if (p_b.type != INT) {
+ _RETURN_FAIL;
+ }
#ifdef DEBUG_ENABLED
if (p_b._data._int == 0) {
r_valid = false;
@@ -827,15 +1064,18 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
}
#endif
_RETURN(p_a._data._int % p_b._data._int);
+ }
- } else if (p_a.type == STRING) {
- const String *format = reinterpret_cast<const String *>(p_a._data._mem);
+ CASE_TYPE(math, OP_MODULE, STRING) {
+ const String *format =
+ reinterpret_cast<const String *>(p_a._data._mem);
String result;
bool error;
if (p_b.type == ARRAY) {
// e.g. "frog %s %d" % ["fish", 12]
- const Array *args = reinterpret_cast<const Array *>(p_b._data._mem);
+ const Array *args =
+ reinterpret_cast<const Array *>(p_b._data._mem);
result = format->sprintf(*args, &error);
} else {
// e.g. "frog %d" % 12
@@ -847,119 +1087,151 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, const Variant &
_RETURN(result);
}
- r_valid = false;
- return;
+ CASE_TYPE(math, OP_MODULE, NIL)
+ CASE_TYPE(math, OP_MODULE, BOOL)
+ CASE_TYPE(math, OP_MODULE, REAL)
+ CASE_TYPE(math, OP_MODULE, VECTOR2)
+ CASE_TYPE(math, OP_MODULE, RECT2)
+ CASE_TYPE(math, OP_MODULE, VECTOR3)
+ CASE_TYPE(math, OP_MODULE, TRANSFORM2D)
+ CASE_TYPE(math, OP_MODULE, PLANE)
+ CASE_TYPE(math, OP_MODULE, QUAT)
+ CASE_TYPE(math, OP_MODULE, RECT3)
+ CASE_TYPE(math, OP_MODULE, BASIS)
+ CASE_TYPE(math, OP_MODULE, TRANSFORM)
+ CASE_TYPE(math, OP_MODULE, COLOR)
+ CASE_TYPE(math, OP_MODULE, NODE_PATH)
+ CASE_TYPE(math, OP_MODULE, _RID)
+ CASE_TYPE(math, OP_MODULE, OBJECT)
+ CASE_TYPE(math, OP_MODULE, DICTIONARY)
+ CASE_TYPE(math, OP_MODULE, ARRAY)
+ CASE_TYPE(math, OP_MODULE, POOL_BYTE_ARRAY)
+ CASE_TYPE(math, OP_MODULE, POOL_INT_ARRAY)
+ CASE_TYPE(math, OP_MODULE, POOL_REAL_ARRAY)
+ CASE_TYPE(math, OP_MODULE, POOL_STRING_ARRAY)
+ CASE_TYPE(math, OP_MODULE, POOL_VECTOR2_ARRAY)
+ CASE_TYPE(math, OP_MODULE, POOL_VECTOR3_ARRAY)
+ CASE_TYPE(math, OP_MODULE, POOL_COLOR_ARRAY)
+ _RETURN_FAIL;
+ }
- } break;
- case OP_STRING_CONCAT: {
+ SWITCH_OP(math, OP_STRING_CONCAT, p_a.type) {
+ CASE_TYPE_ALL(math, OP_STRING_CONCAT)
_RETURN(p_a.operator String() + p_b.operator String());
- } break;
- //bitwise
- case OP_SHIFT_LEFT: {
- if (p_a.type == INT && p_b.type == INT)
- _RETURN(p_a._data._int << p_b._data._int);
+ }
- r_valid = false;
- return;
+ SWITCH_OP(math, OP_SHIFT_LEFT, p_a.type) {
+ CASE_TYPE(math, OP_SHIFT_LEFT, INT) {
+ if (p_b.type != INT)
+ _RETURN_FAIL;
+ _RETURN(p_a._data._int << p_b._data._int);
+ }
+ CASE_TYPE_ALL_BUT_INT(math, OP_SHIFT_LEFT)
+ _RETURN_FAIL;
+ }
- } break;
- case OP_SHIFT_RIGHT: {
- if (p_a.type == INT && p_b.type == INT)
+ SWITCH_OP(math, OP_SHIFT_RIGHT, p_a.type) {
+ CASE_TYPE(math, OP_SHIFT_RIGHT, INT) {
+ if (p_b.type != INT)
+ _RETURN_FAIL;
_RETURN(p_a._data._int >> p_b._data._int);
+ }
+ CASE_TYPE_ALL_BUT_INT(math, OP_SHIFT_RIGHT)
+ _RETURN_FAIL;
+ }
- r_valid = false;
- return;
-
- } break;
- case OP_BIT_AND: {
- if (p_a.type == INT && p_b.type == INT)
+ SWITCH_OP(math, OP_BIT_AND, p_a.type) {
+ CASE_TYPE(math, OP_BIT_AND, INT) {
+ if (p_b.type != INT)
+ _RETURN_FAIL;
_RETURN(p_a._data._int & p_b._data._int);
+ }
+ CASE_TYPE_ALL_BUT_INT(math, OP_BIT_AND)
+ _RETURN_FAIL;
+ }
- r_valid = false;
- return;
-
- } break;
- case OP_BIT_OR: {
-
- if (p_a.type == INT && p_b.type == INT)
+ SWITCH_OP(math, OP_BIT_OR, p_a.type) {
+ CASE_TYPE(math, OP_BIT_OR, INT) {
+ if (p_b.type != INT)
+ _RETURN_FAIL;
_RETURN(p_a._data._int | p_b._data._int);
+ }
+ CASE_TYPE_ALL_BUT_INT(math, OP_BIT_OR)
+ _RETURN_FAIL;
+ }
- r_valid = false;
- return;
-
- } break;
- case OP_BIT_XOR: {
-
- if (p_a.type == INT && p_b.type == INT)
+ SWITCH_OP(math, OP_BIT_XOR, p_a.type) {
+ CASE_TYPE(math, OP_BIT_XOR, INT) {
+ if (p_b.type != INT)
+ _RETURN_FAIL;
_RETURN(p_a._data._int ^ p_b._data._int);
+ }
+ CASE_TYPE_ALL_BUT_INT(math, OP_BIT_XOR)
+ _RETURN_FAIL;
+ }
- r_valid = false;
- return;
-
- } break;
- case OP_BIT_NEGATE: {
-
- if (p_a.type == INT)
+ SWITCH_OP(math, OP_BIT_NEGATE, p_a.type) {
+ CASE_TYPE(math, OP_BIT_NEGATE, INT) {
_RETURN(~p_a._data._int);
+ }
+ CASE_TYPE_ALL_BUT_INT(math, OP_BIT_NEGATE)
+ _RETURN_FAIL;
+ }
- r_valid = false;
- return;
-
- } break;
- //logic
- case OP_AND: {
- bool l = p_a.booleanize(r_valid);
- if (!r_valid)
- return;
- bool r = p_b.booleanize(r_valid);
- if (!r_valid)
- return;
+ SWITCH_OP(math, OP_AND, p_a.type) {
+ CASE_TYPE_ALL(math, OP_AND) {
+ bool l = p_a.booleanize(r_valid);
+ if (!r_valid)
+ return;
+ bool r = p_b.booleanize(r_valid);
+ if (!r_valid)
+ return;
- _RETURN(l && r);
- } break;
- case OP_OR: {
- bool l = p_a.booleanize(r_valid);
- if (!r_valid)
- return;
- bool r = p_b.booleanize(r_valid);
- if (!r_valid)
- return;
+ _RETURN(l && r);
+ }
+ }
- _RETURN(l || r);
+ SWITCH_OP(math, OP_OR, p_a.type) {
+ CASE_TYPE_ALL(math, OP_OR) {
+ bool l = p_a.booleanize(r_valid);
+ if (!r_valid)
+ return;
+ bool r = p_b.booleanize(r_valid);
+ if (!r_valid)
+ return;
- } break;
- case OP_XOR: {
- bool l = p_a.booleanize(r_valid);
- if (!r_valid)
- return;
- bool r = p_b.booleanize(r_valid);
- if (!r_valid)
- return;
+ _RETURN(l || r);
+ }
+ }
- _RETURN((l || r) && !(l && r));
- } break;
- case OP_NOT: {
+ SWITCH_OP(math, OP_XOR, p_a.type) {
+ CASE_TYPE_ALL(math, OP_XOR) {
+ bool l = p_a.booleanize(r_valid);
+ if (!r_valid)
+ return;
+ bool r = p_b.booleanize(r_valid);
+ if (!r_valid)
+ return;
- bool l = p_a.booleanize(r_valid);
- if (!r_valid)
- return;
- _RETURN(!l);
+ _RETURN((l || r) && !(l && r));
+ }
+ }
- } break;
- case OP_IN: {
+ SWITCH_OP(math, OP_NOT, p_a.type) {
+ CASE_TYPE_ALL(math, OP_NOT) {
+ bool l = p_a.booleanize(r_valid);
+ if (!r_valid)
+ return;
+ _RETURN(!l);
+ }
+ }
+ SWITCH_OP(math, OP_IN, p_a.type) {
+ CASE_TYPE_ALL(math, OP_IN)
_RETURN(p_b.in(p_a, &r_valid));
-
- } break;
- case OP_MAX: {
-
- r_valid = false;
- ERR_FAIL();
}
}
-
- r_valid = false;
}
void Variant::set_named(const StringName &p_index, const Variant &p_value, bool *r_valid) {
@@ -1512,7 +1784,8 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
DEFAULT_OP_DVECTOR_SET(POOL_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) // 25
DEFAULT_OP_DVECTOR_SET(POOL_VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3)
DEFAULT_OP_DVECTOR_SET(POOL_COLOR_ARRAY, Color, p_value.type != Variant::COLOR)
- default: return;
+ default:
+ return;
}
}
@@ -1885,7 +2158,8 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
DEFAULT_OP_DVECTOR_GET(POOL_VECTOR2_ARRAY, Vector2) // 25
DEFAULT_OP_DVECTOR_GET(POOL_VECTOR3_ARRAY, Vector3)
DEFAULT_OP_DVECTOR_GET(POOL_COLOR_ARRAY, Color)
- default: return Variant();
+ default:
+ return Variant();
}
return Variant();
@@ -2374,7 +2648,8 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
return true;
} break;
- default: {}
+ default: {
+ }
}
valid = false;
@@ -2401,7 +2676,7 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
return true;
} break;
case VECTOR2: {
- int64_t to = reinterpret_cast<const Vector3 *>(_data._mem)->y;
+ int64_t to = reinterpret_cast<const Vector2 *>(_data._mem)->y;
int64_t idx = r_iter;
idx++;
@@ -2793,7 +3068,9 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst)
r_dst = Color(r, g, b, a);
}
return;
- default: { r_dst = c < 0.5 ? a : b; }
+ default: {
+ r_dst = c < 0.5 ? a : b;
+ }
return;
}
}
diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml
index 7b120afa51..b61cf93ef7 100644
--- a/doc/classes/@GDScript.xml
+++ b/doc/classes/@GDScript.xml
@@ -23,11 +23,11 @@
<argument index="3" name="a8" type="int">
</argument>
<description>
- Returns a 32 bit color with red, green, blue and alpha channels. Each channel has 8bits of information ranging from 0 to 255.
- 'r8' red channel
- 'g8' green channel
- 'b8' blue channel
- 'a8' alpha channel
+ Returns a 32 bit color with red, green, blue and alpha channels. Each channel has 8 bits of information ranging from 0 to 255.
+ [code]r8[/code] red channel
+ [code]g8[/code] green channel
+ [code]b8[/code] blue channel
+ [code]a8[/code] alpha channel
[codeblock]
red = Color8(255, 0, 0)
[/codeblock]
@@ -41,7 +41,7 @@
<argument index="1" name="alpha" type="float">
</argument>
<description>
- Returns color 'name' with alpha ranging from 0 to 1. Note: 'name' is defined in color_names.inc.
+ Returns color [code]name[/code] with [code]alpha[/code] ranging from 0 to 1. Note: [code]name[/code] is defined in color_names.inc.
[codeblock]
red = ColorN('red')
[/codeblock]
@@ -53,7 +53,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns the absolute value of parameter 's' (i.e. unsigned value, works for integer and float).
+ Returns the absolute value of parameter [code]s[/code] (i.e. unsigned value, works for integer and float).
[codeblock]
# a is 1
a = abs(-1)
@@ -66,7 +66,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns the arc cosine of 's' in radians. Use to get the angle of cosine 's'.
+ Returns the arc cosine of [code]s[/code] in radians. Use to get the angle of cosine [code]s[/code].
[codeblock]
# c is 0.523599 or 30 degrees if converted with rad2deg(s)
c = acos(0.866025)
@@ -79,7 +79,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns the arc sine of 's' in radians. Use to get the angle of sine 's'.
+ Returns the arc sine of [code]s[/code] in radians. Use to get the angle of sine [code]s[/code].
[codeblock]
# s is 0.523599 or 30 degrees if converted with rad2deg(s)
s = asin(0.5)
@@ -92,7 +92,7 @@
<argument index="0" name="condition" type="bool">
</argument>
<description>
- Assert that the condition is true. If the condition is false a fatal error is generated and the program is halted. Useful for debugging to make sure a value is always true.
+ Assert that the [code]condition[/code] is true. If the [code]condition[/code] is false a fatal error is generated and the program is halted. Useful for debugging to make sure a value is always true.
[codeblock]
# Speed should always be between 0 and 20
speed = -10
@@ -108,7 +108,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns the arc tangent of 's' in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code].
+ Returns the arc tangent of [code]s[/code] in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code].
The method cannot know in which quadrant the angle should fall. See [method atan2] if you always want an exact angle.
[codeblock]
a = atan(0.5) # a is 0.463648
@@ -123,7 +123,7 @@
<argument index="1" name="y" type="float">
</argument>
<description>
- Returns the arc tangent of y/x in radians. Use to get the angle of tangent y/x. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.
+ Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.
[codeblock]
a = atan(0,-1) # a is 3.141593
[/codeblock]
@@ -135,7 +135,7 @@
<argument index="0" name="bytes" type="PoolByteArray">
</argument>
<description>
- Decode a byte array back to a value.
+ Decodes a byte array back to a value.
</description>
</method>
<method name="ceil">
@@ -144,7 +144,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Rounds 's' upward, returning the smallest integral value that is not less than 's'.
+ Rounds [code]s[/code] upward, returning the smallest integral value that is not less than [code]s[/code].
[codeblock]
i = ceil(1.45) # i is 2
i = ceil(1.001) # i is 2
@@ -157,7 +157,7 @@
<argument index="0" name="ascii" type="int">
</argument>
<description>
- Returns a character as String of the given ASCII code.
+ Returns a character as a String of the given ASCII code.
[codeblock]
# a is 'A'
a = char(65)
@@ -176,7 +176,7 @@
<argument index="2" name="max" type="float">
</argument>
<description>
- Clamp 'val' and return a value not less than 'min' and not more than 'max'.
+ Clamps [code]val[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code].
[codeblock]
speed = 1000
# a is 20
@@ -196,7 +196,7 @@
<argument index="1" name="type" type="int">
</argument>
<description>
- Convert from a type to another in the best way possible. The "type" parameter uses the enum TYPE_* in [@Global Scope].
+ Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the enum TYPE_* in [@Global Scope].
[codeblock]
a = Vector2(1, 0)
# prints 1
@@ -214,7 +214,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns the cosine of angle 's' in radians.
+ Returns the cosine of angle [code]s[/code] in radians.
[codeblock]
# prints 1 and -1
print(cos(PI*2))
@@ -228,7 +228,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns the hyperbolic cosine of 's' in radians.
+ Returns the hyperbolic cosine of [code]s[/code] in radians.
[codeblock]
# prints 1.543081
print(cosh(1))
@@ -241,7 +241,7 @@
<argument index="0" name="db" type="float">
</argument>
<description>
- Convert from decibels to linear energy (audio).
+ Converts from decibels to linear energy (audio).
</description>
</method>
<method name="decimals">
@@ -250,7 +250,7 @@
<argument index="0" name="step" type="float">
</argument>
<description>
- Returns the number of digit places after the decimal that the first non-zero digit occurs.
+ Returns the position of the first non-zero digit, after the decimal point.
[codeblock]
# n is 2
n = decimals(0.035)
@@ -267,7 +267,7 @@
<argument index="2" name="step" type="float">
</argument>
<description>
- Returns the result of 'value' decreased by 'step' * 'amount'.
+ Returns the result of [code]value[/code] decreased by [code]step[/code] * [code]amount[/code].
[codeblock]
# a = 59
a = dectime(60, 10, 0.1))
@@ -293,7 +293,7 @@
<argument index="0" name="dict" type="Dictionary">
</argument>
<description>
- Convert a previously converted instance to dictionary back into an instance. Useful for deserializing.
+ Converts a previously converted instance to a dictionary, back into an instance. Useful for deserializing.
</description>
</method>
<method name="ease">
@@ -313,7 +313,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Raises the Euler's constant [b]e[/b] to the power of 's' and returns it. [b] has an approximate value of 2.71828.
+ Raises the Euler's constant [b]e[/b] to the power of [code]s[/code] and returns it. [b]e[/b] has an approximate value of 2.71828.
[codeblock]
a = exp(2) # approximately 7.39
[/codeblock]
@@ -325,7 +325,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Rounds 's' to the closest smaller integer and returns it.
+ Rounds [code]s[/code] to the closest smaller integer and returns it.
[codeblock]
# a is 2
a = floor(2.99)
@@ -342,11 +342,11 @@
<argument index="1" name="y" type="float">
</argument>
<description>
- Returns the floating-point remainder of x/y (rounded towards zero):
+ Returns the floating-point remainder of [code]x/y[/code].
[codeblock]
- fmod = x - tquot * y
+ # remainder is 1.5
+ var remainder = fmod(7, 5.5)
[/codeblock]
- Where tquot is the truncated (i.e., rounded towards zero) result of: x/y.
</description>
</method>
<method name="fposmod">
@@ -357,7 +357,7 @@
<argument index="1" name="y" type="float">
</argument>
<description>
- Returns the floating-point remainder of x/y that wraps equally in positive and negative.
+ Returns the floating-point remainder of [code]x/y[/code] that wraps equally in positive and negative.
[codeblock]
var i = -10;
while i &lt; 0:
@@ -387,7 +387,7 @@
<argument index="1" name="funcname" type="String">
</argument>
<description>
- Returns a reference to the specified function 'funcname' in the 'instance' node. As functions aren't first-class objects in GDscript, use 'funcref' to store a function in a variable and call it later.
+ Returns a reference to the specified function [code]funcname[/code] in the [code]instance[/code] node. As functions aren't first-class objects in GDscript, use [code]funcref[/code] to store a [FuncRef] in a variable and call it later.
[codeblock]
func foo():
return("bar")
@@ -415,7 +415,7 @@
<argument index="0" name="inst" type="Object">
</argument>
<description>
- Returns the passed instance converted a dictionary (useful for serializing).
+ Returns the passed instance converted to a dictionary (useful for serializing).
[codeblock]
var foo = "bar"
func _ready():
@@ -436,7 +436,7 @@
<argument index="0" name="instance_id" type="int">
</argument>
<description>
- Returns the Object that corresponds to 'instance_id'. All Objects have a unique instance ID.
+ Returns the Object that corresponds to [code]instance_id[/code]. All Objects have a unique instance ID.
[codeblock]
var foo = "bar"
func _ready():
@@ -468,7 +468,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns True/False whether 's' is an infinity value (either positive infinity or negative infinity).
+ Returns True/False whether [code]s[/code] is an infinity value (either positive infinity or negative infinity).
</description>
</method>
<method name="is_nan">
@@ -477,7 +477,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns True/False whether 's' is a NaN (Not-A-Number) value.
+ Returns True/False whether [code]s[/code] is a NaN (Not-A-Number) value.
</description>
</method>
<method name="len">
@@ -486,7 +486,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
- Returns length of Variant 'var'. Length is the character count of String, element count of Array, size of Dictionary, etc. Note: Generates a fatal error if Variant can not provide a length.
+ Returns length of Variant [code]var[/code]. Length is the character count of String, element count of Array, size of Dictionary, etc. Note: Generates a fatal error if Variant can not provide a length.
[codeblock]
a = [1, 2, 3, 4]
len(a) # returns 4
@@ -503,7 +503,7 @@
<argument index="2" name="weight" type="float">
</argument>
<description>
- Linear interpolates between two values by a normalized value.
+ Linearly interpolates between two values by a normalized value.
[codeblock]
lerp(1, 3, 0.5) # returns 2
[/codeblock]
@@ -515,7 +515,7 @@
<argument index="0" name="nrg" type="float">
</argument>
<description>
- Convert from linear energy to decibels (audio).
+ Converts from linear energy to decibels (audio).
</description>
</method>
<method name="load">
@@ -524,7 +524,7 @@
<argument index="0" name="path" type="String">
</argument>
<description>
- Load a resource from the filesystem located at 'path'. Note: resource paths can be obtained by right clicking on a resource in the Assets Pannel and choosing "Copy Path".
+ Loads a resource from the filesystem located at 'path'. Note: resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path".
[codeblock]
# load a scene called main located in the root of the project directory
var main = load("res://main.tscn")
@@ -537,7 +537,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Natural logarithm. The amount of time needed to reach a certain level of continuous growth. Note: This is not the same as the log funcation on your calculator which is a base 10 logarithm.
+ Natural logarithm. The amount of time needed to reach a certain level of continuous growth. Note: This is not the same as the log function on your calculator which is a base 10 logarithm.
[codeblock]
log(10) # returns 2.302585
[/codeblock]
@@ -579,7 +579,7 @@
<argument index="0" name="val" type="int">
</argument>
<description>
- Returns the nearest larger power of 2 for integer 'val'.
+ Returns the nearest larger power of 2 for integer [code]val[/code].
[codeblock]
nearest_po2(3) # returns 4
nearest_po2(4) # returns 4
@@ -594,7 +594,7 @@
</argument>
<description>
Parse JSON text to a Variant (use [method typeof] to check if it is what you expect).
- Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert every numerical values to [float] types.
+ Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert all numerical values to [float] types.
[codeblock]
p = parse_json('["a", "b", "c"]')
if typeof(p) == TYPE_ARRAY:
@@ -612,7 +612,7 @@
<argument index="1" name="y" type="float">
</argument>
<description>
- Returns the result of 'x' raised to the power of 'y'.
+ Returns the result of [code]x[/code] raised to the power of [code]y[/code].
[codeblock]
pow(2,5) # returns 32
[/codeblock]
@@ -624,7 +624,7 @@
<argument index="0" name="path" type="String">
</argument>
<description>
- Returns a resource from the filesystem that is loaded during script parsing. Note: resource paths can be obtained by right clicking on a resource in the Assets Pannel and choosing "Copy Path".
+ Returns a resource from the filesystem that is loaded during script parsing. Note: resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path".
[codeblock]
# load a scene called main located in the root of the project directory
var main = preload("res://main.tscn")
@@ -646,7 +646,7 @@
<return type="void">
</return>
<description>
- Print a stack track at code location, only works when running with debugger turned on.
+ Prints a stack track at code location, only works when running with debugger turned on.
Output in the console would look something like this:
[codeblock]
Frame 0 - res://test.gd:16 in function '_process'
@@ -657,7 +657,7 @@
<return type="void">
</return>
<description>
- Print one or more arguments to strings in the best way possible to standard error line.
+ Prints one or more arguments to strings in the best way possible to standard error line.
[codeblock]
printerr("prints to stderr")
[/codeblock]
@@ -667,7 +667,7 @@
<return type="void">
</return>
<description>
- Print one or more arguments to strings in the best way possible to console. No newline is added at the end.
+ Prints one or more arguments to strings in the best way possible to console. No newline is added at the end.
[codeblock]
printraw("A")
printraw("B")
@@ -679,7 +679,7 @@
<return type="void">
</return>
<description>
- Print one or more arguments to the console with a space between each argument.
+ Prints one or more arguments to the console with a space between each argument.
[codeblock]
prints("A", "B", "C") # prints A B C
[/codeblock]
@@ -689,7 +689,7 @@
<return type="void">
</return>
<description>
- Print one or more arguments to the console with a tab between each argument.
+ Prints one or more arguments to the console with a tab between each argument.
[codeblock]
printt("A", "B", "C") # prints A B C
[/codeblock]
@@ -701,7 +701,7 @@
<argument index="0" name="rad" type="float">
</argument>
<description>
- Convert from radians to degrees.
+ Converts from radians to degrees.
[codeblock]
rad2deg(0.523599) # returns 30
[/codeblock]
@@ -715,7 +715,7 @@
<argument index="1" name="to" type="float">
</argument>
<description>
- Random range, any floating point value between 'from' and 'to'.
+ Random range, any floating point value between [code]from[/code] and [code]to[/code].
[codeblock]
prints(rand_range(0, 1), rand_range(0, 1)) # prints 0.135591 0.405263
[/codeblock]
@@ -727,14 +727,14 @@
<argument index="0" name="seed" type="int">
</argument>
<description>
- Random from seed: pass a seed, and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
+ Random from seed: pass a [code]seed[/code], and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
</description>
</method>
<method name="randf">
<return type="float">
</return>
<description>
- Return a random floating point value between 0 and 1.
+ Returns a random floating point value between 0 and 1.
[codeblock]
randf() # returns 0.375671
[/codeblock]
@@ -744,7 +744,7 @@
<return type="int">
</return>
<description>
- Return a random 32 bit integer. Use remainder to obtain a random value between 0 and N (where N is smaller than 2^32 -1).
+ Returns a random 32 bit integer. Use remainder to obtain a random value between 0 and N (where N is smaller than 2^32 -1).
[codeblock]
randi() % 20 # returns random number between 0 and 19
randi() % 100 # returns random number between 0 and 99
@@ -756,7 +756,7 @@
<return type="void">
</return>
<description>
- Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
+ Randomizes the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
[codeblock]
func _ready():
randomize()
@@ -767,7 +767,7 @@
<return type="Array">
</return>
<description>
- Return an array with the given range. Range can be 1 argument N (0 to N-1), two arguments (initial, final-1) or three arguments (initial, final-1, increment).
+ Returns an array with the given range. Range can be 1 argument N (0 to N-1), two arguments (initial, final-1) or three arguments (initial, final-1, increment).
[codeblock]
for i in range(4):
print(i)
@@ -807,7 +807,7 @@
<argument index="4" name="ostop" type="float">
</argument>
<description>
- Maps a value from range [istart, istop] to [ostart, ostop].
+ Maps a [code]value[/code] from range [code][istart, istop][/code] to [code][ostart, ostop][/code].
[codeblock]
range_lerp(75, 0, 100, -1, 1) # returns 0.5
[/codeblock]
@@ -819,7 +819,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns the integral value that is nearest to s, with halfway cases rounded away from zero.
+ Returns the integral value that is nearest to [code]s[/code], with halfway cases rounded away from zero.
[codeblock]
round(2.6) # returns 3
[/codeblock]
@@ -831,7 +831,7 @@
<argument index="0" name="seed" type="int">
</argument>
<description>
- Set seed for the random number generator.
+ Sets seed for the random number generator.
[codeblock]
my_seed = "Godot Rocks"
seed(my_seed.hash())
@@ -844,7 +844,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Return sign of 's' -1 or 1.
+ Returns sign of [code]s[/code] -1 or 1.
[codeblock]
sign(-6) # returns -1
sign(6) # returns 1
@@ -857,7 +857,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Return the sine of angle 's' in radians.
+ Returns the sine of angle [code]s[/code] in radians.
[codeblock]
sin(0.523599) # returns 0.5
[/codeblock]
@@ -869,7 +869,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Return the hyperbolic sine of 's'.
+ Returns the hyperbolic sine of [code]s[/code].
[codeblock]
a = log(2.0) # returns 0.693147
sinh(a) # returns 0.75
@@ -882,7 +882,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Return the square root of 's'.
+ Returns the square root of [code]s[/code].
[codeblock]
sqrt(9) # returns 3
[/codeblock]
@@ -896,14 +896,14 @@
<argument index="1" name="step" type="float">
</argument>
<description>
- Snap float value to a given step.
+ Snaps float value [code]s[/code] to a given [code]step[/code].
</description>
</method>
<method name="str" qualifiers="vararg">
<return type="String">
</return>
<description>
- Convert one or more arguments to string in the best way possible.
+ Converts one or more arguments to string in the best way possible.
[codeblock]
var a = [10, 20, 30]
var b = str(a);
@@ -918,7 +918,7 @@
<argument index="0" name="string" type="String">
</argument>
<description>
- Convert a formatted string that was returned by [method var2str] to the original value.
+ Converts a formatted string that was returned by [method var2str] to the original value.
[codeblock]
a = '{ "a": 1, "b": 2 }'
b = str2var(a)
@@ -932,7 +932,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Return the tangent of angle 's' in radians.
+ Returns the tangent of angle [code]s[/code] in radians.
[codeblock]
tan( deg2rad(45) ) # returns 1
[/codeblock]
@@ -944,7 +944,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
- Returns the hyperbolic tangent of 's'.
+ Returns the hyperbolic tangent of [code]s[/code].
[codeblock]
a = log(2.0) # returns 0.693147
tanh(a) # returns 0.6
@@ -957,7 +957,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
- Convert a Variant 'var' to json text and return the result. Useful for serializing data to store or send over the network
+ Converts a Variant [code]var[/code] to JSON text and return the result. Useful for serializing data to store or send over the network.
[codeblock]
a = { 'a': 1, 'b': 2 }
b = to_json(a)
@@ -971,7 +971,7 @@
<argument index="0" name="type" type="String">
</argument>
<description>
- Returns whether the given class is exist in [ClassDB].
+ Returns whether the given class exists in [ClassDB].
[codeblock]
type_exists("Sprite") # returns true
type_exists("Variant") # returns false
@@ -984,7 +984,7 @@
<argument index="0" name="what" type="Variant">
</argument>
<description>
- Return the internal type of the given Variant object, using the TYPE_* enum in [@Global Scope].
+ Returns the internal type of the given Variant object, using the TYPE_* enum in [@Global Scope].
[codeblock]
p = parse_json('["a", "b", "c"]')
if typeof(p) == TYPE_ARRAY:
@@ -1000,7 +1000,7 @@
<argument index="0" name="json" type="String">
</argument>
<description>
- Check that 'json' is valid json data. Return empty string if valid. Return error message if not valid.
+ Checks that [code]json[/code] is valid JSON data. Returns empty string if valid. Returns error message if not valid.
[codeblock]
j = to_json([1, 2, 3])
v = validate_json(j)
@@ -1017,7 +1017,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
- Encode a variable value to a byte array.
+ Encodes a variable value to a byte array.
</description>
</method>
<method name="var2str">
@@ -1026,7 +1026,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
- Convert a value to a formatted string that can later be parsed using [method str2var].
+ Converts a Variant [code]var[/code] to a formatted string that can later be parsed using [method str2var].
[codeblock]
a = { 'a': 1, 'b': 2 }
print(var2str(a))
@@ -1046,7 +1046,7 @@
<argument index="0" name="obj" type="Object">
</argument>
<description>
- Return a weak reference to an object.
+ Returns a weak reference to an object.
A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.
</description>
</method>
@@ -1058,7 +1058,7 @@
<argument index="1" name="signal" type="String">
</argument>
<description>
- Stop the function execution and return the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state.
+ Stops the function execution and returns the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state.
Returns anything that was passed to the resume function call. If passed an object and a signal, the execution is resumed when the object's signal is emitted.
</description>
</method>
diff --git a/doc/classes/RigidBody.xml b/doc/classes/RigidBody.xml
index fc9d241e35..8347597daf 100644
--- a/doc/classes/RigidBody.xml
+++ b/doc/classes/RigidBody.xml
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RigidBody" inherits="PhysicsBody" category="Core" version="3.0.alpha.custom_build">
<brief_description>
- Rigid body node.
+ Physics Body whose position is determined through physics simulation in 3D space.
</brief_description>
<description>
- Rigid body node. This node is used for placing rigid bodies in the scene. It can contain a number of shapes, and also shift mode between regular Rigid body, Kinematic, Character or Static.
+ This is the node that implements full 3D physics. This means that you do not control a RigidBody directly. Instead you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
+ This node can use custom force integration, for writing complex physics motion behavior per node.
+ This node can shift state between regular Rigid body, Kinematic, Character or Static.
+ Character mode forbids this node from being rotated.
+ As a warning, don't change RigidBody's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop will yield strange behavior.
</description>
<tutorials>
</tutorials>
@@ -324,55 +328,56 @@
</methods>
<members>
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp">
- Dampens rotational forces of the Rigid body by the 'angular_damp' rate.
+ Damps RigidBody's rotational forces.
</member>
<member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity">
- The current rotational velocity of the Rigid body
+ RigidBody's rotational velocity.
</member>
<member name="axis_lock" type="int" setter="set_axis_lock" getter="get_axis_lock" enum="RigidBody.AxisLock">
Locks the rotational forces to a particular axis, preventing rotations on other axes.
</member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
- Bounciness of the Rigid body.
+ RigidBody's bounciness.
</member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep">
- If true, the Rigid body will no longer calculate forces when there is no movement and will act as a static body. It will wake up when other forces are applied through other collisions or when the 'apply_impulse' method is used.
+ If [code]true[/code] the RigidBody will not calculate forces and will act as a static body while there is no movement. It will wake up when forces are applied through other collisions or when the [code]apply_impulse[/code] method is used.
</member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled">
- If true, the Rigid body will emit signals when it collides with another Rigid body.
+ If true, the RigidBody will emit signals when it collides with another RigidBody.
</member>
<member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported">
The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
</member>
<member name="continuous_cd" type="bool" setter="set_use_continuous_collision_detection" getter="is_using_continuous_collision_detection">
- Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. The first is more precise, and misses less impacts by small, fast-moving objects. The second is faster to compute, but can miss small, fast-moving objects.
+ If [code]true[/code] continuous collision detection is used.
+ Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses less impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects.
</member>
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator">
- If true, internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined.
+ If [code]true[/code] internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined.
</member>
<member name="friction" type="float" setter="set_friction" getter="get_friction">
The body friction, from 0 (frictionless) to 1 (max friction).
</member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale">
- The 'gravity_scale' for this Rigid body will be multiplied by the global 3d gravity setting found in "Project &gt; Project Settings &gt; Physics &gt; 3d". A value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
+ This is multiplied by the global 3D gravity setting found in "Project &gt; Project Settings &gt; Physics &gt; 3d" to produce RigidBody's gravity. E.g. a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp">
- The linear damp for this body. Default of -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.
+ RigidBody's linear damp. Default value: -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.
</member>
<member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity">
- The body linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
+ RigidBody's linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
</member>
<member name="mass" type="float" setter="set_mass" getter="get_mass">
- The body mass.
+ RigidBody's mass.
</member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody.Mode">
The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER.
</member>
<member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping">
- The current 'sleeping' state of the Rigid body.
+ If [code]true[/code] RigidBody is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method.
</member>
<member name="weight" type="float" setter="set_weight" getter="get_weight">
- The body weight given standard earth-weight (gravity 9.8).
+ RigidBody's weight based on its mass and the global 3D gravity. Global values are set in "Project &gt; Project Settings &gt; Physics &gt; 3d".
</member>
</members>
<signals>
diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml
index e92c417323..a4faa697de 100644
--- a/doc/classes/RigidBody2D.xml
+++ b/doc/classes/RigidBody2D.xml
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RigidBody2D" inherits="PhysicsBody2D" category="Core" version="3.0.alpha.custom_build">
<brief_description>
- Rigid body 2D node.
+ Physics Body whose position is determined through physics simulation in 2D space.
</brief_description>
<description>
- Rigid body 2D node. This node is used for placing rigid bodies in the scene. It can contain a number of shapes, and also shift state between regular Rigid body, Kinematic, Character or Static.
- Character mode forbids the node from being rotated. This node can have a custom force integrator function, for writing complex physics motion behavior per node.
- As a warning, don't change this node position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop will yield strange behavior.
+ This is the node that implements full 2D physics. This means that you do not control a RigidBody2D directly. Instead you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
+ This node can use custom force integration, for writing complex physics motion behavior per node.
+ This node can shift state between regular Rigid body, Kinematic, Character or Static.
+ Character mode forbids this node from being rotated.
+ As a warning, don't change RigidBody2D's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop will yield strange behavior.
</description>
<tutorials>
</tutorials>
@@ -382,36 +384,53 @@
</methods>
<members>
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp">
+ Damps RigidBody2D's rotational forces.
</member>
<member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity">
+ RigidBody2D's rotational velocity.
</member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
+ RigidBody2D's bounciness.
</member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep">
+ If [code]true[/code] RigidBody2D will not calculate forces and will act as a static body while there is no movement. It will wake up when other forces are applied through other collisions or when the [code]apply_impulse[/code] method is used. Default value: [code]true[/code]
</member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled">
+ If [code]true[/code] RigidBody2D will emit signals when it collides with another RigidBody2D.
</member>
<member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported">
+ The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
</member>
<member name="continuous_cd" type="int" setter="set_continuous_collision_detection_mode" getter="get_continuous_collision_detection_mode" enum="RigidBody2D.CCDMode">
+ If [code]true[/code] continuous collision detection is used. Default value: [code]false[/code]
+ Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses less impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects.
</member>
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator">
+ If [code]true[/code] internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined.
</member>
<member name="friction" type="float" setter="set_friction" getter="get_friction">
+ The body friction, from 0 (frictionless) to 1 (max friction).
</member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale">
+ This is multiplied by the global 2D gravity setting found in "Project &gt; Project Settings &gt; Physics &gt; 2d" to produce RigidBody2D's gravity. E.g. a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp">
+ RigidBody2D's linear damp. Default of -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.
</member>
<member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity">
+ RigidBody2D's linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
</member>
<member name="mass" type="float" setter="set_mass" getter="get_mass">
+ RigidBody2D's mass.
</member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody2D.Mode">
+ The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER.
</member>
<member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping">
+ If [code]true[/code] RigidBody2D is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method.
</member>
<member name="weight" type="float" setter="set_weight" getter="get_weight">
+ RigidBody2D's weight based on its mass and the global 2D gravity. Global values are set in "Project &gt; Project Settings &gt; Physics &gt; 2d".
</member>
</members>
<signals>
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 8c153d2745..5dd8b8a800 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1023,8 +1023,10 @@ void CodeTextEditor::_line_col_changed() {
void CodeTextEditor::_text_changed() {
- code_complete_timer->start();
- idle->start();
+ if (text_editor->is_insert_text_operation()) {
+ code_complete_timer->start();
+ idle->start();
+ }
}
void CodeTextEditor::_code_complete_timer_timeout() {
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 07aa83d342..1a89d6ef6e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4061,27 +4061,29 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
ERR_FAIL_INDEX(p_idx, bottom_panel_items.size());
if (p_enable) {
+ // this is the debug panel wich uses tabs, so the top section should be smaller
+ if (ScriptEditor::get_singleton()->get_debugger() == bottom_panel_items[p_idx].control) {
+ Ref<StyleBoxFlat> style_panel_invisible_top = gui_base->get_stylebox("debugger_panel", "EditorStyles");
+ bottom_panel->add_style_override("panel", style_panel_invisible_top);
+ } else {
+ bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
+ }
for (int i = 0; i < bottom_panel_items.size(); i++) {
bottom_panel_items[i].button->set_pressed(i == p_idx);
bottom_panel_items[i].control->set_visible(i == p_idx);
}
- if (ScriptEditor::get_singleton()->get_debugger() == bottom_panel_items[p_idx].control) { // this is the debug panel wich uses tabs, so the top section should be smaller
- Ref<StyleBoxFlat> style_panel_invisible_top = gui_base->get_stylebox("panel", "TabContainer")->duplicate();
- int stylebox_offset = gui_base->get_font("font", "Tabs")->get_height() + gui_base->get_stylebox("tab_fg", "Tabs")->get_minimum_size().height + gui_base->get_stylebox("panel", "TabContainer")->get_default_margin(MARGIN_TOP);
- style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset);
- bottom_panel->add_style_override("panel", style_panel_invisible_top);
- } else {
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
- }
center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE);
center_split->set_collapsed(false);
} else {
+ bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
+
for (int i = 0; i < bottom_panel_items.size(); i++) {
bottom_panel_items[i].button->set_pressed(false);
bottom_panel_items[i].control->set_visible(false);
}
+
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
center_split->set_collapsed(true);
}
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 0cba024595..3482261c19 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -322,6 +322,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const int border_width = CLAMP(border_size, 0, 3) * EDSCALE;
const int default_margin_size = 4;
+ const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 3);
// styleboxes
// this is the most commonly used stylebox, variations should be made as duplicate of this
@@ -333,11 +334,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// Button and widgets
Ref<StyleBoxFlat> style_widget = style_default->duplicate();
- // style_widget->set_bg_color(dark_color_1.linear_interpolate(base_color, 0.4));
style_widget->set_bg_color(dark_color_1);
style_widget->set_default_margin(MARGIN_LEFT, 6 * EDSCALE);
style_widget->set_default_margin(MARGIN_RIGHT, 6 * EDSCALE);
- // style_widget->set_border_color_all(contrast_color_1);
style_widget->set_border_color_all(dark_color_2);
Ref<StyleBoxFlat> style_widget_disabled = style_widget->duplicate();
@@ -368,18 +367,19 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size);
// Tabs
+ const int tab_default_margin_side = 10 * EDSCALE;
Ref<StyleBoxFlat> style_tab_selected = style_default->duplicate();
style_tab_selected->set_border_width_all(border_width);
style_tab_selected->set_border_width(MARGIN_BOTTOM, 0);
style_tab_selected->set_border_color_all(dark_color_3);
style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width);
- style_tab_selected->set_default_margin(MARGIN_LEFT, 10 * EDSCALE);
- style_tab_selected->set_default_margin(MARGIN_RIGHT, 10 * EDSCALE);
+ style_tab_selected->set_default_margin(MARGIN_LEFT, tab_default_margin_side);
+ style_tab_selected->set_default_margin(MARGIN_RIGHT, tab_default_margin_side);
style_tab_selected->set_bg_color(tab_color);
- Ref<StyleBoxEmpty> style_tab_unselected = style_empty->duplicate();
- style_tab_unselected->set_default_margin(MARGIN_LEFT, 10 * EDSCALE);
- style_tab_unselected->set_default_margin(MARGIN_RIGHT, 10 * EDSCALE);
+ Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate();
+ style_tab_unselected->set_bg_color(Color(0.0, 0.0, 0.0, 0.0));
+ style_tab_unselected->set_border_color_all(Color(0.0, 0.0, 0.0, 0.0));
// Editor background
theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size));
@@ -603,13 +603,18 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<StyleBoxFlat> style_content_panel = style_default->duplicate();
style_content_panel->set_border_color_all(dark_color_3);
style_content_panel->set_border_width_all(border_width);
+ // compensate the border
+ style_content_panel->set_default_margin(MARGIN_TOP, margin_size_extra);
+ style_content_panel->set_default_margin(MARGIN_RIGHT, margin_size_extra);
+ style_content_panel->set_default_margin(MARGIN_BOTTOM, margin_size_extra);
+ style_content_panel->set_default_margin(MARGIN_LEFT, margin_size_extra);
// this is the stylebox used in 3d and 2d viewports (no borders)
Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate();
- style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width);
+ style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width * 2);
style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size);
- style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width);
- style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width);
+ style_content_panel_vp->set_default_margin(MARGIN_RIGHT, border_width * 2);
+ style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width * 2);
theme->set_stylebox("panel", "TabContainer", style_content_panel);
theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);
@@ -617,15 +622,28 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width));
theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, true));
- // Debugger
- Ref<StyleBoxFlat> style_panel_debugger = style_default->duplicate();
- theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger);
+ // HACK Debuger panel
+ Ref<StyleBoxFlat> style_panel_debugger = style_content_panel->duplicate();
+ const int v_offset = theme->get_font("font", "Tabs")->get_height() + style_tab_selected->get_minimum_size().height + default_margin_size * EDSCALE;
+ style_panel_debugger->set_expand_margin_size(MARGIN_TOP, -v_offset);
+ theme->set_stylebox("debugger_panel", "EditorStyles", style_panel_debugger);
+ // Debugger
+ Ref<StyleBoxFlat> style_debugger_contents = style_content_panel->duplicate();
+ style_debugger_contents->set_default_margin(MARGIN_LEFT, 0);
+ style_debugger_contents->set_default_margin(MARGIN_BOTTOM, 0);
+ style_debugger_contents->set_default_margin(MARGIN_RIGHT, 0);
+ style_debugger_contents->set_border_width_all(0);
+ style_debugger_contents->set_expand_margin_size(MARGIN_TOP, -v_offset);
+ theme->set_stylebox("DebuggerPanel", "EditorStyles", style_debugger_contents);
Ref<StyleBoxFlat> style_tab_fg_debugger = style_tab_selected->duplicate();
- style_tab_fg_debugger->set_border_width_all(0);
-
+ style_tab_fg_debugger->set_expand_margin_size(MARGIN_LEFT, default_margin_size * EDSCALE + border_width);
+ style_tab_fg_debugger->set_default_margin(MARGIN_LEFT, tab_default_margin_side - default_margin_size * EDSCALE);
theme->set_stylebox("DebuggerTabFG", "EditorStyles", style_tab_fg_debugger);
- theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_unselected);
+ Ref<StyleBoxFlat> style_tab_bg_debugger = style_tab_unselected->duplicate();
+ style_tab_bg_debugger->set_expand_margin_size(MARGIN_LEFT, default_margin_size * EDSCALE + border_width);
+ style_tab_bg_debugger->set_default_margin(MARGIN_LEFT, tab_default_margin_side - default_margin_size * EDSCALE);
+ theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_bg_debugger);
// LineEdit
theme->set_stylebox("normal", "LineEdit", style_widget);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index cc519c1c4b..b448ab8920 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -120,13 +120,13 @@ String ResourceImporterScene::get_preset_name(int p_idx) const {
switch (p_idx) {
case PRESET_SINGLE_SCENE: return TTR("Import as Single Scene");
- case PRESET_SEPERATE_ANIMATIONS: return TTR("Import with Seperate Animations");
+ case PRESET_SEPARATE_ANIMATIONS: return TTR("Import with Separate Animations");
case PRESET_SEPARATE_MATERIALS: return TTR("Import with Separate Materials");
case PRESET_SEPARATE_MESHES: return TTR("Import with Separate Objects");
case PRESET_SEPARATE_MESHES_AND_MATERIALS: return TTR("Import with Separate Objects+Materials");
- case PRESET_SEPARATE_MESHES_AND_ANIMATIONS: return TTR("Import with Seperate Objects+Animations");
- case PRESET_SEPERATE_MATERIALS_AND_ANIMATIONS: return TTR("Import with Seperate Materials+Animations");
- case PRESET_SEPERATE_MESHES_MATERIALS_AND_ANIMATIONS: return TTR("Import with Seperate Objects+Materials+Animations");
+ case PRESET_SEPARATE_MESHES_AND_ANIMATIONS: return TTR("Import with Separate Objects+Animations");
+ case PRESET_SEPARATE_MATERIALS_AND_ANIMATIONS: return TTR("Import with Separate Materials+Animations");
+ case PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS: return TTR("Import with Separate Objects+Materials+Animations");
case PRESET_MULTIPLE_SCENES: return TTR("Import as Multiple Scenes");
case PRESET_MULTIPLE_SCENES_AND_MATERIALS: return TTR("Import as Multiple Scenes+Materials");
}
@@ -954,10 +954,10 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
script_ext_hint += "*." + E->get();
}
- bool materials_out = p_preset == PRESET_SEPARATE_MATERIALS || p_preset == PRESET_SEPARATE_MESHES_AND_MATERIALS || p_preset == PRESET_MULTIPLE_SCENES_AND_MATERIALS || p_preset == PRESET_SEPERATE_MATERIALS_AND_ANIMATIONS || p_preset == PRESET_SEPERATE_MESHES_MATERIALS_AND_ANIMATIONS;
- bool meshes_out = p_preset == PRESET_SEPARATE_MESHES || p_preset == PRESET_SEPARATE_MESHES_AND_MATERIALS || PRESET_SEPARATE_MESHES_AND_ANIMATIONS || PRESET_SEPERATE_MESHES_MATERIALS_AND_ANIMATIONS;
+ bool materials_out = p_preset == PRESET_SEPARATE_MATERIALS || p_preset == PRESET_SEPARATE_MESHES_AND_MATERIALS || p_preset == PRESET_MULTIPLE_SCENES_AND_MATERIALS || p_preset == PRESET_SEPARATE_MATERIALS_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS;
+ bool meshes_out = p_preset == PRESET_SEPARATE_MESHES || p_preset == PRESET_SEPARATE_MESHES_AND_MATERIALS || PRESET_SEPARATE_MESHES_AND_ANIMATIONS || PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS;
bool scenes_out = p_preset == PRESET_MULTIPLE_SCENES || p_preset == PRESET_MULTIPLE_SCENES_AND_MATERIALS;
- bool animations_out = p_preset == PRESET_SEPERATE_ANIMATIONS || PRESET_SEPARATE_MESHES_AND_ANIMATIONS || p_preset == PRESET_SEPERATE_MATERIALS_AND_ANIMATIONS || p_preset == PRESET_SEPERATE_MESHES_MATERIALS_AND_ANIMATIONS;
+ bool animations_out = p_preset == PRESET_SEPARATE_ANIMATIONS || PRESET_SEPARATE_MESHES_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MATERIALS_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS;
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/custom_script", PROPERTY_HINT_FILE, script_ext_hint), ""));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "nodes/storage", PROPERTY_HINT_ENUM, "Single Scene,Instanced Sub-Scenes"), scenes_out ? 1 : 0));
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 652977b98a..c3a66aa8b8 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -85,14 +85,14 @@ class ResourceImporterScene : public ResourceImporter {
enum Presets {
PRESET_SEPARATE_MATERIALS,
PRESET_SEPARATE_MESHES,
- PRESET_SEPERATE_ANIMATIONS,
+ PRESET_SEPARATE_ANIMATIONS,
PRESET_SINGLE_SCENE,
PRESET_SEPARATE_MESHES_AND_MATERIALS,
PRESET_SEPARATE_MESHES_AND_ANIMATIONS,
- PRESET_SEPERATE_MATERIALS_AND_ANIMATIONS,
- PRESET_SEPERATE_MESHES_MATERIALS_AND_ANIMATIONS,
+ PRESET_SEPARATE_MATERIALS_AND_ANIMATIONS,
+ PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS,
PRESET_MULTIPLE_SCENES,
PRESET_MULTIPLE_SCENES_AND_MATERIALS,
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 9a6449727c..76e75cff0a 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -1623,8 +1623,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
tabs->set_area_as_parent_rect();
- tabs->set_margin(MARGIN_LEFT, -EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel", "TabContainer")->get_margin(MARGIN_LEFT));
- tabs->set_margin(MARGIN_RIGHT, EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel", "TabContainer")->get_margin(MARGIN_LEFT));
add_child(tabs);
{ //debugger
diff --git a/main/main.cpp b/main/main.cpp
index bb601198db..04375666a9 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -248,7 +248,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
performance = memnew(Performance);
globals->add_singleton(ProjectSettings::Singleton("Performance", performance));
- GLOBAL_DEF("debug/settings/backtrace/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues"));
+ GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues"));
MAIN_PRINT("Main: Parse CMDLine");
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index 4803781c67..7036a708e5 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -131,7 +131,7 @@ int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser:
switch (p_expression->op) {
case GDParser::OperatorNode::OP_ASSIGN_ADD: var_op = Variant::OP_ADD; break;
- case GDParser::OperatorNode::OP_ASSIGN_SUB: var_op = Variant::OP_SUBSTRACT; break;
+ case GDParser::OperatorNode::OP_ASSIGN_SUB: var_op = Variant::OP_SUBTRACT; break;
case GDParser::OperatorNode::OP_ASSIGN_MUL: var_op = Variant::OP_MULTIPLY; break;
case GDParser::OperatorNode::OP_ASSIGN_DIV: var_op = Variant::OP_DIVIDE; break;
case GDParser::OperatorNode::OP_ASSIGN_MOD: var_op = Variant::OP_MODULE; break;
@@ -759,7 +759,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level)) return -1;
} break;
case GDParser::OperatorNode::OP_SUB: {
- if (!_create_binary_operator(codegen, on, Variant::OP_SUBSTRACT, p_stack_level)) return -1;
+ if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level)) return -1;
} break;
case GDParser::OperatorNode::OP_MUL: {
if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level)) return -1;
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index bc51b84047..aa39ad92c4 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -908,7 +908,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
Variant::Operator vop = Variant::OP_MAX;
switch (op->op) {
case GDParser::OperatorNode::OP_ADD: vop = Variant::OP_ADD; break;
- case GDParser::OperatorNode::OP_SUB: vop = Variant::OP_SUBSTRACT; break;
+ case GDParser::OperatorNode::OP_SUB: vop = Variant::OP_SUBTRACT; break;
case GDParser::OperatorNode::OP_MUL: vop = Variant::OP_MULTIPLY; break;
case GDParser::OperatorNode::OP_DIV: vop = Variant::OP_DIVIDE; break;
case GDParser::OperatorNode::OP_MOD: vop = Variant::OP_MODULE; break;
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 72c3f9612a..36aaa1f807 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -1699,7 +1699,7 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
_REDUCE_BINARY(Variant::OP_ADD);
} break;
case OperatorNode::OP_SUB: {
- _REDUCE_BINARY(Variant::OP_SUBSTRACT);
+ _REDUCE_BINARY(Variant::OP_SUBTRACT);
} break;
case OperatorNode::OP_MUL: {
_REDUCE_BINARY(Variant::OP_MULTIPLY);
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index eae866d167..897e910f20 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -1023,7 +1023,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
case TK_OP_OR: op = Variant::OP_OR; break;
case TK_OP_NOT: op = Variant::OP_NOT; break;
case TK_OP_ADD: op = Variant::OP_ADD; break;
- case TK_OP_SUB: op = Variant::OP_SUBSTRACT; break;
+ case TK_OP_SUB: op = Variant::OP_SUBTRACT; break;
case TK_OP_MUL: op = Variant::OP_MULTIPLY; break;
case TK_OP_DIV: op = Variant::OP_DIVIDE; break;
case TK_OP_MOD: op = Variant::OP_MODULE; break;
@@ -1085,7 +1085,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
case Variant::OP_MODULE: priority = 2; break;
case Variant::OP_ADD: priority = 3; break;
- case Variant::OP_SUBSTRACT: priority = 3; break;
+ case Variant::OP_SUBTRACT: priority = 3; break;
case Variant::OP_SHIFT_LEFT: priority = 4; break;
case Variant::OP_SHIFT_RIGHT: priority = 4; break;
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 267946750f..f02e797fe6 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -1546,7 +1546,7 @@ public:
value = Variant::evaluate(Variant::OP_ADD, value, p_argument);
} break;
case VisualScriptPropertySet::ASSIGN_OP_SUB: {
- value = Variant::evaluate(Variant::OP_SUBSTRACT, value, p_argument);
+ value = Variant::evaluate(Variant::OP_SUBTRACT, value, p_argument);
} break;
case VisualScriptPropertySet::ASSIGN_OP_MUL: {
value = Variant::evaluate(Variant::OP_MULTIPLY, value, p_argument);
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index b617c11bab..16aec76e57 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -3762,7 +3762,7 @@ void register_visual_script_nodes() {
VisualScriptLanguage::singleton->add_register_func("operators/compare/greater_equal", create_op_node<Variant::OP_GREATER_EQUAL>);
//mathematic
VisualScriptLanguage::singleton->add_register_func("operators/math/add", create_op_node<Variant::OP_ADD>);
- VisualScriptLanguage::singleton->add_register_func("operators/math/subtract", create_op_node<Variant::OP_SUBSTRACT>);
+ VisualScriptLanguage::singleton->add_register_func("operators/math/subtract", create_op_node<Variant::OP_SUBTRACT>);
VisualScriptLanguage::singleton->add_register_func("operators/math/multiply", create_op_node<Variant::OP_MULTIPLY>);
VisualScriptLanguage::singleton->add_register_func("operators/math/divide", create_op_node<Variant::OP_DIVIDE>);
VisualScriptLanguage::singleton->add_register_func("operators/math/negate", create_op_node<Variant::OP_NEGATE>);
diff --git a/platform/osx/crash_handler_osx.mm b/platform/osx/crash_handler_osx.mm
index 9239573734..a8146696bc 100644
--- a/platform/osx/crash_handler_osx.mm
+++ b/platform/osx/crash_handler_osx.mm
@@ -77,7 +77,7 @@ static void handle_crash(int sig) {
void *bt_buffer[256];
size_t size = backtrace(bt_buffer, 256);
String _execpath = OS::get_singleton()->get_executable_path();
- String msg = GLOBAL_GET("debug/settings/backtrace/message");
+ String msg = GLOBAL_GET("debug/settings/crash_handler/message");
// Dump the backtrace to stderr with a message to the user
fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig);
diff --git a/platform/windows/crash_handler_win.cpp b/platform/windows/crash_handler_win.cpp
index c9385f36d6..2f5ee7956e 100644
--- a/platform/windows/crash_handler_win.cpp
+++ b/platform/windows/crash_handler_win.cpp
@@ -116,7 +116,7 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
DWORD cbNeeded;
std::vector<HMODULE> module_handles(1);
- if (OS::get_singleton() == NULL || OS::get_singleton()->is_disable_crash_handler()) {
+ if (OS::get_singleton() == NULL || OS::get_singleton()->is_disable_crash_handler() || IsDebuggerPresent()) {
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -159,7 +159,7 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
IMAGE_NT_HEADERS *h = ImageNtHeader(base);
DWORD image_type = h->FileHeader.Machine;
int n = 0;
- String msg = GLOBAL_GET("debug/settings/backtrace/message");
+ String msg = GLOBAL_GET("debug/settings/crash_handler/message");
fprintf(stderr, "Dumping the backtrace. %ls\n", msg.c_str());
diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp
index 4450cb3670..cff2cbad42 100644
--- a/platform/windows/godot_win.cpp
+++ b/platform/windows/godot_win.cpp
@@ -156,32 +156,36 @@ int widechar_main(int argc, wchar_t **argv) {
return os.get_exit_code();
};
-int main(int _argc, char **_argv) {
-// _argc and _argv are ignored
-// we are going to use the WideChar version of them instead
+int _main() {
+ LPWSTR *wc_argv;
+ int argc;
+ int result;
-#ifdef CRASH_HANDLER_EXCEPTION
- __try {
-#endif
- LPWSTR *wc_argv;
- int argc;
- int result;
+ wc_argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+
+ if (NULL == wc_argv) {
+ wprintf(L"CommandLineToArgvW failed\n");
+ return 0;
+ }
- wc_argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+ result = widechar_main(argc, wc_argv);
- if (NULL == wc_argv) {
- wprintf(L"CommandLineToArgvW failed\n");
- return 0;
- }
+ LocalFree(wc_argv);
+ return result;
+}
- result = widechar_main(argc, wc_argv);
+int main(int _argc, char **_argv) {
+// _argc and _argv are ignored
+// we are going to use the WideChar version of them instead
- LocalFree(wc_argv);
- return result;
#ifdef CRASH_HANDLER_EXCEPTION
+ __try {
+ return _main();
} __except (CrashHandlerException(GetExceptionInformation())) {
return 1;
}
+#else
+ return _main();
#endif
}
diff --git a/platform/x11/crash_handler_x11.cpp b/platform/x11/crash_handler_x11.cpp
index c926b7799d..419b014475 100644
--- a/platform/x11/crash_handler_x11.cpp
+++ b/platform/x11/crash_handler_x11.cpp
@@ -47,7 +47,7 @@ static void handle_crash(int sig) {
void *bt_buffer[256];
size_t size = backtrace(bt_buffer, 256);
String _execpath = OS::get_singleton()->get_executable_path();
- String msg = GLOBAL_GET("debug/settings/backtrace/message");
+ String msg = GLOBAL_GET("debug/settings/crash_handler/message");
// Dump the backtrace to stderr with a message to the user
fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig);
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 16d1b320b7..41f4beb1c9 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -106,9 +106,9 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
if (ofs < grabber_ofs) {
if (scrolling) {
- target_scroll = target_scroll - get_page();
+ target_scroll = CLAMP(target_scroll - get_page(), get_min(), get_max() - get_page());
} else {
- target_scroll = get_value() - get_page();
+ target_scroll = CLAMP(get_value() - get_page(), get_min(), get_max() - get_page());
}
if (smooth_scroll_enabled) {
@@ -130,9 +130,9 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
update();
} else {
if (scrolling) {
- target_scroll = target_scroll + get_page();
+ target_scroll = CLAMP(target_scroll + get_page(), get_min(), get_max() - get_page());
} else {
- target_scroll = get_value() + get_page();
+ target_scroll = CLAMP(get_value() + get_page(), get_min(), get_max() - get_page());
}
if (smooth_scroll_enabled) {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 2ca4c81319..d30e0b9f25 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4266,6 +4266,10 @@ bool TextEdit::is_insert_mode() const {
return insert_mode;
}
+bool TextEdit::is_insert_text_operation() {
+ return (current_op.type == TextOperation::TYPE_INSERT);
+}
+
uint32_t TextEdit::get_version() const {
return current_op.version;
}
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 68ef559f46..7e61c4e8b1 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -386,6 +386,8 @@ public:
void begin_complex_operation();
void end_complex_operation();
+ bool is_insert_text_operation();
+
void set_text(String p_text);
void insert_text_at_cursor(const String &p_text);
void insert_at(const String &p_text, int at);