kopia lustrzana https://github.com/jameshball/osci-render
Fix BlockingQueue implementation
rodzic
a6d25a122c
commit
298b2eeb77
|
@ -35,7 +35,7 @@ public:
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(mutex);
|
std::unique_lock<std::mutex> lk(mutex);
|
||||||
not_full.wait(lk, [this]() { return size < content.size() || killed; });
|
not_full.wait(lk, [this]() { return size < content.size() || killed; });
|
||||||
content[head] = std::move(item);
|
content[(head + size) % content.size()] = std::move(item);
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
not_empty.notify_one();
|
not_empty.notify_one();
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
if (size == content.size()) {
|
if (size == content.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
content[head] = std::move(item);
|
content[(head + size) % content.size()] = std::move(item);
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
not_empty.notify_one();
|
not_empty.notify_one();
|
||||||
|
|
|
@ -7,8 +7,15 @@ Camera::Camera(double focalLength, double x, double y, double z) : focalLength(f
|
||||||
std::vector<std::unique_ptr<Shape>> Camera::draw(WorldObject& object) {
|
std::vector<std::unique_ptr<Shape>> Camera::draw(WorldObject& object) {
|
||||||
std::vector<std::unique_ptr<Shape>> shapes;
|
std::vector<std::unique_ptr<Shape>> shapes;
|
||||||
object.nextFrame();
|
object.nextFrame();
|
||||||
|
Line3D* prevLine = nullptr;
|
||||||
|
Vector2 prevVertex;
|
||||||
for (auto& edge : object.edges) {
|
for (auto& edge : object.edges) {
|
||||||
Vector2 start = project(object.rotateX, object.rotateY, object.rotateZ, edge.x1, edge.y1, edge.z1);
|
Vector2 start;
|
||||||
|
if (prevLine != nullptr && prevLine->x2 == edge.x1 && prevLine->y2 == edge.y1 && prevLine->z2 == edge.z1) {
|
||||||
|
start = prevVertex;
|
||||||
|
} else {
|
||||||
|
start = project(object.rotateX, object.rotateY, object.rotateZ, edge.x1, edge.y1, edge.z1);
|
||||||
|
}
|
||||||
Vector2 end = project(object.rotateX, object.rotateY, object.rotateZ, edge.x2, edge.y2, edge.z2);
|
Vector2 end = project(object.rotateX, object.rotateY, object.rotateZ, edge.x2, edge.y2, edge.z2);
|
||||||
|
|
||||||
shapes.push_back(std::make_unique<Line>(start.x, start.y, end.x, end.y));
|
shapes.push_back(std::make_unique<Line>(start.x, start.y, end.x, end.y));
|
||||||
|
|
Ładowanie…
Reference in New Issue