开源(MIT)跨平台 2D/3D 游戏引擎。单二进制同时是编辑器与运行时,游戏导出到 Windows / macOS / Linux / Android / iOS / Web / 主机。由 Godot Foundation(非营利)支持,社区驱动。

  • GitHub: https://github.com/godotengine/godot(116k stars,85k+ commits)
  • 本地源码:~/6ai/opensources/godot
  • 版本:4.8.0-dev(version.py);分析基线见 SCHEMA
  • 前身:Juan Linietsky 与 Ariel Manzur 的内部引擎,2014 年 2 月开源

核心特性

  • 统一引擎:2D 有独立的像素级 2D 渲染管线(非 2D-in-3D),3D 支持 Vulkan Forward+/Mobile 渲染
  • 一切皆节点:场景系统以 Node 树为核心抽象,见 scene-tree
  • 多脚本语言:GDScript(内置,见 gdscript)、C#(mono 模块)、GDExtension(C/C++/Rust 等原生扩展)
  • 编辑器即引擎:编辑器本身用引擎的 GUI/场景系统写成,见 editor-architecture
  • 服务器架构:渲染/物理/音频等跑在独立线程的”服务器”中,主线程通过命令队列访问,见 architecture

仓库结构

目录职责规模
core/Object 模型、Variant、容器、数学、IO、OS 抽象7.6M
scene/Node/SceneTree/2D/3D 节点/GUI/动画/音频节点13M
servers/渲染/物理/音频/文本/导航/显示服务器9.4M
editor/编辑器(627 个文件,约 31.7 万行)40M
modules/59 个可插拔模块(GDScript/mono/物理/格式等)26M
platform/7 个平台后端10M
drivers/图形/音频/图像驱动5.3M
thirdparty/第三方库源码132M
doc/classes/809 个类的 XML 文档(编辑器内帮助的来源)-

自底向上的依赖方向:core → servers/drivers → scene → editor/main → modules/platform。详见 architecture。

阅读路线

  1. architecture — 分层、启动流程、线程模型
  2. object-model — Object/ClassDB/信号/通知(引擎的基石)
  3. variant — Variant 类型系统(脚本与引擎的桥梁)
  4. scene-tree — Node/SceneTree/主循环
  5. rendering — 渲染管线
  6. gdscript — GDScript 编译与执行
  7. module-catalog、platform-drivers — 模块与平台清单

构建

SCons 构建,入口 SConstruct。典型命令:

scons platform=macos target=editor   # 开发用编辑器构建
scons platform=linuxbsd target=template_release  # 发布模板

详见 build-system。