Blender V5.3
rna_lattice_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "RNA_define.hh"
12
13#include "rna_internal.hh" /* own include */
14
15#ifdef RNA_RUNTIME
16
18# include "BKE_lattice.hh"
19
20# include "DEG_depsgraph.hh"
21
22namespace blender {
23
24static const char *rna_Lattice_unit_test_compare(Lattice *lt, Lattice *lt2, float threshold)
25{
26 using namespace bke::compare_geometry;
27 const std::optional<GeoMismatch> mismatch = compare_lattices(*lt, *lt2, threshold);
28
29 if (!mismatch) {
30 return "Same";
31 }
32
33 return mismatch_to_string(mismatch.value());
34}
35
36static void rna_Lattice_transform(Lattice *lt, const float mat[16], bool shape_keys)
37{
38 BKE_lattice_transform(lt, reinterpret_cast<const float (*)[4]>(mat), shape_keys);
39
40 DEG_id_tag_update(&lt->id, 0);
41}
42
43static void rna_Lattice_update_gpu_tag(Lattice *lt)
44{
46}
47
48} // namespace blender
49
50#else
51
52namespace blender {
53
55{
56 FunctionRNA *func;
57 PropertyRNA *parm;
58
59 func = RNA_def_function(srna, "transform", "rna_Lattice_transform");
60 RNA_def_function_ui_description(func, "Transform lattice by a matrix");
61 parm = RNA_def_float_matrix(func, "matrix", 4, 4, nullptr, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
63 RNA_def_boolean(func, "shape_keys", false, "", "Transform Shape Keys");
64
65 RNA_def_function(srna, "update_gpu_tag", "rna_Lattice_update_gpu_tag");
66
67 func = RNA_def_function(srna, "unit_test_compare", "rna_Lattice_unit_test_compare");
68 RNA_def_pointer(func, "lattice", "Lattice", "", "Lattice to compare to");
70 "threshold",
71 FLT_EPSILON * 60,
72 0.0f,
73 FLT_MAX,
74 "Threshold",
75 "Comparison tolerance threshold",
76 0.0f,
77 FLT_MAX);
78 /* return value */
79 parm = RNA_def_string(
80 func, "result", "nothing", 64, "Return value", "String description of result of comparison");
81 RNA_def_function_return(func, parm);
82}
83
84} // namespace blender
85
86#endif
#define FLT_MAX
#define FLT_EPSILON
const char * mismatch_to_string(const GeoMismatch &mismatch)
std::optional< GeoMismatch > compare_lattices(const Lattice &lattice1, const Lattice &lattice2, float threshold)
Checks if the two lattices are different, returning the type of mismatch if any.
BMesh Iterators.
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ BKE_LATTICE_BATCH_DIRTY_ALL
void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
Definition lattice.cc:645
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_api_lattice(StructRNA *srna)
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void DEG_id_tag_update(ID *id, unsigned int flags)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
Definition lattice.cc:718
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, const int rows, const int columns, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
@ PARM_REQUIRED
Definition RNA_types.hh:631