调试进入进程,
进入方式 --path E:/G4WorkProject/SimpleDebug --remote-debug tcp://127.0.0.1:6007 --allow_focus_steal_pid 14416 --position 448,240 res://main.tscn
1,启动过程:
Node *scene = NULL;
Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path);
if (scenedata.is_valid())
scene = scenedata->instance();
sml->add_current_scene(scene);
ScriptInstance *GDScript::instance_create(Object *p_this)
启用 --remote-debug
if (debug_mode == "remote") {
ScriptDebuggerRemote *sdr = memnew(ScriptDebuggerRemote);
uint16_t debug_port = 6007;
if (debug_host.find(":") != -1) {
int sep_pos = debug_host.find_last(":");
debug_port = debug_host.substr(sep_pos + 1, debug_host.length()).to_int();
debug_host = debug_host.substr(0, sep_pos);
}
Error derr = sdr->connect_to_host(debug_host, debug_port);
sdr->set_skip_breakpoints(skip_breakpoints);
if (derr != OK) {
memdelete(sdr);
} else {
script_debugger = sdr;
sdr->set_allow_focus_steal_pid(allow_focus_steal_pid);
}
打印:
if (script_debugger) {
if (script_debugger->is_profiling()) {
script_debugger->profiling_set_frame_times(USEC_TO_SEC(frame_time), USEC_TO_SEC(idle_process_ticks), USEC_TO_SEC(physics_process_ticks), frame_slice);
}
script_debugger->idle_poll();
}
Can't add child 'main' to 'EditorNode', already has a parent
2,几个类分析
class Script : public Resource 抽象类
1,节点产生
Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path); 从这里开始分析
ScriptInstance *GDScript::instance_create(Object *p_this)
2,脚本
脚本加载
ResourceInteractiveLoaderText::poll()
RES res = ResourceLoader::load(path, type);
ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_original_path, Error *r_error)
GDScript::reload(bool p_keep_state)
脚本执行
Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state)
GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error)
Node::_propagate_ready()
get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready, NULL, 0);
GDScriptInstance::call_multilevel_reversed(
GDScriptInstance::_ml_call_reversed
Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E) {
E->get()->call(this, p_args, p_argcount, ce);
}
GDScriptFunctions::call(func, (const Variant **)argptrs, argc, *dst, err);
如:
OS.get_datetime
base->call_ptr(*methodname, (const Variant **)argptrs, argc, ret, err);
Variant::call_ptr(const StringName &p_method, const Variant **p_args, int p_argcount, Variant *r_ret, CallError &r_error)
Variant Object::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error)
Dictionary _OS::get_datetime(bool utc)
_OS::_bind_methods()中
如:
脚本:var _client = WebSocketClient.new()
ClassDB::bind_method(D_METHOD("new"), &GDScriptNativeClass::_new);
Variant GDScriptNativeClass::_new()
Object *GDScriptNativeClass::instance()
Object *ClassDB::instance(const StringName &p_class)
如
var tt = load("res://Xx")
void GDScriptFunctions::call(Function p_func
ResourceLoader::load(*p_args[0])
游戏进入参数
E:\godot3\bin\godot.windows.tools.32.exe --path E:/G4WorkProject/SimpleDebug --remote-debug tcp://127.0.0.1:6007 --allow_focus_steal_pid 14416 --position 448,240
D:\godot2\bin\godot.windows.tools.64.exe --path E:\G3WorkCode\SimpleDebug --remote-debug tcp://127.0.0.1:6007 --allow_focus_steal_pid 14416 --position 448,240
D:\godot2\bin\godot.windows.tools.32.exe --path E:\G3WorkCode\SimpleDebug --remote-debug tcp://127.0.0.1:6007 --allow_focus_steal_pid 14416 --position 448,240
VisualServer : public Object 纯虚函数
VisualServer是所有可见对象的API后端
在3D中,所有的视觉对象都必须与一个场景相关联
在2D中,需要一个画布来绘制所有的画布项目
class VisualServerRaster : public VisualServer
VisualServerWrapMT : public VisualServer
两个实例,其实是一样,VisualServerWrapMT脚本上可用
在OS_Windows::initialize中创建
visual_server = memnew(VisualServerRaster);
而VisualServer::VisualServer()
{
//ERR_FAIL_COND(singleton);
singleton = this;
}
VisualServerRaster::VisualServerRaster()
{
VSG::canvas = memnew(VisualServerCanvas);
VSG::viewport = memnew(VisualServerViewport);
VSG::scene = memnew(VisualServerScene);
VSG::rasterizer = Rasterizer::create();
VSG::storage = VSG::rasterizer->get_storage();
VSG::canvas_render = VSG::rasterizer->get_canvas();
VSG::scene_render = VSG::rasterizer->get_scene();
}
Rasterizer纯虚函数
class RasterizerGLES3 : public Rasterizer
class RasterizerDummy : public Rasterizer
class RasterizerGLES2 : public Rasterizer其成员:
RasterizerStorageGLES2 *storage;
RasterizerCanvasGLES2 *canvas;
RasterizerSceneGLES2 *scene;
绘制主函数
bool Main::iteration()
{
if (OS::get_singleton()->can_draw() && VisualServer::get_singleton()->is_render_loop_enabled())
{
if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode())
{
if (VisualServer::get_singleton()->has_changed())
{
VisualServer::get_singleton()->draw(true, scaled_step); // flush visual commands
Engine::get_singleton()->frames_drawn++;
}
}
else
{
VisualServer::get_singleton()->draw(true, scaled_step); // flush visual commands
Engine::get_singleton()->frames_drawn++;
force_redraw_requested = false;
}
}
}
整个绘制工作
void VisualServerRaster::draw(bool p_swap_buffers, double frame_step)
{
changes = 0;
VSG::rasterizer->begin_frame(frame_step);
VSG::scene->update_dirty_instances(); //update scene stuff
VSG::viewport->draw_viewports();
VSG::scene->render_probes();
_draw_margins();
VSG::rasterizer->end_frame(p_swap_buffers);
}
//主要做更新各新参数,变化
void RasterizerGLES3::begin_frame(double frame_step
{
storage->update_dirty_resources();
storage->info.render_final = storage->info.render;
storage->info.render.reset();
scene->iteration();
}
void VisualServerRaster::_draw_margins() {
VSG::canvas_render->draw_window_margins(black_margin, black_image);
};
void VisualServerViewport::draw_viewports()
{
}
VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye)
{
}
**************************各类分析*****************
VisualServerViewport成员
mutable RID_Owner<Viewport> viewport_owner;
Vector<Viewport *> active_viewports;