~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/makesrna/intern/rna_object.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:
48
48
 
49
49
#include "BLI_utildefines.h"
50
50
 
 
51
#include "BKE_paint.h"
51
52
#include "BKE_tessmesh.h"
52
53
#include "BKE_group.h" /* needed for object_in_group() */
53
54
 
66
67
        {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
67
68
        {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
68
69
        {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose", ""},
69
 
        {0, NULL, 0, NULL, NULL}};
 
70
        {0, NULL, 0, NULL, NULL}
 
71
};
 
72
 
 
73
EnumPropertyItem object_empty_drawtype_items[] = {
 
74
        {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""},
 
75
        {OB_ARROWS, "ARROWS", 0, "Arrows", ""},
 
76
        {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""},
 
77
        {OB_CIRCLE, "CIRCLE", 0, "Circle", ""},
 
78
        {OB_CUBE, "CUBE", 0, "Cube", ""},
 
79
        {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""},
 
80
        {OB_EMPTY_CONE, "CONE", 0, "Cone", ""},
 
81
        {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""},
 
82
        {0, NULL, 0, NULL, NULL}
 
83
};
 
84
 
70
85
 
71
86
static EnumPropertyItem parent_type_items[] = {
72
87
        {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"},
77
92
        {PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"},
78
93
        {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
79
94
        {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"},
80
 
        {0, NULL, 0, NULL, NULL}};
81
 
        
 
95
        {0, NULL, 0, NULL, NULL}
 
96
};
 
97
 
 
98
#ifndef RNA_RUNTIME
 
99
static EnumPropertyItem dupli_items[] = {
 
100
        {0, "NONE", 0, "None", ""},
 
101
        {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"},
 
102
        {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"},
 
103
        {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"},
 
104
        {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"},
 
105
        {0, NULL, 0, NULL, NULL}
 
106
};
 
107
#endif
 
108
 
82
109
static EnumPropertyItem collision_bounds_items[] = {
83
110
        {OB_BOUND_BOX, "BOX", 0, "Box", ""},
84
111
        {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""},
88
115
        {OB_BOUND_TRIANGLE_MESH, "TRIANGLE_MESH", 0, "Triangle Mesh", ""},
89
116
        {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""},
90
117
        /*{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, */
91
 
        {0, NULL, 0, NULL, NULL}};
 
118
        {0, NULL, 0, NULL, NULL}
 
119
};
92
120
 
93
121
EnumPropertyItem metaelem_type_items[] = {
94
122
        {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
96
124
        {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
97
125
        {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, /* NOTE: typo at original definition! */
98
126
        {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
99
 
        {0, NULL, 0, NULL, NULL}};
 
127
        {0, NULL, 0, NULL, NULL}
 
128
};
100
129
 
101
130
/* used for 2 enums */
102
131
#define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""}
117
146
        {OB_CAMERA, "CAMERA", 0, "Camera", ""},
118
147
        {OB_LAMP, "LAMP", 0, "Lamp", ""},
119
148
        {OB_SPEAKER, "SPEAKER", 0, "Speaker", ""},
120
 
        {0, NULL, 0, NULL, NULL}};
 
149
        {0, NULL, 0, NULL, NULL}
 
150
};
121
151
 
122
152
EnumPropertyItem object_type_curve_items[] = {
123
153
        OBTYPE_CU_CURVE,
124
154
        OBTYPE_CU_SURF,
125
155
        OBTYPE_CU_FONT,
126
 
        {0, NULL, 0, NULL, NULL}};
 
156
        {0, NULL, 0, NULL, NULL}
 
157
};
127
158
 
 
159
EnumPropertyItem object_axis_items[] = {
 
160
        {OB_POSX, "POS_X", 0, "+X", ""},
 
161
        {OB_POSY, "POS_Y", 0, "+Y", ""},
 
162
        {OB_POSZ, "POS_Z", 0, "+Z", ""},
 
163
        {OB_NEGX, "NEG_X", 0, "-X", ""},
 
164
        {OB_NEGY, "NEG_Y", 0, "-Y", ""},
 
165
        {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
 
166
        {0, NULL, 0, NULL, NULL}
 
167
};
128
168
 
129
169
#ifdef RNA_RUNTIME
130
170
 
164
204
static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
165
205
{
166
206
        /* don't use compat so we get predictable rotation */
167
 
        object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE);
 
207
        BKE_object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE);
168
208
        rna_Object_internal_update(bmain, scene, ptr);
169
209
}
170
210
 
 
211
static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
 
212
{
 
213
        DAG_id_type_tag(bmain, ID_OB);
 
214
}
 
215
 
171
216
static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
172
217
{
173
218
        Object *ob = ptr->id.data;
199
244
        }
200
245
 
201
246
        /* don't use compat so we get predictable rotation */
202
 
        object_apply_mat4(ob, ob->obmat, FALSE, FALSE);
 
247
        BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE);
203
248
}
204
249
 
205
250
static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16])
206
251
{
207
252
        Object *ob = ptr->id.data;
208
 
        object_to_mat4(ob, (float(*)[4])values);
 
253
        BKE_object_to_mat4(ob, (float(*)[4])values);
209
254
}
210
255
 
211
256
static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16])
212
257
{
213
258
        Object *ob = ptr->id.data;
214
 
        object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE);
 
259
        BKE_object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE);
215
260
}
216
261
 
217
262
void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
218
263
{
219
264
        DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
220
 
        WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data);
 
265
        WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
221
266
}
222
267
 
223
 
void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
268
static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
224
269
{
225
270
        Object *ob = ptr->id.data;
226
271
 
230
275
                        case OB_MESH:
231
276
                                EDBM_mesh_load(ob);
232
277
                                EDBM_mesh_make(scene->toolsettings, scene, ob);
233
 
                                EDBM_mesh_normals_update(((Mesh*)ob->data)->edit_btmesh);
234
 
                                BMEdit_RecalcTessellation(((Mesh*)ob->data)->edit_btmesh);
 
278
                                EDBM_mesh_normals_update(((Mesh *)ob->data)->edit_btmesh);
 
279
                                BMEdit_RecalcTessellation(((Mesh *)ob->data)->edit_btmesh);
235
280
                                break;
236
281
                        case OB_CURVE:
237
282
                        case OB_SURF:
254
299
        if (scene) {
255
300
                DAG_scene_sort(bmain, scene);
256
301
        }
257
 
        WM_main_add_notifier(NC_OBJECT|ND_PARENT, ptr->id.data);
 
302
        WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->id.data);
258
303
}
259
304
 
260
305
/* when changing the selection flag the scene needs updating */
261
306
static void rna_Object_select_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
262
307
{
263
308
        if (scene) {
264
 
                Object *ob = (Object*)ptr->id.data;
 
309
                Object *ob = (Object *)ptr->id.data;
265
310
                short mode = ob->flag & SELECT ? BA_SELECT : BA_DESELECT;
266
 
                ED_base_object_select(object_in_scene(ob, scene), mode);
 
311
                ED_base_object_select(BKE_scene_base_find(scene, ob), mode);
267
312
        }
268
313
}
269
314
 
270
315
static void rna_Base_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
271
316
{
272
 
        Base *base = (Base*)ptr->data;
 
317
        Base *base = (Base *)ptr->data;
273
318
        short mode = base->flag & BA_SELECT ? BA_SELECT : BA_DESELECT;
274
319
        ED_base_object_select(base, mode);
275
320
}
281
326
                /* pass - unlikely but when running scripts on startup it happens */
282
327
        }
283
328
        else if ((ob->lay & scene->lay) && (base->lay & scene->lay)) {
284
 
                 /* pass */
 
329
                /* pass */
285
330
        }
286
331
        else if ((ob->lay & scene->lay) == 0 && (base->lay & scene->lay) == 0) {
287
332
                /* pass */
295
340
 
296
341
static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
297
342
{
298
 
        Object *ob = (Object*)ptr->id.data;
 
343
        Object *ob = (Object *)ptr->id.data;
299
344
        Base *base;
300
345
 
301
 
        base = scene ? object_in_scene(ob, scene) : NULL;
 
346
        base = scene ? BKE_scene_base_find(scene, ob) : NULL;
302
347
        if (!base)
303
348
                return;
304
349
        
305
 
        SWAP(int, base->lay, ob->lay);
 
350
        SWAP(unsigned int, base->lay, ob->lay);
306
351
 
307
352
        rna_Object_layer_update__internal(bmain, scene, base, ob);
308
353
        ob->lay = base->lay;
309
354
 
310
 
        WM_main_add_notifier(NC_SCENE|ND_LAYER_CONTENT, scene);
 
355
        WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
311
356
}
312
357
 
313
358
static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
314
359
{
315
 
        Base *base = (Base*)ptr->data;
316
 
        Object *ob = (Object*)base->object;
 
360
        Base *base = (Base *)ptr->data;
 
361
        Object *ob = (Object *)base->object;
317
362
 
318
363
        rna_Object_layer_update__internal(bmain, scene, base, ob);
319
364
        ob->lay = base->lay;
320
365
 
321
 
        WM_main_add_notifier(NC_SCENE|ND_LAYER_CONTENT, scene);
 
366
        WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
322
367
}
323
368
 
324
369
static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
325
370
{
326
 
        Object *ob = (Object*)ptr->data;
 
371
        Object *ob = (Object *)ptr->data;
327
372
        ID *id = value.data;
328
373
 
329
374
        if (id == NULL || ob->mode & OB_MODE_EDIT)
331
376
 
332
377
        if (ob->type == OB_EMPTY) {
333
378
                if (ob->data) {
334
 
                        id_us_min((ID*)ob->data);
 
379
                        id_us_min((ID *)ob->data);
335
380
                        ob->data = NULL;
336
381
                }
337
382
 
341
386
                }
342
387
        }
343
388
        else if (ob->type == OB_MESH) {
344
 
                set_mesh(ob, (Mesh*)id);
 
389
                set_mesh(ob, (Mesh *)id);
345
390
        }
346
391
        else {
347
 
                if (ob->data)
348
 
                        id_us_min((ID*)ob->data);
349
 
                if (id)
 
392
                if (ob->data) {
 
393
                        id_us_min((ID *)ob->data);
 
394
                }
 
395
                if (id) {
 
396
                        /* no need to type-check here ID. this is done in the _typef() function */
 
397
                        BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name)));
350
398
                        id_us_plus(id);
 
399
                }
351
400
 
352
401
                ob->data = id;
353
402
                test_object_materials(id);
354
403
 
355
404
                if (GS(id->name) == ID_CU)
356
 
                        test_curve_type(ob);
 
405
                        BKE_curve_type_test(ob);
357
406
                else if (ob->type == OB_ARMATURE)
358
 
                        armature_rebuild_pose(ob, ob->data);
 
407
                        BKE_pose_rebuild(ob, ob->data);
359
408
        }
360
409
}
361
410
 
362
411
static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
363
412
{
364
 
        Object *ob = (Object*)ptr->data;
 
413
        Object *ob = (Object *)ptr->data;
365
414
 
 
415
        /* keep in sync with OB_DATA_SUPPORT_ID() macro */
366
416
        switch (ob->type) {
367
417
                case OB_EMPTY: return &RNA_Image;
368
418
                case OB_MESH: return &RNA_Mesh;
381
431
 
382
432
static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value)
383
433
{
384
 
        Object *ob = (Object*)ptr->data;
385
 
        Object *par = (Object*)value.data;
 
434
        Object *ob = (Object *)ptr->data;
 
435
        Object *par = (Object *)value.data;
386
436
        
 
437
#ifdef FREE_WINDOWS
387
438
        /* NOTE: this dummy check here prevents this method causing weird runtime errors on mingw 4.6.2 */
388
 
        if (ob) {
 
439
        if (ob)
 
440
#endif
 
441
        {
389
442
                ED_object_parent(ob, par, ob->partype, ob->parsubstr);
390
443
        }
391
444
}
392
445
 
393
446
static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
394
447
{
395
 
        Object *ob = (Object*)ptr->data;
 
448
        Object *ob = (Object *)ptr->data;
396
449
 
397
450
        ED_object_parent(ob, ob->parent, value, ob->parsubstr);
398
451
}
400
453
static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C), PointerRNA *ptr,
401
454
                                                      PropertyRNA *UNUSED(prop), int *free)
402
455
{
403
 
        Object *ob = (Object*)ptr->data;
 
456
        Object *ob = (Object *)ptr->data;
404
457
        EnumPropertyItem *item = NULL;
405
458
        int totitem = 0;
406
459
 
434
487
static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *UNUSED(C), PointerRNA *ptr,
435
488
                                                           PropertyRNA *UNUSED(prop), int *free)
436
489
{
437
 
        Object *ob = (Object*)ptr->data;
 
490
        Object *ob = (Object *)ptr->data;
438
491
        EnumPropertyItem *item = NULL;
439
492
        int totitem = 0;
440
493
 
457
510
 
458
511
static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
459
512
{
460
 
        Object *ob = (Object*)ptr->data;
 
513
        Object *ob = (Object *)ptr->data;
461
514
 
462
515
        ED_object_parent(ob, ob->parent, ob->partype, value);
463
516
}
474
527
                ob->dup_group = grp;
475
528
        else
476
529
                BKE_report(NULL, RPT_ERROR,
477
 
                           "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle");
 
530
                           "Cannot set dupli-group as object belongs in group being instanced, thus causing a cycle");
478
531
}
479
532
 
480
 
void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
 
533
static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
481
534
{
482
535
        Object *ob = (Object *)ptr->id.data;
483
536
        bDeformGroup *dg = (bDeformGroup *)ptr->data;
487
540
 
488
541
static int rna_VertexGroup_index_get(PointerRNA *ptr)
489
542
{
490
 
        Object *ob = (Object*)ptr->id.data;
 
543
        Object *ob = (Object *)ptr->id.data;
491
544
 
492
545
        return BLI_findindex(&ob->defbase, ptr->data);
493
546
}
494
547
 
495
548
static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
496
549
{
497
 
        Object *ob = (Object*)ptr->id.data;
498
 
        return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef-1));
 
550
        Object *ob = (Object *)ptr->id.data;
 
551
        return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef - 1));
499
552
}
500
553
 
501
554
static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
502
555
{
503
 
        Object *ob = (Object*)ptr->id.data;
504
 
        return ob->actdef-1;
 
556
        Object *ob = (Object *)ptr->id.data;
 
557
        return ob->actdef - 1;
505
558
}
506
559
 
507
560
static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
508
561
{
509
 
        Object *ob = (Object*)ptr->id.data;
510
 
        ob->actdef = value+1;
 
562
        Object *ob = (Object *)ptr->id.data;
 
563
        ob->actdef = value + 1;
511
564
}
512
565
 
513
566
static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
514
567
{
515
 
        Object *ob = (Object*)ptr->id.data;
 
568
        Object *ob = (Object *)ptr->id.data;
516
569
 
517
570
        *min = 0;
518
 
        *max = BLI_countlist(&ob->defbase)-1;
519
 
        *max = MAX2(0, *max);
 
571
        *max = max_ii(0, BLI_countlist(&ob->defbase) - 1);
520
572
}
521
573
 
