~ubuntu-branches/ubuntu/saucy/blender/saucy-proposed

« back to all changes in this revision

Viewing changes to source/blender/makesrna/intern/rna_lattice.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <stdlib.h>
29
29
 
30
30
#include "RNA_define.h"
 
31
#include "RNA_enum_types.h"
31
32
 
32
33
#include "rna_internal.h"
33
34
 
51
52
 
52
53
static void rna_LatticePoint_co_get(PointerRNA *ptr, float *values)
53
54
{
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));
60
61
 
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;
64
65
}
65
66
 
66
67
static void rna_LatticePoint_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
67
68
{
68
 
        Lattice *lt = (Lattice*)ptr->id.data;
 
69
        Lattice *lt = (Lattice *)ptr->id.data;
69
70
 
70
71
        if (lt->dvert) {
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);
73
74
 
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);
75
76
        }
76
77
        else
77
78
                rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL);
79
80
 
80
81
static void rna_Lattice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
81
82
{
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;
84
85
 
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);
87
88
        else if (lt->def)
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);
89
90
        else
90
91
                rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL);
91
92
}
95
96
        ID *id = ptr->id.data;
96
97
 
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);
99
100
}
100
101
 
101
102
static void rna_Lattice_update_size(Main *bmain, Scene *scene, PointerRNA *ptr)
105
106
        int newu, newv, neww;
106
107
 
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;
111
112
 
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);
118
119
                        break;
119
120
                }
120
121
        }
121
122
 
122
123
        /* otherwise without, means old points are not repositioned */
123
124
        if (!ob) {
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);
127
128
        }
128
129
 
129
130
        rna_Lattice_update_data(bmain, scene, ptr);
148
149
 
149
150
static int rna_Lattice_size_editable(PointerRNA *ptr)
150
151
{
151
 
        Lattice *lt = (Lattice*)ptr->data;
 
152
        Lattice *lt = (Lattice *)ptr->data;
152
153
 
153
154
        return lt->key == NULL;
154
155
}
155
156
 
156
157
static void rna_Lattice_points_u_set(PointerRNA *ptr, int value)
157
158
{
158
 
        Lattice *lt = (Lattice*)ptr->data;
 
159
        Lattice *lt = (Lattice *)ptr->data;
159
160
 
160
161
        lt->opntsu = CLAMPIS(value, 1, 64);
161
162
}
162
163
 
163
164
static void rna_Lattice_points_v_set(PointerRNA *ptr, int value)
164
165
{
165
 
        Lattice *lt = (Lattice*)ptr->data;
 
166
        Lattice *lt = (Lattice *)ptr->data;
166
167
 
167
168
        lt->opntsv = CLAMPIS(value, 1, 64);
168
169
}
169
170
 
170
171
static void rna_Lattice_points_w_set(PointerRNA *ptr, int value)
171
172
{
172
 
        Lattice *lt = (Lattice*)ptr->data;
 
173
        Lattice *lt = (Lattice *)ptr->data;
173
174
 
174
175
        lt->opntsw = CLAMPIS(value, 1, 64);
175
176
}
187
188
/* annoying, but is a consequence of RNA structures... */
188
189
static char *rna_LatticePoint_path(PointerRNA *ptr)
189
190
{
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;
193
194
        
197
198
                points = lt->def;
198
199
        
199
200
        if (points && point) {
200
 
                int tot = lt->pntsu*lt->pntsv*lt->pntsw;
 
201
                int tot = lt->pntsu * lt->pntsv * lt->pntsw;
201
202
                
202
203
                /* only return index if in range */
203
204
                if ((point >= (void *)points) && (point < (void *)(points + tot))) {
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");
225
226
 
 
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");
 
230
 
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");
237
242
 
 
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");
 
248
 
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",
248
259
        StructRNA *srna;
249
260
        PropertyRNA *prop;
250
261
 
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}};
256
 
 
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);
284
289
 
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");
290
295
 
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");
296
301
 
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");
302
307
 
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");
324
 
        
 
329
 
325
330
        /* pointers */
326
331
        rna_def_animdata_common(srna);
327
332
}