MCPcopy Create free account
hub / github.com/admtrv/objcurses / depth

Method depth

entities/rendering/buffer.cpp:115–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115float Buffer::depth(const Projection &projection, const Vec3 &normal, const int pixel_x, const int pixel_y) const
116{
117 const float center_x = (static_cast<float>(pixel_x) + 0.5f) * dx;
118 const float center_y = (static_cast<float>(pixel_y) + 0.5f) * dy;
119
120 if (std::fabs(normal.z) < 1e-7f)
121 {
122 return projection.p1.z;
123 }
124
125 const float d_z = normal.x * (center_x - projection.p1.x) + normal.y * (center_y - projection.p1.y);
126 const float z = projection.p1.z - d_z / normal.z;
127
128 return z;
129}
130
131void Buffer::draw_projection(const Projection &projection, const char c, int material)
132{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected