Blender V5.0
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
19static const char *rna_Lattice_unit_test_compare(Lattice *lt, Lattice *lt2, float threshold)
20{
21 using namespace blender::bke::compare_geometry;
22 const std::optional<GeoMismatch> mismatch = compare_lattices(*lt, *lt2, threshold);
23
24 if (!mismatch) {
25 return "Same";
26 }
27
28 return mismatch_to_string(mismatch.value());
29}
30
31static void rna_Lattice_transform(Lattice *lt, const float mat[16], bool shape_keys)
32{
33 BKE_lattice_transform(lt, (const float (*)[4])mat, shape_keys);
34
35 DEG_id_tag_update(&lt->id, 0);
36}
37
38static void rna_Lattice_update_gpu_tag(Lattice *lt)
39{
41}
42
43#else
44
46{
47 FunctionRNA *func;
48 PropertyRNA *parm;
49
50 func = RNA_def_function(srna, "transform", "rna_Lattice_transform");
51 RNA_def_function_ui_description(func, "Transform lattice by a matrix");
52 parm = RNA_def_float_matrix(func, "matrix", 4, 4, nullptr, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
54 RNA_def_boolean(func, "shape_keys", false, "", "Transform Shape Keys");
55
56 RNA_def_function(srna, "update_gpu_tag", "rna_Lattice_update_gpu_tag");
57
58 func = RNA_def_function(srna, "unit_test_compare", "rna_Lattice_unit_test_compare");
59 RNA_def_pointer(func, "lattice", "Lattice", "", "Lattice to compare to");
61 "threshold",
62 FLT_EPSILON * 60,
63 0.0f,
64 FLT_MAX,
65 "Threshold",
66 "Comparison tolerance threshold",
67 0.0f,
68 FLT_MAX);
69 /* return value */
70 parm = RNA_def_string(
71 func, "result", "nothing", 64, "Return value", "String description of result of comparison");
72 RNA_def_function_return(func, parm);
73}
74
75#endif
@ BKE_LATTICE_BATCH_DIRTY_ALL
void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
Definition lattice.cc:631
void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
Definition lattice.cc:704
void DEG_id_tag_update(ID *id, unsigned int flags)
@ PARM_REQUIRED
Definition RNA_types.hh:545
PropertyFlag
Definition RNA_types.hh:300
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.
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)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
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)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_api_lattice(StructRNA *srna)
#define FLT_MAX
Definition stdcycles.h:14