Skip to content

Commit

Permalink
Improvement quality of floors and ceilings
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Podgajny committed Oct 13, 2022
1 parent 77f8c65 commit 8f49399
Show file tree
Hide file tree
Showing 26 changed files with 437 additions and 248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.example.raycaster.View.Raycasting.UpperBlocks.UpperShapes;
import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.WallHit;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PointOnRay;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumn;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumns.PreColumn;
import com.example.raycaster.Model.Raycasting.RenderProcedure;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Sprites.Sprites;
import com.example.raycaster.View.Raycasting.BasicElements.Floor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.AngleRay;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PointOnRay;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumn;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumns.PreColumn;
import com.example.raycaster.Model.Raycasting.RenderProcedure;
import com.example.raycaster.Model.Resources.Map.Map;
import com.example.raycaster.View.Raycasting.BasicElements.SpriteColumn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public final class Sight {
public static int lcolumnhalf = 0;
public static int lshadowh = 0;

public static int halflposX;
public static int halflposY;

public static double halflheight = 0;
public static int halflposX = 0;
public static int halflposY = 0;


private static double countTan(){
Expand Down Expand Up @@ -105,10 +105,10 @@ private static void initSight(){
lcolumnhalf = 0;
lshadowh = 0;

halflposX = 0;
halflposY = 0;

halflheight = 0;
halflposY = 0;
halflposX = 0;
}
public static void renderSight(){

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Uppers;

import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Ray;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumns.UpperPreColumn;
import com.example.raycaster.View.Raycasting.UpperBlocks.UpperBlock;
import com.example.raycaster.View.Raycasting.UpperBlocks.UpperBuildingBlocks;
import com.example.raycaster.View.Raycasting.UpperBlocks.UpperHalfBlock;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PointOnRay;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumn;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumns.PreColumn;
import com.example.raycaster.Model.Raycasting.RenderProcedure;

public final class UpperBlocks {
Expand All @@ -15,7 +16,7 @@ public static void renderUpperBlocks(){

final double height = PreColumn.fakeHeight / PreColumn.z;
final double lha = PreColumn.getLastUpperHeight(height);
final double lhaa = PreColumn.getLastUpperBuildingHeight(height);
final double lhaa = UpperPreColumn.getLastUpperBuildingHeight(height);

int shadow = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Ray;
import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Sight;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumns.PreColumn;
import com.example.raycaster.Model.Raycasting.RenderProcedure;

public final class PointOnRay {
Expand Down Expand Up @@ -59,6 +60,8 @@ public static void nextStep(){

intdeltaPosX = (int) PointOnRay.deltaPosX & RenderProcedure.deltaPosMask;
intdeltaPosY = (int) PointOnRay.deltaPosY & RenderProcedure.deltaPosMask;

PreColumn.lheightpos = PreColumn.height;
}

public static void reductionAmountOfRaycastStep(){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumns;

import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.InPoint;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PointOnRay;
import com.example.raycaster.Model.Raycasting.Raycasting.RenderInfoBuffer;

public final class HalfPreColumn {

public static void bufferHalfUpperColumn(double height){

RenderInfoBuffer.llhheight[ PreColumn.uppernum] = height;


RenderInfoBuffer.lluposX[ PreColumn.uppernum] = (int) PointOnRay.posX;
RenderInfoBuffer.lluposY[ PreColumn.uppernum] = (int) PointOnRay.posY;

RenderInfoBuffer.lhheight[InPoint.countPos] = height;

if ( PreColumn.uppernum < RenderInfoBuffer.lhheight.length - 1) PreColumn.uppernum++;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray;
package com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumns;

import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.AngleRay;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PointOnRay;
import com.example.raycaster.Model.Resources.Map.Map;
import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.InPoint;
import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Ray;
Expand Down Expand Up @@ -28,6 +30,7 @@ public final class PreColumn {
public static int minh = 0;

public static double height = 0;
public static double lheightpos =0;

public static void start(){

Expand All @@ -50,6 +53,7 @@ public static void start(){
z = 0;

minY = 0;
lheightpos =RenderProcedure.canvasHeight;
}

public static void countHeight(){
Expand All @@ -75,38 +79,6 @@ public static double getLastUpperHeight(double height){
return lha;
}

public static double getLastUpperBuildingHeight(double height){
double lhaa = RenderInfoBuffer.lhhheight[InPoint.countPos];

if (Map.isNeighbourhood((int) PointOnRay.posX, (int) PointOnRay.posY, RenderInfoBuffer.llluposX[PreColumn.uppernumh],RenderInfoBuffer.llluposY[ PreColumn.uppernumh])) {
if (Column.noTrapeze(PointOnRay.deltaPosY, AngleRay.val) || (!Sight.lupperbuildingXa || Ray.upperbuildingXa)) {
lhaa = height;
}
}

if (lhaa == 0) {
lhaa = RenderInfoBuffer.lllhheight[PreColumn.uppernumh];
if(lhaa == 0) lhaa = height;

double taa = height / lhaa;
if (taa > 4 || taa < 0.25) lhaa = height;
}

return lhaa;
}

public static void bufferUpperBuildingColumn(double height){
RenderInfoBuffer.llluposX[PreColumn.uppernumh] = (int) PointOnRay.posX;
RenderInfoBuffer.llluposY[PreColumn.uppernumh] = (int) PointOnRay.posY;


RenderInfoBuffer.lhhheight[InPoint.countPos] = height;
Ray.upperbuildingXa = true;

RenderInfoBuffer.lllhheight[PreColumn.uppernumh] = height;
if (PreColumn.uppernumh < RenderInfoBuffer.lhheight.length - 1) PreColumn.uppernumh++;
}

public static void bufferUpperColumn(double height){

RenderInfoBuffer.llhheight[ PreColumn.uppernum] = height;
Expand All @@ -123,18 +95,6 @@ public static void bufferUpperColumn(double height){

if ( PreColumn.uppernum < RenderInfoBuffer.lhheight.length - 1) PreColumn.uppernum++;
}
public static void bufferHalfUpperColumn(double height){

RenderInfoBuffer.llhheight[ PreColumn.uppernum] = height;


RenderInfoBuffer.lluposX[ PreColumn.uppernum] = (int) PointOnRay.posX;
RenderInfoBuffer.lluposY[ PreColumn.uppernum] = (int) PointOnRay.posY;


RenderInfoBuffer.lhheight[InPoint.countPos] = height;

if ( PreColumn.uppernum < RenderInfoBuffer.lhheight.length - 1) PreColumn.uppernum++;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PreColumns;

import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.InPoint;
import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Ray;
import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Sight;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.AngleRay;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PointOnRay;
import com.example.raycaster.Model.Raycasting.Raycasting.RenderInfoBuffer;
import com.example.raycaster.Model.Resources.Map.Map;
import com.example.raycaster.View.Raycasting.BasicElements.Column;

public final class UpperPreColumn {


public static double getLastUpperBuildingHeight(double height){
double lhaa = RenderInfoBuffer.lhhheight[InPoint.countPos];

if (Map.isNeighbourhood((int) PointOnRay.posX, (int) PointOnRay.posY, RenderInfoBuffer.llluposX[PreColumn.uppernumh],RenderInfoBuffer.llluposY[ PreColumn.uppernumh])) {
if (Column.noTrapeze(PointOnRay.deltaPosY, AngleRay.val) || (!Sight.lupperbuildingXa || Ray.upperbuildingXa)) {
lhaa = height;
}
}

if (lhaa == 0) {
lhaa = RenderInfoBuffer.lllhheight[PreColumn.uppernumh];
if(lhaa == 0) lhaa = height;

double taa = height / lhaa;
if (taa > 4 || taa < 0.25) lhaa = height;
}

return lhaa;
}

public static void bufferUpperBuildingColumn(double height){
RenderInfoBuffer.llluposX[PreColumn.uppernumh] = (int) PointOnRay.posX;
RenderInfoBuffer.llluposY[PreColumn.uppernumh] = (int) PointOnRay.posY;


RenderInfoBuffer.lhhheight[InPoint.countPos] = height;
Ray.upperbuildingXa = true;

RenderInfoBuffer.lllhheight[PreColumn.uppernumh] = height;
if (PreColumn.uppernumh < RenderInfoBuffer.lhheight.length - 1) PreColumn.uppernumh++;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Sprites;

import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Ray;
import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Sight;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Math.Functions;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PointOnRay;
import com.example.raycaster.View.Raycasting.Sprites.SpriteRotateColumn;

public final class DynamicSprite {

public static boolean statusofangle = false;

public static void renderDynamicSprite(double heights,int shadows){
final int fun = (int) (-Sight.tan * (double) PointOnRay.intdeltaPosX + Sight.tan * (double) Sight.spritePosX + (double) Sight.spritePosY);


final int posTexX = Functions.getSqrt(SpriteDetector.eq) + 1;
statusofangle = PointOnRay.intdeltaPosY > fun;

if (statusofangle != Ray.lstatusofAngle) {

SpriteRotateColumn.render(heights, (byte) posTexX, shadows);

}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Sprites;

import com.example.raycaster.Model.Raycasting.Raycasting.Analyse.Entities.Sight;
import com.example.raycaster.Model.Raycasting.Raycasting.PreBaking.Ray.PointOnRay;
import com.example.raycaster.Model.Raycasting.RenderProcedure;

public final class SpriteDetector {

public static int eq;

public static boolean isSprite(){
boolean decision;

if (Sight.obj != 3) decision = true;
else {

int sqx = (PointOnRay.intdeltaPosX - Sight.spritePosX);
int sqy = (PointOnRay.intdeltaPosY - Sight.spritePosY);
eq = sqx * sqx + sqy * sqy;
decision = eq < 512;
}


if ((int) PointOnRay.posX == (int) RenderProcedure.pos.x && (int) PointOnRay.posY == (int) RenderProcedure.pos.y) {
decision = false;
}

return decision;
}

}
Loading

0 comments on commit 8f49399

Please sign in to comment.