DDA アルゴリズムを実装するにあたっての変数の設定。
mapX、mapY
どのグリッドにプレイヤーがいるか
//which box of the map we're in
int mapX = int(posX);
int mapY = int(posY);
sideDistX、sideDistY
プレイヤーの初期値からの初めのグリッドまでの移動距離
sideDistX と sideDistY は、最初は光線の開始位置から最初の x サイドと最初の y サイドまでの移動距離です。この後、ステップを踏みながらインクリメントされます。
//length of ray from current position to next x or y-side
double sideDistX;
double sideDistY;
deltaDistXとdeltaDistY
光線の移動距離
deltaDistX と deltaDistY は、光線が x-方向及び 1 y-方向へ移動するために必要な距離です。
stepX、stepY、
どの方向に光線を飛ばすか(−1か1で判定される)
//length of ray from one x or y-side to next x or y-side
double deltaDistX = (rayDirX == 0) ? 1e30 : std::abs(1 / rayDirX);
double deltaDistY = (rayDirY == 0) ? 1e30 : std::abs(1 / rayDirY);
double perpWallDist;
stepX、stepY、
どの方向に光線を飛ばすか(−1か1で判定される)
stepX と stepY cub3d 壁の判定
hit, side
壁に当たったかの判定
//what direction to step in x or y-direction (either +1 or -1)
int stepX;
int stepY;
hit, side
壁に当たったかの判定
int hit = 0; //was there a wall hit?
int side; //was a NS or a EW wall hit?