Fix cross-platform rendering and optimize frame performance
Correct selection orientation, game-entry lifecycle, mounted NPCs, labels and skill panels. Add the native GPU scene path, resident geometry, bounded texture and Python caches, and collision broad phase. Pin the independently maintained Metin2 SDK through a submodule and document reproducible setup. Include rendering regressions and macOS packaging improvements. Validation: client Debug build and 12 targeted client tests passed; SDK build and all 14 SDK tests passed.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
namespace ava2 {
|
||||
|
||||
@@ -17,9 +18,46 @@ inline void MakeTransformMatrix(float yawDegrees, float tx, float ty, float tz,
|
||||
out[12] = tx; out[13] = ty; out[14] = tz; out[15] = 1.0f;
|
||||
}
|
||||
|
||||
// Conservative homogeneous frustum rejection, including near/far planes.
|
||||
// Reject only when every AABB corner is outside the same plane.
|
||||
inline bool IsBoundsVisible(const float lo[3], const float hi[3], const float* view, const float* proj) {
|
||||
if (!view || !proj) return true;
|
||||
unsigned outside = 63;
|
||||
for (unsigned corner = 0; corner < 8; ++corner) {
|
||||
float p[4] = {corner&1 ? hi[0] : lo[0], corner&2 ? hi[1] : lo[1], corner&4 ? hi[2] : lo[2], 1};
|
||||
float v[4]{}, c[4]{};
|
||||
for (int j=0;j<4;++j) for(int k=0;k<4;++k) v[j]+=p[k]*view[k*4+j];
|
||||
for (int j=0;j<4;++j) for(int k=0;k<4;++k) c[j]+=v[k]*proj[k*4+j];
|
||||
unsigned bits = (c[0]<-c[3] ? 1:0) | (c[0]>c[3] ? 2:0) | (c[1]<-c[3] ? 4:0) |
|
||||
(c[1]>c[3] ? 8:0) | (c[2]<0 ? 16:0) | (c[2]>c[3] ? 32:0);
|
||||
outside &= bits;
|
||||
if (!outside) return true;
|
||||
}
|
||||
return outside == 0;
|
||||
}
|
||||
|
||||
// Intermediate 3D draw command structure, modeled after 40250 cross-platform architecture.
|
||||
// Decouples game logic/animation (GR2) from the underlying GPU/software renderer.
|
||||
struct Render3DDraw {
|
||||
// Per-frame commands reference immutable mesh streams; transforms/material remain local.
|
||||
std::shared_ptr<const Render3DDraw> geometry;
|
||||
const Render3DDraw& Mesh() const { return geometry ? *geometry : *this; }
|
||||
static Render3DDraw ShareGeometry(Render3DDraw source) {
|
||||
Render3DDraw command = source;
|
||||
command.positions.clear(); command.positions.shrink_to_fit();
|
||||
command.normals.clear(); command.normals.shrink_to_fit();
|
||||
command.uv0.clear(); command.uv0.shrink_to_fit();
|
||||
command.uv1.clear(); command.uv1.shrink_to_fit();
|
||||
command.diffuse.clear(); command.diffuse.shrink_to_fit();
|
||||
command.indices.clear(); command.indices.shrink_to_fit();
|
||||
command.bone_indices.clear(); command.bone_indices.shrink_to_fit();
|
||||
command.bone_weights.clear(); command.bone_weights.shrink_to_fit();
|
||||
command.bone_matrices.clear(); command.bone_matrices.shrink_to_fit();
|
||||
command.geometry = std::make_shared<const Render3DDraw>(std::move(source));
|
||||
return command;
|
||||
}
|
||||
|
||||
bool gpu_skinning = false;
|
||||
std::uint64_t geometry_key = 0;
|
||||
std::uint64_t geometry_revision = 0;
|
||||
|
||||
@@ -56,15 +94,16 @@ struct Render3DDraw {
|
||||
bool alpha_test = false;
|
||||
std::uint32_t alpha_ref = 0;
|
||||
bool fog = true;
|
||||
bool terrain = false; // SDL painter layers keep terrain splats ahead of actors.
|
||||
|
||||
// Lighting & Material
|
||||
bool lighting = true;
|
||||
float material_diffuse[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
float material_ambient[4] = {0.4f, 0.4f, 0.4f, 1.0f};
|
||||
float material_emissive[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
float material_ambient[4] = {0.85f, 0.85f, 0.85f, 1.0f};
|
||||
float material_emissive[4] = {0.05f, 0.05f, 0.05f, 0.05f};
|
||||
float light_direction[3] = {0.577f, 0.577f, -0.577f}; // Normalized key light
|
||||
float light_diffuse[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
float light_ambient[4] = {0.3f, 0.3f, 0.3f, 1.0f};
|
||||
float light_ambient[4] = {0.55f, 0.55f, 0.55f, 1.0f};
|
||||
};
|
||||
|
||||
} // namespace ava2
|
||||
|
||||
Reference in New Issue
Block a user