载入中...
搜索中...
未找到
PcgPhotoModeRanges.cpp
浏览该文件的文档.
3#include <simplesquirrel/simplesquirrel.hpp>
4#include <algorithm>
5#include <cmath>
6#include <limits>
7namespace eve::ui { namespace {
8const std::vector<std::pair<std::string,PcgPhotoModeRange>>&defaults(){static const std::vector<std::pair<std::string,PcgPhotoModeRange>>v={
9{"m_0To1",{0.0,1.0,false}},
10{"m_lodBias",{0.001,10.0,false}},
11{"m_targetFPS",{-1.0,240.0,true}},
12{"m_shadowDistance",{0.0,5000.0,false}},
13{"m_fieldOfView",{1.0,115.0,false}},
14{"m_pcgCullinDistance",{-10000.0,10000.0,false}},
15{"m_cameraAperture",{0.1,32.0,false}},
16{"m_cameraFocalLength",{0.05,250.0,false}},
17{"m_globalVolume",{0.0,1.0,false}},
18{"m_cameraRoll",{-90.0,90.0,false}},
19{"m_pcgLoadRange",{0.0,5000.0,false}},
20{"m_pcgImpostorRange",{0.0,5000.0,false}},
21{"m_pcgWindDirection",{0.0,1.0,false}},
22{"m_pcgWindSpeed",{0.0,1.0,false}},
23{"m_pcgTime",{0.0,24.0,false}},
24{"m_pcgTimeScale",{0.0,200.0,false}},
25{"m_pcgAdditionalLinearFog",{-5000.0,5000.0,false}},
26{"m_pcgAdditionalExponentialFog",{0.0,0.05,false}},
27{"m_sunRotation",{0.0,360.0,false}},
28{"m_sunPitch",{0.0,360.0,false}},
29{"m_fogDensity",{0.0,0.05,false}},
30{"m_fogStart",{0.0,5000.0,false}},
31{"m_fogEnd",{0.0,5000.0,false}},
32{"m_fogEndHDRP",{1.0,5000.0,false}},
33{"m_skyboxRotation",{0.0,360.0,false}},
34{"m_skyboxExposure",{0.0,4.0,false}},
35{"m_skyboxExposureHDRP",{0.0,30.0,false}},
36{"m_ambientIntensity",{0.0,10.0,false}},
37{"m_sunIntensity",{0.0,8.0,false}},
38{"m_sunIntensityHDRP",{0.0,250000.0,false}},
39{"m_sunKelvinValue",{1500.0,20000.0,false}},
40{"m_densityVolumeFogDistance",{0.01,std::numeric_limits<double>::infinity(),false}},
41{"m_pcgWaterReflectionDistance",{-5000.0,5000.0,false}},
42{"m_pcgReflectionsLODBias",{0.0,10.0,false}},
43{"m_pcgUnderwaterFogDistance",{0.1,200.0,false}},
44{"m_pcgUnderwaterFogDensity",{0.0,1.0,false}},
45{"m_postFXExposure",{0.0,5.0,false}},
46{"m_postFXExposureURP",{-5.0,5.0,false}},
47{"m_postFXExposureHDRP",{-5.0,15.0,false}},
48{"m_postFXDOFFocusDistanceHDRP",{0.01,300.0,false}},
49{"m_postFXDOFFocusDistanceURP",{0.01,300.0,false}},
50{"m_postFXDOFFocusDistance",{0.01,200.0,false}},
51{"m_postFXDOFNearBlurStart",{0.01,400.0,false}},
52{"m_postFXDOFNearBlurEnd",{0.1,5000.0,false}},
53{"m_postFXDOFFarBlurStart",{0.01,400.0,false}},
54{"m_postFXDOFFarBlurEnd",{0.1,5000.0,false}},
55{"m_postFXDOFGaussianBlurStartURP",{0.01,250.0,false}},
56{"m_postFXDOFGaussianBlurEndURP",{0.1,5000.0,false}},
57{"m_postFXDOFGaussianBlurMaxRadiusURP",{0.5,1.5,false}},
58{"m_terrainDetailDensity",{0.0,1.0,false}},
59{"m_terrainDetailDistance",{0.0,1000.0,false}},
60{"m_terrainPixelError",{1.0,200.0,false}},
61{"m_terrainBasemapDistance",{0.0,20000.0,false}},
62{"m_globalGrassDensity",{0.01,4.0,false}},
63{"m_globalGrassDistance",{0.01,4.0,false}},
64{"m_cameraCellDistance",{0.01,4.0,false}},
65{"m_cameraCellSubdivision",{-8.0,8.0,true}},
66};return v;}
67}
68PcgPhotoModeRanges::PcgPhotoModeRanges(){resetDefaults();}void PcgPhotoModeRanges::resetDefaults(){std::unordered_map<std::string,PcgPhotoModeRange>n;for(const auto&v:defaults())n.emplace(v);ranges_=std::move(n);selected_={};}uint64_t PcgPhotoModeRanges::getCount()const noexcept{return defaults().size();}
69Result<std::string> PcgPhotoModeRanges::getName(uint64_t i)const{if(i>=defaults().size())return Result<std::string>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode range index is out of bounds",{}, {},"ui.pcgPhotoModeRanges"));return Result<std::string>::success(defaults()[i].first);}
70Result<void> PcgPhotoModeRanges::select(const std::string&n){auto i=ranges_.find(n);if(i==ranges_.end())return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"unknown photo-mode range: "+n,{}, {},"ui.pcgPhotoModeRanges"));selected_=i->second;return Result<void>::success();}
71Result<void> PcgPhotoModeRanges::setRange(const std::string&n,double lo,double hi){auto i=ranges_.find(n);if(i==ranges_.end())return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"unknown photo-mode range: "+n,{}, {},"ui.pcgPhotoModeRanges"));if(!std::isfinite(lo)||std::isnan(hi)||hi<lo)return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode range endpoints are invalid",{}, {},"ui.pcgPhotoModeRanges"));if(i->second.integral&&(std::trunc(lo)!=lo||std::trunc(hi)!=hi))return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"integer photo-mode range requires integral endpoints",{}, {},"ui.pcgPhotoModeRanges"));i->second.minimum=lo;i->second.maximum=hi;return Result<void>::success();}
72Result<double> PcgPhotoModeRanges::clamp(const std::string&n,double v)const{auto i=ranges_.find(n);if(i==ranges_.end())return Result<double>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"unknown photo-mode range: "+n,{}, {},"ui.pcgPhotoModeRanges"));if(!std::isfinite(v))return Result<double>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"photo-mode clamp value must be finite",{}, {},"ui.pcgPhotoModeRanges"));return Result<double>::success(std::clamp(v,i->second.minimum,i->second.maximum));}
73void exposePcgPhotoModeRangesBindings(ssq::Table&t){auto vm=t.getHandle();auto c=t.addClass("PcgPhotoModeRanges",ssq::Class::Ctor<PcgPhotoModeRanges()>());c.addFunc("resetDefaults",[](PcgPhotoModeRanges*s){s->resetDefaults();});c.addFunc("getCount",[](const PcgPhotoModeRanges*s){return s->getCount();});c.addFunc("getName",[vm](const PcgPhotoModeRanges*s,uint64_t i){return eve::script::projectResult(vm,s->getName(i),[](const std::string&v){return v;});});c.addFunc("select",[vm](PcgPhotoModeRanges*s,const std::string&n){return eve::script::projectResult(vm,s->select(n));});c.addFunc("setRange",[vm](PcgPhotoModeRanges*s,const std::string&n,double a,double b){return eve::script::projectResult(vm,s->setRange(n,a,b));});c.addFunc("clamp",[vm](const PcgPhotoModeRanges*s,const std::string&n,double v){return eve::script::projectResult(vm,s->clamp(n,v),[](double x){return x;});});c.addFunc("getMinimum",[](const PcgPhotoModeRanges*s){return s->getMinimum();});c.addFunc("getMaximum",[](const PcgPhotoModeRanges*s){return s->getMaximum();});c.addFunc("getIntegral",[](const PcgPhotoModeRanges*s){return s->getIntegral();});}
74}
float x
Definition AnimClip.cpp:738
const std::string & s
HSQUIRRELVM vm
Definition ECS.cpp:20
glm::vec3 n
Definition Grass.cpp:63
float v
std::int32_t c
std::int32_t first
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float t
The single Squirrel projection for common Result, Status and Value.
float size
Definition TreeMesh.cpp:156
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Complete 57-range contract from Pcg PhotoModeMinAndMaxValues.
Result< double > clamp(const std::string &name, double value) const
Clamp a finite value to the named range.
uint64_t getCount() const noexcept
Return range count.
Result< void > select(const std::string &name)
Select a range for component reads.
PcgPhotoModeRanges()
Pcg photo mode ranges.
Result< std::string > getName(uint64_t index) const
Return range name in declaration order.
void resetDefaults()
Restore all Pcg range defaults.
Result< void > setRange(const std::string &name, double minimum, double maximum)
Replace one range; integer ranges require integral endpoints.
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
void exposePcgPhotoModeRangesBindings(ssq::Table &t)
Register Pcg photo-mode range bindings.