From a74580123fe36ba1227611c3703c1fe1a520719a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 9 Mar 2023 01:41:26 +0000 Subject: Refactor of asset factory to address mutation/face controller logic Fixes issue where face controller extrusions applied to a rotated or scaled mesh would be applied incorrectly. Now we create the mesh at the origin, deform it as required (scale), apply face controllers and finally relocate it as required (position and rotation). A relative level of detail is cascade into the generation for shapes like cylinder, which generate fewer faces for small objects. --- assetFactory/cuboid.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'assetFactory/cuboid.cpp') diff --git a/assetFactory/cuboid.cpp b/assetFactory/cuboid.cpp index 24fe4a4..03b1304 100644 --- a/assetFactory/cuboid.cpp +++ b/assetFactory/cuboid.cpp @@ -2,7 +2,7 @@ #include "modelFactoryMesh.h" Cuboid::CreatedFaces -Cuboid::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) const +Cuboid::createMesh(ModelFactoryMesh & mesh, float) const { static constexpr std::array VERTICES {{ // bottom @@ -17,7 +17,7 @@ Cuboid::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) c {n, n, o}, }}; - const auto vhs = addMutatedToMesh(mesh, VERTICES, mutation); + const auto vhs = addToMesh(mesh, VERTICES); return { mesh.add_namedFace("top", {vhs[4], vhs[5], vhs[6], vhs[7]}), mesh.add_namedFace("bottom", {vhs[0], vhs[1], vhs[2], vhs[3]}), -- cgit v1.2.3 From 92c1aed7a471f34e18eb8d0077aad90fd8b7344b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 9 Mar 2023 18:18:43 +0000 Subject: Make add_namedFace a thin template wrapper --- assetFactory/cuboid.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'assetFactory/cuboid.cpp') diff --git a/assetFactory/cuboid.cpp b/assetFactory/cuboid.cpp index 03b1304..f200258 100644 --- a/assetFactory/cuboid.cpp +++ b/assetFactory/cuboid.cpp @@ -19,11 +19,11 @@ Cuboid::createMesh(ModelFactoryMesh & mesh, float) const const auto vhs = addToMesh(mesh, VERTICES); return { - mesh.add_namedFace("top", {vhs[4], vhs[5], vhs[6], vhs[7]}), - mesh.add_namedFace("bottom", {vhs[0], vhs[1], vhs[2], vhs[3]}), - mesh.add_namedFace("left", {vhs[0], vhs[7], vhs[6], vhs[1]}), - mesh.add_namedFace("right", {vhs[2], vhs[5], vhs[4], vhs[3]}), - mesh.add_namedFace("front", {vhs[0], vhs[3], vhs[4], vhs[7]}), - mesh.add_namedFace("back", {vhs[2], vhs[1], vhs[6], vhs[5]}), + mesh.add_namedFace("top", vhs[4], vhs[5], vhs[6], vhs[7]), + mesh.add_namedFace("bottom", vhs[0], vhs[1], vhs[2], vhs[3]), + mesh.add_namedFace("left", vhs[0], vhs[7], vhs[6], vhs[1]), + mesh.add_namedFace("right", vhs[2], vhs[5], vhs[4], vhs[3]), + mesh.add_namedFace("front", vhs[0], vhs[3], vhs[4], vhs[7]), + mesh.add_namedFace("back", vhs[2], vhs[1], vhs[6], vhs[5]), }; } -- cgit v1.2.3