载入中...
搜索中...
未找到
RenderTransformProjection.cpp
浏览该文件的文档.
2#include <algorithm>
3#include <cmath>
4#include <glm/gtc/matrix_transform.hpp>
5
6namespace eve::graphics::detail {
8 if (t.hasLinkedWorld) return t.linkedWorld;
9 if (t.yaw == 0.f && t.pitch == 0.f && t.roll == 0.f) {
10 glm::mat4 m(1.f);
11 m[0][0] = t.sx;
12 m[1][1] = t.sy;
13 m[2][2] = t.sz;
14 m[3] = glm::vec4(t.x, t.y, t.z, 1.f);
15 return m;
16 }
17 glm::mat4 m(1.f);
18 m = glm::translate(m, glm::vec3(t.x, t.y, t.z));
19 m = glm::rotate(m, t.yaw, glm::vec3(0.f, 1.f, 0.f));
20 m = glm::rotate(m, t.pitch, glm::vec3(1.f, 0.f, 0.f));
21 m = glm::rotate(m, t.roll, glm::vec3(0.f, 0.f, 1.f));
22 return glm::scale(m, glm::vec3(t.sx, t.sy, t.sz));
23}
25 if (!t.hasLinkedWorld) return std::max(std::abs(t.sx), std::max(std::abs(t.sy), std::abs(t.sz)));
26 double sum = 0;
27 for (int column = 0; column < 3; ++column)
28 for (int row = 0; row < 3; ++row) sum += double(t.linkedWorld[column][row]) * t.linkedWorld[column][row];
29 return static_cast<float>(std::sqrt(sum));
30}
31} // namespace eve::graphics::detail
double m[16]
float t
unsigned column
glm::mat4 modelFromTransform(const Renderable3D::Transform3D &t)
Resolve the value-owned scene world matrix or the local TRS on the render thread.
float sphereStretch(const Renderable3D::Transform3D &t)
Conservative sphere stretch; preserves culling under scene-parent shear.