This is a basic armature deformation test for #141535 using Lattices instead of Mesh as the target object type. Lattice deformation was briefly broken, which is caught by this test. The test adds the general-purpose `unit_test_compare` function to lattice object data. It only compares lattice point counts and positions for now, more data can be added later if necessary. The `MeshTest` class did not support lattice object types yet, so needed some changes. The Curves case was already supported, but only by full conversion to mesh data, without actually using the `unit_test_compare` function specific for curves geometry. This is unchanged, because applying constructive modifiers on curves does not work. If it were not for this limitation the test could do actual curves comparisons now. For lattice support the `MeshTest` class comparison function has been generalized to all supported object data types. It runs the appropriate `unit_test_compare` api function and validation where supported (only meshes at this point). Pull Request: https://projects.blender.org/blender/blender/pulls/141546
61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "BKE_curves.hh"
|
|
#include "BKE_mesh_types.hh"
|
|
|
|
#include "DNA_lattice_types.h"
|
|
|
|
/** \file
|
|
* \ingroup bke
|
|
*/
|
|
|
|
namespace blender::bke::compare_geometry {
|
|
|
|
enum class GeoMismatch : int8_t;
|
|
|
|
/**
|
|
* Convert the mismatch to a human-readable string for display.
|
|
*/
|
|
const char *mismatch_to_string(const GeoMismatch &mismatch);
|
|
|
|
/**
|
|
* \brief Checks if the two meshes are different, returning the type of mismatch if any. Changes in
|
|
* index order are detected, but treated as a mismatch.
|
|
*
|
|
* \details Instead of just blindly comparing the two meshes, the code tries to determine if they
|
|
* are isomorphic. Two meshes are considered isomorphic, if, for each domain, there is a bijection
|
|
* between the two meshes such that the bijections preserve connectivity.
|
|
*
|
|
* In general, determining if two graphs are isomorphic is a very difficult problem (no polynomial
|
|
* time algorithm is known). Because we have more information than just connectivity (attributes),
|
|
* we can compute it in a more reasonable time in most cases.
|
|
*
|
|
* \returns The type of mismatch that was detected, if there is any.
|
|
*/
|
|
std::optional<GeoMismatch> compare_meshes(const Mesh &mesh1, const Mesh &mesh2, float threshold);
|
|
|
|
/**
|
|
* \brief Checks if the two curves geometries are different, returning the type of mismatch if any.
|
|
* Changes in index order are detected, but treated as a mismatch.
|
|
*
|
|
* \returns The type of mismatch that was detected, if there is any.
|
|
*/
|
|
std::optional<GeoMismatch> compare_curves(const CurvesGeometry &curves1,
|
|
const CurvesGeometry &curves2,
|
|
float threshold);
|
|
|
|
/**
|
|
* \brief Checks if the two lattices are different, returning the type of mismatch if any.
|
|
*
|
|
* \returns The type of mismatch that was detected, if there is any.
|
|
*/
|
|
std::optional<GeoMismatch> compare_lattices(const Lattice &lattice1,
|
|
const Lattice &lattice2,
|
|
float threshold);
|
|
|
|
} // namespace blender::bke::compare_geometry
|