2019-12-14 13:28:14 +00:00
|
|
|
#ifndef DUST3D_COMBINER_H
|
|
|
|
#define DUST3D_COMBINER_H
|
2019-02-18 12:57:18 +00:00
|
|
|
#include <QVector3D>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-12-14 13:28:14 +00:00
|
|
|
class MeshCombiner
|
2019-02-18 12:57:18 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class Method
|
|
|
|
{
|
|
|
|
Union,
|
|
|
|
Diff
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class Source
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
First,
|
|
|
|
Second
|
|
|
|
};
|
|
|
|
|
|
|
|
class Mesh
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Mesh() = default;
|
2020-01-04 10:29:10 +00:00
|
|
|
Mesh(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &faces, bool disableSelfIntersects=false);
|
2019-02-18 12:57:18 +00:00
|
|
|
Mesh(const Mesh &other);
|
|
|
|
~Mesh();
|
|
|
|
void fetch(std::vector<QVector3D> &vertices, std::vector<std::vector<size_t>> &faces) const;
|
|
|
|
bool isNull() const;
|
2020-04-11 06:53:12 +00:00
|
|
|
bool isCombinable() const;
|
2019-02-18 12:57:18 +00:00
|
|
|
|
2019-12-14 13:28:14 +00:00
|
|
|
friend MeshCombiner;
|
2019-02-18 12:57:18 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void *m_privateData = nullptr;
|
2020-04-11 06:53:12 +00:00
|
|
|
bool m_isCombinable = false;
|
2019-05-25 23:24:24 +00:00
|
|
|
|
|
|
|
void validate();
|
2019-02-18 12:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static Mesh *combine(const Mesh &firstMesh, const Mesh &secondMesh, Method method,
|
|
|
|
std::vector<std::pair<Source, size_t>> *combinedVerticesComeFrom=nullptr);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|