载入中...
搜索中...
未找到
PrimitiveTypes.cpp
浏览该文件的文档.
2
3#include "common/Assert.h"
4
5#include <glm/gtc/constants.hpp>
6
7#include <algorithm>
8#include <cmath>
9#include <numeric>
10
11namespace eve::graphics {
12
13std::uint32_t resolveRadialSegments(const RadialTessellation& tessellation, float projectedRadiusPixels) {
14 const bool validError = std::isfinite(tessellation.maxScreenErrorPixels) && tessellation.maxScreenErrorPixels > 0.f;
15 EV_PARAM_CHECK(validError, "radial tessellation screen error must be finite and positive");
16 if (tessellation.customSegments != 0) {
17 const bool validCustom = tessellation.customSegments >= 3 && tessellation.customSegments <= 4096;
18 EV_PARAM_CHECK(validCustom, "custom radial segment count must be in [3, 4096]");
19 return tessellation.customSegments;
20 }
21 switch (tessellation.quality) {
22 case PrimitiveQuality::Low: return 16;
23 case PrimitiveQuality::Medium: return 32;
24 case PrimitiveQuality::High: return 64;
26 }
27 const bool validRadius = std::isfinite(projectedRadiusPixels) && projectedRadiusPixels >= 0.f;
28 EV_PARAM_CHECK(validRadius, "adaptive radial projected radius must be finite and non-negative");
29 if (projectedRadiusPixels <= tessellation.maxScreenErrorPixels) return 8;
30 const float cosine = glm::clamp(1.f - tessellation.maxScreenErrorPixels / projectedRadiusPixels, -1.f, 1.f);
31 const float halfAngle = std::acos(cosine);
32 if (halfAngle <= 1e-6f) return 256;
33 return std::clamp(static_cast<std::uint32_t>(std::ceil(glm::pi<float>() / halfAngle)), 8u, 256u);
34}
35
37 EV_PARAM_CHECK(!intervals.empty(), "dash intervals must not be empty");
38 EV_PARAM_CHECK(intervals.size() % 2 == 0, "dash intervals must contain draw/gap pairs");
39 EV_PARAM_CHECK(std::isfinite(phase), "dash phase must be finite");
40 for (float interval : intervals) {
41 const bool validInterval = std::isfinite(interval) && interval > 0.f;
42 EV_PARAM_CHECK(validInterval, "dash intervals must be finite and greater than zero");
43 }
44}
45
46float DashPattern::period() const {
47 validate();
48 return std::accumulate(intervals.begin(), intervals.end(), 0.f);
49}
50
52 const bool validWidth = std::isfinite(width) && width >= 0.f;
53 EV_PARAM_CHECK(validWidth, "stroke width must be finite and non-negative");
54 const bool validMiterLimit = std::isfinite(miterLimit) && miterLimit > 0.f;
55 EV_PARAM_CHECK(validMiterLimit, "stroke miter limit must be finite and greater than zero");
56 if (dash) dash->validate();
57}
58
60
62 const bool validViewport = viewportSize.x > 0 && viewportSize.y > 0;
63 EV_PARAM_CHECK(validViewport, "scene primitive viewport must be positive");
64 const bool validNearPlane = std::isfinite(nearPlane) && nearPlane > 0.f;
65 EV_PARAM_CHECK(validNearPlane, "scene primitive near plane must be finite and positive");
66 const bool validFarPlane = std::isfinite(farPlane) && farPlane > nearPlane;
67 EV_PARAM_CHECK(validFarPlane, "scene primitive far plane must be finite and greater than near plane");
68}
69
70} // namespace eve::graphics
EVEngine assertion entry point, backed by zeroerr.
#define EV_PARAM_CHECK(cond,...)
Validate a function parameter / public API precondition.
Definition Assert.h:30
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
std::uint32_t resolveRadialSegments(const RadialTessellation &tessellation, float projectedRadiusPixels)
Resolves a radial tessellation policy to a validated segment count.
float period() const
Returns the sum of all draw and gap intervals.
void validate() const
Validates finite positive intervals and an even interval count.
std::vector< float > intervals
void validate() const
Validates paint state used by a draw command.
Quality and screen-error policy used by circles and curved spatial primitives.
void validate() const
Validates viewport and clip-plane values.
void validate() const
Validates all scalar and optional dash state.
std::optional< DashPattern > dash