mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
Parity with LU Toolbox's Process Model, Bake Lighting and icon renderer, with its defaults as the settings' defaults: - Colors from its LU palette (UgcPalette: LU colors, LDD colors mapped to the nearest LU one, unknown ones black), transparent bricks at 58.82% opacity, a brick transparent only when all of its materials are. - Color variation: each brick's material gets its HSV value shifted in a 2.224 gamma by up to 5% (times the color's own amount), from a random number of the model, brick and material, so reprocessing gives the same colors in every LOD. Icons get none, and the icon renderer's color corrections. - LODs 0 and 2 with its distance logic, written as NiLODNode/NiRangeLODData like its exports and the game's own brick models, shapes divided at 65535 vertices along the longest side like divide_mesh. - Ambient occlusion like its AO-only bake: 64 rays per vertex, distance 5, after hidden surface removal, transparent bricks neither baked nor occluding, glow colors added. - Icons from its icon scene: 50 mm lens at 53.4/19.5 degrees, sun of 2.5 at 21/50.3 degrees with soft shadows, grey world light with occlusion; LOD 0's hidden surface removal and occlusion are reused for them. - Optional ground plane for hidden surface removal; stats.json per model and the previous version's previews kept for comparing. Budgets, applied live on config reload: max_cpu_percent (workers account their thread CPU time and sleep to stay under it, long renders included), worker_nice, max_memory_mb (jobs are estimated from their brick count and wait until they fit), max_model_bricks and pause_hours. /status and the traffic report show CPU, memory and throttling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.4 KiB
C++
37 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
/**
|
|
* Keeps the UGC workers' CPU use under a budget. The long loops (renders, ambient occlusion, icons) call Checkpoint
|
|
* every few milliseconds of work; it adds the calling thread's CPU time since its last call to a shared account that
|
|
* the budget fills at `budget` CPUs per second, and sleeps while the account is overdrawn. So the workers together
|
|
* average at most the budget however many there are, long jobs included, and without a budget it costs nothing.
|
|
*/
|
|
namespace UgcThrottle {
|
|
// CPUs the workers may use together on average (1.5: one and a half cores); 0 or less: no limit
|
|
void SetBudget(double cpus);
|
|
double GetBudget();
|
|
|
|
// Account the calling thread's CPU time and sleep when over the budget
|
|
void Checkpoint();
|
|
|
|
// Start accounting on this thread from now (a worker starting a job), so time spent idle isn't counted
|
|
void Begin();
|
|
|
|
struct Stats {
|
|
uint64_t sleptMs{}; // since start
|
|
int64_t lastSleepUnixMs{}; // when it last slept, 0 never
|
|
};
|
|
Stats GetStats();
|
|
|
|
// This thread's CPU time in seconds
|
|
double ThreadCpuSeconds();
|
|
|
|
// Parses "18-23" (from 18:00 to 23:59; may wrap past midnight, "22-6") into from and to; false when it isn't that
|
|
bool ParseHours(const std::string& text, int& from, int& to);
|
|
// Whether `hour` (0-23) is inside the range; never when from or to is negative
|
|
bool InHours(int hour, int from, int to);
|
|
}
|