summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assetFactory/assimp.cpp2
-rw-r--r--assetFactory/cuboid.cpp2
-rw-r--r--assetFactory/cuboid.h2
-rw-r--r--assetFactory/cylinder.cpp4
-rw-r--r--assetFactory/cylinder.h2
-rw-r--r--assetFactory/factoryMesh.cpp3
-rw-r--r--assetFactory/mutation.cpp6
-rw-r--r--assetFactory/mutation.h2
-rw-r--r--assetFactory/object.cpp2
-rw-r--r--assetFactory/object.h2
-rw-r--r--assetFactory/plane.cpp2
-rw-r--r--assetFactory/plane.h2
-rw-r--r--assetFactory/shape.h2
-rw-r--r--assetFactory/use.cpp4
-rw-r--r--assetFactory/use.h2
15 files changed, 15 insertions, 24 deletions
diff --git a/assetFactory/assimp.cpp b/assetFactory/assimp.cpp
index bd5467b..f72e50a 100644
--- a/assetFactory/assimp.cpp
+++ b/assetFactory/assimp.cpp
@@ -39,7 +39,7 @@ public:
const aiNode * node;
CreatedFaces
- createMesh(ModelFactoryMesh & mesh, float) const
+ createMesh(ModelFactoryMesh & mesh, Scale3D) const
{
CreatedFaces faces;
addMesh(faces, mesh, node);
diff --git a/assetFactory/cuboid.cpp b/assetFactory/cuboid.cpp
index 1019830..4774ede 100644
--- a/assetFactory/cuboid.cpp
+++ b/assetFactory/cuboid.cpp
@@ -2,7 +2,7 @@
#include "modelFactoryMesh.h"
Cuboid::CreatedFaces
-Cuboid::createMesh(ModelFactoryMesh & mesh, float) const
+Cuboid::createMesh(ModelFactoryMesh & mesh, Scale3D) const
{
static constexpr std::array<RelativePosition3D, 8> VERTICES {{
// bottom
diff --git a/assetFactory/cuboid.h b/assetFactory/cuboid.h
index 4e375a9..f7910b0 100644
--- a/assetFactory/cuboid.h
+++ b/assetFactory/cuboid.h
@@ -4,5 +4,5 @@
class Cuboid : public Shape {
public:
- CreatedFaces createMesh(ModelFactoryMesh & mesh, float lodf) const override;
+ CreatedFaces createMesh(ModelFactoryMesh & mesh, Scale3D lodf) const override;
};
diff --git a/assetFactory/cylinder.cpp b/assetFactory/cylinder.cpp
index 29c09b0..fd96c8b 100644
--- a/assetFactory/cylinder.cpp
+++ b/assetFactory/cylinder.cpp
@@ -3,9 +3,9 @@
#include "modelFactoryMesh.h"
Cylinder::CreatedFaces
-Cylinder::createMesh(ModelFactoryMesh & mesh, float lodf) const
+Cylinder::createMesh(ModelFactoryMesh & mesh, Scale3D lodf) const
{
- const auto P = static_cast<unsigned int>(std::round(15.F * std::sqrt(lodf)));
+ const auto P = std::max(5U, static_cast<unsigned int>(std::round(10.F * std::max(lodf.x, lodf.y))));
const auto step = two_pi / static_cast<float>(P);
// Generate 2D circumference points
diff --git a/assetFactory/cylinder.h b/assetFactory/cylinder.h
index 1d7b0e0..71e3a6c 100644
--- a/assetFactory/cylinder.h
+++ b/assetFactory/cylinder.h
@@ -4,5 +4,5 @@
class Cylinder : public Shape {
public:
- CreatedFaces createMesh(ModelFactoryMesh & mesh, float lodf) const override;
+ CreatedFaces createMesh(ModelFactoryMesh & mesh, Scale3D lodf) const override;
};
diff --git a/assetFactory/factoryMesh.cpp b/assetFactory/factoryMesh.cpp
index 3caf5e8..bf4706e 100644
--- a/assetFactory/factoryMesh.cpp
+++ b/assetFactory/factoryMesh.cpp
@@ -1,5 +1,4 @@
#include "factoryMesh.h"
-#include "collections.h"
#include "gfx/models/vertex.h"
#include "modelFactoryMesh.h"
@@ -11,7 +10,7 @@ FactoryMesh::createMesh() const
for (const auto & use : uses) {
ModelFactoryMesh mesh;
- use->createMesh(mesh, 1);
+ use->createMesh(mesh, Scale3D {1});
if (!mesh.normalsProvidedProperty) {
mesh.update_face_normals();
diff --git a/assetFactory/mutation.cpp b/assetFactory/mutation.cpp
index c5c3f5b..6695dff 100644
--- a/assetFactory/mutation.cpp
+++ b/assetFactory/mutation.cpp
@@ -22,12 +22,6 @@ Mutation::getLocationMatrix() const
return glm::translate(glm::identity<Matrix>(), position) * rotate_ypr(rotation);
}
-float
-Mutation::relativeLevelOfDetail() const
-{
- return std::max({scale.x, scale.y, scale.z});
-}
-
bool
Mutation::persist(Persistence::PersistenceStore & store)
{
diff --git a/assetFactory/mutation.h b/assetFactory/mutation.h
index 4fa7e01..7656742 100644
--- a/assetFactory/mutation.h
+++ b/assetFactory/mutation.h
@@ -12,8 +12,6 @@ struct Mutation {
[[nodiscard]] Matrix getDeformationMatrix() const;
[[nodiscard]] Matrix getLocationMatrix() const;
- [[nodiscard]] float relativeLevelOfDetail() const;
-
RelativePosition3D position {};
Rotation3D rotation {};
Scale3D scale {1};
diff --git a/assetFactory/object.cpp b/assetFactory/object.cpp
index 5c86f47..f48dcf6 100644
--- a/assetFactory/object.cpp
+++ b/assetFactory/object.cpp
@@ -4,7 +4,7 @@
Object::Object(std::string i) : id {std::move(i)} { }
Object::CreatedFaces
-Object::createMesh(ModelFactoryMesh & mesh, float levelOfDetailFactor) const
+Object::createMesh(ModelFactoryMesh & mesh, Scale3D levelOfDetailFactor) const
{
CreatedFaces faces;
for (const auto & use : uses) {
diff --git a/assetFactory/object.h b/assetFactory/object.h
index 77e1469..5cdb4da 100644
--- a/assetFactory/object.h
+++ b/assetFactory/object.h
@@ -10,7 +10,7 @@ public:
Object() = default;
Object(std::string i);
- CreatedFaces createMesh(ModelFactoryMesh & mesh, float lodf) const override;
+ CreatedFaces createMesh(ModelFactoryMesh & mesh, Scale3D lodf) const override;
Use::Collection uses;
std::string id;
diff --git a/assetFactory/plane.cpp b/assetFactory/plane.cpp
index e8847a2..6ae2c62 100644
--- a/assetFactory/plane.cpp
+++ b/assetFactory/plane.cpp
@@ -2,7 +2,7 @@
#include "modelFactoryMesh.h"
Plane::CreatedFaces
-Plane::createMesh(ModelFactoryMesh & mesh, float) const
+Plane::createMesh(ModelFactoryMesh & mesh, Scale3D) const
{
static constexpr std::array<RelativePosition3D, 4> VERTICES {{
{n, n, z},
diff --git a/assetFactory/plane.h b/assetFactory/plane.h
index f24e2c1..df89256 100644
--- a/assetFactory/plane.h
+++ b/assetFactory/plane.h
@@ -4,5 +4,5 @@
class Plane : public Shape {
public:
- CreatedFaces createMesh(ModelFactoryMesh & mesh, float lodf) const override;
+ CreatedFaces createMesh(ModelFactoryMesh & mesh, Scale3D lodf) const override;
};
diff --git a/assetFactory/shape.h b/assetFactory/shape.h
index 2c2e702..8f4fccf 100644
--- a/assetFactory/shape.h
+++ b/assetFactory/shape.h
@@ -19,7 +19,7 @@ public:
virtual ~Shape() = default;
- virtual CreatedFaces createMesh(ModelFactoryMesh &, float levelOfDetailFactor) const = 0;
+ virtual CreatedFaces createMesh(ModelFactoryMesh &, Scale3D levelOfDetailFactor) const = 0;
static std::vector<OpenMesh::VertexHandle> addToMesh(
ModelFactoryMesh & mesh, const std::span<const RelativePosition3D> vertices);
diff --git a/assetFactory/use.cpp b/assetFactory/use.cpp
index 0994c8c..d5ea39d 100644
--- a/assetFactory/use.cpp
+++ b/assetFactory/use.cpp
@@ -7,7 +7,7 @@
#include <stream_support.h>
Shape::CreatedFaces
-Use::createMesh(ModelFactoryMesh & mesh, float levelOfDetailFactor) const
+Use::createMesh(ModelFactoryMesh & mesh, Scale3D levelOfDetailFactor) const
{
auto apply = [&mesh](const auto & faces, const Mutation::Matrix & m) {
std::set<ModelFactoryMesh::VertexHandle> vs;
@@ -22,7 +22,7 @@ Use::createMesh(ModelFactoryMesh & mesh, float levelOfDetailFactor) const
}
};
- auto faces = type->createMesh(mesh, levelOfDetailFactor * relativeLevelOfDetail());
+ auto faces = type->createMesh(mesh, levelOfDetailFactor * scale);
applyStyle(mesh, {this}, faces);
apply(faces, getDeformationMatrix());
for (const auto & [name, faceController] : faceControllers) {
diff --git a/assetFactory/use.h b/assetFactory/use.h
index 289bf6e..31063d8 100644
--- a/assetFactory/use.h
+++ b/assetFactory/use.h
@@ -11,7 +11,7 @@ class Use : public StdTypeDefs<Use>, public Mutation, public Style, public Persi
public:
using FaceControllers = std::map<std::string, std::unique_ptr<FaceController>>;
- Shape::CreatedFaces createMesh(ModelFactoryMesh & mesh, float lodf) const;
+ Shape::CreatedFaces createMesh(ModelFactoryMesh & mesh, Scale3D lodf) const;
Shape::CPtr type;
FaceControllers faceControllers;