Fix BlockingQueue implementation

pull/170/head
James Ball 2023-09-10 10:53:50 +01:00
rodzic a6d25a122c
commit 298b2eeb77
2 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

@ -35,7 +35,7 @@ public:
{
std::unique_lock<std::mutex> lk(mutex);
not_full.wait(lk, [this]() { return size < content.size() || killed; });
content[head] = std::move(item);
content[(head + size) % content.size()] = std::move(item);
size++;
}
not_empty.notify_one();
@ -47,7 +47,7 @@ public:
if (size == content.size()) {
return false;
}
content[head] = std::move(item);
content[(head + size) % content.size()] = std::move(item);
size++;
}
not_empty.notify_one();

Wyświetl plik

@ -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>> shapes;
object.nextFrame();
Line3D* prevLine = nullptr;
Vector2 prevVertex;
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);
shapes.push_back(std::make_unique<Line>(start.x, start.y, end.x, end.y));