//
// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty.  In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
//    claim that you wrote the original software. If you use this software
//    in a product, an acknowledgment in the product documentation would be
//    appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
//    misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//

#pragma once

#include "Recast.h"
#include "Sample.h"

#include <cstdint>

class Sample_SoloMesh : public Sample
{
protected:
	float totalBuildTimeMs = 0;

	rcConfig config{};

	unsigned char* triAreas = nullptr;
	rcHeightfield* heightfield = nullptr;
	rcCompactHeightfield* compactHeightfield = nullptr;
	rcContourSet* contourSet = nullptr;
	rcPolyMesh* polyMesh = nullptr;
	rcPolyMeshDetail* detailMesh = nullptr;

	enum class DrawMode : uint8_t
	{
		MESH,
		NAVMESH,
		NAVMESH_INVIS,
		NAVMESH_TRANS,
		NAVMESH_BVTREE,
		NAVMESH_NODES,
		VOXELS,
		VOXELS_WALKABLE,
		COMPACT,
		COMPACT_DISTANCE,
		COMPACT_REGIONS,
		REGION_CONNECTIONS,
		RAW_CONTOURS,
		BOTH_CONTOURS,
		CONTOURS,
		POLYMESH,
		POLYMESH_DETAIL
	};
	DrawMode currentDrawMode = DrawMode::NAVMESH;
	static const char* drawModeNames[];

	void cleanup();

public:
	Sample_SoloMesh();
	~Sample_SoloMesh() override;
	Sample_SoloMesh(const Sample_SoloMesh&) = delete;
	Sample_SoloMesh& operator=(const Sample_SoloMesh&) = delete;
	Sample_SoloMesh(const Sample_SoloMesh&&) = delete;
	Sample_SoloMesh& operator=(const Sample_SoloMesh&&) = delete;

	void drawSettingsUI() override;
	void drawToolsUI() override;
	void drawDebugUI() override;

	void render() override;
	void renderOverlay() override;
	void onMeshChanged(InputGeom* geom) override;
	bool build() override;

private:
	void UI_DrawModeOption(DrawMode drawMode, bool enabled);
};
