src/ldrawalgorithm.h

Sat, 11 Jun 2022 14:30:30 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sat, 11 Jun 2022 14:30:30 +0300
changeset 212
27259810da6d
parent 206
654661eab7f3
child 232
8efa3a33172e
permissions
-rw-r--r--

Rewrite dependency loading

#pragma once
#include "basics.h"
#include "model.h"

namespace ldraw
{
	/// Determines how quadrilaterals are split into triangles
	enum class Diagonal
	{
		Diagonal_13,
		Diagonal_24
	};

	std::pair<Triangle, Triangle> splitTriangles(
		const Quadrilateral& q,
		ldraw::Diagonal diagonal);

	/*
	void makeUnofficial(ModelEditor &editor);
	*/

	template<typename Fn>
	void circle(int segments, int divisions, Fn&& fn)
	{
		float factor = 2.0f * pi<> / divisions;
		for (int i = 0; i < segments; i += 1)
		{
			fn(
				glm::vec2{std::sin((i - 1) * factor), std::cos((i - 1) * factor)},
				glm::vec2{std::sin(i * factor), std::cos(i * factor)},
				glm::vec2{std::sin((i + 1) * factor), std::cos((i - 1) * factor)}
			);
		}
	}
}

ModelElement inverted(const ModelElement &element);

mercurial