Removed old render_progress in SoftwareRenderer

This commit is contained in:
Michaël Lemaire 2014-08-19 14:20:37 +02:00
parent 1bf6d9382b
commit 2b135eedac
7 changed files with 28 additions and 30 deletions

View file

@ -37,6 +37,8 @@ Rasterizer::Rasterizer(SoftwareRenderer* renderer, int client_id, const Color &c
this->color = new Color(color);
interrupted = false;
predicted_poly_count = 0;
done_poly_count = 0;
}
Rasterizer::~Rasterizer()
@ -49,6 +51,16 @@ void Rasterizer::interrupt()
interrupted = true;
}
void Rasterizer::addPredictedPolys(int count)
{
predicted_poly_count += count;
}
void Rasterizer::addDonePolys(int count)
{
done_poly_count += count;
}
void Rasterizer::pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pixel1, const Vector3 &pixel2, const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2, const Vector3 &location3)
{
ScanPoint point1, point2, point3;

View file

@ -25,6 +25,9 @@ public:
virtual void interrupt();
protected:
void addPredictedPolys(int count=1);
void addDonePolys(int count=1);
void pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pixel1, const Vector3 &pixel2, const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2, const Vector3 &location3);
void pushTriangle(CanvasPortion *canvas, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3);
@ -43,6 +46,9 @@ private:
void pushScanPoint(CanvasPortion *canvas, RenderScanlines *scanlines, ScanPoint *point);
void pushScanLineEdge(CanvasPortion *canvas, RenderScanlines *scanlines, ScanPoint *point1, ScanPoint *point2);
void renderScanLines(CanvasPortion *canvas, RenderScanlines *scanlines);
int predicted_poly_count;
int done_poly_count;
};
}

View file

@ -14,6 +14,7 @@
SoftwareCanvasRenderer::SoftwareCanvasRenderer()
{
started = false;
interrupted = false;
canvas = new Canvas();
rasterizers.push_back(new SkyRasterizer(this, 0));
@ -60,13 +61,13 @@ void SoftwareCanvasRenderer::render()
{
CanvasPortion *portion = canvas->at(x, y);
if (not render_interrupt)
if (not interrupted)
{
portion->preparePixels();
rasterize(portion, true);
}
if (not render_interrupt)
if (not interrupted)
{
applyPixelShader(portion, true);
}
@ -78,7 +79,7 @@ void SoftwareCanvasRenderer::render()
void SoftwareCanvasRenderer::interrupt()
{
SoftwareRenderer::interrupt();
interrupted = true;
if (current_work)
{
@ -119,7 +120,7 @@ void SoftwareCanvasRenderer::applyPixelShader(CanvasPortion *portion, bool threa
// Render chunks in parallel
for (int sub_chunk_size = chunk_size; sub_chunk_size >= 1; sub_chunk_size /= 2)
{
if (render_interrupt)
if (interrupted)
{
break;
}

View file

@ -36,7 +36,10 @@ public:
*/
void render();
virtual void interrupt() override;
/**
* @brief Interrupt the render process.
*/
void interrupt();
/**
* @brief Get the list of objects that can be rasterized to polygons on a canvas.
@ -67,6 +70,7 @@ private:
Canvas *canvas;
std::vector<Rasterizer*> rasterizers;
bool started;
bool interrupted;
ParallelWork *current_work;
};

View file

@ -23,9 +23,6 @@
SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
{
render_quality = 5;
render_interrupt = 0;
render_progress = 0.0;
is_rendering = 0;
render_camera = new CameraDefinition;
atmosphere_renderer = new BaseAtmosphereRenderer(this);
@ -145,11 +142,6 @@ void SoftwareRenderer::disableAtmosphere(const std::vector<LightComponent> &ligh
atmosphere_renderer->setStaticLights(lights);
}
void SoftwareRenderer::interrupt()
{
render_interrupt = 1;
}
Color SoftwareRenderer::applyLightingToSurface(const Vector3 &location, const Vector3 &normal, const SurfaceMaterial &material)
{
LightStatus status(lighting, location, getCameraLocation(location));
@ -185,11 +177,6 @@ RayCastingResult SoftwareRenderer::rayWalking(const Vector3 &location, const Vec
return result;
}
int SoftwareRenderer::addRenderProgress(double)
{
return not render_interrupt;
}
Vector3 SoftwareRenderer::getCameraLocation(const Vector3 &)
{
return render_camera->getLocation();

View file

@ -22,11 +22,6 @@ public:
int render_quality;
CameraDefinition* render_camera;
/* Render related */
double render_progress;
int render_interrupt;
int is_rendering;
void* customData[10];
virtual Vector3 getCameraLocation(const Vector3 &target);
@ -34,7 +29,6 @@ public:
virtual double getPrecision(const Vector3 &location);
virtual Vector3 projectPoint(const Vector3 &point);
virtual Vector3 unprojectPoint(const Vector3 &point);
virtual int addRenderProgress(double progress);
/*!
* \brief Set the scenery to render.
@ -65,8 +59,6 @@ public:
void disableAtmosphere();
void disableAtmosphere(const std::vector<LightComponent> &lights);
virtual void interrupt();
inline Scenery* getScenery() const {return scenery;}
inline BaseAtmosphereRenderer* getAtmosphereRenderer() const {return atmosphere_renderer;}

View file

@ -195,15 +195,11 @@ void TerrainRasterizer::getTessellationInfo(CanvasPortion* canvas, int displaced
void TerrainRasterizer::processChunk(CanvasPortion* canvas, TerrainChunkInfo* chunk, double progress)
{
tessellateChunk(canvas, chunk, chunk->detail_hint);
renderer->render_progress = 0.05 * progress;
}
void TerrainRasterizer::rasterizeToCanvas(CanvasPortion *canvas)
{
renderer->render_progress = 0.0;
getTessellationInfo(canvas, 0);
renderer->render_progress = 0.05;
}
Color TerrainRasterizer::shadeFragment(const CanvasFragment &fragment) const