52
53
static void rna_LatticePoint_co_get(PointerRNA *ptr, float *values)
54
Lattice *lt = (Lattice*)ptr->id.data;
55
BPoint *bp = (BPoint*)ptr->data;
55
Lattice *lt = (Lattice *)ptr->id.data;
56
BPoint *bp = (BPoint *)ptr->data;
56
57
int a = bp - lt->def;
57
58
int x = a % lt->pntsu;
58
int y = (a/lt->pntsu) % lt->pntsv;
59
int z = (a/(lt->pntsu*lt->pntsv));
59
int y = (a / lt->pntsu) % lt->pntsv;
60
int z = (a / (lt->pntsu * lt->pntsv));
61
values[0] = lt->fu + x*lt->du;
62
values[1] = lt->fv + y*lt->dv;
63
values[2] = lt->fw + z*lt->dw;
62
values[0] = lt->fu + x * lt->du;
63
values[1] = lt->fv + y * lt->dv;
64
values[2] = lt->fw + z * lt->dw;
66
67
static void rna_LatticePoint_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
68
Lattice *lt = (Lattice*)ptr->id.data;
69
Lattice *lt = (Lattice *)ptr->id.data;
71
BPoint *bp = (BPoint*)ptr->data;
72
MDeformVert *dvert = lt->dvert + (bp-lt->def);
72
BPoint *bp = (BPoint *)ptr->data;
73
MDeformVert *dvert = lt->dvert + (bp - lt->def);
74
rna_iterator_array_begin(iter, (void*)dvert->dw, sizeof(MDeformWeight), dvert->totweight, 0, NULL);
75
rna_iterator_array_begin(iter, (void *)dvert->dw, sizeof(MDeformWeight), dvert->totweight, 0, NULL);
77
78
rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL);
80
81
static void rna_Lattice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
82
Lattice *lt = (Lattice*)ptr->data;
83
int tot = lt->pntsu*lt->pntsv*lt->pntsw;
83
Lattice *lt = (Lattice *)ptr->data;
84
int tot = lt->pntsu * lt->pntsv * lt->pntsw;
85
86
if (lt->editlatt && lt->editlatt->latt->def)
86
rna_iterator_array_begin(iter, (void*)lt->editlatt->latt->def, sizeof(BPoint), tot, 0, NULL);
87
rna_iterator_array_begin(iter, (void *)lt->editlatt->latt->def, sizeof(BPoint), tot, 0, NULL);
88
rna_iterator_array_begin(iter, (void*)lt->def, sizeof(BPoint), tot, 0, NULL);
89
rna_iterator_array_begin(iter, (void *)lt->def, sizeof(BPoint), tot, 0, NULL);
90
91
rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL);
95
96
ID *id = ptr->id.data;
97
98
DAG_id_tag_update(id, 0);
98
WM_main_add_notifier(NC_GEOM|ND_DATA, id);
99
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
101
102
static void rna_Lattice_update_size(Main *bmain, Scene *scene, PointerRNA *ptr)
105
106
int newu, newv, neww;
107
108
/* we don't modify the actual pnts, but go through opnts instead */
108
newu = (lt->opntsu > 0)? lt->opntsu: lt->pntsu;
109
newv = (lt->opntsv > 0)? lt->opntsv: lt->pntsv;
110
neww = (lt->opntsw > 0)? lt->opntsw: lt->pntsw;
109
newu = (lt->opntsu > 0) ? lt->opntsu : lt->pntsu;
110
newv = (lt->opntsv > 0) ? lt->opntsv : lt->pntsv;
111
neww = (lt->opntsw > 0) ? lt->opntsw : lt->pntsw;
112
/* resizelattice needs an object, any object will have the same result */
113
/* BKE_lattice_resize needs an object, any object will have the same result */
113
114
for (ob = bmain->object.first; ob; ob = ob->id.next) {
114
115
if (ob->data == lt) {
115
resizelattice(lt, newu, newv, neww, ob);
116
BKE_lattice_resize(lt, newu, newv, neww, ob);
116
117
if (lt->editlatt)
117
resizelattice(lt->editlatt->latt, newu, newv, neww, ob);
118
BKE_lattice_resize(lt->editlatt->latt, newu, newv, neww, ob);
122
123
/* otherwise without, means old points are not repositioned */
124
resizelattice(lt, newu, newv, neww, NULL);
125
BKE_lattice_resize(lt, newu, newv, neww, NULL);
125
126
if (lt->editlatt)
126
resizelattice(lt->editlatt->latt, newu, newv, neww, NULL);
127
BKE_lattice_resize(lt->editlatt->latt, newu, newv, neww, NULL);
129
130
rna_Lattice_update_data(bmain, scene, ptr);
149
150
static int rna_Lattice_size_editable(PointerRNA *ptr)
151
Lattice *lt = (Lattice*)ptr->data;
152
Lattice *lt = (Lattice *)ptr->data;
153
154
return lt->key == NULL;
156
157
static void rna_Lattice_points_u_set(PointerRNA *ptr, int value)
158
Lattice *lt = (Lattice*)ptr->data;
159
Lattice *lt = (Lattice *)ptr->data;
160
161
lt->opntsu = CLAMPIS(value, 1, 64);
163
164
static void rna_Lattice_points_v_set(PointerRNA *ptr, int value)
165
Lattice *lt = (Lattice*)ptr->data;
166
Lattice *lt = (Lattice *)ptr->data;
167
168
lt->opntsv = CLAMPIS(value, 1, 64);
170
171
static void rna_Lattice_points_w_set(PointerRNA *ptr, int value)
172
Lattice *lt = (Lattice*)ptr->data;
173
Lattice *lt = (Lattice *)ptr->data;
174
175
lt->opntsw = CLAMPIS(value, 1, 64);
187
188
/* annoying, but is a consequence of RNA structures... */
188
189
static char *rna_LatticePoint_path(PointerRNA *ptr)
190
Lattice *lt = (Lattice*)ptr->id.data;
191
Lattice *lt = (Lattice *)ptr->id.data;
191
192
void *point = ptr->data;
192
193
BPoint *points = NULL;
223
224
RNA_def_struct_ui_text(srna, "LatticePoint", "Point in the lattice grid");
224
225
RNA_def_struct_path_func(srna, "rna_LatticePoint_path");
227
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
228
RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
229
RNA_def_property_ui_text(prop, "Point selected", "Selection status");
226
231
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
227
232
RNA_def_property_array(prop, 3);
228
233
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
235
240
RNA_def_property_ui_text(prop, "Deformed Location", "");
236
241
RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
243
prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE);
244
RNA_def_property_float_sdna(prop, NULL, "weight");
245
RNA_def_property_range(prop, 0.01f, 100.0f);
246
RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
247
RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
238
249
prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
239
250
RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next",
240
251
"rna_iterator_array_end", "rna_iterator_array_get",
249
260
PropertyRNA *prop;
251
static EnumPropertyItem prop_keyblock_type_items[] = {
252
{KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""},
253
{KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""},
254
{KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""},
255
{0, NULL, 0, NULL, NULL}};
257
262
srna = RNA_def_struct(brna, "Lattice", "ID");
258
263
RNA_def_struct_ui_text(srna, "Lattice", "Lattice datablock defining a grid for deforming other objects");
259
264
RNA_def_struct_ui_icon(srna, ICON_LATTICE_DATA);
285
290
prop = RNA_def_property(srna, "interpolation_type_u", PROP_ENUM, PROP_NONE);
286
291
RNA_def_property_enum_sdna(prop, NULL, "typeu");
287
RNA_def_property_enum_items(prop, prop_keyblock_type_items);
292
RNA_def_property_enum_items(prop, keyblock_type_items);
288
293
RNA_def_property_ui_text(prop, "Interpolation Type U", "");
289
294
RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
291
296
prop = RNA_def_property(srna, "interpolation_type_v", PROP_ENUM, PROP_NONE);
292
297
RNA_def_property_enum_sdna(prop, NULL, "typev");
293
RNA_def_property_enum_items(prop, prop_keyblock_type_items);
298
RNA_def_property_enum_items(prop, keyblock_type_items);
294
299
RNA_def_property_ui_text(prop, "Interpolation Type V", "");
295
300
RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
297
302
prop = RNA_def_property(srna, "interpolation_type_w", PROP_ENUM, PROP_NONE);
298
303
RNA_def_property_enum_sdna(prop, NULL, "typew");
299
RNA_def_property_enum_items(prop, prop_keyblock_type_items);
304
RNA_def_property_enum_items(prop, keyblock_type_items);
300
305
RNA_def_property_ui_text(prop, "Interpolation Type W", "");
301
306
RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
321
326
RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next",
322
327
"rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
323
328
RNA_def_property_ui_text(prop, "Points", "Points of the lattice");
326
331
rna_def_animdata_common(srna);