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/mutation.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'assetFactory/mutation.cpp') diff --git a/assetFactory/mutation.cpp b/assetFactory/mutation.cpp index 21d2a24..9722dc3 100644 --- a/assetFactory/mutation.cpp +++ b/assetFactory/mutation.cpp @@ -1,4 +1,5 @@ #include "mutation.h" +#include #include #include @@ -8,3 +9,21 @@ Mutation::getMatrix() const return glm::translate(glm::identity(), position) * rotate_ypr(rotation) * glm::scale(glm::identity(), scale); } + +Mutation::Matrix +Mutation::getDeformationMatrix() const +{ + return glm::scale(glm::identity(), scale); +} + +Mutation::Matrix +Mutation::getLocationMatrix() const +{ + return glm::translate(glm::identity(), position) * rotate_ypr(rotation); +} + +float +Mutation::relativeLevelOfDetail() const +{ + return std::max({scale.x, scale.y, scale.z}); +} -- cgit v1.2.3