M0' scaffold: Godot 4.7 + GDExtension + libgr2 wired up (macOS)

- extension/: godot-cpp submodule (master, API 4.7), Metin2Model node
  registered, links xrender-poc/libgr2 via sibling-dir reference.
- project/: Godot 4.7 project — orbit camera + DirectionalLight3D (shadows)
  + WorldEnvironment/procedural sky + placeholder cube; main.gd probes the
  extension and can run libgr2 on a real .gr2 (MTGODOT_PROBE_GR2).
- build.sh one-shot build into project/bin/.
- docs/GODOT-POC-PLAN.md (phased: Phase 1 macOS -> M0'/M1/M2/M2.5).

Verified on this machine:
  [mtgodot] Metin2Model registered OK — libgr2 linked
  probe_gr2(warrior_cheongrin.gr2) -> gr2 OK: format_version=6 sections=8
  Metal Forward+ renders the scene (test/golden/m0-scaffold.png).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WaHYEY9rwLWt21PULiYjeJ
This commit is contained in:
Claude
2026-08-29 09:09:55 +09:00
commit c52b8657c4
21 changed files with 839 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
#include "metin2_model.h"
#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
#include <string>
#include <gr2/gr2.h> // libgr2 (xrender-poc)
using namespace godot;
namespace mtgodot {
Metin2Model::Metin2Model() = default;
Metin2Model::~Metin2Model() = default;
void Metin2Model::_bind_methods() {
ClassDB::bind_method(D_METHOD("libgr2_info"), &Metin2Model::libgr2_info);
ClassDB::bind_method(D_METHOD("probe_gr2", "path"), &Metin2Model::probe_gr2);
}
String Metin2Model::libgr2_info() const {
// Forces a reference to a libgr2 symbol so the link is real, not dead-stripped.
return String("libgr2 linked; gr2::Magic enum size=") + itos((int)sizeof(gr2::Magic));
}
String Metin2Model::probe_gr2(const String &path) const {
gr2::LoadError err;
const std::string p(path.utf8().get_data());
auto file = gr2::File::load_path(p, &err);
if (!file) {
return vformat("gr2 load FAILED [%s]: %s",
String(err.stage.c_str()), String(err.message.c_str()));
}
return vformat("gr2 OK: format_version=%d sections=%d",
(int)file->format_version(), (int)file->sections().size());
}
} // namespace mtgodot