src/inputvertices.cpp

Sun, 09 Apr 2023 12:23:32 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 09 Apr 2023 12:23:32 +0300
changeset 360
41b38b9e05a2
parent 322
a39f454a3d7f
permissions
-rw-r--r--

`PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time

#include "src/inputvertices.h"

bool InputVertices::currentPointOnExistingPoint() const
{
	const glm::vec3& pos = this->polygon.back();
	return std::any_of(
		this->polygon.begin(),
		this->polygon.end() - 1,
		[&pos](const glm::vec3& p){return isclose(pos, p);});
}

std::size_t InputVertices::calcNumPoints() const
{
	std::size_t result = this->polygon.size();
	if (this->currentPointOnExistingPoint()) {
		result -= 1;
	}
	return result;
}

void InputVertices::updateCurrentPoint(const glm::vec3& p)
{
	this->polygon.back() = p;
	this->numpoints = this->calcNumPoints();
}

void InputVertices::removeLastPoint()
{
	if (this->polygon.size() > 1) {
		this->polygon.erase(this->polygon.end() - 2);
		this->numpoints = this->calcNumPoints();
	}
}

void InputVertices::finishCurrentPoint()
{
	this->polygon.push_back(this->polygon.back());
}

void InputVertices::clear()
{
	*this = {};
}

mercurial