Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-05-17 10:41:32 +0300
committerHans Goudey <h.goudey@me.com>2022-05-17 10:41:32 +0300
commitf11401d32a30ddbfa775177b67ad78100dc6c5ea (patch)
tree548aff018541e9af466c8833d2d82cce11c14ee6 /source/blender/modifiers/intern/MOD_meshsequencecache.cc
parent51195c17ac441b44117a19d0408cdcf13d0466c5 (diff)
Cleanup: Deduplicate Alembic procedural bounding box mesh creation
This removes the manual construction of a box mesh in the mesh sequence cache modifier when the Alembic procedural is enabled. It also removes the use of `BKE_object_boundbox_get` which doesn't make sense on a non-evaluated object. Differential Revision: https://developer.blender.org/D14958
Diffstat (limited to 'source/blender/modifiers/intern/MOD_meshsequencecache.cc')
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.cc47
1 files changed, 13 insertions, 34 deletions
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.cc b/source/blender/modifiers/intern/MOD_meshsequencecache.cc
index 998fb0a94a3..273050eafd8 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.cc
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.cc
@@ -5,8 +5,9 @@
*/
#include <cstring>
+#include <limits>
-#include "BLI_math_vector.h"
+#include "BLI_math_vector.hh"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -15,7 +16,6 @@
#include "DNA_cachefile_types.h"
#include "DNA_defaults.h"
#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -42,6 +42,8 @@
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
+#include "GEO_mesh_primitive_cuboid.hh"
+
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
@@ -104,40 +106,17 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
return (mcmd->cache_file == nullptr) || (mcmd->object_path[0] == '\0');
}
-static Mesh *generate_bounding_box_mesh(Object *object, Mesh *org_mesh)
+static Mesh *generate_bounding_box_mesh(const Mesh *org_mesh)
{
- const BoundBox *bb = BKE_object_boundbox_get(object);
- Mesh *result = BKE_mesh_new_nomain_from_template(org_mesh, 8, 0, 0, 24, 6);
-
- MVert *mvert = result->mvert;
- for (int i = 0; i < 8; ++i) {
- copy_v3_v3(mvert[i].co, bb->vec[i]);
- }
-
- /* See DNA_object_types.h for the diagram showing the order of the vertices for a BoundBox. */
- static unsigned int loops_v[6][4] = {
- {0, 4, 5, 1},
- {4, 7, 6, 5},
- {7, 3, 2, 6},
- {3, 0, 1, 2},
- {1, 5, 6, 2},
- {3, 7, 4, 0},
- };
-
- MLoop *mloop = result->mloop;
- for (int i = 0; i < 6; ++i) {
- for (int j = 0; j < 4; ++j, ++mloop) {
- mloop->v = loops_v[i][j];
- }
- }
-
- MPoly *mpoly = result->mpoly;
- for (int i = 0; i < 6; ++i) {
- mpoly[i].loopstart = i * 4;
- mpoly[i].totloop = 4;
+ using namespace blender;
+ float3 min(std::numeric_limits<float>::max());
+ float3 max(-std::numeric_limits<float>::max());
+ if (!BKE_mesh_minmax(org_mesh, min, max)) {
+ return nullptr;
}
- BKE_mesh_calc_edges(result, false, false);
+ Mesh *result = geometry::create_cuboid_mesh(max - min, 2, 2, 2);
+ BKE_mesh_translate(result, math::midpoint(min, max), false);
return result;
}
@@ -170,7 +149,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* Do not process data if using a render procedural, return a box instead for displaying in the
* viewport. */
if (BKE_cache_file_uses_render_procedural(cache_file, scene)) {
- return generate_bounding_box_mesh(ctx->object, org_mesh);
+ return generate_bounding_box_mesh(org_mesh);
}
/* If this invocation is for the ORCO mesh, and the mesh hasn't changed topology, we