Fenscaster is now using the first version of Lode's DDA raycasting algorithm but the coordinates/angles in the left map view don't matchthe right view, and the right view distorts the distance to far wall so they're viewed at 'infinity'.
This commit is contained in:
parent
75a927e192
commit
96b44a4eb2
2 changed files with 132 additions and 29 deletions
34
matrix.hpp
34
matrix.hpp
|
@ -10,8 +10,15 @@ namespace matrix {
|
|||
using std::vector, std::queue, std::array;
|
||||
using std::min, std::max, std::floor;
|
||||
|
||||
typedef vector<int> Row;
|
||||
typedef vector<Row> Matrix;
|
||||
template<typename T>
|
||||
using BaseRow = vector<T>;
|
||||
|
||||
template<typename T>
|
||||
using Base = vector<BaseRow<T>>;
|
||||
|
||||
using Row = vector<int>;
|
||||
using Matrix = vector<Row>;
|
||||
|
||||
|
||||
/*
|
||||
* Just a quick thing to reset a matrix to a value.
|
||||
|
@ -40,6 +47,17 @@ namespace matrix {
|
|||
return mat.size();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Base<T> make_base(size_t width, size_t height) {
|
||||
Base<T> result(height, BaseRow<T>(width));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline Matrix make(size_t width, size_t height) {
|
||||
Matrix result(height, Row(width));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline size_t next_x(size_t x, size_t width) {
|
||||
return (x + 1) * ((x + 1) < width);
|
||||
}
|
||||
|
@ -150,6 +168,10 @@ namespace matrix {
|
|||
size_t bottom = 0;
|
||||
|
||||
box_t(MAT &mat, size_t at_x, size_t at_y, size_t size) :
|
||||
box_t(mat, at_x, at_y, size, size) {
|
||||
}
|
||||
|
||||
box_t(MAT &mat, size_t at_x, size_t at_y, size_t width, size_t height) :
|
||||
from_x(at_x), from_y(at_y)
|
||||
{
|
||||
size_t h = matrix::height(mat);
|
||||
|
@ -157,15 +179,15 @@ namespace matrix {
|
|||
|
||||
// keeps it from going below zero
|
||||
// need extra -1 to compensate for the first next()
|
||||
left = max(from_x, size) - size;
|
||||
left = max(from_x, width) - width;
|
||||
x = left - 1; // must be -1 for next()
|
||||
// keeps it from going above width
|
||||
right = min(from_x + size + 1, w);
|
||||
right = min(from_x + width + 1, w);
|
||||
|
||||
// same for these two
|
||||
top = max(from_y, size) - size;
|
||||
top = max(from_y, height) - height;
|
||||
y = top - (left == 0);
|
||||
bottom = min(from_y + size + 1, h);
|
||||
bottom = min(from_y + height + 1, h);
|
||||
}
|
||||
|
||||
bool next() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue