src/ldrawalgorithm.h

Wed, 25 May 2022 12:01:58 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 12:01:58 +0300
changeset 189
815fbaae9cb2
parent 186
922662adb72a
child 196
6bcb284679d4
permissions
-rw-r--r--

cleanup, gl::Compiler changed to gl::ModelShaders

#pragma once
#include "modeleditor.h"

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

	// Splits the specified quadrilateral into triangles.
	// If it is not a quadrilateral then no action is performed
	auto splitQuadrilateral(ModelEditor& editor,
		quadrilateralid_t quadrilateral_id,
		Diagonal splitType = Diagonal::Diagonal_13
	) -> std::optional<std::pair<triangleid_t, triangleid_t>>;

	void invert(ModelEditor& editor, ldraw::id_t id, GetPolygonsContext *context);
	void makeUnofficial(ModelEditor &editor);

	template<typename Fn>
	void circle(int segments, int divisions, Fn&& fn)
	{
		float factor = 2.0f * math::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)}
			);
		}
	}
}

mercurial