summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assetFactory/modelFactoryMesh.cpp8
-rw-r--r--assetFactory/modelFactoryMesh.h11
-rw-r--r--game/geoData.cpp5
-rw-r--r--game/geoData.h5
-rw-r--r--thirdparty/openmesh/helpers.h11
5 files changed, 18 insertions, 22 deletions
diff --git a/assetFactory/modelFactoryMesh.cpp b/assetFactory/modelFactoryMesh.cpp
index 3d4b5f3..3660fb7 100644
--- a/assetFactory/modelFactoryMesh.cpp
+++ b/assetFactory/modelFactoryMesh.cpp
@@ -1,13 +1,5 @@
#include "modelFactoryMesh.h"
-ModelFactoryMesh::ModelFactoryMesh()
-{
- add_property(smoothFaceProperty);
- add_property(materialFaceProperty);
- add_property(nameFaceProperty);
- add_property(nameAdjFaceProperty);
-}
-
void
ModelFactoryMesh::configNamedFace(const std::string & name, OpenMesh::FaceHandle handle)
{
diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h
index 299986e..6a18155 100644
--- a/assetFactory/modelFactoryMesh.h
+++ b/assetFactory/modelFactoryMesh.h
@@ -8,6 +8,7 @@
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <thirdparty/openmesh/glmcompat.h>
+#include <thirdparty/openmesh/helpers.h>
struct ModelFactoryTraits : public OpenMesh::DefaultTraits {
FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status | OpenMesh::Attributes::Color);
@@ -21,13 +22,11 @@ struct ModelFactoryTraits : public OpenMesh::DefaultTraits {
};
struct ModelFactoryMesh : public OpenMesh::PolyMesh_ArrayKernelT<ModelFactoryTraits> {
- ModelFactoryMesh();
-
bool normalsProvidedProperty {};
- OpenMesh::FPropHandleT<bool> smoothFaceProperty;
- OpenMesh::FPropHandleT<GLuint> materialFaceProperty;
- OpenMesh::FPropHandleT<std::string> nameFaceProperty;
- OpenMesh::HPropHandleT<std::string> nameAdjFaceProperty;
+ const OpenMesh::Helpers::Property<bool, OpenMesh::FPropHandleT> smoothFaceProperty {this};
+ const OpenMesh::Helpers::Property<GLuint, OpenMesh::FPropHandleT> materialFaceProperty {this};
+ const OpenMesh::Helpers::Property<std::string, OpenMesh::FPropHandleT> nameFaceProperty {this};
+ const OpenMesh::Helpers::Property<std::string, OpenMesh::HPropHandleT> nameAdjFaceProperty {this};
template<typename... Vs>
std::pair<std::string, OpenMesh::FaceHandle>
diff --git a/game/geoData.cpp b/game/geoData.cpp
index f0e38d0..950fb73 100644
--- a/game/geoData.cpp
+++ b/game/geoData.cpp
@@ -7,11 +7,6 @@
#include <ranges>
#include <set>
-GeoData::GeoData()
-{
- add_property(surface);
-}
-
GeoData
GeoData::loadFromAsciiGrid(const std::filesystem::path & input)
{
diff --git a/game/geoData.h b/game/geoData.h
index e3fc313..11ba568 100644
--- a/game/geoData.h
+++ b/game/geoData.h
@@ -10,6 +10,7 @@
#include <glm/vec2.hpp>
#include <optional>
#include <thirdparty/openmesh/glmcompat.h>
+#include <thirdparty/openmesh/helpers.h>
struct GeoDataTraits : public OpenMesh::DefaultTraits {
FaceAttributes(OpenMesh::Attributes::Status);
@@ -22,9 +23,7 @@ struct GeoDataTraits : public OpenMesh::DefaultTraits {
class GeoData : public OpenMesh::TriMesh_ArrayKernelT<GeoDataTraits> {
private:
- GeoData();
-
- OpenMesh::FPropHandleT<const Surface *> surface;
+ const OpenMesh::Helpers::Property<const Surface *, OpenMesh::FPropHandleT> surface {this};
public:
static GeoData loadFromAsciiGrid(const std::filesystem::path &);
diff --git a/thirdparty/openmesh/helpers.h b/thirdparty/openmesh/helpers.h
new file mode 100644
index 0000000..bed885c
--- /dev/null
+++ b/thirdparty/openmesh/helpers.h
@@ -0,0 +1,11 @@
+#pragma once
+#include <OpenMesh/Core/Mesh/BaseKernel.hh>
+
+namespace OpenMesh::Helpers {
+ template<typename Type, template<typename> typename PropertyT> struct Property : public PropertyT<Type> {
+ template<typename... Params> explicit Property(OpenMesh::BaseKernel * kernel, Params &&... params)
+ {
+ kernel->add_property(*this, std::forward<Params>(params)...);
+ }
+ };
+}