2V2-e.1: 3D draw-command channel — recording D3D8 device, StateManager, GrpBase, camera

EterLib/StateManager.cpp and GrpBase.cpp ported verbatim. CGraphicDevice::Create builds a platform
IDirect3DDevice8 that keeps the device state and records every Draw* call as a Render3DDraw
(vertices decoded by FVF, strips/fans expanded, textures, world/view/proj, blend/depth/light state).
The 40250 camera (__UpdateCamera, SetCenterPosition, ...) and the Process order
(__UpdateCamera -> OnCameraUpdate -> OnUIUpdate -> Begin/SetInterfaceRenderState/OnUIRender/End)
are in place; CScreen Begin/End, CPythonGraphic render states and CCullingManager::Process matrix
updates are verbatim. port.login_flow asserts a textured, lit character draw under the RH
perspective with every vertex on screen; offline and live pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-23 20:15:54 +09:00
co-authored by Claude Opus 5.5
parent 668f48d6ec
commit 5bfa13c5cc
27 changed files with 3616 additions and 777 deletions
+31
View File
@@ -40,6 +40,7 @@
#include "../src/platform/ScriptLib/PythonHost.h"
#include "../src/platform/UserInterface/UserInterface.h"
#include "../src/platform/EterBase/TraceErrorObserver.h"
#include "../src/platform/EterLib/RenderCommands3D.h"
#include "GameLib/StdAfx.h"
#include "GameLib/RaceManager.h"
#include "GameLib/RaceData.h"
@@ -56,6 +57,7 @@
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
@@ -346,6 +348,35 @@ int main(int argc, char** argv)
const std::vector<float> before = bones();
CHECK(pump_until(3, [&] { return bones() != before; }));
}
// (批次 2V2-e.1) RenderGame drew the character through CStateManager into the recording device:
// a frame holds a textured, lit triangle draw (the PNT vertex format of RenderWithOneTexture)
// under CPythonGraphic::SetPerspective's right-handed projection (_34 = -1), and the camera that
// __UpdateCamera centred on the main actor puts every vertex of it on screen.
auto on_screen = [](const Render3DDraw& d) {
auto mul = [](const float* v, const float* m, float* o) {
for (int c = 0; c < 4; ++c)
o[c] = v[0] * m[c] + v[1] * m[4 + c] + v[2] * m[8 + c] + v[3] * m[12 + c];
};
for (size_t i = 0; i + 2 < d.positions.size(); i += 3)
{
const float local[4] = {d.positions[i], d.positions[i + 1], d.positions[i + 2], 1.0f};
float world[4], view[4], clip[4];
mul(local, d.world, world);
mul(world, d.view, view);
mul(view, d.proj, clip);
if (clip[3] <= 0.0f || std::fabs(clip[0]) > clip[3] || std::fabs(clip[1]) > clip[3])
return false;
}
return true;
};
auto character_draw = [&] {
for (const Render3DDraw& d : Render3DDraws())
if (!d.pretransformed && !d.lines && !d.indices.empty() && !d.texture0.empty() &&
!d.normals.empty() && !d.uv0.empty() && d.proj[11] == -1.0f && on_screen(d))
return true;
return false;
};
CHECK(pump_until(3, character_draw));
}
if (server)
{