支持抗锯齿
This commit is contained in:
@@ -1,23 +1,36 @@
|
||||
#include "dvr_triangle.h"
|
||||
#include "rasterizer/dvc_rasterizer_triangle.h"
|
||||
|
||||
void Triangle::build(const davinci::fVector3& _pixelColor, int32_t canvasWidth, int32_t canvasHeight, bool debug)
|
||||
int32_t Triangle::nextID()
|
||||
{
|
||||
pixelColor = _pixelColor;
|
||||
pixels.clear();
|
||||
static int32_t id = 0;
|
||||
return id++;
|
||||
}
|
||||
|
||||
davinci::fVector3 Triangle::randomColor()
|
||||
{
|
||||
return davinci::fVector3(rand() * 0.8f / RAND_MAX, rand() * 0.8f / RAND_MAX, rand() * 0.8f / RAND_MAX);
|
||||
}
|
||||
|
||||
void Triangle::build(int32_t canvasWidth, int32_t canvasHeight, davinci::AntiAliasingTech aaTech)
|
||||
{
|
||||
m_pixels.clear();
|
||||
|
||||
//make sure it's cw
|
||||
bool ccw = false;
|
||||
if ((p2 - p1).crossProduct(p0 - p2).z > 0) {
|
||||
if ((m_p2 - m_p1).crossProduct(m_p0 - m_p2).z > 0) {
|
||||
ccw = true;
|
||||
}
|
||||
|
||||
//build pixel data
|
||||
davinci::Rasterizer::drawTriangleLarrabee(canvasWidth, canvasHeight,
|
||||
p0.xy(), p1.xy(), p2.xy(),
|
||||
[this](std::pair<int32_t, int32_t> pos, const davinci::fVector3& t)
|
||||
davinci::Rasterizer::drawTriangleLarrabee(aaTech,
|
||||
canvasWidth, canvasHeight,
|
||||
m_p0.xy(), m_p1.xy(), m_p2.xy(),
|
||||
[this](std::pair<int32_t, int32_t> pos, const davinci::fVector3& t, uint32_t mask)
|
||||
{
|
||||
pixels.push_back(pos);
|
||||
Pixel pixel;
|
||||
pixel.x = pos.first;
|
||||
pixel.y = pos.second;
|
||||
pixel.mask = mask;
|
||||
m_pixels.push_back(pixel);
|
||||
},
|
||||
ccw
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user