diff options
Diffstat (limited to 'main')
-rwxr-xr-x | main/main.cpp | 110 | ||||
-rw-r--r-- | main/tests/test_gdscript.cpp | 298 | ||||
-rw-r--r-- | main/tests/test_physics.cpp | 2 | ||||
-rw-r--r-- | main/tests/test_physics_2d.cpp | 20 | ||||
-rw-r--r-- | main/tests/test_render.cpp | 4 |
5 files changed, 239 insertions, 195 deletions
diff --git a/main/main.cpp b/main/main.cpp index c98bc6e5f6..5410aae1d2 100755 --- a/main/main.cpp +++ b/main/main.cpp @@ -35,6 +35,7 @@ #include "message_queue.h" #include "modules/register_module_types.h" #include "os/os.h" +#include "platform/register_platform_apis.h" #include "project_settings.h" #include "scene/register_scene_types.h" #include "script_debugger_local.h" @@ -47,6 +48,8 @@ #include "scene/main/scene_tree.h" #include "servers/arvr_server.h" #include "servers/audio_server.h" +#include "servers/physics_2d_server.h" +#include "servers/physics_server.h" #include "io/resource_loader.h" #include "script_language.h" @@ -84,6 +87,8 @@ static bool _start_success = false; static ScriptDebugger *script_debugger = NULL; AudioServer *audio_server = NULL; ARVRServer *arvr_server = NULL; +PhysicsServer *physics_server = NULL; +Physics2DServer *physics_2d_server = NULL; static MessageQueue *message_queue = NULL; static Performance *performance = NULL; @@ -120,6 +125,35 @@ static int fixed_fps = -1; static OS::ProcessID allow_focus_steal_pid = 0; +void initialize_physics() { + + /// 3D Physics Server + physics_server = PhysicsServerManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServerManager::setting_property_name)); + if (!physics_server) { + // Physics server not found, Use the default physics + physics_server = PhysicsServerManager::new_default_server(); + } + ERR_FAIL_COND(!physics_server); + physics_server->init(); + + /// 2D Physics server + physics_2d_server = Physics2DServerManager::new_server(ProjectSettings::get_singleton()->get(Physics2DServerManager::setting_property_name)); + if (!physics_2d_server) { + // Physics server not found, Use the default physics + physics_2d_server = Physics2DServerManager::new_default_server(); + } + ERR_FAIL_COND(!physics_2d_server); + physics_2d_server->init(); +} + +void finalize_physics() { + physics_server->finish(); + memdelete(physics_server); + + physics_2d_server->finish(); + memdelete(physics_2d_server); +} + static String unescape_cmdline(const String &p_str) { return p_str.replace("%20", " "); @@ -143,7 +177,7 @@ static String get_full_version_string() { void Main::print_help(const char *p_binary) { - print_line(String(_MKSTR(VERSION_NAME)) + " v" + get_full_version_string() + " - https://godotengine.org"); + print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - https://godotengine.org"); OS::get_singleton()->print("(c) 2007-2017 Juan Linietsky, Ariel Manzur.\n"); OS::get_singleton()->print("(c) 2014-2017 Godot Engine contributors.\n"); OS::get_singleton()->print("\n"); @@ -261,7 +295,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph translation_server = memnew(TranslationServer); performance = memnew(Performance); ClassDB::register_class<Performance>(); - globals->add_singleton(ProjectSettings::Singleton("Performance", performance)); + engine->add_singleton(Engine::Singleton("Performance", performance)); GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues")); @@ -288,8 +322,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph I = args.front(); - video_mode = OS::get_singleton()->get_default_video_mode(); - String video_driver = ""; String audio_driver = ""; String game_path = "."; @@ -748,38 +780,41 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph //if (video_driver == "") // useless for now, so removing // video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0))); - if (!force_res && use_custom_res && globals->has_setting("display/window/size/width")) - video_mode.width = globals->get("display/window/size/width"); - if (!force_res && use_custom_res && globals->has_setting("display/window/size/height")) - video_mode.height = globals->get("display/window/size/height"); - if (!editor && ((globals->has_setting("display/window/dpi/allow_hidpi") && !globals->get("display/window/dpi/allow_hidpi")) || force_lowdpi)) { - OS::get_singleton()->_allow_hidpi = false; - } - if (use_custom_res && globals->has_setting("display/window/size/fullscreen")) - video_mode.fullscreen = globals->get("display/window/size/fullscreen"); - if (use_custom_res && globals->has_setting("display/window/size/resizable")) - video_mode.resizable = globals->get("display/window/size/resizable"); - if (use_custom_res && globals->has_setting("display/window/size/borderless")) - video_mode.borderless_window = globals->get("display/window/size/borderless"); - - if (!force_res && use_custom_res && globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) { - int tw = globals->get("display/window/size/test_width"); - int th = globals->get("display/window/size/test_height"); - if (tw > 0 && th > 0) { - video_mode.width = tw; - video_mode.height = th; + GLOBAL_DEF("display/window/size/width", 1024); + GLOBAL_DEF("display/window/size/height", 600); + GLOBAL_DEF("display/window/size/resizable", true); + GLOBAL_DEF("display/window/size/borderless", false); + GLOBAL_DEF("display/window/size/fullscreen", false); + GLOBAL_DEF("display/window/size/test_width", 0); + GLOBAL_DEF("display/window/size/test_height", 0); + + if (use_custom_res) { + + if (!force_res) { + video_mode.width = GLOBAL_GET("display/window/size/width"); + video_mode.height = GLOBAL_GET("display/window/size/height"); + + if (globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) { + int tw = globals->get("display/window/size/test_width"); + int th = globals->get("display/window/size/test_height"); + if (tw > 0 && th > 0) { + video_mode.width = tw; + video_mode.height = th; + } + } } + + video_mode.resizable = GLOBAL_GET("display/window/size/resizable"); + video_mode.borderless_window = GLOBAL_GET("display/window/size/borderless"); + video_mode.fullscreen = GLOBAL_GET("display/window/size/fullscreen"); } - GLOBAL_DEF("display/window/size/width", video_mode.width); - GLOBAL_DEF("display/window/size/height", video_mode.height); - GLOBAL_DEF("display/window/dpi/allow_hidpi", false); - GLOBAL_DEF("display/window/size/fullscreen", video_mode.fullscreen); - GLOBAL_DEF("display/window/size/resizable", video_mode.resizable); - GLOBAL_DEF("display/window/size/borderless", video_mode.borderless_window); - use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", use_vsync); - GLOBAL_DEF("display/window/size/test_width", 0); - GLOBAL_DEF("display/window/size/test_height", 0); + if (!force_lowdpi) { + OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false); + } + + use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", true); + GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2); GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3); @@ -1074,9 +1109,14 @@ Error Main::setup2(Thread::ID p_main_tid_override) { OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid); } - MAIN_PRINT("Main: Load Scripts, Modules, Drivers"); + MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts"); + register_platform_apis(); register_module_types(); + + initialize_physics(); + register_server_singletons(); + register_driver_types(); ScriptServer::init_languages(); @@ -1789,10 +1829,12 @@ void Main::cleanup() { unregister_driver_types(); unregister_module_types(); + unregister_platform_apis(); unregister_scene_types(); unregister_server_types(); OS::get_singleton()->finalize(); + finalize_physics(); if (packed_data) memdelete(packed_data); diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index bcf4278bde..b41b5f6452 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -35,10 +35,10 @@ #ifdef GDSCRIPT_ENABLED -#include "modules/gdscript/gd_compiler.h" -#include "modules/gdscript/gd_parser.h" -#include "modules/gdscript/gd_script.h" -#include "modules/gdscript/gd_tokenizer.h" +#include "modules/gdscript/gdscript.h" +#include "modules/gdscript/gdscript_compiler.h" +#include "modules/gdscript/gdscript_parser.h" +#include "modules/gdscript/gdscript_tokenizer.h" namespace TestGDScript { @@ -52,7 +52,7 @@ static void _print_indent(int p_ident, const String &p_text) { print_line(txt + p_text); } -static String _parser_extends(const GDParser::ClassNode *p_class) { +static String _parser_extends(const GDScriptParser::ClassNode *p_class) { String txt = "extends "; if (String(p_class->extends_file) != "") { @@ -72,29 +72,29 @@ static String _parser_extends(const GDParser::ClassNode *p_class) { return txt; } -static String _parser_expr(const GDParser::Node *p_expr) { +static String _parser_expr(const GDScriptParser::Node *p_expr) { String txt; switch (p_expr->type) { - case GDParser::Node::TYPE_IDENTIFIER: { + case GDScriptParser::Node::TYPE_IDENTIFIER: { - const GDParser::IdentifierNode *id_node = static_cast<const GDParser::IdentifierNode *>(p_expr); + const GDScriptParser::IdentifierNode *id_node = static_cast<const GDScriptParser::IdentifierNode *>(p_expr); txt = id_node->name; } break; - case GDParser::Node::TYPE_CONSTANT: { - const GDParser::ConstantNode *c_node = static_cast<const GDParser::ConstantNode *>(p_expr); + case GDScriptParser::Node::TYPE_CONSTANT: { + const GDScriptParser::ConstantNode *c_node = static_cast<const GDScriptParser::ConstantNode *>(p_expr); if (c_node->value.get_type() == Variant::STRING) txt = "\"" + String(c_node->value) + "\""; else txt = c_node->value; } break; - case GDParser::Node::TYPE_SELF: { + case GDScriptParser::Node::TYPE_SELF: { txt = "self"; } break; - case GDParser::Node::TYPE_ARRAY: { - const GDParser::ArrayNode *arr_node = static_cast<const GDParser::ArrayNode *>(p_expr); + case GDScriptParser::Node::TYPE_ARRAY: { + const GDScriptParser::ArrayNode *arr_node = static_cast<const GDScriptParser::ArrayNode *>(p_expr); txt += "["; for (int i = 0; i < arr_node->elements.size(); i++) { @@ -104,51 +104,51 @@ static String _parser_expr(const GDParser::Node *p_expr) { } txt += "]"; } break; - case GDParser::Node::TYPE_DICTIONARY: { - const GDParser::DictionaryNode *dict_node = static_cast<const GDParser::DictionaryNode *>(p_expr); + case GDScriptParser::Node::TYPE_DICTIONARY: { + const GDScriptParser::DictionaryNode *dict_node = static_cast<const GDScriptParser::DictionaryNode *>(p_expr); txt += "{"; for (int i = 0; i < dict_node->elements.size(); i++) { if (i > 0) txt += ", "; - const GDParser::DictionaryNode::Pair &p = dict_node->elements[i]; + const GDScriptParser::DictionaryNode::Pair &p = dict_node->elements[i]; txt += _parser_expr(p.key); txt += ":"; txt += _parser_expr(p.value); } txt += "}"; } break; - case GDParser::Node::TYPE_OPERATOR: { + case GDScriptParser::Node::TYPE_OPERATOR: { - const GDParser::OperatorNode *c_node = static_cast<const GDParser::OperatorNode *>(p_expr); + const GDScriptParser::OperatorNode *c_node = static_cast<const GDScriptParser::OperatorNode *>(p_expr); switch (c_node->op) { - case GDParser::OperatorNode::OP_PARENT_CALL: + case GDScriptParser::OperatorNode::OP_PARENT_CALL: txt += "."; - case GDParser::OperatorNode::OP_CALL: { + case GDScriptParser::OperatorNode::OP_CALL: { ERR_FAIL_COND_V(c_node->arguments.size() < 1, ""); String func_name; - const GDParser::Node *nfunc = c_node->arguments[0]; + const GDScriptParser::Node *nfunc = c_node->arguments[0]; int arg_ofs = 0; - if (nfunc->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) { + if (nfunc->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) { - const GDParser::BuiltInFunctionNode *bif_node = static_cast<const GDParser::BuiltInFunctionNode *>(nfunc); - func_name = GDFunctions::get_func_name(bif_node->function); + const GDScriptParser::BuiltInFunctionNode *bif_node = static_cast<const GDScriptParser::BuiltInFunctionNode *>(nfunc); + func_name = GDScriptFunctions::get_func_name(bif_node->function); arg_ofs = 1; - } else if (nfunc->type == GDParser::Node::TYPE_TYPE) { + } else if (nfunc->type == GDScriptParser::Node::TYPE_TYPE) { - const GDParser::TypeNode *t_node = static_cast<const GDParser::TypeNode *>(nfunc); + const GDScriptParser::TypeNode *t_node = static_cast<const GDScriptParser::TypeNode *>(nfunc); func_name = Variant::get_type_name(t_node->vtype); arg_ofs = 1; } else { ERR_FAIL_COND_V(c_node->arguments.size() < 2, ""); nfunc = c_node->arguments[1]; - ERR_FAIL_COND_V(nfunc->type != GDParser::Node::TYPE_IDENTIFIER, ""); + ERR_FAIL_COND_V(nfunc->type != GDScriptParser::Node::TYPE_IDENTIFIER, ""); - if (c_node->arguments[0]->type != GDParser::Node::TYPE_SELF) + if (c_node->arguments[0]->type != GDScriptParser::Node::TYPE_SELF) func_name = _parser_expr(c_node->arguments[0]) + "."; func_name += _parser_expr(nfunc); @@ -159,7 +159,7 @@ static String _parser_expr(const GDParser::Node *p_expr) { for (int i = arg_ofs; i < c_node->arguments.size(); i++) { - const GDParser::Node *arg = c_node->arguments[i]; + const GDScriptParser::Node *arg = c_node->arguments[i]; if (i > arg_ofs) txt += ", "; txt += _parser_expr(arg); @@ -168,7 +168,7 @@ static String _parser_expr(const GDParser::Node *p_expr) { txt += ")"; } break; - case GDParser::OperatorNode::OP_INDEX: { + case GDScriptParser::OperatorNode::OP_INDEX: { ERR_FAIL_COND_V(c_node->arguments.size() != 2, ""); @@ -176,125 +176,125 @@ static String _parser_expr(const GDParser::Node *p_expr) { txt = _parser_expr(c_node->arguments[0]) + "[" + _parser_expr(c_node->arguments[1]) + "]"; } break; - case GDParser::OperatorNode::OP_INDEX_NAMED: { + case GDScriptParser::OperatorNode::OP_INDEX_NAMED: { ERR_FAIL_COND_V(c_node->arguments.size() != 2, ""); txt = _parser_expr(c_node->arguments[0]) + "." + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_NEG: { + case GDScriptParser::OperatorNode::OP_NEG: { txt = "-" + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_NOT: { + case GDScriptParser::OperatorNode::OP_NOT: { txt = "not " + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_BIT_INVERT: { + case GDScriptParser::OperatorNode::OP_BIT_INVERT: { txt = "~" + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_PREINC: { + case GDScriptParser::OperatorNode::OP_PREINC: { } break; - case GDParser::OperatorNode::OP_PREDEC: { + case GDScriptParser::OperatorNode::OP_PREDEC: { } break; - case GDParser::OperatorNode::OP_INC: { + case GDScriptParser::OperatorNode::OP_INC: { } break; - case GDParser::OperatorNode::OP_DEC: { + case GDScriptParser::OperatorNode::OP_DEC: { } break; - case GDParser::OperatorNode::OP_IN: { + case GDScriptParser::OperatorNode::OP_IN: { txt = _parser_expr(c_node->arguments[0]) + " in " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_EQUAL: { + case GDScriptParser::OperatorNode::OP_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "==" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_NOT_EQUAL: { + case GDScriptParser::OperatorNode::OP_NOT_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "!=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_LESS: { + case GDScriptParser::OperatorNode::OP_LESS: { txt = _parser_expr(c_node->arguments[0]) + "<" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_LESS_EQUAL: { + case GDScriptParser::OperatorNode::OP_LESS_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "<=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_GREATER: { + case GDScriptParser::OperatorNode::OP_GREATER: { txt = _parser_expr(c_node->arguments[0]) + ">" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_GREATER_EQUAL: { + case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + ">=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_AND: { + case GDScriptParser::OperatorNode::OP_AND: { txt = _parser_expr(c_node->arguments[0]) + " and " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_OR: { + case GDScriptParser::OperatorNode::OP_OR: { txt = _parser_expr(c_node->arguments[0]) + " or " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ADD: { + case GDScriptParser::OperatorNode::OP_ADD: { txt = _parser_expr(c_node->arguments[0]) + "+" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SUB: { + case GDScriptParser::OperatorNode::OP_SUB: { txt = _parser_expr(c_node->arguments[0]) + "-" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_MUL: { + case GDScriptParser::OperatorNode::OP_MUL: { txt = _parser_expr(c_node->arguments[0]) + "*" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_DIV: { + case GDScriptParser::OperatorNode::OP_DIV: { txt = _parser_expr(c_node->arguments[0]) + "/" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_MOD: { + case GDScriptParser::OperatorNode::OP_MOD: { txt = _parser_expr(c_node->arguments[0]) + "%" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SHIFT_LEFT: { + case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { txt = _parser_expr(c_node->arguments[0]) + "<<" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SHIFT_RIGHT: { + case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { txt = _parser_expr(c_node->arguments[0]) + ">>" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN: { + case GDScriptParser::OperatorNode::OP_ASSIGN: { txt = _parser_expr(c_node->arguments[0]) + "=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_ADD: { + case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: { txt = _parser_expr(c_node->arguments[0]) + "+=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SUB: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: { txt = _parser_expr(c_node->arguments[0]) + "-=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_MUL: { + case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: { txt = _parser_expr(c_node->arguments[0]) + "*=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_DIV: { + case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: { txt = _parser_expr(c_node->arguments[0]) + "/=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_MOD: { + case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: { txt = _parser_expr(c_node->arguments[0]) + "%=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: { txt = _parser_expr(c_node->arguments[0]) + "<<=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: { txt = _parser_expr(c_node->arguments[0]) + ">>=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: { txt = _parser_expr(c_node->arguments[0]) + "&=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: { txt = _parser_expr(c_node->arguments[0]) + "|=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: { txt = _parser_expr(c_node->arguments[0]) + "^=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_AND: { + case GDScriptParser::OperatorNode::OP_BIT_AND: { txt = _parser_expr(c_node->arguments[0]) + "&" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_OR: { + case GDScriptParser::OperatorNode::OP_BIT_OR: { txt = _parser_expr(c_node->arguments[0]) + "|" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_XOR: { + case GDScriptParser::OperatorNode::OP_BIT_XOR: { txt = _parser_expr(c_node->arguments[0]) + "^" + _parser_expr(c_node->arguments[1]); } break; default: {} } } break; - case GDParser::Node::TYPE_NEWLINE: { + case GDScriptParser::Node::TYPE_NEWLINE: { //skippie } break; @@ -310,20 +310,20 @@ static String _parser_expr(const GDParser::Node *p_expr) { //return "("+txt+")"; } -static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) { +static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_indent) { for (int i = 0; i < p_block->statements.size(); i++) { - const GDParser::Node *statement = p_block->statements[i]; + const GDScriptParser::Node *statement = p_block->statements[i]; switch (statement->type) { - case GDParser::Node::TYPE_CONTROL_FLOW: { + case GDScriptParser::Node::TYPE_CONTROL_FLOW: { - const GDParser::ControlFlowNode *cf_node = static_cast<const GDParser::ControlFlowNode *>(statement); + const GDScriptParser::ControlFlowNode *cf_node = static_cast<const GDScriptParser::ControlFlowNode *>(statement); switch (cf_node->cf_type) { - case GDParser::ControlFlowNode::CF_IF: { + case GDScriptParser::ControlFlowNode::CF_IF: { ERR_FAIL_COND(cf_node->arguments.size() != 1); String txt; @@ -339,7 +339,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } break; - case GDParser::ControlFlowNode::CF_FOR: { + case GDScriptParser::ControlFlowNode::CF_FOR: { ERR_FAIL_COND(cf_node->arguments.size() != 2); String txt; txt += "for "; @@ -352,7 +352,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) _parser_show_block(cf_node->body, p_indent + 1); } break; - case GDParser::ControlFlowNode::CF_WHILE: { + case GDScriptParser::ControlFlowNode::CF_WHILE: { ERR_FAIL_COND(cf_node->arguments.size() != 1); String txt; @@ -364,18 +364,18 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) _parser_show_block(cf_node->body, p_indent + 1); } break; - case GDParser::ControlFlowNode::CF_SWITCH: { + case GDScriptParser::ControlFlowNode::CF_SWITCH: { } break; - case GDParser::ControlFlowNode::CF_CONTINUE: { + case GDScriptParser::ControlFlowNode::CF_CONTINUE: { _print_indent(p_indent, "continue"); } break; - case GDParser::ControlFlowNode::CF_BREAK: { + case GDScriptParser::ControlFlowNode::CF_BREAK: { _print_indent(p_indent, "break"); } break; - case GDParser::ControlFlowNode::CF_RETURN: { + case GDScriptParser::ControlFlowNode::CF_RETURN: { if (cf_node->arguments.size()) _print_indent(p_indent, "return " + _parser_expr(cf_node->arguments[0])); @@ -385,9 +385,9 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } break; - case GDParser::Node::TYPE_LOCAL_VAR: { + case GDScriptParser::Node::TYPE_LOCAL_VAR: { - const GDParser::LocalVarNode *lv_node = static_cast<const GDParser::LocalVarNode *>(statement); + const GDScriptParser::LocalVarNode *lv_node = static_cast<const GDScriptParser::LocalVarNode *>(statement); _print_indent(p_indent, "var " + String(lv_node->name)); } break; default: { @@ -398,7 +398,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } -static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_indent, GDParser::BlockNode *p_initializer = NULL) { +static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = NULL) { String txt; if (p_func->_static) @@ -434,7 +434,7 @@ static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_in _parser_show_block(p_func->body, p_indent + 1); } -static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, const Vector<String> &p_code) { +static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_indent, const Vector<String> &p_code) { if (p_indent == 0 && (String(p_class->extends_file) != "" || p_class->extends_class.size())) { @@ -444,7 +444,7 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, for (int i = 0; i < p_class->subclasses.size(); i++) { - const GDParser::ClassNode *subclass = p_class->subclasses[i]; + const GDScriptParser::ClassNode *subclass = p_class->subclasses[i]; String line = "class " + subclass->name; if (String(subclass->extends_file) != "" || subclass->extends_class.size()) line += " " + _parser_extends(subclass); @@ -456,13 +456,13 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, for (int i = 0; i < p_class->constant_expressions.size(); i++) { - const GDParser::ClassNode::Constant &constant = p_class->constant_expressions[i]; + const GDScriptParser::ClassNode::Constant &constant = p_class->constant_expressions[i]; _print_indent(p_indent, "const " + String(constant.identifier) + "=" + _parser_expr(constant.expression)); } for (int i = 0; i < p_class->variables.size(); i++) { - const GDParser::ClassNode::Member &m = p_class->variables[i]; + const GDScriptParser::ClassNode::Member &m = p_class->variables[i]; _print_indent(p_indent, "var " + String(m.identifier)); } @@ -487,27 +487,27 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, print_line("\n"); } -static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction &func, int p_addr) { +static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFunction &func, int p_addr) { - int addr = p_addr & GDFunction::ADDR_MASK; + int addr = p_addr & GDScriptFunction::ADDR_MASK; - switch (p_addr >> GDFunction::ADDR_BITS) { + switch (p_addr >> GDScriptFunction::ADDR_BITS) { - case GDFunction::ADDR_TYPE_SELF: { + case GDScriptFunction::ADDR_TYPE_SELF: { return "self"; } break; - case GDFunction::ADDR_TYPE_CLASS: { + case GDScriptFunction::ADDR_TYPE_CLASS: { return "class"; } break; - case GDFunction::ADDR_TYPE_MEMBER: { + case GDScriptFunction::ADDR_TYPE_MEMBER: { return "member(" + p_script->debug_get_member_by_index(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_CLASS_CONSTANT: { + case GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT: { return "class_const(" + func.get_global_name(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_LOCAL_CONSTANT: { + case GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT: { Variant v = func.get_constant(addr); String txt; @@ -517,19 +517,19 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction txt = v; return "const(" + txt + ")"; } break; - case GDFunction::ADDR_TYPE_STACK: { + case GDScriptFunction::ADDR_TYPE_STACK: { return "stack(" + itos(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_STACK_VARIABLE: { + case GDScriptFunction::ADDR_TYPE_STACK_VARIABLE: { return "var_stack(" + itos(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_GLOBAL: { + case GDScriptFunction::ADDR_TYPE_GLOBAL: { return "global(" + func.get_global_name(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_NIL: { + case GDScriptFunction::ADDR_TYPE_NIL: { return "nil"; } break; } @@ -539,11 +539,11 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String> &p_code) { - const Map<StringName, GDFunction *> &mf = p_class->debug_get_member_functions(); + const Map<StringName, GDScriptFunction *> &mf = p_class->debug_get_member_functions(); - for (const Map<StringName, GDFunction *>::Element *E = mf.front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = mf.front(); E; E = E->next()) { - const GDFunction &func = *E->get(); + const GDScriptFunction &func = *E->get(); const int *code = func.get_code(); int codelen = func.get_code_size(); String defargs; @@ -568,7 +568,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String switch (code[ip]) { - case GDFunction::OPCODE_OPERATOR: { + case GDScriptFunction::OPCODE_OPERATOR: { int op = code[ip + 1]; txt += "op "; @@ -583,7 +583,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 5; } break; - case GDFunction::OPCODE_SET: { + case GDScriptFunction::OPCODE_SET: { txt += "set "; txt += DADDR(1); @@ -594,7 +594,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 4; } break; - case GDFunction::OPCODE_GET: { + case GDScriptFunction::OPCODE_GET: { txt += " get "; txt += DADDR(3); @@ -606,7 +606,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 4; } break; - case GDFunction::OPCODE_SET_NAMED: { + case GDScriptFunction::OPCODE_SET_NAMED: { txt += " set_named "; txt += DADDR(1); @@ -617,7 +617,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 4; } break; - case GDFunction::OPCODE_GET_NAMED: { + case GDScriptFunction::OPCODE_GET_NAMED: { txt += " get_named "; txt += DADDR(3); @@ -629,7 +629,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 4; } break; - case GDFunction::OPCODE_SET_MEMBER: { + case GDScriptFunction::OPCODE_SET_MEMBER: { txt += " set_member "; txt += "[\""; @@ -639,7 +639,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 3; } break; - case GDFunction::OPCODE_GET_MEMBER: { + case GDScriptFunction::OPCODE_GET_MEMBER: { txt += " get_member "; txt += DADDR(2); @@ -650,7 +650,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 3; } break; - case GDFunction::OPCODE_ASSIGN: { + case GDScriptFunction::OPCODE_ASSIGN: { txt += " assign "; txt += DADDR(1); @@ -659,7 +659,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 3; } break; - case GDFunction::OPCODE_ASSIGN_TRUE: { + case GDScriptFunction::OPCODE_ASSIGN_TRUE: { txt += " assign "; txt += DADDR(1); @@ -667,7 +667,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 2; } break; - case GDFunction::OPCODE_ASSIGN_FALSE: { + case GDScriptFunction::OPCODE_ASSIGN_FALSE: { txt += " assign "; txt += DADDR(1); @@ -675,7 +675,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 2; } break; - case GDFunction::OPCODE_CONSTRUCT: { + case GDScriptFunction::OPCODE_CONSTRUCT: { Variant::Type t = Variant::Type(code[ip + 1]); int argc = code[ip + 2]; @@ -696,7 +696,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 4 + argc; } break; - case GDFunction::OPCODE_CONSTRUCT_ARRAY: { + case GDScriptFunction::OPCODE_CONSTRUCT_ARRAY: { int argc = code[ip + 1]; txt += " make_array "; @@ -714,7 +714,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 3 + argc; } break; - case GDFunction::OPCODE_CONSTRUCT_DICTIONARY: { + case GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY: { int argc = code[ip + 1]; txt += " make_dict "; @@ -735,10 +735,10 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; - case GDFunction::OPCODE_CALL: - case GDFunction::OPCODE_CALL_RETURN: { + case GDScriptFunction::OPCODE_CALL: + case GDScriptFunction::OPCODE_CALL_RETURN: { - bool ret = code[ip] == GDFunction::OPCODE_CALL_RETURN; + bool ret = code[ip] == GDScriptFunction::OPCODE_CALL_RETURN; if (ret) txt += " call-ret "; @@ -764,14 +764,14 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 5 + argc; } break; - case GDFunction::OPCODE_CALL_BUILT_IN: { + case GDScriptFunction::OPCODE_CALL_BUILT_IN: { txt += " call-built-in "; int argc = code[ip + 2]; txt += DADDR(3 + argc) + "="; - txt += GDFunctions::get_func_name(GDFunctions::Function(code[ip + 1])); + txt += GDScriptFunctions::get_func_name(GDScriptFunctions::Function(code[ip + 1])); txt += "("; for (int i = 0; i < argc; i++) { @@ -784,7 +784,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 4 + argc; } break; - case GDFunction::OPCODE_CALL_SELF_BASE: { + case GDScriptFunction::OPCODE_CALL_SELF_BASE: { txt += " call-self-base "; @@ -804,13 +804,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 4 + argc; } break; - case GDFunction::OPCODE_YIELD: { + case GDScriptFunction::OPCODE_YIELD: { txt += " yield "; incr = 1; } break; - case GDFunction::OPCODE_YIELD_SIGNAL: { + case GDScriptFunction::OPCODE_YIELD_SIGNAL: { txt += " yield_signal "; txt += DADDR(1); @@ -818,13 +818,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String txt += DADDR(2); incr = 3; } break; - case GDFunction::OPCODE_YIELD_RESUME: { + case GDScriptFunction::OPCODE_YIELD_RESUME: { txt += " yield resume: "; txt += DADDR(1); incr = 2; } break; - case GDFunction::OPCODE_JUMP: { + case GDScriptFunction::OPCODE_JUMP: { txt += " jump "; txt += itos(code[ip + 1]); @@ -832,7 +832,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 2; } break; - case GDFunction::OPCODE_JUMP_IF: { + case GDScriptFunction::OPCODE_JUMP_IF: { txt += " jump-if "; txt += DADDR(1); @@ -841,7 +841,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 3; } break; - case GDFunction::OPCODE_JUMP_IF_NOT: { + case GDScriptFunction::OPCODE_JUMP_IF_NOT: { txt += " jump-if-not "; txt += DADDR(1); @@ -850,12 +850,12 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 3; } break; - case GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: { + case GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: { txt += " jump-to-default-argument "; incr = 1; } break; - case GDFunction::OPCODE_RETURN: { + case GDScriptFunction::OPCODE_RETURN: { txt += " return "; txt += DADDR(1); @@ -863,19 +863,19 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 2; } break; - case GDFunction::OPCODE_ITERATE_BEGIN: { + case GDScriptFunction::OPCODE_ITERATE_BEGIN: { txt += " for-init " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]); incr += 5; } break; - case GDFunction::OPCODE_ITERATE: { + case GDScriptFunction::OPCODE_ITERATE: { txt += " for-loop " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]); incr += 5; } break; - case GDFunction::OPCODE_LINE: { + case GDScriptFunction::OPCODE_LINE: { int line = code[ip + 1] - 1; if (line >= 0 && line < p_code.size()) @@ -884,12 +884,12 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String txt = ""; incr += 2; } break; - case GDFunction::OPCODE_END: { + case GDScriptFunction::OPCODE_END: { txt += " end"; incr += 1; } break; - case GDFunction::OPCODE_ASSERT: { + case GDScriptFunction::OPCODE_ASSERT: { txt += " assert "; txt += DADDR(1); @@ -952,15 +952,15 @@ MainLoop *test(TestType p_type) { if (p_type == TEST_TOKENIZER) { - GDTokenizerText tk; + GDScriptTokenizerText tk; tk.set_code(code); int line = -1; - while (tk.get_token() != GDTokenizer::TK_EOF) { + while (tk.get_token() != GDScriptTokenizer::TK_EOF) { String text; - if (tk.get_token() == GDTokenizer::TK_IDENTIFIER) + if (tk.get_token() == GDScriptTokenizer::TK_IDENTIFIER) text = "'" + tk.get_token_identifier() + "' (identifier)"; - else if (tk.get_token() == GDTokenizer::TK_CONSTANT) { + else if (tk.get_token() == GDScriptTokenizer::TK_CONSTANT) { Variant c = tk.get_token_constant(); if (c.get_type() == Variant::STRING) text = "\"" + String(c) + "\""; @@ -968,12 +968,12 @@ MainLoop *test(TestType p_type) { text = c; text = text + " (" + Variant::get_type_name(c.get_type()) + " constant)"; - } else if (tk.get_token() == GDTokenizer::TK_ERROR) + } else if (tk.get_token() == GDScriptTokenizer::TK_ERROR) text = "ERROR: " + tk.get_token_error(); - else if (tk.get_token() == GDTokenizer::TK_NEWLINE) + else if (tk.get_token() == GDScriptTokenizer::TK_NEWLINE) text = "newline (" + itos(tk.get_token_line()) + ") + indent: " + itos(tk.get_token_line_indent()); - else if (tk.get_token() == GDTokenizer::TK_BUILT_IN_FUNC) - text = "'" + String(GDFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)"; + else if (tk.get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) + text = "'" + String(GDScriptFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)"; else text = tk.get_token_name(tk.get_token()); @@ -995,7 +995,7 @@ MainLoop *test(TestType p_type) { if (p_type == TEST_PARSER) { - GDParser parser; + GDScriptParser parser; Error err = parser.parse(code); if (err) { print_line("Parse Error:\n" + itos(parser.get_error_line()) + ":" + itos(parser.get_error_column()) + ":" + parser.get_error()); @@ -1003,16 +1003,16 @@ MainLoop *test(TestType p_type) { return NULL; } - const GDParser::Node *root = parser.get_parse_tree(); - ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, NULL); - const GDParser::ClassNode *cnode = static_cast<const GDParser::ClassNode *>(root); + const GDScriptParser::Node *root = parser.get_parse_tree(); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, NULL); + const GDScriptParser::ClassNode *cnode = static_cast<const GDScriptParser::ClassNode *>(root); _parser_show_class(cnode, 0, lines); } if (p_type == TEST_COMPILER) { - GDParser parser; + GDScriptParser parser; Error err = parser.parse(code); if (err) { @@ -1023,7 +1023,7 @@ MainLoop *test(TestType p_type) { GDScript *script = memnew(GDScript); - GDCompiler gdc; + GDScriptCompiler gdc; err = gdc.compile(&parser, script); if (err) { @@ -1046,7 +1046,7 @@ MainLoop *test(TestType p_type) { } else if (p_type == TEST_BYTECODE) { - Vector<uint8_t> buf = GDTokenizerBuffer::parse_code_string(code); + Vector<uint8_t> buf = GDScriptTokenizerBuffer::parse_code_string(code); String dst = test.get_basename() + ".gdc"; FileAccess *fw = FileAccess::open(dst, FileAccess::WRITE); fw->store_buffer(buf.ptr(), buf.size()); diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp index f149821928..1c50470544 100644 --- a/main/tests/test_physics.cpp +++ b/main/tests/test_physics.cpp @@ -299,7 +299,7 @@ public: VisualServer *vs = VisualServer::get_singleton(); /* LIGHT */ - RID lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL); + RID lightaux = vs->directional_light_create(); scenario = vs->scenario_create(); vs->light_set_shadow(lightaux, true); light = vs->instance_create2(lightaux, scenario); diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index a746973799..7d596fbda3 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -86,7 +86,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_SEGMENT].image = vs->texture_create_from_image(image); - RID segment_shape = ps->shape_create(Physics2DServer::SHAPE_SEGMENT); + RID segment_shape = ps->segment_shape_create(); Rect2 sg(Point2(-16, 0), Point2(16, 0)); ps->shape_set_data(segment_shape, sg); @@ -113,7 +113,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CIRCLE].image = vs->texture_create_from_image(image); - RID circle_shape = ps->shape_create(Physics2DServer::SHAPE_CIRCLE); + RID circle_shape = ps->circle_shape_create(); ps->shape_set_data(circle_shape, 16); body_shape_data[Physics2DServer::SHAPE_CIRCLE].shape = circle_shape; @@ -140,7 +140,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image = vs->texture_create_from_image(image); - RID rectangle_shape = ps->shape_create(Physics2DServer::SHAPE_RECTANGLE); + RID rectangle_shape = ps->rectangle_shape_create(); ps->shape_set_data(rectangle_shape, Vector2(16, 16)); body_shape_data[Physics2DServer::SHAPE_RECTANGLE].shape = rectangle_shape; @@ -168,7 +168,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CAPSULE].image = vs->texture_create_from_image(image); - RID capsule_shape = ps->shape_create(Physics2DServer::SHAPE_CAPSULE); + RID capsule_shape = ps->capsule_shape_create(); ps->shape_set_data(capsule_shape, Vector2(16, 32)); body_shape_data[Physics2DServer::SHAPE_CAPSULE].shape = capsule_shape; @@ -182,7 +182,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image = vs->texture_create_from_image(image); - RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON); + RID convex_polygon_shape = ps->convex_polygon_shape_create(); PoolVector<Vector2> arr; Point2 sb(32, 32); @@ -277,10 +277,11 @@ protected: arr.push_back(p_normal); arr.push_back(p_d); - RID plane = ps->shape_create(Physics2DServer::SHAPE_LINE); + RID plane = ps->line_shape_create(); ps->shape_set_data(plane, arr); - RID plane_body = ps->body_create(Physics2DServer::BODY_MODE_STATIC); + RID plane_body = ps->body_create(); + ps->body_set_mode(plane_body, Physics2DServer::BODY_MODE_STATIC); ps->body_set_space(plane_body, space); ps->body_add_shape(plane_body, plane); } @@ -290,9 +291,10 @@ protected: Physics2DServer *ps = Physics2DServer::get_singleton(); VisualServer *vs = VisualServer::get_singleton(); - RID concave = ps->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON); + RID concave = ps->concave_polygon_shape_create(); ps->shape_set_data(concave, p_points); - RID body = ps->body_create(Physics2DServer::BODY_MODE_STATIC); + RID body = ps->body_create(); + ps->body_set_mode(body, Physics2DServer::BODY_MODE_STATIC); ps->body_set_space(body, space); ps->body_add_shape(body, concave); ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform); diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp index 1f6217928d..cbf1a57855 100644 --- a/main/tests/test_render.cpp +++ b/main/tests/test_render.cpp @@ -180,7 +180,7 @@ public: */ RID lightaux; - lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL); + lightaux = vs->directional_light_create(); //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) ); vs->light_set_color(lightaux, Color(1.0, 1.0, 1.0)); //vs->light_set_shadow( lightaux, true ); @@ -191,7 +191,7 @@ public: vs->instance_set_transform(light, lla); - lightaux = vs->light_create(VisualServer::LIGHT_OMNI); + lightaux = vs->omni_light_create(); //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) ); vs->light_set_color(lightaux, Color(1.0, 1.0, 0.0)); vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_RANGE, 4); |