Skip to content

Commit 2191154

Browse files
committed
Renderer : Removed floor rendering before a reimplementation
1 parent c8d6918 commit 2191154

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/WorldRasterizer.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RasterizeWorldContext InitRasterizeWorldContext(uint32_t RenderTargetWidth, uint
1616
.RenderTargetWidth = RenderTargetWidth,
1717
.RenderTargetHeight = RenderTargetHeight,
1818
.FloorVerticalOffset = ComputeVerticalOffset(cam, RenderTargetHeight),
19-
.CamCurrentSectorElevationOffset = 0,//ComputeElevationOffset(cam, world, RenderTargetHeight),
19+
.CamCurrentSectorElevationOffset = 0, // TODO : ComputeElevationOffset(cam, world, RenderTargetHeight),
2020
};
2121

2222
context.yBoundaries.resize(RenderTargetWidth);
@@ -110,11 +110,11 @@ void RasterizeInRenderArea(RasterizeWorldContext& worldContext, SectorRenderCont
110110
{
111111
// Floor / ceiling rendering
112112
{
113-
// Draw floor
114-
float centerY = ((RenderTargetHeight / 2) - FloorVerticalOffset) + CamCurrentSectorElevationOffset;
115-
DrawLine(x, yMinMax.min, x, centerY, currentSector.ceilingColor);
116-
// Draw Ceiling
117-
DrawLine(x, centerY, x, yMinMax.max, currentSector.floorColor);
113+
// // Draw floor
114+
// float centerY = ((RenderTargetHeight / 2) - FloorVerticalOffset) + CamCurrentSectorElevationOffset;
115+
// DrawLine(x, yMinMax.min, x, centerY, currentSector.ceilingColor);
116+
// // Draw Ceiling
117+
// DrawLine(x, centerY, x, yMinMax.max, currentSector.floorColor);
118118
}
119119

120120
// Means this is a slid wall
@@ -156,7 +156,7 @@ void RasterizeInRenderArea(RasterizeWorldContext& worldContext, SectorRenderCont
156156
}
157157
else
158158
{
159-
renderAreaToPushInStack[nextSectorId].renderArea.xEnd = x;
159+
renderAreaToPushInStack.at(nextSectorId).renderArea.xEnd = x;
160160
}
161161

162162
// Draw a Purple placeholder where next sector will be drawn
@@ -176,6 +176,12 @@ void RasterizeInRenderArea(RasterizeWorldContext& worldContext, SectorRenderCont
176176

177177
void RenderNextAreaBorders(RasterizeWorldContext& worldContext, RenderAreaYMinMax& yMinMax, const Sector& currentSector, const Sector& nextSector, uint32_t x, float hitDistance)
178178
{
179+
// TODO :
180+
// zCeilling shloud not be < to current zFloor
181+
// And this is the same in the other way
182+
// zFloor should not be > to current zCeiling
183+
184+
// Top Border
179185
{
180186
bool nextSectCelingHigher = nextSector.zCeiling >= currentSector.zCeiling;
181187

@@ -190,14 +196,15 @@ void RenderNextAreaBorders(RasterizeWorldContext& worldContext, RenderAreaYMinMa
190196

191197
if(!nextSectCelingHigher)
192198
{
193-
bool topBorder = !nextSectCelingHigher;
194-
RenderCameraYLine(topBorderLineData, nextSector.topBorderColor, topBorder, true);
199+
bool topEdge = !nextSectCelingHigher;
200+
RenderCameraYLine(topBorderLineData, nextSector.topBorderColor, topEdge, true);
195201
}
196202

197203
// Apply Y min
198204
yMinMax.min = topBorderLineData.bottom.y;
199205
}
200206

207+
// Bottom Border
201208
{
202209
bool nextSectFloorHigher = nextSector.zFloor >= currentSector.zFloor;
203210

@@ -212,8 +219,8 @@ void RenderNextAreaBorders(RasterizeWorldContext& worldContext, RenderAreaYMinMa
212219

213220
if(!nextSectFloorHigher)
214221
{
215-
bool bottomBorder = !nextSectFloorHigher;
216-
RenderCameraYLine(bottomBorderLineData, nextSector.bottomBorderColor, true, bottomBorder);
222+
bool bottomEdge = !nextSectFloorHigher;
223+
RenderCameraYLine(bottomBorderLineData, nextSector.bottomBorderColor, true, bottomEdge);
217224
}
218225

219226
// Apply Y max
@@ -228,7 +235,7 @@ float ComputeVerticalOffset(const RaycastingCamera& cam, uint32_t RenderTargetHe
228235

229236
float ComputeElevationOffset(const RaycastingCamera& cam, const World& world, uint32_t RenderTargetHeight)
230237
{
231-
// const float OneSectorHeight = RenderTargetHeight * cam.nearPlaneDistance;
238+
// TODO : const float OneSectorHeight = RenderTargetHeight * cam.nearPlaneDistance;
232239

233240
const Sector& currentSector = world.Sectors.at(cam.currentSectorId);
234241
return Lerp((float)RenderTargetHeight, 0.f, currentSector.zFloor);
@@ -270,7 +277,7 @@ CameraYLineData ComputeCameraYAxis(
270277
};
271278
}
272279

273-
void RenderCameraYLine(CameraYLineData renderData, Color color, bool topBorder, bool bottomBorder)
280+
void RenderCameraYLine(CameraYLineData renderData, Color color, bool topEdge, bool bottomEdge)
274281
{
275282
float darkness = Lerp(1, 0, renderData.normalizedDepth);
276283

@@ -281,8 +288,8 @@ void RenderCameraYLine(CameraYLineData renderData, Color color, bool topBorder,
281288
// color
282289
);
283290

284-
if(topBorder)
291+
if(topEdge)
285292
DrawRectangle(renderData.top.x - 1, renderData.top.y - 1, 3, 3, GRAY);
286-
if(bottomBorder)
293+
if(bottomEdge)
287294
DrawRectangle(renderData.bottom.x - 1, renderData.bottom.y - 1, 3, 3, GRAY);
288295
}

0 commit comments

Comments
 (0)