25 return 2.0f * std::atan2(rz, rw);
33 f32 rotationZ,
f32 rotationW
35 if (worldW == 0.0f || worldH == 0.0f)
return false;
37 f32 sinA = std::sin(-angle);
38 f32 cosA = std::cos(-angle);
42 f32 localX = dx * cosA - dy * sinA + worldX;
43 f32 localY = dx * sinA + dy * cosA + worldY;
45 f32 left = worldX - worldW * pivotX;
46 f32 right = worldX + worldW * (1.0f - pivotX);
47 f32 bottom = worldY - worldH * pivotY;
48 f32 top = worldY + worldH * (1.0f - pivotY);
50 return localX >= std::min(left, right) && localX <= std::max(left, right)
51 && localY >= std::min(bottom, top) && localY <= std::max(bottom, top);
61 glm::vec3
dir{0.0f, 0.0f, -1.0f};
70 if (std::abs(ray.
dir.z) <= 1e-9f)
return false;
72 if (t < 0.0f)
return false;
87 const glm::vec3& centre,
const glm::quat& rotation,
88 const glm::vec3& scale,
89 const glm::vec3& localMin,
const glm::vec3& localMax,
91 const glm::quat inverse = glm::conjugate(glm::normalize(rotation));
92 const glm::vec3 origin = inverse * (ray.
origin - centre);
93 const glm::vec3 dir = inverse * ray.
dir;
95 const glm::vec3 a = localMin * scale;
96 const glm::vec3 b = localMax * scale;
97 const glm::vec3 lo = glm::min(a, b);
98 const glm::vec3 hi = glm::max(a, b);
104 f32 exit = std::numeric_limits<f32>::max();
105 for (
int axis = 0; axis < 3; ++axis) {
106 if (std::abs(dir[axis]) <= 1e-9f) {
108 if (origin[axis] < lo[axis] || origin[axis] > hi[axis])
return false;
111 f32 t0 = (lo[axis] - origin[axis]) / dir[axis];
112 f32 t1 = (hi[axis] - origin[axis]) / dir[axis];
113 if (t0 > t1) std::swap(t0, t1);
114 enter = std::max(enter, t0);
115 exit = std::min(exit, t1);
116 if (enter > exit)
return false;
131 if (width == 0.0f || height == 0.0f)
return false;
133 const f64 determinant =
static_cast<f64>(matrix[0].x) * matrix[1].y
134 -
static_cast<f64>(matrix[1].x) * matrix[0].y;
135 if (determinant == 0.0 || !std::isfinite(determinant))
return false;
138 const f64 localX = (dx * matrix[1].y - dy * matrix[1].x) / determinant;
139 const f64 localY = (dy * matrix[0].x - dx * matrix[0].y) / determinant;
140 const f32 x0 = -width * pivotX, x1 = width * (1.0f - pivotX);
141 const f32 y0 = -height * pivotY, y1 = height * (1.0f - pivotY);
142 return localX >= std::min(x0, x1) && localX <= std::max(x0, x1)
143 && localY >= std::min(y0, y1) && localY <= std::max(y0, y1);
155 if (!registry.
valid(ancestor))
break;
158 if (mask && mask->enabled) {
162 t->ensureDecomposed();
165 registry, ancestor, *t, worldMouseX, worldMouseY,
166 node->computed_size_.x, node->computed_size_.y, 0.5f, 0.5f
Hierarchy components for parent-child relationships.
Central ECS registry for entity and component management.
Central container for all entities and components.
T & get(Entity entity)
Gets a component from an entity (must exist).
bool has(Entity entity) const
Checks if an entity has a specific component.
bool valid(Entity entity) const
Checks if an entity is currently valid.
T * tryGet(Entity entity)
Tries to get a component from an entity.
bool rayHitsOBB(const PickRay &ray, const glm::vec3 ¢re, const glm::quat &rotation, const glm::vec3 &scale, const glm::vec3 &localMin, const glm::vec3 &localMax, f32 &outT)
bool hasFlatGeometryArea(Transform &transform, bool parented)
bool pointInOBB(f32 px, f32 py, f32 worldX, f32 worldY, f32 worldW, f32 worldH, f32 pivotX, f32 pivotY, f32 rotationZ, f32 rotationW)
bool pointInTransformedBox(Registry ®istry, Entity entity, Transform &transform, f32 px, f32 py, f32 width, f32 height, f32 pivotX, f32 pivotY)
f32 quaternionToAngle2D(f32 rz, f32 rw)
bool isClippedByMask(Registry ®istry, Entity entity, f32 worldMouseX, f32 worldMouseY)
bool rayHitsPlaneZ(const PickRay &ray, f32 planeZ, f32 &outX, f32 &outY, f32 &outT)
double f64
64-bit floating point
float f32
32-bit floating point
Entity identifier with packed index + generation.
Parent reference component.
UINode — the CSS box-model layout input (the CSS/Flex primary layout model).