mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-27 06:57:15 +00:00
feat(ugc): the fast hidden-face method back, next to LU Toolbox's
UgcHsr::Options::method picks how hidden faces are found: toolbox (LU Toolbox's paths, the default, unchanged) or fast, the test the UGC server used before "hidden faces removed as LU Toolbox's Remove Hidden Faces decides them", restored unchanged as UgcRender::VisibleFromAround: the opaque mesh rendered from 42 directions around the model (Options::fastResolution pixels square, 1024 as before) and the triangles that show in none removed. It is much faster, but it also removes faces seen only by bounced light (interiors, recesses), which LU Toolbox keeps. Nothing sets it yet. Check: the UGC tests (the fast method removes a box seen only through a chimney, which the paths keep; its files are the same every time). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include "UgcRays.h"
|
||||
#include "UgcRender.h"
|
||||
#include "UgcThrottle.h"
|
||||
|
||||
namespace {
|
||||
@@ -407,6 +408,17 @@ namespace {
|
||||
}
|
||||
|
||||
namespace UgcHsr {
|
||||
std::string_view Name(eMethod method) {
|
||||
return method == eMethod::FAST ? "fast" : "toolbox";
|
||||
}
|
||||
|
||||
std::optional<eMethod> Parse(std::string_view name) {
|
||||
for (const auto method : { eMethod::TOOLBOX, eMethod::FAST }) {
|
||||
if (Name(method) == name) return method;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> SamplePoints(const glm::vec3& a, const glm::vec3& b, const glm::vec3& c, float spacing, size_t minimum) {
|
||||
// Too small to lay out: the centre and one point towards each corner (the centres of its four halved-side
|
||||
// triangles)
|
||||
@@ -501,7 +513,8 @@ namespace UgcHsr {
|
||||
auto& opaque = model.opaque;
|
||||
result.trianglesBefore = opaque.TriangleCount() + model.transparent.TriangleCount();
|
||||
if (opaque.Empty() || !options.enabled) return result;
|
||||
result.kept = Visible(opaque, options, &result.points, &result.paths);
|
||||
result.kept = options.method == eMethod::FAST ? UgcRender::VisibleFromAround(model, options.fastResolution, options.groundPlane) :
|
||||
Visible(opaque, options, &result.points, &result.paths);
|
||||
for (const bool kept : result.kept) result.trianglesRemoved += kept ? 0 : 1;
|
||||
UgcModel::KeepTriangles(opaque, result.kept);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user