522
574
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
523
575
{
524
 
        Object *ob = (Object*)ptr->id.data;
 
576
        Object *ob = (Object *)ptr->id.data;
525
577
        bDeformGroup *dg;
526
578
 
527
 
        dg = BLI_findlink(&ob->defbase, index-1);
 
579
        dg = BLI_findlink(&ob->defbase, index - 1);
528
580
 
529
581
        if (dg) BLI_strncpy(value, dg->name, sizeof(dg->name));
530
582
        else value[0] = '\0';
532
584
 
533
585
int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
534
586
{
535
 
        Object *ob = (Object*)ptr->id.data;
 
587
        Object *ob = (Object *)ptr->id.data;
536
588
        bDeformGroup *dg;
537
589
 
538
 
        dg = BLI_findlink(&ob->defbase, index-1);
539
 
        return (dg)? strlen(dg->name): 0;
 
590
        dg = BLI_findlink(&ob->defbase, index - 1);
 
591
        return (dg) ? strlen(dg->name) : 0;
540
592
}
541
593
 
542
594
void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
543
595
{
544
 
        Object *ob = (Object*)ptr->id.data;
 
596
        Object *ob = (Object *)ptr->id.data;
545
597
        *index = defgroup_name_index(ob, value) + 1;
546
598
}
547
599
 
548
600
void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
549
601
{
550
 
        Object *ob = (Object*)ptr->id.data;
 
602
        Object *ob = (Object *)ptr->id.data;
551
603
        bDeformGroup *dg = defgroup_find_name(ob, value);
552
604
        if (dg) {
553
605
                BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
559
611
 
560
612
void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
561
613
{
562
 
        Object *ob = (Object*)ptr->id.data;
 
614
        Object *ob = (Object *)ptr->id.data;
563
615
        Mesh *me;
564
616
        CustomDataLayer *layer;
565
617
        int a;
566
618
 
567
619
        if (ob->type == OB_MESH && ob->data) {
568
 
                me = (Mesh*)ob->data;
 
620
                me = (Mesh *)ob->data;
569
621
 
570
 
                for (a = 0; a<me->pdata.totlayer; a++) {
 
622
                for (a = 0; a < me->pdata.totlayer; a++) {
571
623
                        layer = &me->pdata.layers[a];
572
624
 
573
625
                        if (layer->type == CD_MTEXPOLY && strcmp(layer->name, value) == 0) {
582
634
 
583
635
void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
584
636
{
585
 
        Object *ob = (Object*)ptr->id.data;
 
637
        Object *ob = (Object *)ptr->id.data;
586
638
        Mesh *me;
587
639
        CustomDataLayer *layer;
588
640
        int a;
589
641
 
590
642
        if (ob->type == OB_MESH && ob->data) {
591
 
                me = (Mesh*)ob->data;
 
643
                me = (Mesh *)ob->data;
592
644
 
593
 
                for (a = 0; a<me->fdata.totlayer; a++) {
 
645
                for (a = 0; a < me->fdata.totlayer; a++) {
594
646
                        layer = &me->fdata.layers[a];
595
647
 
596
648
                        if (layer->type == CD_MCOL && strcmp(layer->name, value) == 0) {
605
657
 
606
658
static int rna_Object_active_material_index_get(PointerRNA *ptr)
607
659
{
608
 
        Object *ob = (Object*)ptr->id.data;
 
660
        Object *ob = (Object *)ptr->id.data;
609
661
        return MAX2(ob->actcol - 1, 0);
610
662
}
611
663
 
612
664
static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
613
665
{
614
 
        Object *ob = (Object*)ptr->id.data;
615
 
        ob->actcol = value+1;
 
666
        Object *ob = (Object *)ptr->id.data;
 
667
        ob->actcol = value + 1;
616
668
 
617
669
        if (ob->type == OB_MESH) {
618
670
                Mesh *me = ob->data;
624
676
 
625
677
static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
626
678
{
627
 
        Object *ob = (Object*)ptr->id.data;
 
679
        Object *ob = (Object *)ptr->id.data;
628
680
        *min = 0;
629
 
        *max = MAX2(ob->totcol-1, 0);
 
681
        *max = max_ii(ob->totcol - 1, 0);
630
682
}
631
683
 
632
684
/* returns active base material */
633
685
static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
634
686
{
635
 
        Object *ob = (Object*)ptr->id.data;
 
687
        Object *ob = (Object *)ptr->id.data;
636
688
        Material *ma;
637
689
        
638
 
        ma = (ob->totcol)? give_current_material(ob, ob->actcol): NULL;
 
690
        ma = (ob->totcol) ? give_current_material(ob, ob->actcol) : NULL;
639
691
        return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
640
692
}
641
693
 
642
694
static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
643
695
{
644
 
        Object *ob = (Object*)ptr->id.data;
 
696
        Object *ob = (Object *)ptr->id.data;
645
697
 
646
698
        DAG_id_tag_update(value.data, 0);
647
 
        assign_material(ob, value.data, ob->actcol);
 
699
        assign_material(ob, value.data, ob->actcol, BKE_MAT_ASSIGN_USERPREF);
648
700
}
649
701
 
650
702
static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max,
651
703
                                                          int *softmin, int *softmax)
652
704
{
653
 
        Object *ob = (Object*)ptr->id.data;
 
705
        Object *ob = (Object *)ptr->id.data;
654
706
        *min = 0;
655
 
        *max = BLI_countlist(&ob->particlesystem)-1;
656
 
        *max = MAX2(0, *max);
 
707
        *max = max_ii(0, BLI_countlist(&ob->particlesystem) - 1);
657
708
}
658
709
 
659
710
static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
660
711
{
661
 
        Object *ob = (Object*)ptr->id.data;
 
712
        Object *ob = (Object *)ptr->id.data;
662
713
        return psys_get_current_num(ob);
663
714
}
664
715
 
665
716
static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
666
717
{
667
 
        Object *ob = (Object*)ptr->id.data;
 
718
        Object *ob = (Object *)ptr->id.data;
668
719
        psys_set_current_num(ob, value);
669
720
}
670
721
 
671
722
static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
672
723
{
673
 
        Object *ob = (Object*)ptr->id.data;
 
724
        Object *ob = (Object *)ptr->id.data;
674
725
 
675
726
        PE_current_changed(scene, ob);
676
727
}
711
762
static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
712
763
{
713
764
        Object *ob = ptr->data;
714
 
        object_get_dimensions(ob, value);
 
765
        BKE_object_dimensions_get(ob, value);
715
766
}
716
767
 
717
768
static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
718
769
{
719
770
        Object *ob = ptr->data;
720
 
        object_set_dimensions(ob, value);
 
771
        BKE_object_dimensions_set(ob, value);
721
772
}
722
773
 
723
774
static int rna_Object_location_editable(PointerRNA *ptr, int index)
788
839
 
789
840
static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
790
841
{
791
 
        Object *ob = (Object*)ptr->id.data;
 
842
        Object *ob = (Object *)ptr->id.data;
792
843
        Material *ma;
793
 
        int index = (Material**)ptr->data - ob->mat;
 
844
        int index = (Material **)ptr->data - ob->mat;
794
845
 
795
 
        ma = give_current_material(ob, index+1);
 
846
        ma = give_current_material(ob, index + 1);
796
847
        return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
797
848
}
798
849
 
799
850
static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value)
800
851
{
801
 
        Object *ob = (Object*)ptr->id.data;
802
 
        int index = (Material**)ptr->data - ob->mat;
 
852
        Object *ob = (Object *)ptr->id.data;
 
853
        int index = (Material **)ptr->data - ob->mat;
803
854
 
804
 
        assign_material(ob, value.data, index+1);
 
855
        assign_material(ob, value.data, index + 1, BKE_MAT_ASSIGN_USERPREF);
805
856
}
806
857
 
807
858
static int rna_MaterialSlot_link_get(PointerRNA *ptr)
808
859
{
809
 
        Object *ob = (Object*)ptr->id.data;
810
 
        int index = (Material**)ptr->data - ob->mat;
 
860
        Object *ob = (Object *)ptr->id.data;
 
861
        int index = (Material **)ptr->data - ob->mat;
811
862
 
812
863
        return ob->matbits[index] != 0;
813
864
}
814
865
 
815
866
static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
816
867
{
817
 
        Object *ob = (Object*)ptr->id.data;
818
 
        int index = (Material**)ptr->data - ob->mat;
 
868
        Object *ob = (Object *)ptr->id.data;
 
869
        int index = (Material **)ptr->data - ob->mat;
819
870
        
820
871
        if (value) {
821
872
                ob->matbits[index] = 1;
822
 
                /* ob->colbits |= (1<<index); */ /* DEPRECATED */
 
873
                /* ob->colbits |= (1 << index); */ /* DEPRECATED */
823
874
        }
824
875
        else {
825
876
                ob->matbits[index] = 0;
826
 
                /* ob->colbits &= ~(1<<index); */ /* DEPRECATED */
 
877
                /* ob->colbits &= ~(1 << index); */ /* DEPRECATED */
827
878
        }
828
879
}
829
880
 
830
881
static int rna_MaterialSlot_name_length(PointerRNA *ptr)
831
882
{
832
 
        Object *ob = (Object*)ptr->id.data;
 
883
        Object *ob = (Object *)ptr->id.data;
833
884
        Material *ma;
834
 
        int index = (Material**)ptr->data - ob->mat;
 
885
        int index = (Material **)ptr->data - ob->mat;
835
886
 
836
 
        ma = give_current_material(ob, index+1);
 
887
        ma = give_current_material(ob, index + 1);
837
888
 
838
889
        if (ma)
839
 
                return strlen(ma->id.name+2);
 
890
                return strlen(ma->id.name + 2);
840
891
        
841
892
        return 0;
842
893
}
843
894
 
844
895
static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str)
845
896
{
846
 
        Object *ob = (Object*)ptr->id.data;
 
897
        Object *ob = (Object *)ptr->id.data;
847
898
        Material *ma;
848
 
        int index = (Material**)ptr->data - ob->mat;
 
899
        int index = (Material **)ptr->data - ob->mat;
849
900
 
850
 
        ma = give_current_material(ob, index+1);
 
901
        ma = give_current_material(ob, index + 1);
851
902
 
852
903
        if (ma)
853
 
                strcpy(str, ma->id.name+2);
 
904
                strcpy(str, ma->id.name + 2);
854
905
        else
855
906
                str[0] = '\0';
856
907
}
858
909
static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
859
910
{
860
911
        rna_Object_internal_update(bmain, scene, ptr);
861
 
        WM_main_add_notifier(NC_OBJECT|ND_OB_SHADING, ptr->id.data);
 
912
        WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->id.data);
862
913
}
863
914
 
864
915
/* why does this have to be so complicated?, can't all this crap be
868
919
 *  */
869
920
static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
870
921
{
871
 
        Object *ob = (Object*)ptr->id.data;
 
922
        Object *ob = (Object *)ptr->id.data;
872
923
 
873
924
        /* determine the body_type setting based on flags */
874
925
        if (!(ob->gameflag & OB_COLLISION)) {
882
933
                        ob->body_type = OB_BODY_TYPE_NO_COLLISION;
883
934
                }
884
935
        }
 
936
        else if (ob->gameflag & OB_CHARACTER) {
 
937
                ob->body_type = OB_BODY_TYPE_CHARACTER;
 
938
        }
885
939
        else if (ob->gameflag & OB_SENSOR) {
886
940
                ob->body_type = OB_BODY_TYPE_SENSOR;
887
941
        }
888
942
        else if (!(ob->gameflag & OB_DYNAMIC)) {
889
943
                ob->body_type = OB_BODY_TYPE_STATIC;
890
944
        }
891
 
        else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) {
 
945
        else if (!(ob->gameflag & (OB_RIGID_BODY | OB_SOFT_BODY))) {
892
946
                ob->body_type = OB_BODY_TYPE_DYNAMIC;
893
947
        }
894
948
        else if (ob->gameflag & OB_RIGID_BODY) {
906
960
 
907
961
static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
908
962
{
909
 
        Object *ob = (Object*)ptr->id.data;
 
963
        Object *ob = (Object *)ptr->id.data;
910
964
        const int was_navmesh = (ob->gameflag & OB_NAVMESH);
911
965
        ob->body_type = value;
912
966
 
913
967
        switch (ob->body_type) {
914
 
        case OB_BODY_TYPE_SENSOR:
915
 
                ob->gameflag |= OB_SENSOR|OB_COLLISION|OB_GHOST;
916
 
                ob->gameflag &= ~(OB_OCCLUDER|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_ACTOR|OB_ANISOTROPIC_FRICTION
917
 
                                  |OB_DO_FH|OB_ROT_FH|OB_COLLISION_RESPONSE|OB_NAVMESH);
918
 
                break;
919
 
        case OB_BODY_TYPE_OCCLUDER:
920
 
                ob->gameflag |= OB_OCCLUDER;
921
 
                ob->gameflag &= ~(OB_SENSOR|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION|OB_DYNAMIC|OB_NAVMESH);
922
 
                break;
923
 
        case OB_BODY_TYPE_NAVMESH:
924
 
                ob->gameflag |= OB_NAVMESH;
925
 
                ob->gameflag &= ~(OB_SENSOR|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION|OB_DYNAMIC|OB_OCCLUDER);
926
 
 
927
 
                if (ob->type == OB_MESH) {
928
 
                        /* could be moved into mesh UI but for now ensure mesh data layer */
929
 
                        BKE_mesh_ensure_navmesh(ob->data);
930
 
                }
931
 
 
932
 
                break;
933
 
        case OB_BODY_TYPE_NO_COLLISION:
934
 
                ob->gameflag &= ~(OB_SENSOR|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC|OB_NAVMESH);
935
 
                break;
936
 
        case OB_BODY_TYPE_STATIC:
937
 
                ob->gameflag |= OB_COLLISION;
938
 
                ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
939
 
                break;
940
 
        case OB_BODY_TYPE_DYNAMIC:
941
 
                ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR;
942
 
                ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
943
 
                break;
944
 
        case OB_BODY_TYPE_RIGID:
945
 
                ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR;
946
 
                ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
947
 
                break;
948
 
        default:
949
 
        case OB_BODY_TYPE_SOFT:
950
 
                ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
951
 
                ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
952
 
 
953
 
                /* assume triangle mesh, if no bounds chosen for soft body */
954
 
                if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype<OB_BOUND_TRIANGLE_MESH)) {
955
 
                        ob->boundtype = OB_BOUND_TRIANGLE_MESH;
956
 
                }
957
 
                /* create a BulletSoftBody structure if not already existing */
958
 
                if (!ob->bsoft)
959
 
                        ob->bsoft = bsbNew();
960
 
                break;
 
968
                case OB_BODY_TYPE_SENSOR:
 
969
                        ob->gameflag |= OB_SENSOR | OB_COLLISION | OB_GHOST;
 
970
                        ob->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
 
971
                                          OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
 
972
                        break;
 
973
                case OB_BODY_TYPE_OCCLUDER:
 
974
                        ob->gameflag |= OB_OCCLUDER;
 
975
                        ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_NAVMESH);
 
976
                        break;
 
977
                case OB_BODY_TYPE_NAVMESH:
 
978
                        ob->gameflag |= OB_NAVMESH;
 
979
                        ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_OCCLUDER);
 
980
 
 
981
                        if (ob->type == OB_MESH) {
 
982
                                /* could be moved into mesh UI but for now ensure mesh data layer */
 
983
                                BKE_mesh_ensure_navmesh(ob->data);
 
984
                        }
 
985
 
 
986
                        break;
 
987
                case OB_BODY_TYPE_NO_COLLISION:
 
988
                        ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
 
989
                        break;
 
990
                case OB_BODY_TYPE_CHARACTER:
 
991
                        ob->gameflag |= OB_COLLISION | OB_GHOST | OB_CHARACTER;
 
992
                        ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
 
993
                                      OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
 
994
                break;
 
995
                case OB_BODY_TYPE_STATIC:
 
996
                        ob->gameflag |= OB_COLLISION;
 
997
                        ob->gameflag &= ~(OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
 
998
                        break;
 
999
                case OB_BODY_TYPE_DYNAMIC:
 
1000
                        ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_ACTOR;
 
1001
                        ob->gameflag &= ~(OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
 
1002
                        break;
 
1003
                case OB_BODY_TYPE_RIGID:
 
1004
                        ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY | OB_ACTOR;
 
1005
                        ob->gameflag &= ~(OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
 
1006
                        break;
 
1007
                default:
 
1008
                case OB_BODY_TYPE_SOFT:
 
1009
                        ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_SOFT_BODY | OB_ACTOR;
 
1010
                        ob->gameflag &= ~(OB_RIGID_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
 
1011
 
 
1012
                        /* assume triangle mesh, if no bounds chosen for soft body */
 
1013
                        if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype < OB_BOUND_TRIANGLE_MESH)) {
 
1014
                                ob->boundtype = OB_BOUND_TRIANGLE_MESH;
 
1015
                        }
 
1016
                        /* create a BulletSoftBody structure if not already existing */
 
1017
                        if (!ob->bsoft)
 
1018
                                ob->bsoft = bsbNew();
 
1019
                        break;
961
1020
        }
962
1021
 
963
1022
        if (was_navmesh != (ob->gameflag & OB_NAVMESH)) {
967
1026
                }
968
1027
        }
969
1028
 
970
 
        WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data);
 
1029
        WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
971
1030
}
972
1031
 
973
1032
static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
974
1033
{
975
 
        Object *ob = (Object*)ptr->id.data;
 
1034
        Object *ob = (Object *)ptr->id.data;
976
1035
        ParticleSystem *psys = psys_get_current(ob);
977
1036
        return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
978
1037
}
988
1047
        int i, tot = 0;
989
1048
 
990
1049
        /* ensure we always have some layer selected */
991
 
        for (i = 0; i<20; i++)
 
1050
        for (i = 0; i < 20; i++)
992
1051
                if (values[i])
993
1052
                        tot++;
994
1053
 
995
1054
        if (tot == 0)
996
1055
                return 0;
997
1056
 
998
 
        for (i = 0; i<20; i++) {
999
 
                if (values[i])  lay |= (1<<i);
1000
 
                else                    lay &= ~(1<<i);
 
1057
        for (i = 0; i < 20; i++) {
 
1058
                if (values[i]) lay |=  (1 << i);
 
1059
                else           lay &= ~(1 << i);
1001
1060
        }
1002
1061
 
1003
1062
        return lay;
1005
1064
 
1006
1065
static void rna_Object_layer_set(PointerRNA *ptr, const int *values)
1007
1066
{
1008
 
        Object *ob = (Object*)ptr->data;
 
1067
        Object *ob = (Object *)ptr->data;
1009
1068
        unsigned int lay;
1010
1069
 
1011
1070
        lay = rna_Object_layer_validate__internal(values, ob->lay);
1015
1074
 
1016
1075
static void rna_Base_layer_set(PointerRNA *ptr, const int *values)
1017
1076
{
1018
 
        Base *base = (Base*)ptr->data;
 
1077
        Base *base = (Base *)ptr->data;
1019
1078
 
1020
1079
        unsigned int lay;
1021
1080
        lay = rna_Object_layer_validate__internal(values, base->lay);
1027
1086
 
1028
1087
static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
1029
1088
{
1030
 
        Object *ob = (Object*)ptr->data;
 
1089
        Object *ob = (Object *)ptr->data;
1031
1090
        int i;
1032
 
        int all_states = (ob->scaflag & OB_ALLSTATE?1:0);
 
1091
        int all_states = (ob->scaflag & OB_ALLSTATE ? 1 : 0);
1033
1092
 
1034
 
        memset(values, 0, sizeof(int)*OB_MAX_STATES);
1035
 
        for (i = 0; i<OB_MAX_STATES; i++)
1036
 
                values[i] = (ob->state & (1<<i)) | all_states;
 
1093
        memset(values, 0, sizeof(int) * OB_MAX_STATES);
 
1094
        for (i = 0; i < OB_MAX_STATES; i++) {
 
1095
                values[i] = (ob->state & (1 << i)) | all_states;
 
1096
        }
1037
1097
}
1038
1098
 
1039
1099
static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
1040
1100
{
1041
 
        Object *ob = (Object*)ptr->data;
 
1101
        Object *ob = (Object *)ptr->data;
1042
1102
        int i, tot = 0;
1043
1103
 
1044
1104
        /* ensure we always have some state selected */
1045
 
        for (i = 0; i<OB_MAX_STATES; i++)
 
1105
        for (i = 0; i < OB_MAX_STATES; i++)
1046
1106
                if (values[i])
1047
1107
                        tot++;
1048
1108
        
1049
1109
        if (tot == 0)
1050
1110
                return;
1051
1111
 
1052
 
        for (i = 0; i<OB_MAX_STATES; i++) {
1053
 
                if (values[i]) ob->state |= (1<<i);
1054
 
                else ob->state &= ~(1<<i);
 
1112
        for (i = 0; i < OB_MAX_STATES; i++) {
 
1113
                if (values[i]) ob->state |= (1 << i);
 
1114
                else ob->state &= ~(1 << i);
1055
1115
        }
1056
1116
}
1057
1117
 
1058
1118
static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
1059
1119
{
1060
 
        Object *ob = (Object*)ptr->data;
 
1120
        Object *ob = (Object *)ptr->data;
1061
1121
        bController *cont;
1062
1122
 
1063
 
        memset(values, 0, sizeof(int)*OB_MAX_STATES);
 
1123
        memset(values, 0, sizeof(int) * OB_MAX_STATES);
1064
1124
        for (cont = ob->controllers.first; cont; cont = cont->next) {
1065
1125
                int i;
1066
1126
 
1067
 
                for (i = 0; i<OB_MAX_STATES; i++) {
1068
 
                        if (cont->state_mask & (1<<i))
 
1127
                for (i = 0; i < OB_MAX_STATES; i++) {
 
1128
                        if (cont->state_mask & (1 << i))
1069
1129
                                values[i] = 1;
1070
1130
                }
1071
1131
        }
1072
1132
}
1073
1133
 
 
1134
static void rna_GameObjectSettings_col_group_get(PointerRNA *ptr, int *values)
 
1135
{
 
1136
        Object *ob = (Object *)ptr->data;
 
1137
        int i;
 
1138
 
 
1139
        for (i = 0; i < OB_MAX_COL_MASKS; i++) {
 
1140
                values[i] = (ob->col_group & (1 << i));
 
1141
        }
 
1142
}
 
1143
 
 
1144
static void rna_GameObjectSettings_col_group_set(PointerRNA *ptr, const int *values)
 
1145
{
 
1146
        Object *ob = (Object *)ptr->data;
 
1147
        int i, tot = 0;
 
1148
 
 
1149
        /* ensure we always have some group selected */
 
1150
        for (i = 0; i < OB_MAX_COL_MASKS; i++)
 
1151
                if (values[i])
 
1152
                        tot++;
 
1153
 
 
1154
        if (tot == 0)
 
1155
                return;
 
1156
 
 
1157
        for (i = 0; i < OB_MAX_COL_MASKS; i++) {
 
1158
                if (values[i]) ob->col_group |=  (1 << i);
 
1159
                else           ob->col_group &= ~(1 << i);
 
1160
        }
 
1161
}
 
1162
 
 
1163
static void rna_GameObjectSettings_col_mask_get(PointerRNA *ptr, int *values)
 
1164
{
 
1165
        Object *ob = (Object *)ptr->data;
 
1166
        int i;
 
1167
 
 
1168
        for (i = 0; i < OB_MAX_COL_MASKS; i++) {
 
1169
                values[i] = (ob->col_mask & (1 << i));
 
1170
        }
 
1171
}
 
1172
 
 
1173
static void rna_GameObjectSettings_col_mask_set(PointerRNA *ptr, const int *values)
 
1174
{
 
1175
        Object *ob = (Object *)ptr->data;
 
1176
        int i, tot = 0;
 
1177
 
 
1178
        /* ensure we always have some mask selected */
 
1179
        for (i = 0; i < OB_MAX_COL_MASKS; i++)
 
1180
                if (values[i])
 
1181
                        tot++;
 
1182
 
 
1183
        if (tot == 0)
 
1184
                return;
 
1185
 
 
1186
        for (i = 0; i < OB_MAX_COL_MASKS; i++) {
 
1187
                if (values[i]) ob->col_mask |=  (1 << i);
 
1188
                else           ob->col_mask &= ~(1 << i);
 
1189
        }
 
1190
}
 
1191
 
 
1192
 
1074
1193
static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1075
1194
{
1076
 
        Object *ob = (Object*)ptr->id.data;
1077
 
        Key *key = ob_get_key(ob);
 
1195
        Object *ob = (Object *)ptr->id.data;
 
1196
        Key *key = BKE_key_from_object(ob);
1078
1197
 
1079
1198
        *min = 0;
1080
1199
        if (key) {
1081
 
                *max = BLI_countlist(&key->block)-1;
 
1200
                *max = BLI_countlist(&key->block) - 1;
1082
1201
                if (*max < 0) *max = 0;
1083
1202
        }
1084
1203
        else {
1088
1207
 
1089
1208
static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
1090
1209
{
1091
 
        Object *ob = (Object*)ptr->id.data;
 
1210
        Object *ob = (Object *)ptr->id.data;
1092
1211
 
1093
 
        return MAX2(ob->shapenr-1, 0);
 
1212
        return MAX2(ob->shapenr - 1, 0);
1094
1213
}
1095
1214
 
1096
1215
static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
1097
1216
{
1098
 
        Object *ob = (Object*)ptr->id.data;
 
1217
        Object *ob = (Object *)ptr->id.data;
1099
1218
 
1100
 
        ob->shapenr = value+1;
 
1219
        ob->shapenr = value + 1;
1101
1220
}
1102
1221
 
1103
1222
static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
1104
1223
{
1105
 
        Object *ob = (Object*)ptr->id.data;
1106
 
        Key *key = ob_get_key(ob);
 
1224
        Object *ob = (Object *)ptr->id.data;
 
1225
        Key *key = BKE_key_from_object(ob);
1107
1226
        KeyBlock *kb;
1108
1227
        PointerRNA keyptr;
1109
1228
 
1110
1229
        if (key == NULL)
1111
1230
                return PointerRNA_NULL;
1112
1231
        
1113
 
        kb = BLI_findlink(&key->block, ob->shapenr-1);
 
1232
        kb = BLI_findlink(&key->block, ob->shapenr - 1);
1114
1233
        RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr);
1115
1234
        return keyptr;
1116
1235
}
1117
1236
 
1118
1237
static PointerRNA rna_Object_field_get(PointerRNA *ptr)
1119
1238
{
1120
 
        Object *ob = (Object*)ptr->id.data;
 
1239
        Object *ob = (Object *)ptr->id.data;
1121
1240
 
1122
1241
        /* weak */
1123
1242
        if (!ob->pd)
1128
1247
 
1129
1248
static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
1130
1249
{
1131
 
        Object *ob = (Object*)ptr->id.data;
 
1250
        Object *ob = (Object *)ptr->id.data;
1132
1251
 
1133
1252
        if (ob->type != OB_MESH)
1134
1253
                return PointerRNA_NULL;
1142
1261
 
1143
1262
static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
1144
1263
{
1145
 
        Object *ob = (Object*)ptr->id.data;
1146
 
        bConstraint *con = constraints_get_active(&ob->constraints);
 
1264
        Object *ob = (Object *)ptr->id.data;
 
1265
        bConstraint *con = BKE_constraints_get_active(&ob->constraints);
1147
1266
        return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
1148
1267
}
1149
1268
 
1150
1269
static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
1151
1270
{
1152
 
        Object *ob = (Object*)ptr->id.data;
1153
 
        constraints_set_active(&ob->constraints, (bConstraint *)value.data);
 
1271
        Object *ob = (Object *)ptr->id.data;
 
1272
        BKE_constraints_set_active(&ob->constraints, (bConstraint *)value.data);
1154
1273
}
1155
1274
 
1156
1275
static bConstraint *rna_Object_constraints_new(Object *object, int type)
1157
1276
{
1158
 
        WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object);
1159
 
        return add_ob_constraint(object, NULL, type);
 
1277
        WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
 
1278
        return BKE_add_ob_constraint(object, NULL, type);
1160
1279
}
1161
1280
 
1162
 
static void rna_Object_constraints_remove(Object *object, ReportList *reports, bConstraint *con)
 
1281
static void rna_Object_constraints_remove(Object *object, ReportList *reports, PointerRNA *con_ptr)
1163
1282
{
 
1283
        bConstraint *con = con_ptr->data;
1164
1284
        if (BLI_findindex(&object->constraints, con) == -1) {
1165
 
                BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'", con->name, object->id.name+2);
 
1285
                BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'", con->name, object->id.name + 2);
1166
1286
                return;
1167
1287
        }
1168
1288
 
1169
 
        remove_constraint(&object->constraints, con);
 
1289
        BKE_remove_constraint(&object->constraints, con);
 
1290
        RNA_POINTER_INVALIDATE(con_ptr);
 
1291
 
1170
1292
        ED_object_constraint_update(object);
1171
1293
        ED_object_constraint_set_active(object, NULL);
1172
 
        WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object);
 
1294
        WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1173
1295
}
1174
1296
 
1175
1297
static void rna_Object_constraints_clear(Object *object)
1176
1298
{
1177
 
        free_constraints(&object->constraints);
 
1299
        BKE_free_constraints(&object->constraints);
1178
1300
 
1179
1301
        ED_object_constraint_update(object);
1180
1302
        ED_object_constraint_set_active(object, NULL);
1181
1303
 
1182
 
        WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object);
 
1304
        WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1183
1305
}
1184
1306
 
1185
1307
static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports,
1188
1310
        return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1189
1311
}
1190
1312
 
1191
 
static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md)
 
1313
static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr)
1192
1314
{
1193
 
        ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md);
1194
 
 
1195
 
        WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object);
 
1315
        ModifierData *md = md_ptr->data;
 
1316
        if (ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md) == FALSE) {
 
1317
                /* error is already set */
 
1318
                return;
 
1319
        }
 
1320
 
 
1321
        RNA_POINTER_INVALIDATE(md_ptr);
 
1322
 
 
1323
        WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1196
1324
}
1197
1325
 
1198
1326
static void rna_Object_modifier_clear(Object *object, bContext *C)
1199
1327
{
1200
1328
        ED_object_modifier_clear(CTX_data_main(C), CTX_data_scene(C), object);
1201
1329
 
1202
 
        WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object);
 
1330
        WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1203
1331
}
1204
1332
 
1205
1333
static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
1206
1334
{
1207
 
        Object *ob = (Object*)ptr->id.data;
1208
 
        BoundBox *bb = object_get_boundbox(ob);
 
1335
        Object *ob = (Object *)ptr->id.data;
 
1336
        BoundBox *bb = BKE_object_boundbox_get(ob);
1209
1337
        if (bb) {
1210
1338
                memcpy(values, bb->vec, sizeof(bb->vec));
1211
1339
        }
1212
1340
        else {
1213
 
                fill_vn_fl(values, sizeof(bb->vec)/sizeof(float), 0.0f);
 
1341
                fill_vn_fl(values, sizeof(bb->vec) / sizeof(float), 0.0f);
1214
1342
        }
1215
1343
 
1216
1344
}
1219
1347
{
1220
1348
        bDeformGroup *defgroup = ED_vgroup_add_name(ob, name);
1221
1349
 
1222
 
        WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob);
 
1350
        WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1223
1351
 
1224
1352
        return defgroup;
1225
1353
}
1226
1354
 
1227
 
static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup)
 
1355
static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr)
1228
1356
{
 
1357
        bDeformGroup *defgroup = defgroup_ptr->data;
 
1358
        if (BLI_findindex(&ob->defbase, defgroup) == -1) {
 
1359
                BKE_reportf(reports, RPT_ERROR, "DeformGroup '%s' not in object '%s'", defgroup->name, ob->id.name + 2);
 
1360
                return;
 
1361
        }
 
1362
 
1229
1363
        ED_vgroup_delete(ob, defgroup);
 
1364
        RNA_POINTER_INVALIDATE(defgroup_ptr);
1230
1365
 
1231
 
        WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob);
 
1366
        WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1232
1367
}
1233
1368
 
1234
1369
static void rna_Object_vgroup_clear(Object *ob)
1235
1370
{
1236
1371
        ED_vgroup_clear(ob);
1237
1372
 
1238
 
        WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob);
 
1373
        WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1239
1374
}
1240
1375
 
1241
1376
static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len,
1244
1379
        Object *ob = (Object *)id;
1245
1380
 
1246
1381
        if (ED_vgroup_object_is_edit_mode(ob)) {
1247
 
                BKE_reportf(reports, RPT_ERROR, "VertexGroup.add(): Can't be called while object is in edit mode");
 
1382
                BKE_report(reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode");
1248
1383
                return;
1249
1384
        }
1250
1385
 
1251
1386
        while (index_len--)
1252
 
                ED_vgroup_vert_add(ob, def, *index++, weight, assignmode); /* XXX, not efficient calling within loop*/
 
1387
                ED_vgroup_vert_add(ob, def, *index++, weight, assignmode);  /* XXX, not efficient calling within loop*/
1253
1388
 
1254
 
        WM_main_add_notifier(NC_GEOM|ND_DATA, (ID *)ob->data);
 
1389
        WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1255
1390
}
1256
1391
 
1257
1392
static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *reports, int index_len, int *index)
1259
1394
        Object *ob = (Object *)id;
1260
1395
 
1261
1396
        if (ED_vgroup_object_is_edit_mode(ob)) {
1262
 
                BKE_reportf(reports, RPT_ERROR, "VertexGroup.remove(): Can't be called while object is in edit mode");
 
1397
                BKE_report(reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode");
1263
1398
                return;
1264
1399
        }
1265
1400
 
1266
1401
        while (index_len--)
1267
1402
                ED_vgroup_vert_remove(ob, dg, *index++);
1268
1403
 
1269
 
        WM_main_add_notifier(NC_GEOM|ND_DATA, (ID *)ob->data);
 
1404
        WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1270
1405
}
1271
1406
 
1272
1407
static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index)
1274
1409
        float weight = ED_vgroup_vert_weight((Object *)id, dg, index);
1275
1410
 
1276
1411
        if (weight < 0) {
1277
 
                BKE_reportf(reports, RPT_ERROR, "Vertex not in group");
 
1412
                BKE_report(reports, RPT_ERROR, "Vertex not in group");
1278
1413
        }
1279
1414
        return weight;
1280
1415
}
1305
1440
        return ((Object *)value.id.data)->type == OB_CAMERA;
1306
1441
}
1307
1442
 
 
1443
int rna_DupliObject_index_get(PointerRNA *ptr)
 
1444
{
 
1445
        DupliObject *dob = (DupliObject *)ptr->data;
 
1446
        return dob->persistent_id[0];
 
1447
}
 
1448
 
 
1449
int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
 
1450
{
 
1451
        SculptSession *ss = ((Object *)ptr->id.data)->sculpt;
 
1452
        return (ss && ss->bm);
 
1453
}
 
1454
 
1308
1455
#else
1309
1456
 
1310
1457
static int rna_matrix_dimsize_4x4[] = {4, 4};
1331
1478
        RNA_def_property_ui_text(prop, "Name", "Vertex group name");
1332
1479
        RNA_def_struct_name_property(srna, prop);
1333
1480
        RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
1334
 
                /* update data because modifiers may use [#24761] */
1335
 
        RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data");
 
1481
        /* update data because modifiers may use [#24761] */
 
1482
        RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1336
1483
        
1337
1484
        prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
1338
1485
        RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
1339
1486
        RNA_def_property_boolean_sdna(prop, NULL, "flag", 0);
1340
 
                /* update data because modifiers may use [#24761] */
1341
 
        RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data");
 
1487
        /* update data because modifiers may use [#24761] */
 
1488
        RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1342
1489
 
1343
1490
        prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1344
1491
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1347
1494
 
1348
1495
        func = RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add");
1349
1496
        RNA_def_function_ui_description(func, "Add vertices to the group");
1350
 
        RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID);
 
1497
        RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1351
1498
        /* TODO, see how array size of 0 works, this shouldnt be used */
1352
1499
        prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1353
 
        RNA_def_property_flag(prop, PROP_DYNAMIC|PROP_REQUIRED);
 
1500
        RNA_def_property_flag(prop, PROP_DYNAMIC | PROP_REQUIRED);
1354
1501
        prop = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
1355
1502
        RNA_def_property_flag(prop, PROP_REQUIRED);
1356
1503
        prop = RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode");
1358
1505
 
1359
1506
        func = RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove");
1360
1507
        RNA_def_function_ui_description(func, "Remove a vertex from the group");
1361
 
        RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID);
 
1508
        RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1362
1509
        /* TODO, see how array size of 0 works, this shouldnt be used */
1363
1510
        prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1364
 
        RNA_def_property_flag(prop, PROP_DYNAMIC|PROP_REQUIRED);
 
1511
        RNA_def_property_flag(prop, PROP_DYNAMIC | PROP_REQUIRED);
1365
1512
 
1366
1513
        func = RNA_def_function(srna, "weight", "rna_VertexGroup_weight");
1367
1514
        RNA_def_function_ui_description(func, "Get a vertex weight from the group");
1368
 
        RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID);
 
1515
        RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1369
1516
        prop = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex", 0, INT_MAX);
1370
1517
        RNA_def_property_flag(prop, PROP_REQUIRED);
1371
1518
        prop = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
1380
1527
        static EnumPropertyItem link_items[] = {
1381
1528
                {1, "OBJECT", 0, "Object", ""},
1382
1529
                {0, "DATA", 0, "Data", ""},
1383
 
                {0, NULL, 0, NULL, NULL}};
 
1530
                {0, NULL, 0, NULL, NULL}
 
1531
        };
1384
1532
        
1385
1533
        /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
1386
1534
         * pointer data points to ob->mat + index, and we manually implement
1395
1543
        RNA_def_property_flag(prop, PROP_EDITABLE);
1396
1544
        RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL, NULL);
1397
1545
        RNA_def_property_ui_text(prop, "Material", "Material datablock used by this material slot");
1398
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update");
 
1546
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
1399
1547
 
1400
1548
        prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
1401
1549
        RNA_def_property_enum_items(prop, link_items);
1402
1550
        RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
1403
1551
        RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
1404
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update");
 
1552
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
1405
1553
 
1406
1554
        prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1407
1555
        RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL);
1426
1574
                                      "Collision Sensor, detects static and dynamic objects but not the other "
1427
1575
                                      "collision sensor objects"},
1428
1576
                {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"},
1429
 
                {0, NULL, 0, NULL, NULL}};
 
1577
                {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character",
 
1578
                                         "Simple kinematic physics appropriate for game characters"},
 
1579
                {0, NULL, 0, NULL, NULL}
 
1580
        };
1430
1581
 
1431
1582
        srna = RNA_def_struct(brna, "GameObjectSettings", NULL);
1432
1583
        RNA_def_struct_sdna(srna, "Object");
1482
1633
 
1483
1634
        prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE);
1484
1635
        RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST);
1485
 
        RNA_def_property_ui_text(prop, "Ghost", "Object does not restitute collisions, like a ghost");
 
1636
        RNA_def_property_ui_text(prop, "Ghost", "Object does not react to collisions, like a ghost");
1486
1637
 
1487
1638
        prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
1488
1639
        RNA_def_property_range(prop, 0.01, 10000.0);
1489
1640
        RNA_def_property_ui_text(prop, "Mass", "Mass of the object");
1490
1641
 
1491
 
        prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
 
1642
        prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1492
1643
        RNA_def_property_float_sdna(prop, NULL, "inertia");
1493
1644
        RNA_def_property_range(prop, 0.01f, FLT_MAX);
1494
1645
        RNA_def_property_ui_range(prop, 0.01f, 10.0f, 1, 3);
1495
1646
        RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics");
1496
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
1647
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1497
1648
 
1498
1649
        prop = RNA_def_property(srna, "use_sleep", PROP_BOOLEAN, PROP_NONE);
1499
1650
        RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_COLLISION_RESPONSE);
1518
1669
        RNA_def_property_float_sdna(prop, NULL, "max_vel");
1519
1670
        RNA_def_property_range(prop, 0.0, 1000.0);
1520
1671
        RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed");
 
1672
        
 
1673
        /* Character physics */
 
1674
        prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE);
 
1675
        RNA_def_property_float_sdna(prop, NULL, "step_height");
 
1676
        RNA_def_property_range(prop, 0.01, 1.0);
 
1677
        RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over");
 
1678
 
 
1679
        prop = RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE);
 
1680
        RNA_def_property_float_sdna(prop, NULL, "jump_speed");
 
1681
        RNA_def_property_range(prop, 0.0, 1000.0);
 
1682
        RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping");
 
1683
 
 
1684
        prop = RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE);
 
1685
        RNA_def_property_float_sdna(prop, NULL, "fall_speed");
 
1686
        RNA_def_property_range(prop, 0.0, 1000.0);
 
1687
        RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall");
 
1688
 
 
1689
        /* Collision Masks */
 
1690
        prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER);
 
1691
        RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1);
 
1692
        RNA_def_property_array(prop, OB_MAX_COL_MASKS);
 
1693
        RNA_def_property_ui_text(prop, "Collision Group", "The collision group of the object");
 
1694
        RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_group_get", "rna_GameObjectSettings_col_group_set");
 
1695
 
 
1696
        prop = RNA_def_property(srna, "collision_mask", PROP_BOOLEAN, PROP_LAYER_MEMBER);
 
1697
        RNA_def_property_boolean_sdna(prop, NULL, "col_mask", 1);
 
1698
        RNA_def_property_array(prop, OB_MAX_COL_MASKS);
 
1699
        RNA_def_property_ui_text(prop, "Collision Mask", "The groups this object can collide with");
 
1700
        RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_mask_get", "rna_GameObjectSettings_col_mask_set");
1521
1701
 
1522
1702
        /* lock position */
1523
1703
        prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE);
1580
1760
        prop = RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE);
1581
1761
        RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS);
1582
1762
        RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default");
1583
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
1763
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1584
1764
 
1585
1765
        prop = RNA_def_property(srna, "collision_bounds_type", PROP_ENUM, PROP_NONE);
1586
1766
        RNA_def_property_enum_sdna(prop, NULL, "collision_boundtype");
1587
1767
        RNA_def_property_enum_items(prop, collision_bounds_items);
1588
1768
        RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf");
1589
1769
        RNA_def_property_ui_text(prop, "Collision Bounds",  "Select the collision type");
1590
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
1770
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1591
1771
 
1592
1772
        prop = RNA_def_property(srna, "use_collision_compound", PROP_BOOLEAN, PROP_NONE);
1593
1773
        RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD);
1594
1774
        RNA_def_property_ui_text(prop, "Collision Compound", "Add children to form a compound collision object");
1595
1775
 
1596
 
        prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
 
1776
        prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1597
1777
        RNA_def_property_float_sdna(prop, NULL, "margin");
1598
1778
        RNA_def_property_range(prop, 0.0, 1.0);
1599
1779
        RNA_def_property_ui_text(prop, "Collision Margin",
1608
1788
        RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_HASOBSTACLE);
1609
1789
        RNA_def_property_ui_text(prop, "Create obstacle", "Create representation for obstacle simulation");
1610
1790
 
1611
 
        prop = RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
 
1791
        prop = RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1612
1792
        RNA_def_property_float_sdna(prop, NULL, "obstacleRad");
1613
1793
        RNA_def_property_range(prop, 0.0, 1000.0);
1614
1794
        RNA_def_property_ui_text(prop, "Obstacle Radius", "Radius of object representation in obstacle simulation");
1685
1865
        RNA_def_function_flag(func, FUNC_USE_REPORTS);
1686
1866
        /* constraint to remove */
1687
1867
        parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
1688
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
 
1868
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
 
1869
        RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1689
1870
 
1690
1871
        func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
1691
1872
        RNA_def_function_ui_description(func, "Remove all constraint from this object");
1717
1898
/*              RNA_def_property_collection_active(prop, prop_act); */
1718
1899
#endif
1719
1900
 
1720
 
        /* add target */
 
1901
        /* add modifier */
1721
1902
        func = RNA_def_function(srna, "new", "rna_Object_modifier_new");
1722
 
        RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
 
1903
        RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1723
1904
        RNA_def_function_ui_description(func, "Add a new modifier");
1724
 
        parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the bone");
 
1905
        parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier");
1725
1906
        RNA_def_property_flag(parm, PROP_REQUIRED);
1726
1907
        /* modifier to add */
1727
1908
        parm = RNA_def_enum(func, "type", modifier_type_items, 1, "", "Modifier type to add");
1730
1911
        parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier");
1731
1912
        RNA_def_function_return(func, parm);
1732
1913
 
1733
 
        /* remove target */
 
1914
        /* remove modifier */
1734
1915
        func = RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
1735
 
        RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
 
1916
        RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1736
1917
        RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
1737
 
        /* target to remove*/
 
1918
        /* modifier to remove */
1738
1919
        parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
1739
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
 
1920
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
 
1921
        RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1740
1922
 
1741
1923
        /* clear all modifiers */
1742
1924
        func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
1763
1945
        RNA_def_property_struct_type(prop, "ParticleSystem");
1764
1946
        RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL, NULL);
1765
1947
        RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed");
1766
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
1948
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1767
1949
        
1768
1950
        prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1769
1951
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1771
1953
                                   "rna_Object_active_particle_system_index_set",
1772
1954
                                   "rna_Object_active_particle_system_index_range");
1773
1955
        RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot");
1774
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_particle_update");
 
1956
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_particle_update");
1775
1957
}
1776
1958
 
1777
1959
 
1795
1977
        RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get",
1796
1978
                                       "rna_Object_active_vertex_group_set", NULL, NULL);
1797
1979
        RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
1798
 
        RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data");
 
1980
        RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
1799
1981
 
1800
 
        prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
 
1982
        prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1801
1983
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1802
1984
        RNA_def_property_int_sdna(prop, NULL, "actdef");
1803
1985
        RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get",
1804
1986
                                   "rna_Object_active_vertex_group_index_set",
1805
1987
                                   "rna_Object_active_vertex_group_index_range");
1806
1988
        RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array");
1807
 
        RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data");
 
1989
        RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
1808
1990
        
1809
1991
        /* vertex groups */ /* add_vertex_group */
1810
1992
        func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
1814
1996
        RNA_def_function_return(func, parm);
1815
1997
 
1816
1998
        func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
 
1999
        RNA_def_function_flag(func, FUNC_USE_REPORTS);
1817
2000
        RNA_def_function_ui_description(func, "Delete vertex group from object");
1818
2001
        parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
1819
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
 
2002
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
 
2003
        RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1820
2004
 
1821
2005
        func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
1822
2006
        RNA_def_function_ui_description(func, "Delete all vertex groups from object");
1828
2012
        StructRNA *srna;
1829
2013
        PropertyRNA *prop;
1830
2014
 
1831
 
        static EnumPropertyItem empty_drawtype_items[] = {
1832
 
                {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""},
1833
 
                {OB_ARROWS, "ARROWS", 0, "Arrows", ""},
1834
 
                {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""},
1835
 
                {OB_CIRCLE, "CIRCLE", 0, "Circle", ""},
1836
 
                {OB_CUBE, "CUBE", 0, "Cube", ""},
1837
 
                {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""},
1838
 
                {OB_EMPTY_CONE, "CONE", 0, "Cone", ""},
1839
 
                {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""},
1840
 
                {0, NULL, 0, NULL, NULL}};
1841
 
        
1842
 
        static EnumPropertyItem track_items[] = {
1843
 
                {OB_POSX, "POS_X", 0, "+X", ""},
1844
 
                {OB_POSY, "POS_Y", 0, "+Y", ""},
1845
 
                {OB_POSZ, "POS_Z", 0, "+Z", ""},
1846
 
                {OB_NEGX, "NEG_X", 0, "-X", ""},
1847
 
                {OB_NEGY, "NEG_Y", 0, "-Y", ""},
1848
 
                {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
1849
 
                {0, NULL, 0, NULL, NULL}};
1850
 
 
1851
2015
        static EnumPropertyItem up_items[] = {
1852
2016
                {OB_POSX, "X", 0, "X", ""},
1853
2017
                {OB_POSY, "Y", 0, "Y", ""},
1854
2018
                {OB_POSZ, "Z", 0, "Z", ""},
1855
 
                {0, NULL, 0, NULL, NULL}};
 
2019
                {0, NULL, 0, NULL, NULL}
 
2020
        };
1856
2021
 
1857
2022
        static EnumPropertyItem drawtype_items[] = {
1858
2023
                {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Draw the bounds of the object"},
1860
2025
                {OB_SOLID, "SOLID", 0, "Solid", "Draw the object as a solid (if solid drawing is enabled in the viewport)"},
1861
2026
                {OB_TEXTURE, "TEXTURED", 0, "Textured",
1862
2027
                             "Draw the object with textures (if textures are enabled in the viewport)"},
1863
 
                {0, NULL, 0, NULL, NULL}};
 
2028
                {0, NULL, 0, NULL, NULL}
 
2029
        };
1864
2030
 
1865
2031
        static EnumPropertyItem boundtype_items[] = {
1866
2032
                {OB_BOUND_BOX, "BOX", 0, "Box", "Draw bounds as box"},
1867
2033
                {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Draw bounds as sphere"},
1868
2034
                {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Draw bounds as cylinder"},
1869
2035
                {OB_BOUND_CONE, "CONE", 0, "Cone", "Draw bounds as cone"},
1870
 
                {0, NULL, 0, NULL, NULL}};
 
2036
                {0, NULL, 0, NULL, NULL}
 
2037
        };
1871
2038
 
1872
 
        static EnumPropertyItem dupli_items[] = {
1873
 
                {0, "NONE", 0, "None", ""},
1874
 
                {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"},
1875
 
                {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"},
1876
 
                {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"},
1877
 
                {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"},
1878
 
                {0, NULL, 0, NULL, NULL}};
1879
 
                
 
2039
        
1880
2040
        /* XXX: this RNA enum define is currently duplicated for objects,
1881
2041
         *      since there is some text here which is not applicable */
1882
2042
        static EnumPropertyItem prop_rotmode_items[] = {
1889
2049
                {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order - prone to Gimbal Lock"},
1890
2050
                {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle",
1891
2051
                                     "Axis Angle (W+XYZ), defines a rotation around some axis defined by 3D-Vector"},
1892
 
                {0, NULL, 0, NULL, NULL}};
 
2052
                {0, NULL, 0, NULL, NULL}
 
2053
        };
1893
2054
        
1894
 
        static float default_quat[4] = {1,0,0,0};       /* default quaternion values */
1895
 
        static float default_axisAngle[4] = {0,0,1,0};  /* default axis-angle rotation values */
1896
 
        static float default_scale[3] = {1,1,1}; /* default scale values */
 
2055
        static float default_quat[4] = {1, 0, 0, 0};    /* default quaternion values */
 
2056
        static float default_axisAngle[4] = {0, 0, 1, 0};   /* default axis-angle rotation values */
 
2057
        static float default_scale[3] = {1, 1, 1}; /* default scale values */
1897
2058
        static int boundbox_dimsize[] = {8, 3};
1898
2059
 
1899
2060
        srna = RNA_def_struct(brna, "Object", "ID");
1904
2065
        prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
1905
2066
        RNA_def_property_struct_type(prop, "ID");
1906
2067
        RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL);
1907
 
        RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK);
 
2068
        RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
1908
2069
        RNA_def_property_ui_text(prop, "Data", "Object data");
1909
2070
        RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
1910
2071
 
1926
2087
        RNA_def_property_ui_text(prop, "Layers", "Layers the object is on");
1927
2088
        RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set");
1928
2089
        RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
1929
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_layer_update");
 
2090
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_layer_update");
 
2091
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 
2092
 
 
2093
        prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
 
2094
        RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
 
2095
        RNA_def_property_array(prop, 8);
 
2096
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
2097
        RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object is on");
1930
2098
 
1931
2099
        prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1932
2100
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
1933
2101
        RNA_def_property_ui_text(prop, "Select", "Object selection state");
1934
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_select_update");
 
2102
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_select_update");
1935
2103
 
1936
2104
        /* for data access */
1937
2105
        prop = RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
1945
2113
        /* parent */
1946
2114
        prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
1947
2115
        RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL);
1948
 
        RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
 
2116
        RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
1949
2117
        RNA_def_property_ui_text(prop, "Parent", "Parent Object");
1950
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
 
2118
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
1951
2119
        
1952
2120
        prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
1953
2121
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
1954
2122
        RNA_def_property_enum_items(prop, parent_type_items);
1955
2123
        RNA_def_property_enum_funcs(prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
1956
2124
        RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
1957
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
 
2125
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
1958
2126
 
1959
2127
        prop = RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
1960
2128
        RNA_def_property_int_sdna(prop, NULL, "par1");
1961
2129
        RNA_def_property_array(prop, 3);
1962
2130
        RNA_def_property_ui_text(prop, "Parent Vertices", "Indices of vertices in case of a vertex parenting relation");
1963
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2131
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
1964
2132
 
1965
2133
        prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
1966
2134
        RNA_def_property_string_sdna(prop, NULL, "parsubstr");
1967
2135
        RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set");
1968
2136
        RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
1969
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
 
2137
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
1970
2138
        
1971
2139
        /* Track and Up flags */
1972
2140
        /* XXX: these have been saved here for a bit longer (after old track was removed),
1973
2141
         *      since some other tools still refer to this */
1974
2142
        prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
1975
2143
        RNA_def_property_enum_sdna(prop, NULL, "trackflag");
1976
 
        RNA_def_property_enum_items(prop, track_items);
 
2144
        RNA_def_property_enum_items(prop, object_axis_items);
1977
2145
        RNA_def_property_ui_text(prop, "Track Axis",
1978
2146
                                 "Axis that points in 'forward' direction (applies to DupliFrame when "
1979
2147
                                 "parent 'Follow' is enabled)");
1980
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2148
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
1981
2149
 
1982
2150
        prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
1983
2151
        RNA_def_property_enum_sdna(prop, NULL, "upflag");
1985
2153
        RNA_def_property_ui_text(prop, "Up Axis",
1986
2154
                                 "Axis that points in the upward direction (applies to DupliFrame when "
1987
2155
                                 "parent 'Follow' is enabled)");
1988
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2156
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
1989
2157
        
1990
2158
        /* proxy */
1991
2159
        prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
1998
2166
        prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
1999
2167
        RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
2000
2168
        RNA_def_property_struct_type(prop, "MaterialSlot");
2001
 
                /* don't dereference pointer! */
 
2169
        /* don't dereference pointer! */
2002
2170
        RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL);
2003
2171
        RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
2004
2172
 
2008
2176
                                       "rna_Object_active_material_set", NULL, NULL);
2009
2177
        RNA_def_property_flag(prop, PROP_EDITABLE);
2010
2178
        RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
2011
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update");
 
2179
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2012
2180
 
2013
2181
        prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
2014
2182
        RNA_def_property_int_sdna(prop, NULL, "actcol");
2016
2184
        RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set",
2017
2185
                                   "rna_Object_active_material_index_range");
2018
2186
        RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
2019
 
        RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
2187
        RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, NULL);
2020
2188
        
2021
2189
        /* transform */
2022
2190
        prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
2024
2192
        RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
2025
2193
        RNA_def_property_ui_text(prop, "Location", "Location of the object");
2026
2194
        RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2027
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2195
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2028
2196
        
2029
2197
        prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2030
2198
        RNA_def_property_float_sdna(prop, NULL, "quat");
2031
2199
        RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2032
2200
        RNA_def_property_float_array_default(prop, default_quat);
2033
2201
        RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
2034
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2202
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2035
2203
        
2036
 
                /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
2037
 
                 * having a single one is better for Keyframing and other property-management situations...
2038
 
                 */
 
2204
        /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
 
2205
         * having a single one is better for Keyframing and other property-management situations...
 
2206
         */
2039
2207
        prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2040
2208
        RNA_def_property_array(prop, 4);
2041
2209
        RNA_def_property_float_funcs(prop, "rna_Object_rotation_axis_angle_get",
2043
2211
        RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2044
2212
        RNA_def_property_float_array_default(prop, default_axisAngle);
2045
2213
        RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
2046
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2214
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2047
2215
        
2048
2216
        prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
2049
2217
        RNA_def_property_float_sdna(prop, NULL, "rot");
2050
2218
        RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
2051
2219
        RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
2052
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2220
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2053
2221
        
2054
2222
        prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
2055
2223
        RNA_def_property_enum_sdna(prop, NULL, "rotmode");
2056
2224
        RNA_def_property_enum_items(prop, prop_rotmode_items); /* XXX move to using a single define of this someday */
2057
2225
        RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL);
2058
2226
        RNA_def_property_ui_text(prop, "Rotation Mode", "");
2059
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2227
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2060
2228
        
2061
2229
        prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
2062
2230
        RNA_def_property_float_sdna(prop, NULL, "size");
2064
2232
        RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2065
2233
        RNA_def_property_float_array_default(prop, default_scale);
2066
2234
        RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
2067
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2235
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2068
2236
 
2069
2237
        prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
2070
2238
        RNA_def_property_array(prop, 3);
2071
2239
        RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
2072
2240
        RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2073
2241
        RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object");
2074
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2242
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2075
2243
        
2076
2244
 
2077
2245
        /* delta transforms */
2079
2247
        RNA_def_property_float_sdna(prop, NULL, "dloc");
2080
2248
        RNA_def_property_ui_text(prop, "Delta Location", "Extra translation added to the location of the object");
2081
2249
        RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2082
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2250
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2083
2251
        
2084
2252
        prop = RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
2085
2253
        RNA_def_property_float_sdna(prop, NULL, "drot");
2086
2254
        RNA_def_property_ui_text(prop, "Delta Rotation (Euler)",
2087
2255
                                 "Extra rotation added to the rotation of the object (when using Euler rotations)");
2088
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2256
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2089
2257
        
2090
2258
        prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2091
2259
        RNA_def_property_float_sdna(prop, NULL, "dquat");
2092
2260
        RNA_def_property_float_array_default(prop, default_quat);
2093
2261
        RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)",
2094
2262
                                 "Extra rotation added to the rotation of the object (when using Quaternion rotations)");
2095
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2263
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2096
2264
        
2097
2265
#if 0 /* XXX not supported well yet... */
2098
2266
        prop = RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2099
 
                /* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
 
2267
        /* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
2100
2268
        RNA_def_property_float_sdna(prop, NULL, "dquat");
2101
2269
        RNA_def_property_float_array_default(prop, default_axisAngle);
2102
2270
        RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)",
2103
2271
                                 "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
2104
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2272
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2105
2273
#endif
2106
2274
 
2107
2275
        prop = RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
2109
2277
        RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2110
2278
        RNA_def_property_float_array_default(prop, default_scale);
2111
2279
        RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
2112
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2280
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2113
2281
        
2114
2282
        /* transform locks */
2115
2283
        prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
2117
2285
        RNA_def_property_array(prop, 3);
2118
2286
        RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface");
2119
2287
        RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2120
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2288
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2121
2289
 
2122
2290
        prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
2123
2291
        RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX);
2124
2292
        RNA_def_property_array(prop, 3);
2125
2293
        RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface");
2126
2294
        RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2127
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2295
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2128
2296
        
2129
 
                /* XXX this is sub-optimal - it really should be included above,
2130
 
                 *     but due to technical reasons we can't do this! */
 
2297
        /* XXX this is sub-optimal - it really should be included above,
 
2298
         *     but due to technical reasons we can't do this! */
2131
2299
        prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
2132
2300
        RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW);
2133
2301
        RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2134
2302
        RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)",
2135
2303
                                 "Lock editing of 'angle' component of four-component rotations in the interface");
2136
 
                /* XXX this needs a better name */
 
2304
        /* XXX this needs a better name */
2137
2305
        prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
2138
2306
        RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D);
2139
2307
        RNA_def_property_ui_text(prop, "Lock Rotations (4D)",
2144
2312
        RNA_def_property_array(prop, 3);
2145
2313
        RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface");
2146
2314
        RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2147
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2315
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2148
2316
 
2149
2317
        /* matrix */
2150
2318
        prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
2152
2320
        RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2153
2321
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2154
2322
        RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
2155
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_matrix_world_update");
 
2323
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update");
2156
2324
 
2157
2325
        prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
2158
2326
        RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2159
2327
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2160
2328
        RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix");
2161
2329
        RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL);
2162
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL);
 
2330
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, NULL);
2163
2331
 
2164
2332
        prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
2165
2333
        RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2168
2336
                                 "Matrix access to location, rotation and scale (including deltas), "
2169
2337
                                 "before constraints and parenting are applied");
2170
2338
        RNA_def_property_float_funcs(prop, "rna_Object_matrix_basis_get", "rna_Object_matrix_basis_set", NULL);
2171
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2339
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2172
2340
 
2173
2341
        /*parent_inverse*/
2174
2342
        prop = RNA_def_property(srna, "matrix_parent_inverse", PROP_FLOAT, PROP_MATRIX);
2175
2343
        RNA_def_property_float_sdna(prop, NULL, "parentinv");
2176
2344
        RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2177
2345
        RNA_def_property_ui_text(prop, "Matrix", "Inverse of object's parent matrix at time of parenting");
2178
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2346
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2179
2347
 
2180
2348
        /* modifiers */
2181
2349
        prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
2207
2375
        /* empty */
2208
2376
        prop = RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE);
2209
2377
        RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype");
2210
 
        RNA_def_property_enum_items(prop, empty_drawtype_items);
 
2378
        RNA_def_property_enum_items(prop, object_empty_drawtype_items);
2211
2379
        RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
2212
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2380
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2213
2381
 
2214
2382
        prop = RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE);
2215
2383
        RNA_def_property_float_sdna(prop, NULL, "empty_drawsize");
2216
2384
        RNA_def_property_range(prop, 0.0001f, 1000.0f);
2217
2385
        RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
2218
2386
        RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport");
2219
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2387
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2220
2388
 
2221
2389
        prop = RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_DISTANCE);
2222
2390
        RNA_def_property_float_sdna(prop, NULL, "ima_ofs");
2223
2391
        RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance");
2224
2392
        RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2);
2225
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2393
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2226
2394
 
2227
2395
        /* render */
2228
2396
        prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
2233
2401
        prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
2234
2402
        RNA_def_property_float_sdna(prop, NULL, "col");
2235
2403
        RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled");
2236
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2404
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2237
2405
 
2238
2406
        /* physics */
2239
2407
        prop = RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
2260
2428
        RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
2261
2429
        rna_def_object_particle_systems(brna, prop);
2262
2430
 
 
2431
        
 
2432
        prop = RNA_def_property(srna, "rigid_body", PROP_POINTER, PROP_NONE);
 
2433
        RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_object");
 
2434
        RNA_def_property_struct_type(prop, "RigidBodyObject");
 
2435
        RNA_def_property_ui_text(prop, "Rigid Body Settings", "Settings for rigid body simulation");
 
2436
 
 
2437
        prop = RNA_def_property(srna, "rigid_body_constraint", PROP_POINTER, PROP_NONE);
 
2438
        RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_constraint");
 
2439
        RNA_def_property_struct_type(prop, "RigidBodyConstraint");
 
2440
        RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies");
 
2441
        
2263
2442
        /* restrict */
2264
2443
        prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2265
2444
        RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
2266
2445
        RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
2267
2446
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
2268
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2447
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2269
2448
 
2270
2449
        prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
2271
2450
        RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
2272
2451
        RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport");
2273
2452
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
2274
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2453
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2275
2454
 
2276
2455
        prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
2277
2456
        RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
2278
2457
        RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
2279
2458
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
2280
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2459
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2281
2460
 
2282
2461
        /* anim */
2283
2462
        rna_def_animdata_common(srna);
2292
2471
        RNA_def_property_ui_text(prop, "Slow Parent",
2293
2472
                                 "Create a delay in the parent relationship (beware: this isn't renderfarm "
2294
2473
                                 "safe and may be invalid after jumping around the timeline)");
2295
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2474
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2296
2475
        
2297
 
        prop = RNA_def_property(srna, "slow_parent_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME);
 
2476
        prop = RNA_def_property(srna, "slow_parent_offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_TIME);
2298
2477
        RNA_def_property_float_sdna(prop, NULL, "sf");
2299
2478
        RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2300
2479
        RNA_def_property_ui_text(prop, "Slow Parent Offset", "Delay in the parent relationship");
2301
 
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
 
2480
        RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
 
2481
        
 
2482
        /* depsgraph hack */
 
2483
        prop = RNA_def_property(srna, "extra_recalc_object", PROP_BOOLEAN, PROP_NONE);
 
2484
        RNA_def_property_boolean_sdna(prop, NULL, "depsflag", OB_DEPS_EXTRA_OB_RECALC);
 
2485
        RNA_def_property_ui_text(prop, "Extra Object Update", "Refresh this object again on frame changes, dependency graph hack");
 
2486
        
 
2487
        prop = RNA_def_property(srna, "extra_recalc_data", PROP_BOOLEAN, PROP_NONE);
 
2488
        RNA_def_property_boolean_sdna(prop, NULL, "depsflag", OB_DEPS_EXTRA_DATA_RECALC);
 
2489
        RNA_def_property_ui_text(prop, "Extra Data Update", "Refresh this object's data again on frame changes, dependency graph hack");
2302
2490
        
2303
2491
        /* duplicates */
2304
2492
        prop = RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE);
2305
2493
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
2306
2494
        RNA_def_property_enum_items(prop, dupli_items);
2307
2495
        RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use");
2308
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
 
2496
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2309
2497
 
2310
2498
        prop = RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE);
2311
2499
        RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED);
2312
2500
        RNA_def_property_ui_text(prop, "Dupli Frames Speed",
2313
2501
                                 "Set dupliframes to use the current frame instead of parent curve's evaluation time");
2314
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2502
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2315
2503
 
2316
2504
        prop = RNA_def_property(srna, "use_dupli_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
2317
2505
        RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT);
2318
2506
        RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal");
2319
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2507
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2320
2508
 
2321
2509
        prop = RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE);
2322
2510
        RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE);
2323
2511
        RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size");
2324
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2512
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2325
2513
 
2326
2514
        prop = RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE);
2327
2515
        RNA_def_property_float_sdna(prop, NULL, "dupfacesca");
2328
2516
        RNA_def_property_range(prop, 0.001f, 10000.0f);
2329
2517
        RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects");
2330
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2518
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2331
2519
 
2332
2520
        prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
2333
2521
        RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
2334
2522
        RNA_def_property_flag(prop, PROP_EDITABLE);
2335
2523
        RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_group_set", NULL, NULL);
2336
2524
        RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group");
2337
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
 
2525
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2338
2526
 
2339
 
        prop = RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
 
2527
        prop = RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2340
2528
        RNA_def_property_int_sdna(prop, NULL, "dupsta");
2341
2529
        RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
2342
2530
        RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames");
2343
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2531
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2344
2532
 
2345
 
        prop = RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
 
2533
        prop = RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2346
2534
        RNA_def_property_int_sdna(prop, NULL, "dupend");
2347
2535
        RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
2348
2536
        RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames");
2349
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2537
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2350
2538
 
2351
 
        prop = RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
 
2539
        prop = RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2352
2540
        RNA_def_property_int_sdna(prop, NULL, "dupon");
2353
2541
        RNA_def_property_range(prop, MINFRAME, MAXFRAME);
2354
2542
        RNA_def_property_ui_range(prop, 1, 1500, 1, 0);
2355
2543
        RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames");
2356
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2544
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2357
2545
 
2358
 
        prop = RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
 
2546
        prop = RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2359
2547
        RNA_def_property_int_sdna(prop, NULL, "dupoff");
2360
2548
        RNA_def_property_range(prop, 0, MAXFRAME);
2361
2549
        RNA_def_property_ui_range(prop, 0, 1500, 1, 0);
2362
2550
        RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes");
2363
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
 
2551
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2364
2552
 
2365
2553
        prop = RNA_def_property(srna, "dupli_list", PROP_COLLECTION, PROP_NONE);
2366
2554
        RNA_def_property_collection_sdna(prop, NULL, "duplilist", NULL);
2376
2564
        RNA_def_property_enum_sdna(prop, NULL, "dt");
2377
2565
        RNA_def_property_enum_items(prop, drawtype_items);
2378
2566
        RNA_def_property_ui_text(prop, "Maximum Draw Type",  "Maximum draw type to display object with in viewport");
2379
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2567
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2380
2568
 
2381
2569
        prop = RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE);
2382
 
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_BOUNDBOX);
 
2570
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWBOUNDOX);
2383
2571
        RNA_def_property_ui_text(prop, "Draw Bounds", "Display the object's bounds");
2384
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2572
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2385
2573
 
2386
2574
        prop = RNA_def_property(srna, "draw_bounds_type", PROP_ENUM, PROP_NONE);
2387
2575
        RNA_def_property_enum_sdna(prop, NULL, "boundtype");
2388
2576
        RNA_def_property_enum_items(prop, boundtype_items);
2389
2577
        RNA_def_property_ui_text(prop, "Draw Bounds Type", "Object boundary display type");
2390
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2578
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2391
2579
        
2392
2580
        prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
2393
2581
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME);
2394
2582
        RNA_def_property_ui_text(prop, "Draw Name", "Display the object's name");
2395
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2583
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2396
2584
        
2397
2585
        prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE);
2398
2586
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS);
2399
2587
        RNA_def_property_ui_text(prop, "Draw Axes", "Display the object's origin and axes");
2400
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2588
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2401
2589
        
2402
2590
        prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE);
2403
2591
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE);
2404
2592
        RNA_def_property_ui_text(prop, "Draw Texture Space", "Display the object's texture space");
2405
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2593
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2406
2594
        
2407
2595
        prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
2408
2596
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE);
2409
2597
        RNA_def_property_ui_text(prop, "Draw Wire", "Add the object's wireframe over solid drawing");
2410
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
2411
 
        
 
2598
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
 
2599
 
 
2600
        prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE);
 
2601
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAW_ALL_EDGES);
 
2602
        RNA_def_property_ui_text(prop, "Draw All Edges", "Display all edges for mesh objects");
 
2603
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
 
2604
 
2412
2605
        prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
2413
2606
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
2414
2607
        RNA_def_property_ui_text(prop, "Draw Transparent",
2415
2608
                                 "Display material transparency in the object (unsupported for duplicator drawing)");
2416
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2609
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2417
2610
        
2418
2611
        prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
2419
2612
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY);
2420
2613
        RNA_def_property_ui_text(prop, "X-Ray",
2421
2614
                                 "Make the object draw in front of others (unsupported for duplicator drawing)");
2422
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2615
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2423
2616
        
2424
2617
        /* Grease Pencil */
2425
2618
        prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
2427
2620
        RNA_def_property_flag(prop, PROP_EDITABLE);
2428
2621
        RNA_def_property_struct_type(prop, "GreasePencil");
2429
2622
        RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock");
2430
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
 
2623
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2431
2624
        
2432
2625
        /* pose */
2433
2626
        prop = RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
2467
2660
        RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
2468
2661
        RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
2469
2662
 
 
2663
        /* sculpt */
 
2664
        prop = RNA_def_property(srna, "use_dynamic_topology_sculpting", PROP_BOOLEAN, PROP_NONE);
 
2665
        RNA_def_property_boolean_funcs(prop, "rna_Object_use_dynamic_topology_sculpting_get", NULL);
 
2666
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
2667
        RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", NULL);
 
2668
 
2470
2669
        RNA_api_object(srna);
2471
2670
}
2472
2671
 
2488
2687
        prop = RNA_def_property(srna, "matrix_original", PROP_FLOAT, PROP_MATRIX);
2489
2688
        RNA_def_property_float_sdna(prop, NULL, "omat");
2490
2689
        RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2491
 
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE);
 
2690
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2492
2691
        RNA_def_property_ui_text(prop, "Object Matrix", "The original matrix of this object before it was duplicated");
2493
2692
 
2494
2693
        prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
2495
2694
        RNA_def_property_float_sdna(prop, NULL, "mat");
2496
2695
        RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2497
 
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE);
 
2696
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2498
2697
        RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix");
2499
2698
 
2500
2699
        prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2501
2700
        RNA_def_property_boolean_sdna(prop, NULL, "no_draw", 0);
2502
 
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE);
 
2701
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2503
2702
        RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render");
2504
2703
 
2505
 
        /* TODO: DupliObject has more properties that can be wrapped */
 
2704
        prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
 
2705
        RNA_def_property_int_funcs(prop, "rna_DupliObject_index_get", NULL, NULL);
 
2706
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
 
2707
        RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list");
 
2708
 
 
2709
        prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
 
2710
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
 
2711
        RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur");
 
2712
 
 
2713
        prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
 
2714
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
 
2715
        RNA_def_property_ui_text(prop, "Particle System", "Particle system that this dupli object was instanced from");
 
2716
 
 
2717
        prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION);
 
2718
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
 
2719
        RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space");
 
2720
 
 
2721
        prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
 
2722
        RNA_def_property_array(prop, 2);
 
2723
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
 
2724
        RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space");
 
2725
 
 
2726
        prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
 
2727
        RNA_def_property_enum_items(prop, dupli_items);
 
2728
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
 
2729
        RNA_def_property_ui_text(prop, "Dupli Type", "Duplicator type that generated this dupli object");
2506
2730
}
2507
2731
 
2508
2732
static void rna_def_object_base(BlenderRNA *brna)
2525
2749
        RNA_def_property_array(prop, 20);
2526
2750
        RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on");
2527
2751
        RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set");
2528
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_layer_update");
 
2752
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_layer_update");
 
2753
 
 
2754
        prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
 
2755
        RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
 
2756
        RNA_def_property_array(prop, 8);
 
2757
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
2758
        RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object base is on");
2529
2759
        
2530
2760
        prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2531
2761
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT);
2532
2762
        RNA_def_property_ui_text(prop, "Select", "Object base selection state");
2533
 
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_select_update");
 
2763
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_select_update");
2534
2764
        
2535
2765
        RNA_api_object_base(srna);
2536
2766
}