Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void readdepth(int w, int h, vec &pos)
- {
- // tempest readdepth fix
- float yaw = camera1->yaw-90, pitch = -camera1->pitch;
- vec from = camera1->o, dir, surface;
- float sin_yaw = sinf(yaw*RAD);
- float cos_yaw = cosf(yaw*RAD);
- float sin_pitch = sinf(pitch*RAD);
- float cos_pitch = cosf(pitch*RAD);
- dir.x = cos_pitch * cos_yaw;
- dir.y = cos_pitch * sin_yaw;
- dir.z = -sin_pitch;
- vec ray = dir;
- float dist = raycube(from, ray, surface);
- if(dist < 0) dist = 1000.0f; // if skymap was hit, dist is always -1 ...
- pos = vec(dir).mul(dist).add(from);
- loopv(ents)
- {
- entity &e = ents[i];
- if(e.type != MAPMODEL) continue;
- if(from.dist(vec(e.x, e.y, e.z)) < dist && intersect(&e, from, pos))
- dist = from.dist(vec(e.x, e.y, e.z));
- }
- pos = dir.mul(dist).add(from); // once again, now with correct dist
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement