Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rna_armature.c « intern « makesrna « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4c8f5597e1e0c29114fe0a3c83426c1ce6615f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
/**
 * $Id$
 *
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Contributor(s): Blender Foundation (2008), Joshua Leung
 *
 * ***** END GPL LICENSE BLOCK *****
 */

#include <stdlib.h>

#include "RNA_define.h"
#include "RNA_types.h"

#include "rna_internal.h"

#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"

#include "WM_api.h"
#include "WM_types.h"

#ifdef RNA_RUNTIME

#include "BLI_arithb.h"

#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_main.h"

#include "ED_armature.h"

static void rna_Armature_update_data(bContext *C, PointerRNA *ptr)
{
	Main *bmain= CTX_data_main(C);
	Scene *scene= CTX_data_scene(C);
	ID *id= ptr->id.data;
	Object *ob;

	for(ob=bmain->object.first; ob; ob= ob->id.next) {
		if(ob->data == id) {
			/* XXX this will loop over all objects again (slow) */
			DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
			WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
		}
	}
}

static void rna_Armature_redraw_data(bContext *C, PointerRNA *ptr)
{
	Main *bmain= CTX_data_main(C);
	ID *id= ptr->id.data;
	Object *ob;

	for(ob=bmain->object.first; ob; ob= ob->id.next)
		if(ob->data == id)
			WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
}

static void rna_bone_layer_set(short *layer, const int *values)
{
	int i, tot= 0;

	/* ensure we always have some layer selected */
	for(i=0; i<16; i++)
		if(values[i])
			tot++;
	
	if(tot==0)
		return;

	for(i=0; i<16; i++) {
		if(values[i]) *layer |= (1<<i);
		else *layer &= ~(1<<i);
	}
}

static void rna_Bone_layer_set(PointerRNA *ptr, const int *values)
{
	Bone *bone= (Bone*)ptr->data;
	rna_bone_layer_set(&bone->layer, values);
}

static void rna_Armature_layer_set(PointerRNA *ptr, const int *values)
{
	bArmature *arm= (bArmature*)ptr->data;
	int i, tot= 0;

	/* ensure we always have some layer selected */
	for(i=0; i<20; i++)
		if(values[i])
			tot++;
	
	if(tot==0)
		return;

	for(i=0; i<20; i++) {
		if(values[i]) arm->layer |= (1<<i);
		else arm->layer &= ~(1<<i);
	}
}

static void rna_Armature_ghost_start_frame_set(PointerRNA *ptr, int value)
{
	bArmature *data= (bArmature*)ptr->data;
	CLAMP(value, 1, data->ghostef);
	data->ghostsf= value;
}

static void rna_Armature_ghost_end_frame_set(PointerRNA *ptr, int value)
{
	bArmature *data= (bArmature*)ptr->data;
	CLAMP(value, data->ghostsf, (int)(MAXFRAMEF/2));
	data->ghostef= value;
}

static void rna_Armature_path_start_frame_set(PointerRNA *ptr, int value)
{
	bArmature *data= (bArmature*)ptr->data;
	CLAMP(value, 1, data->pathef);
	data->pathsf= value;
}

static void rna_Armature_path_end_frame_set(PointerRNA *ptr, int value)
{
	bArmature *data= (bArmature*)ptr->data;
	CLAMP(value, data->pathsf, (int)(MAXFRAMEF/2));
	data->pathef= value;
}

static void rna_EditBone_name_get(PointerRNA *ptr, char *value)
{
	EditBone *data= (EditBone*)(ptr->data);
	BLI_strncpy(value, data->name, sizeof(data->name));
}

static int rna_EditBone_name_length(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return strlen(data->name);
}

static void rna_EditBone_name_set(PointerRNA *ptr, const char *value)
{
	bArmature *arm= (bArmature*)ptr->id.data;
	EditBone *ebone= (EditBone*)ptr->data;
	char oldname[32], newname[32];
	
	/* need to be on the stack */
	BLI_strncpy(newname, value, 32);
	BLI_strncpy(oldname, ebone->name, 32);
	
	ED_armature_bone_rename(arm, oldname, newname);
}

static int rna_EditBone_active_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (((data->flag) & BONE_ACTIVE) != 0);
}

static void rna_EditBone_active_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(value) data->flag |= BONE_ACTIVE;
	else data->flag &= ~BONE_ACTIVE;
}

static float rna_EditBone_bbone_in_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (float)(data->ease1);
}

static void rna_EditBone_bbone_in_set(PointerRNA *ptr, float value)
{
	EditBone *data= (EditBone*)(ptr->data);
	data->ease1= CLAMPIS(value, 0.0f, 2.0f);
}

static float rna_EditBone_bbone_out_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (float)(data->ease2);
}

static void rna_EditBone_bbone_out_set(PointerRNA *ptr, float value)
{
	EditBone *data= (EditBone*)(ptr->data);
	data->ease2= CLAMPIS(value, 0.0f, 2.0f);
}

static int rna_EditBone_bbone_segments_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (int)(data->segments);
}

static void rna_EditBone_bbone_segments_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	data->segments= CLAMPIS(value, 1, 32);
}

static void rna_EditBone_layer_get(PointerRNA *ptr, int values[16])
{
	EditBone *data= (EditBone*)(ptr->data);
	values[0]= ((data->layer & (1<<0)) != 0);
	values[1]= ((data->layer & (1<<1)) != 0);
	values[2]= ((data->layer & (1<<2)) != 0);
	values[3]= ((data->layer & (1<<3)) != 0);
	values[4]= ((data->layer & (1<<4)) != 0);
	values[5]= ((data->layer & (1<<5)) != 0);
	values[6]= ((data->layer & (1<<6)) != 0);
	values[7]= ((data->layer & (1<<7)) != 0);
	values[8]= ((data->layer & (1<<8)) != 0);
	values[9]= ((data->layer & (1<<9)) != 0);
	values[10]= ((data->layer & (1<<10)) != 0);
	values[11]= ((data->layer & (1<<11)) != 0);
	values[12]= ((data->layer & (1<<12)) != 0);
	values[13]= ((data->layer & (1<<13)) != 0);
	values[14]= ((data->layer & (1<<14)) != 0);
	values[15]= ((data->layer & (1<<15)) != 0);
}

static void rna_EditBone_layer_set(PointerRNA *ptr, const int values[16])
{
	EditBone *data= (EditBone*)(ptr->data);
	rna_bone_layer_set(&data->layer, values);
}

static void rna_EditBone_connected_check(EditBone *ebone)
{
	if(ebone->parent) {
		if(ebone->flag & BONE_CONNECTED) {
			/* Attach this bone to its parent */
			VECCOPY(ebone->head, ebone->parent->tail);

			if(ebone->flag & BONE_ROOTSEL)
				ebone->parent->flag |= BONE_TIPSEL;
		}
		else if(!(ebone->parent->flag & BONE_ROOTSEL)) {
			ebone->parent->flag &= ~BONE_TIPSEL;
		}
	}
}

static int rna_EditBone_connected_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (((data->flag) & BONE_CONNECTED) != 0);
}

static void rna_EditBone_connected_set(PointerRNA *ptr, int value)
{
	EditBone *ebone= (EditBone*)(ptr->data);

	if(value) ebone->flag |= BONE_CONNECTED;
	else ebone->flag &= ~BONE_CONNECTED;

	rna_EditBone_connected_check(ebone);
}

static int rna_EditBone_cyclic_offset_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (!((data->flag) & BONE_NO_CYCLICOFFSET) != 0);
}

static void rna_EditBone_cyclic_offset_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(!value) data->flag |= BONE_NO_CYCLICOFFSET;
	else data->flag &= ~BONE_NO_CYCLICOFFSET;
}

static int rna_EditBone_deform_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (!((data->flag) & BONE_NO_DEFORM) != 0);
}

static void rna_EditBone_deform_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(!value) data->flag |= BONE_NO_DEFORM;
	else data->flag &= ~BONE_NO_DEFORM;
}

static int rna_EditBone_draw_wire_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (((data->flag) & BONE_DRAWWIRE) != 0);
}

static void rna_EditBone_draw_wire_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(value) data->flag |= BONE_DRAWWIRE;
	else data->flag &= ~BONE_DRAWWIRE;
}

static float rna_EditBone_envelope_distance_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (float)(data->dist);
}

static void rna_EditBone_envelope_distance_set(PointerRNA *ptr, float value)
{
	EditBone *data= (EditBone*)(ptr->data);
	data->dist= CLAMPIS(value, 0.0f, 1000.0f);
}

static float rna_EditBone_envelope_weight_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (float)(data->weight);
}

static void rna_EditBone_envelope_weight_set(PointerRNA *ptr, float value)
{
	EditBone *data= (EditBone*)(ptr->data);
	data->weight= CLAMPIS(value, 0.0f, 1000.0f);
}

static float rna_EditBone_radius_head_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (float)(data->rad_head);
}

static void rna_EditBone_radius_head_set(PointerRNA *ptr, float value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(data->parent)
		data->parent->rad_tail= value;
	else
		data->rad_head= value;
}

static float rna_EditBone_radius_tail_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (float)(data->rad_tail);
}

static void rna_EditBone_radius_tail_set(PointerRNA *ptr, float value)
{
	EditBone *data= (EditBone*)(ptr->data);
	data->rad_tail= value;
}

static void rna_EditBone_head_get(PointerRNA *ptr, float values[3])
{
	EditBone *data= (EditBone*)(ptr->data);
	values[0]= (float)(((float*)data->head)[0]);
	values[1]= (float)(((float*)data->head)[1]);
	values[2]= (float)(((float*)data->head)[2]);
}

static void rna_EditBone_head_set(PointerRNA *ptr, const float values[3])
{
	EditBone *data= (EditBone*)(ptr->data);
	((float*)data->head)[0]= values[0];
	((float*)data->head)[1]= values[1];
	((float*)data->head)[2]= values[2];
}

static int rna_EditBone_head_selected_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (((data->flag) & BONE_ROOTSEL) != 0);
}

static void rna_EditBone_head_selected_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(value) data->flag |= BONE_ROOTSEL;
	else data->flag &= ~BONE_ROOTSEL;
}

static int rna_EditBone_hidden_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (((data->flag) & BONE_HIDDEN_A) != 0);
}

static void rna_EditBone_hidden_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(value) data->flag |= BONE_HIDDEN_A;
	else data->flag &= ~BONE_HIDDEN_A;
}

static int rna_EditBone_hinge_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (!((data->flag) & BONE_HINGE) != 0);
}

static void rna_EditBone_hinge_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(!value) data->flag |= BONE_HINGE;
	else data->flag &= ~BONE_HINGE;
}

static int rna_EditBone_inherit_scale_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (!((data->flag) & BONE_NO_SCALE) != 0);
}

static void rna_EditBone_inherit_scale_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(!value) data->flag |= BONE_NO_SCALE;
	else data->flag &= ~BONE_NO_SCALE;
}

static int rna_EditBone_locked_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (((data->flag) & BONE_EDITMODE_LOCKED) != 0);
}

static void rna_EditBone_locked_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(value) data->flag |= BONE_EDITMODE_LOCKED;
	else data->flag &= ~BONE_EDITMODE_LOCKED;
}

static int rna_EditBone_multiply_vertexgroup_with_envelope_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (((data->flag) & BONE_MULT_VG_ENV) != 0);
}

static void rna_EditBone_multiply_vertexgroup_with_envelope_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(value) data->flag |= BONE_MULT_VG_ENV;
	else data->flag &= ~BONE_MULT_VG_ENV;
}

static PointerRNA rna_EditBone_parent_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->parent);
}

static void rna_EditBone_parent_set(PointerRNA *ptr, PointerRNA value)
{
	EditBone *ebone= (EditBone*)(ptr->data);
	EditBone *pbone, *parbone= (EditBone*)value.data;

	/* within same armature */
	if(value.id.data != ptr->id.data)
		return;

	if(parbone == NULL) {
		if(ebone->parent && !(ebone->parent->flag & BONE_ROOTSEL))
			ebone->parent->flag &= ~BONE_TIPSEL;

		ebone->parent = NULL;
		ebone->flag &= ~BONE_CONNECTED;
	}
	else {
		/* make sure this is a valid child */
		if(parbone == ebone)
			return;
			
		for(pbone= parbone->parent; pbone; pbone=pbone->parent)
			if(pbone == ebone)
				return;

		ebone->parent = parbone;
		rna_EditBone_connected_check(ebone);
	}
}

static float rna_EditBone_roll_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (float)(data->roll);
}

static void rna_EditBone_roll_set(PointerRNA *ptr, float value)
{
	EditBone *data= (EditBone*)(ptr->data);
	data->roll= value;
}

static void rna_EditBone_tail_get(PointerRNA *ptr, float values[3])
{
	EditBone *data= (EditBone*)(ptr->data);
	values[0]= (float)(((float*)data->tail)[0]);
	values[1]= (float)(((float*)data->tail)[1]);
	values[2]= (float)(((float*)data->tail)[2]);
}

static void rna_EditBone_tail_set(PointerRNA *ptr, const float values[3])
{
	EditBone *data= (EditBone*)(ptr->data);
	((float*)data->tail)[0]= values[0];
	((float*)data->tail)[1]= values[1];
	((float*)data->tail)[2]= values[2];
}

static int rna_EditBone_tail_selected_get(PointerRNA *ptr)
{
	EditBone *data= (EditBone*)(ptr->data);
	return (((data->flag) & BONE_TIPSEL) != 0);
}

static void rna_EditBone_tail_selected_set(PointerRNA *ptr, int value)
{
	EditBone *data= (EditBone*)(ptr->data);
	if(value) data->flag |= BONE_TIPSEL;
	else data->flag &= ~BONE_TIPSEL;
}

static void rna_Armature_editbone_transform_update(bContext *C, PointerRNA *ptr)
{
	bArmature *arm= (bArmature*)ptr->id.data;
	EditBone *ebone= (EditBone*)ptr->data;
	EditBone *child, *eboflip;
	
	/* update our parent */
	if(ebone->parent && ebone->flag & BONE_CONNECTED)
		VECCOPY(ebone->parent->tail, ebone->head)

	/* update our children if necessary */
	for(child = arm->edbo->first; child; child=child->next)
		if(child->parent == ebone && (child->flag & BONE_CONNECTED))
			VECCOPY(child->head, ebone->tail);

	if(arm->flag & ARM_MIRROR_EDIT) {
		eboflip= ED_armature_bone_get_mirrored(arm->edbo, ebone);

		if(eboflip) {
			eboflip->roll= -ebone->roll;

			eboflip->head[0]= -ebone->head[0];
			eboflip->tail[0]= -ebone->tail[0];
			
			/* update our parent */
			if(eboflip->parent && eboflip->flag & BONE_CONNECTED)
				VECCOPY(eboflip->parent->tail, eboflip->head);
			
			/* update our children if necessary */
			for(child = arm->edbo->first; child; child=child->next)
				if(child->parent == eboflip && (child->flag & BONE_CONNECTED))
					VECCOPY (child->head, eboflip->tail);
		}
	}

	rna_Armature_update_data(C, ptr);
}

static void rna_Armature_bones_next(CollectionPropertyIterator *iter)
{
	ListBaseIterator *internal= iter->internal;
	Bone *bone= (Bone*)internal->link;

	if(bone->childbase.first)
		internal->link= (Link*)bone->childbase.first;
	else if(bone->next)
		internal->link= (Link*)bone->next;
	else {
		internal->link= NULL;

		do {
			bone= bone->parent;
			if(bone && bone->next) {
				internal->link= (Link*)bone->next;
				break;
			}
		} while(bone);
	}

	iter->valid= (internal->link != NULL);
}

#else

static void rna_def_bone_common(StructRNA *srna, int editbone)
{
	PropertyRNA *prop;

	/* strings */
	prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
	RNA_def_property_ui_text(prop, "Name", "");
	RNA_def_struct_name_property(srna, prop);
	if(editbone) RNA_def_property_string_funcs(prop, "rna_EditBone_name_get", "rna_EditBone_name_length", "rna_EditBone_name_set");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");

	/* flags */
	prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE);
	if(editbone) {
		RNA_def_property_array(prop, 16);
		RNA_def_property_boolean_funcs(prop, "rna_EditBone_layer_get", "rna_EditBone_layer_set");
	}
	else {
		RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);
		RNA_def_property_array(prop, 16);
		RNA_def_property_boolean_funcs(prop, NULL, "rna_Bone_layer_set");
	}
	RNA_def_property_ui_text(prop, "Layers", "Layers bone exists in");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");

	prop= RNA_def_property(srna, "connected", PROP_BOOLEAN, PROP_NONE);
	if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_connected_get", "rna_EditBone_connected_set");
	else {
		RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_CONNECTED);
		RNA_def_property_clear_flag(prop, PROP_EDITABLE);
	}
	RNA_def_property_ui_text(prop, "Connected", "When bone has a parent, bone's head is struck to the parent's tail.");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
	if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_active_get", "rna_EditBone_active_set");
	else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ACTIVE);
	RNA_def_property_ui_text(prop, "Active", "Bone was the last bone clicked on (most operations are applied to only this bone)");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "hinge", PROP_BOOLEAN, PROP_NONE);
	if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_hinge_get", "rna_EditBone_hinge_set");
	else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_HINGE);
	RNA_def_property_ui_text(prop, "Inherit Rotation", "Bone doesn't inherit rotation or scale from parent bone.");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "multiply_vertexgroup_with_envelope", PROP_BOOLEAN, PROP_NONE);
	if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_multiply_vertexgroup_with_envelope_get", "rna_EditBone_multiply_vertexgroup_with_envelope_set");
	else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_MULT_VG_ENV);
	RNA_def_property_ui_text(prop, "Multiply Vertex Group with Envelope", "When deforming bone, multiply effects of Vertex Group weights with Envelope influence.");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "deform", PROP_BOOLEAN, PROP_NONE);
	if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_deform_get", "rna_EditBone_deform_set");
	else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_DEFORM);
	RNA_def_property_ui_text(prop, "Deform", "Bone does not deform any geometry.");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "inherit_scale", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_ui_text(prop, "Inherit Scale", "Bone inherits scaling from parent bone.");
	if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_inherit_scale_get", "rna_EditBone_inherit_scale_set");
	else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_SCALE);
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "draw_wire", PROP_BOOLEAN, PROP_NONE);
	if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_draw_wire_get", "rna_EditBone_draw_wire_set");
	else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE);
	RNA_def_property_ui_text(prop, "Draw Wire", "Bone is always drawn as Wireframe regardless of viewport draw mode. Useful for non-obstructive custom bone shapes.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "cyclic_offset", PROP_BOOLEAN, PROP_NONE);
	if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_cyclic_offset_get", "rna_EditBone_cyclic_offset_set");
	else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_CYCLICOFFSET);
	RNA_def_property_ui_text(prop, "Cyclic Offset", "When bone doesn't have a parent, it receives cyclic offset effects.");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");

	/* Number values */
		/* envelope deform settings */
	prop= RNA_def_property(srna, "envelope_distance", PROP_FLOAT, PROP_NONE);
	if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_envelope_distance_get", "rna_EditBone_envelope_distance_set", NULL);
	else RNA_def_property_float_sdna(prop, NULL, "dist");
	RNA_def_property_range(prop, 0.0f, 1000.0f);
	RNA_def_property_ui_text(prop, "Envelope Deform Distance", "Bone deformation distance (for Envelope deform only).");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "envelope_weight", PROP_FLOAT, PROP_NONE);
	if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_envelope_weight_get", "rna_EditBone_envelope_weight_set", NULL);
	else RNA_def_property_float_sdna(prop, NULL, "weight");
	RNA_def_property_range(prop, 0.0f, 1000.0f);
	RNA_def_property_ui_text(prop, "Envelope Deform Weight", "Bone deformation weight (for Envelope deform only).");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_NONE);
	if(editbone) {
		RNA_def_property_float_funcs(prop, "rna_EditBone_radius_head_get", "rna_EditBone_radius_head_set", NULL);
		RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
	}
	else RNA_def_property_float_sdna(prop, NULL, "rad_head");
	//RNA_def_property_range(prop, 0, 1000);  // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid);
	RNA_def_property_ui_text(prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only).");
	
	prop= RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_NONE);
	if(editbone) {
		RNA_def_property_float_funcs(prop, "rna_EditBone_radius_tail_get", "rna_EditBone_radius_tail_set", NULL);
		RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
	}
	else RNA_def_property_float_sdna(prop, NULL, "rad_tail");
	//RNA_def_property_range(prop, 0, 1000);  // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid);
	RNA_def_property_ui_text(prop, "Envelope Tail Radius", "Radius of tail of bone (for Envelope deform only).");
	
		/* b-bones deform settings */
	prop= RNA_def_property(srna, "bbone_segments", PROP_INT, PROP_NONE);
	if(editbone) RNA_def_property_int_funcs(prop, "rna_EditBone_bbone_segments_get", "rna_EditBone_bbone_segments_set", NULL);
	else RNA_def_property_int_sdna(prop, NULL, "segments");
	RNA_def_property_range(prop, 1, 32);
	RNA_def_property_ui_text(prop, "B-Bone Segments", "Number of subdivisions of bone (for B-Bones only).");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "bbone_in", PROP_FLOAT, PROP_NONE);
	if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_bbone_in_get", "rna_EditBone_bbone_in_set", NULL);
	else RNA_def_property_float_sdna(prop, NULL, "ease1");
	RNA_def_property_range(prop, 0.0f, 2.0f);
	RNA_def_property_ui_text(prop, "B-Bone Ease In", "Length of first Bezier Handle (for B-Bones only).");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "bbone_out", PROP_FLOAT, PROP_NONE);
	if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_bbone_out_get", "rna_EditBone_bbone_out_set", NULL);
	else RNA_def_property_float_sdna(prop, NULL, "ease2");
	RNA_def_property_range(prop, 0.0f, 2.0f);
	RNA_def_property_ui_text(prop, "B-Bone Ease Out", "Length of second Bezier Handle (for B-Bones only).");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
}

// err... bones should not be directly edited (only editbones should be...)
static void rna_def_bone(BlenderRNA *brna)
{
	StructRNA *srna;
	PropertyRNA *prop;
	
	srna= RNA_def_struct(brna, "Bone", NULL);
	RNA_def_struct_ui_text(srna, "Bone", "Bone in an Armature datablock.");
	RNA_def_struct_ui_icon(srna, ICON_BONE_DATA);
	
	/* pointers/collections */
		/* parent (pointer) */
	prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
	RNA_def_property_struct_type(prop, "Bone");
	RNA_def_property_pointer_sdna(prop, NULL, "parent");
	RNA_def_property_ui_text(prop, "Parent", "Parent bone (in same Armature).");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
		/* children (collection) */
	prop= RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE);
	RNA_def_property_collection_sdna(prop, NULL, "childbase", NULL);
	RNA_def_property_struct_type(prop, "Bone");
	RNA_def_property_ui_text(prop, "Children", "Bones which are children of this bone");

	rna_def_bone_common(srna, 0);

		// XXX should we define this in PoseChannel wrapping code instead? but PoseChannels directly get some of their flags from here...
	prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_P);
	RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes).");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");

	prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED);
	RNA_def_property_ui_text(prop, "Selected", "");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
}

static void rna_def_edit_bone(BlenderRNA *brna)
{
	StructRNA *srna;
	PropertyRNA *prop;
	
	srna= RNA_def_struct(brna, "EditBone", NULL);
	RNA_def_struct_ui_text(srna, "Edit Bone", "Editmode bone in an Armature datablock.");
	RNA_def_struct_ui_icon(srna, ICON_BONE_DATA);
	
	prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
	RNA_def_property_struct_type(prop, "EditBone");
	RNA_def_property_pointer_funcs(prop, "rna_EditBone_parent_get", "rna_EditBone_parent_set", NULL);
	RNA_def_property_flag(prop, PROP_EDITABLE);
	RNA_def_property_ui_text(prop, "Parent", "Parent edit bone (in same Armature).");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "roll", PROP_FLOAT, PROP_NONE);
	RNA_def_property_float_funcs(prop, "rna_EditBone_roll_get", "rna_EditBone_roll_set", NULL);
	RNA_def_property_ui_text(prop, "Roll", "Bone rotation around head-tail axis.");
	RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");

	prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_VECTOR);
	RNA_def_property_array(prop, 3);
	RNA_def_property_float_funcs(prop, "rna_EditBone_head_get", "rna_EditBone_head_set", NULL);
	RNA_def_property_ui_text(prop, "Head", "Location of head end of the bone.");
	RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");

	prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_VECTOR);
	RNA_def_property_array(prop, 3);
	RNA_def_property_float_funcs(prop, "rna_EditBone_tail_get", "rna_EditBone_tail_set", NULL);
	RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone.");
	RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");

	rna_def_bone_common(srna, 1);

	prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_funcs(prop, "rna_EditBone_hidden_get", "rna_EditBone_hidden_set");
	RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when in Edit Mode");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");

	prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_funcs(prop, "rna_EditBone_locked_get", "rna_EditBone_locked_set");
	RNA_def_property_ui_text(prop, "Locked", "Bone is not able to be transformed when in Edit Mode.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");

	prop= RNA_def_property(srna, "head_selected", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_funcs(prop, "rna_EditBone_head_selected_get", "rna_EditBone_head_selected_set");
	RNA_def_property_ui_text(prop, "Head Selected", "");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "tail_selected", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_funcs(prop, "rna_EditBone_tail_selected_get", "rna_EditBone_tail_selected_set");
	RNA_def_property_ui_text(prop, "Tail Selected", "");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
}

void rna_def_armature(BlenderRNA *brna)
{
	StructRNA *srna;
	PropertyRNA *prop;
	
	static EnumPropertyItem prop_drawtype_items[] = {
		{ARM_OCTA, "OCTAHEDRAL", 0, "Octahedral", "Draw bones as octahedral shape (default)."},
		{ARM_LINE, "STICK", 0, "Stick", "Draw bones as simple 2D lines with dots."},
		{ARM_B_BONE, "BBONE", 0, "B-Bone", "Draw bones as boxes, showing subdivision and B-Splines"},
		{ARM_ENVELOPE, "ENVELOPE", 0, "Envelope", "Draw bones as extruded spheres, showing defomation influence volume."},
		{0, NULL, 0, NULL, NULL}};
	static EnumPropertyItem prop_ghost_type_items[] = {
		{ARM_GHOST_CUR, "CURRENT_FRAME", 0, "Around Current Frame", "Draw Ghosts of poses within a fixed number of frames around the current frame."},
		{ARM_GHOST_RANGE, "RANGE", 0, "In Range", "Draw Ghosts of poses within specified range."},
		{ARM_GHOST_KEYS, "KEYS", 0, "On Keyframes", "Draw Ghosts of poses on Keyframes."},
		{0, NULL, 0, NULL, NULL}};
	
	srna= RNA_def_struct(brna, "Armature", "ID");
	RNA_def_struct_ui_text(srna, "Armature", "Armature datablock containing a hierarchy of bones, usually used for rigging characters.");
	RNA_def_struct_ui_icon(srna, ICON_ARMATURE_DATA);
	
	RNA_def_struct_sdna(srna, "bArmature");
	
	/* Collections */
	prop= RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE);
	RNA_def_property_collection_sdna(prop, NULL, "bonebase", NULL);
	RNA_def_property_collection_funcs(prop, 0, "rna_Armature_bones_next", 0, 0, 0, 0, 0, 0, 0);
	RNA_def_property_struct_type(prop, "Bone");
	RNA_def_property_ui_text(prop, "Bones", "");

	prop= RNA_def_property(srna, "edit_bones", PROP_COLLECTION, PROP_NONE);
	RNA_def_property_collection_sdna(prop, NULL, "edbo", NULL);
	RNA_def_property_struct_type(prop, "EditBone");
	RNA_def_property_ui_text(prop, "Edit Bones", "");
	
	/* Enum values */
	prop= RNA_def_property(srna, "drawtype", PROP_ENUM, PROP_NONE);
	RNA_def_property_enum_items(prop, prop_drawtype_items);
	RNA_def_property_ui_text(prop, "Draw Type", "");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "ghost_type", PROP_ENUM, PROP_NONE);
	RNA_def_property_enum_sdna(prop, NULL, "ghosttype");
	RNA_def_property_enum_items(prop, prop_ghost_type_items);
	RNA_def_property_ui_text(prop, "Ghost Drawing", "Method of Onion-skinning for active Action");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	/* Boolean values */
		/* layer */
	prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);
	RNA_def_property_array(prop, 16);
	RNA_def_property_ui_text(prop, "Visible Layers", "Armature layer visibility.");
	RNA_def_property_boolean_funcs(prop, NULL, "rna_Armature_layer_set");
	RNA_def_property_update(prop, NC_OBJECT|ND_POSE, NULL);
	
		/* layer protection */
	prop= RNA_def_property(srna, "layer_protection", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "layer_protected", 1);
	RNA_def_property_array(prop, 16);
	RNA_def_property_ui_text(prop, "Layer Proxy Protection", "Protected layers in Proxy Instances are restored to Proxy settings on file reload and undo.");	
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
		
		/* flag */
	prop= RNA_def_property(srna, "rest_position", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_RESTPOS);
	RNA_def_property_ui_text(prop, "Rest Position", "Show Armature in Rest Position. No posing possible.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "draw_axes", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWAXES);
	RNA_def_property_ui_text(prop, "Draw Axes", "Draw bone axes.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "draw_names", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWNAMES);
	RNA_def_property_ui_text(prop, "Draw Names", "Draw bone names.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "delay_deform", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DELAYDEFORM);
	RNA_def_property_ui_text(prop, "Delay Deform", "Don't deform children when manipulating bones in Pose Mode");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "x_axis_mirror", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_MIRROR_EDIT);
	RNA_def_property_ui_text(prop, "X-Axis Mirror", "Apply changes to matching bone on opposite side of X-Axis.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "auto_ik", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_AUTO_IK);
	RNA_def_property_ui_text(prop, "Auto IK", "Add temporaral IK constraints while grabbing bones in Pose Mode.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "draw_custom_bone_shapes", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ARM_NO_CUSTOM);
	RNA_def_property_ui_text(prop, "Draw Custom Bone Shapes", "Draw bones with their custom shapes.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "draw_group_colors", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_COL_CUSTOM);
	RNA_def_property_ui_text(prop, "Draw Bone Group Colors", "Draw bone group colors.");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "ghost_only_selected", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ARM_GHOST_ONLYSEL);
	RNA_def_property_ui_text(prop, "Draw Ghosts on Selected Keyframes Only", "");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
		/* deformflag */
	prop= RNA_def_property(srna, "deform_vertexgroups", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP);
	RNA_def_property_ui_text(prop, "Deform Vertex Groups", "Enable Vertex Groups when defining deform");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "deform_envelope", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE);
	RNA_def_property_ui_text(prop, "Deform Envelopes", "Enable Bone Envelopes when defining deform");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "deform_quaternion", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION);
	RNA_def_property_ui_text(prop, "Use Dual Quaternion Deformation", "Enable deform rotation with Quaternions");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "deform_bbone_rest", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_B_BONE_REST);
	RNA_def_property_ui_text(prop, "B-Bones Deform in Rest Position", "Make B-Bones deform already in Rest Position");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	//prop= RNA_def_property(srna, "deform_invert_vertexgroups", PROP_BOOLEAN, PROP_NONE);
	//RNA_def_property_boolean_negative_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP);
	//RNA_def_property_ui_text(prop, "Invert Vertex Group Influence", "Invert Vertex Group influence (only for Modifiers)");
	//RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
		/* pathflag */
	prop= RNA_def_property(srna, "paths_show_frame_numbers", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_FNUMS);
	RNA_def_property_ui_text(prop, "Paths Show Frame Numbers", "When drawing Armature in Pose Mode, show frame numbers on Bone Paths");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "paths_highlight_keyframes", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_KFRAS);
	RNA_def_property_ui_text(prop, "Paths Highlight Keyframes", "When drawing Armature in Pose Mode, emphasize position of keyframes on Bone Paths");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "paths_show_keyframe_numbers", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_KFNOS);
	RNA_def_property_ui_text(prop, "Paths Show Keyframe Numbers", "When drawing Armature in Pose Mode, show frame numbers of Keyframes on Bone Paths");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "paths_show_around_current_frame", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_ACFRA);
	RNA_def_property_ui_text(prop, "Paths Around Current Frame", "When drawing Armature in Pose Mode, only show section of Bone Paths that falls around current frame");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "paths_calculate_head_positions", PROP_BOOLEAN, PROP_NONE);
	RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_HEADS);
	RNA_def_property_ui_text(prop, "Paths Use Heads", "When calculating Bone Paths, use Head locations instead of Tips");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	/* Number fields */
		/* ghost/onionskining settings */
	prop= RNA_def_property(srna, "ghost_step", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "ghostep");
	RNA_def_property_range(prop, 0, 30);
	RNA_def_property_ui_text(prop, "Ghosting Step", "Number of frame steps on either side of current frame to show as ghosts (only for 'Around Current Frame' Onion-skining method).");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "ghost_size", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "ghostsize");
	RNA_def_property_range(prop, 1, 20);
	RNA_def_property_ui_text(prop, "Ghosting Frame Step", "Frame step for Ghosts (not for 'On Keyframes' Onion-skining method).");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "ghost_start_frame", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "ghostsf");
	RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_start_frame_set", NULL);
	RNA_def_property_ui_text(prop, "Ghosting Start Frame", "Starting frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method).");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "ghost_end_frame", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "ghostef");
	RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_end_frame_set", NULL);
	RNA_def_property_ui_text(prop, "Ghosting End Frame", "End frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method).");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
		/* bone path settings */
	prop= RNA_def_property(srna, "path_size", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "pathsize");
	RNA_def_property_range(prop, 1, 100);
	RNA_def_property_ui_text(prop, "Paths Frame Step", "Number of frames between 'dots' on Bone Paths (when drawing).");
	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
	
	prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "pathsf");
	RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_start_frame_set", NULL);
	RNA_def_property_ui_text(prop, "Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations.");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "pathef");
	RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_end_frame_set", NULL);
	RNA_def_property_ui_text(prop, "Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations.");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "path_before_current", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "pathbc");
	RNA_def_property_range(prop, 1, MAXFRAMEF/2);
	RNA_def_property_ui_text(prop, "Paths Frames Before Current", "Number of frames before current frame to show on Bone Paths (only for 'Around Current' option).");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
	
	prop= RNA_def_property(srna, "path_after_current", PROP_INT, PROP_NONE);
	RNA_def_property_int_sdna(prop, NULL, "pathac");
	RNA_def_property_range(prop, 1, MAXFRAMEF/2);
	RNA_def_property_ui_text(prop, "Paths Frames After Current", "Number of frames after current frame to show on Bone Paths (only for 'Around Current' option).");
	RNA_def_property_update(prop, 0, "rna_Armature_update_data");
}

void RNA_def_armature(BlenderRNA *brna)
{
	rna_def_armature(brna);
	rna_def_bone(brna);
	rna_def_edit_bone(brna);
}

#endif