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

rna_particle.c « intern « makesrna « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 17433ffc23e1a1aae65534bd1ec437df873dd277 (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
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2011 AutoCRC (adaptive time step). */

/** \file
 * \ingroup RNA
 */

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

#include "DNA_boid_types.h"
#include "DNA_cloth_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"

#include "RNA_define.h"
#include "RNA_enum_types.h"

#include "BKE_mesh.h"
#include "BKE_mesh_legacy_convert.h"

#include "BLI_listbase.h"

#include "BLT_translation.h"

#include "rna_internal.h"

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

#ifdef RNA_RUNTIME
static const EnumPropertyItem part_from_items[] = {
    {PART_FROM_VERT, "VERT", 0, "Vertices", ""},
    {PART_FROM_FACE, "FACE", 0, "Faces", ""},
    {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
    {0, NULL, 0, NULL, NULL},
};
#endif

#ifndef RNA_RUNTIME
static const EnumPropertyItem part_reactor_from_items[] = {
    {PART_FROM_VERT, "VERT", 0, "Vertices", ""},
    {PART_FROM_FACE, "FACE", 0, "Faces", ""},
    {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
    {0, NULL, 0, NULL, NULL},
};
#endif

static const EnumPropertyItem part_dist_items[] = {
    {PART_DISTR_JIT, "JIT", 0, "Jittered", ""},
    {PART_DISTR_RAND, "RAND", 0, "Random", ""},
    {PART_DISTR_GRID, "GRID", 0, "Grid", ""},
    {0, NULL, 0, NULL, NULL},
};

#ifdef RNA_RUNTIME
static const EnumPropertyItem part_hair_dist_items[] = {
    {PART_DISTR_JIT, "JIT", 0, "Jittered", ""},
    {PART_DISTR_RAND, "RAND", 0, "Random", ""},
    {0, NULL, 0, NULL, NULL},
};
#endif

static const EnumPropertyItem part_draw_as_items[] = {
    {PART_DRAW_NOT, "NONE", 0, "None", ""},
    {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
    {PART_DRAW_DOT, "DOT", 0, "Point", ""},
    {PART_DRAW_CIRC, "CIRC", 0, "Circle", ""},
    {PART_DRAW_CROSS, "CROSS", 0, "Cross", ""},
    {PART_DRAW_AXIS, "AXIS", 0, "Axis", ""},
    {0, NULL, 0, NULL, NULL},
};

#ifdef RNA_RUNTIME
static const EnumPropertyItem part_hair_draw_as_items[] = {
    {PART_DRAW_NOT, "NONE", 0, "None", ""},
    {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
    {PART_DRAW_PATH, "PATH", 0, "Path", ""},
    {0, NULL, 0, NULL, NULL},
};
#endif

static const EnumPropertyItem part_ren_as_items[] = {
    {PART_DRAW_NOT, "NONE", 0, "None", ""},
    {PART_DRAW_HALO, "HALO", 0, "Halo", ""},
    {PART_DRAW_LINE, "LINE", 0, "Line", ""},
    {PART_DRAW_PATH, "PATH", 0, "Path", ""},
    {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
    {PART_DRAW_GR, "COLLECTION", 0, "Collection", ""},
    {0, NULL, 0, NULL, NULL},
};

#ifdef RNA_RUNTIME
static const EnumPropertyItem part_hair_ren_as_items[] = {
    {PART_DRAW_NOT, "NONE", 0, "None", ""},
    {PART_DRAW_PATH, "PATH", 0, "Path", ""},
    {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
    {PART_DRAW_GR, "COLLECTION", 0, "Collection", ""},
    {0, NULL, 0, NULL, NULL},
};
#endif

static const EnumPropertyItem part_type_items[] = {
    {PART_EMITTER, "EMITTER", 0, "Emitter", ""},
    /*{PART_REACTOR, "REACTOR", 0, "Reactor", ""}, */
    {PART_HAIR, "HAIR", 0, "Hair", ""},
    {0, NULL, 0, NULL, NULL},
};

#ifdef RNA_RUNTIME
static const EnumPropertyItem part_fluid_type_items[] = {
    {PART_FLUID, "FLUID", 0, "Fluid", ""},
    {PART_FLUID_FLIP, "FLIP", 0, "Liquid", ""},
    {PART_FLUID_SPRAY, "SPRAY", 0, "Spray", ""},
    {PART_FLUID_BUBBLE, "BUBBLE", 0, "Bubble", ""},
    {PART_FLUID_FOAM, "FOAM", 0, "Foam", ""},
    {PART_FLUID_TRACER, "TRACER", 0, "Tracer", ""},
    {PART_FLUID_SPRAYFOAM, "SPRAYFOAM", 0, "Spray-Foam", ""},
    {PART_FLUID_SPRAYBUBBLE, "SPRAYBUBBLE", 0, "Spray-Bubble", ""},
    {PART_FLUID_FOAMBUBBLE, "FOAMBUBBLE", 0, "Foam-Bubble", ""},
    {PART_FLUID_SPRAYFOAMBUBBLE, "SPRAYFOAMBUBBLE", 0, "Spray-Foam-Bubble", ""},
    {0, NULL, 0, NULL, NULL},
};
#endif

#ifdef RNA_RUNTIME

#  include "BLI_math.h"
#  include "BLI_string_utils.h"

#  include "BKE_boids.h"
#  include "BKE_cloth.h"
#  include "BKE_colortools.h"
#  include "BKE_context.h"
#  include "BKE_deform.h"
#  include "BKE_effect.h"
#  include "BKE_material.h"
#  include "BKE_modifier.h"
#  include "BKE_particle.h"
#  include "BKE_pointcache.h"
#  include "BKE_texture.h"

#  include "DEG_depsgraph.h"
#  include "DEG_depsgraph_build.h"

/* use for object space hair get/set */
static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr,
                                                     ParticleSystemModifierData **psmd_pt,
                                                     ParticleData **pa_pt)
{
  HairKey *hkey = (HairKey *)ptr->data;
  Object *ob = (Object *)ptr->owner_id;
  ModifierData *md;
  ParticleSystemModifierData *psmd = NULL;
  ParticleSystem *psys;
  ParticleData *pa;
  int i;

  *psmd_pt = NULL;
  *pa_pt = NULL;

  /* given the pointer HairKey *hkey, we iterate over all particles in all
   * particle systems in the object "ob" in order to find
   * - the ParticleSystemData to which the HairKey (and hence the particle)
   *   belongs (will be stored in psmd_pt)
   * - the ParticleData to which the HairKey belongs (will be stored in pa_pt)
   *
   * not a very efficient way of getting hair key location data,
   * but it's the best we've got at the present
   *
   * IDEAS: include additional information in PointerRNA beforehand,
   * for example a pointer to the ParticleSystemModifierData to which the
   * hair-key belongs.
   */

  for (md = ob->modifiers.first; md; md = md->next) {
    if (md->type == eModifierType_ParticleSystem) {
      psmd = (ParticleSystemModifierData *)md;
      if (psmd && psmd->mesh_final && psmd->psys) {
        psys = psmd->psys;
        for (i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) {
          /* Hair-keys are stored sequentially in memory, so we can
           * find if it's the same particle by comparing pointers,
           * without having to iterate over them all. */
          if ((hkey >= pa->hair) && (hkey < pa->hair + pa->totkey)) {
            *psmd_pt = psmd;
            *pa_pt = pa;
            return;
          }
        }
      }
    }
  }
}

static void rna_ParticleHairKey_location_object_get(PointerRNA *ptr, float *values)
{
  HairKey *hkey = (HairKey *)ptr->data;
  Object *ob = (Object *)ptr->owner_id;
  ParticleSystemModifierData *psmd;
  ParticleData *pa;

  rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa);

  if (pa) {
    Mesh *hair_mesh = (psmd->psys->flag & PSYS_HAIR_DYNAMICS) ? psmd->psys->hair_out_mesh : NULL;
    const float(*positions)[3] = BKE_mesh_positions(hair_mesh);
    if (hair_mesh) {
      copy_v3_v3(values, positions[pa->hair_index + (hkey - pa->hair)]);
    }
    else {
      float hairmat[4][4];
      psys_mat_hair_to_object(ob, psmd->mesh_final, psmd->psys->part->from, pa, hairmat);
      copy_v3_v3(values, hkey->co);
      mul_m4_v3(hairmat, values);
    }
  }
  else {
    zero_v3(values);
  }
}

/* Helper function which returns index of the given hair_key in particle which owns it.
 * Works with cases when hair_key is coming from the particle which was passed here, and from the
 * original particle of the given one.
 *
 * Such trickery is needed to allow modification of hair keys in the original object using
 * evaluated particle and object to access proper hair matrix. */
static int hair_key_index_get(const Object *object,
                              /*const*/ HairKey *hair_key,
                              /*const*/ ParticleSystemModifierData *modifier,
                              /*const*/ ParticleData *particle)
{
  if (ARRAY_HAS_ITEM(hair_key, particle->hair, particle->totkey)) {
    return hair_key - particle->hair;
  }

  const ParticleSystem *particle_system = modifier->psys;
  const int particle_index = particle - particle_system->particles;

  const ParticleSystemModifierData *original_modifier = (ParticleSystemModifierData *)
      BKE_modifier_get_original(object, &modifier->modifier);
  const ParticleSystem *original_particle_system = original_modifier->psys;
  const ParticleData *original_particle = &original_particle_system->particles[particle_index];

  if (ARRAY_HAS_ITEM(hair_key, original_particle->hair, original_particle->totkey)) {
    return hair_key - original_particle->hair;
  }

  return -1;
}

/* Set hair_key->co to the given coordinate in object space (the given coordinate will be
 * converted to the proper space).
 *
 * The hair_key can be coming from both original and evaluated object. Object, modifier and
 * particle are to be from evaluated object, so that all the data needed for hair matrix is
 * present. */
static void hair_key_location_object_set(HairKey *hair_key,
                                         Object *object,
                                         ParticleSystemModifierData *modifier,
                                         ParticleData *particle,
                                         const float src_co[3])
{
  Mesh *hair_mesh = (modifier->psys->flag & PSYS_HAIR_DYNAMICS) ? modifier->psys->hair_out_mesh :
                                                                  NULL;

  if (hair_mesh != NULL) {
    const int hair_key_index = hair_key_index_get(object, hair_key, modifier, particle);
    if (hair_key_index == -1) {
      return;
    }
    float(*positions)[3] = BKE_mesh_positions_for_write(hair_mesh);
    copy_v3_v3(positions[particle->hair_index + (hair_key_index)], src_co);
    return;
  }

  float hairmat[4][4];
  psys_mat_hair_to_object(
      object, modifier->mesh_final, modifier->psys->part->from, particle, hairmat);

  float imat[4][4];
  invert_m4_m4(imat, hairmat);

  copy_v3_v3(hair_key->co, src_co);
  mul_m4_v3(imat, hair_key->co);
}

static void rna_ParticleHairKey_location_object_set(PointerRNA *ptr, const float *values)
{
  HairKey *hkey = (HairKey *)ptr->data;
  Object *ob = (Object *)ptr->owner_id;

  ParticleSystemModifierData *psmd;
  ParticleData *pa;
  rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa);

  if (pa == NULL) {
    zero_v3(hkey->co);
    return;
  }

  hair_key_location_object_set(hkey, ob, psmd, pa, values);
}

static void rna_ParticleHairKey_co_object(HairKey *hairkey,
                                          Object *object,
                                          ParticleSystemModifierData *modifier,
                                          ParticleData *particle,
                                          float n_co[3])
{

  Mesh *hair_mesh = (modifier->psys->flag & PSYS_HAIR_DYNAMICS) ? modifier->psys->hair_out_mesh :
                                                                  NULL;
  if (particle) {
    if (hair_mesh) {
      const float(*positions)[3] = BKE_mesh_positions(hair_mesh);
      copy_v3_v3(n_co, positions[particle->hair_index + (hairkey - particle->hair)]);
    }
    else {
      float hairmat[4][4];
      psys_mat_hair_to_object(
          object, modifier->mesh_final, modifier->psys->part->from, particle, hairmat);
      copy_v3_v3(n_co, hairkey->co);
      mul_m4_v3(hairmat, n_co);
    }
  }
  else {
    zero_v3(n_co);
  }
}

static void rna_ParticleHairKey_co_object_set(ID *id,
                                              HairKey *hair_key,
                                              Object *object,
                                              ParticleSystemModifierData *modifier,
                                              ParticleData *particle,
                                              float co[3])
{

  if (particle == NULL) {
    return;
  }

  /* Mark particle system as edited, so then particle_system_update() does not reset the hair
   * keys from path. This behavior is similar to how particle edit mode sets flags. */
  ParticleSystemModifierData *orig_modifier = (ParticleSystemModifierData *)
      BKE_modifier_get_original(object, &modifier->modifier);
  orig_modifier->psys->flag |= PSYS_EDITED;

  hair_key_location_object_set(hair_key, object, modifier, particle, co);

  /* Tag similar to brushes in particle edit mode, so the modifier stack is properly evaluated
   * with the same particle system recalc flags as during combing. */
  DEG_id_tag_update(id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
}

static void rna_Particle_uv_on_emitter(ParticleData *particle,
                                       ReportList *reports,
                                       ParticleSystemModifierData *modifier,
                                       float r_uv[2])
{
#  if 0
  psys_particle_on_emitter(
      psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, nor, 0, 0, sd.orco, 0);
#  endif

  if (modifier->mesh_final == NULL) {
    BKE_report(reports, RPT_ERROR, "uv_on_emitter() requires a modifier from an evaluated object");
    return;
  }

  /* get uvco & mcol */
  int num = particle->num_dmcache;
  int from = modifier->psys->part->from;

  if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_MLOOPUV)) {
    BKE_report(reports, RPT_ERROR, "Mesh has no UV data");
    return;
  }
  BKE_mesh_tessface_ensure(modifier->mesh_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */

  if (ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
    if (particle->num < modifier->mesh_final->totface) {
      num = particle->num;
    }
  }

  /* get uvco */
  if (r_uv && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME) &&
      !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
    MFace *mface;
    MTFace *mtface;

    mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE);
    mtface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MTFACE);

    if (mface && mtface) {
      mtface += num;
      psys_interpolate_uvs(mtface, mface->v4, particle->fuv, r_uv);
      return;
    }
  }

  r_uv[0] = 0.0f;
  r_uv[1] = 0.0f;
}

static void rna_ParticleSystem_co_hair(
    ParticleSystem *particlesystem, Object *object, int particle_no, int step, float n_co[3])
{
  ParticleSettings *part = NULL;
  ParticleData *pars = NULL;
  ParticleCacheKey *cache = NULL;
  int totchild = 0;
  int totpart;
  int max_k = 0;

  if (particlesystem == NULL) {
    return;
  }

  part = particlesystem->part;
  pars = particlesystem->particles;
  totpart = particlesystem->totcached;
  totchild = particlesystem->totchildcache;

  if (part == NULL || pars == NULL) {
    return;
  }

  if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR, PART_DRAW_NOT)) {
    return;
  }

  /* can happen for disconnected/global hair */
  if (part->type == PART_HAIR && !particlesystem->childcache) {
    totchild = 0;
  }

  if (particle_no < totpart && particlesystem->pathcache) {
    cache = particlesystem->pathcache[particle_no];
    max_k = (int)cache->segments;
  }
  else if (particle_no < totpart + totchild && particlesystem->childcache) {
    cache = particlesystem->childcache[particle_no - totpart];

    if (cache->segments < 0) {
      max_k = 0;
    }
    else {
      max_k = (int)cache->segments;
    }
  }
  else {
    return;
  }

  /* Strands key loop data stored in cache + step->co. */
  if (step >= 0 && step <= max_k) {
    copy_v3_v3(n_co, (cache + step)->co);
    mul_m4_v3(particlesystem->imat, n_co);
    mul_m4_v3(object->object_to_world, n_co);
  }
}

static const EnumPropertyItem *rna_Particle_Material_itemf(bContext *C,
                                                           PointerRNA *UNUSED(ptr),
                                                           PropertyRNA *UNUSED(prop),
                                                           bool *r_free)
{
  Object *ob = CTX_data_pointer_get(C, "object").data;
  Material *ma;
  EnumPropertyItem *item = NULL;
  EnumPropertyItem tmp = {0, "", 0, "", ""};
  int totitem = 0;
  int i;

  if (ob && ob->totcol > 0) {
    for (i = 1; i <= ob->totcol; i++) {
      ma = BKE_object_material_get(ob, i);
      tmp.value = i;
      tmp.icon = ICON_MATERIAL_DATA;
      if (ma) {
        tmp.name = ma->id.name + 2;
        tmp.identifier = tmp.name;
      }
      else {
        tmp.name = "Default Material";
        tmp.identifier = tmp.name;
      }
      RNA_enum_item_add(&item, &totitem, &tmp);
    }
  }
  else {
    tmp.value = 1;
    tmp.icon = ICON_MATERIAL_DATA;
    tmp.name = "Default Material";
    tmp.identifier = tmp.name;
    RNA_enum_item_add(&item, &totitem, &tmp);
  }

  RNA_enum_item_end(&item, &totitem);
  *r_free = true;

  return item;
}

/* return < 0 means invalid (no matching tessellated face could be found). */
static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesystem,
                                                     ParticleSystemModifierData *modifier,
                                                     ParticleData *particle,
                                                     int particle_no,
                                                     float (**r_fuv)[4])
{
  ParticleSettings *part = NULL;
  int totpart;
  int totchild = 0;
  int totface;
  int totvert;
  int num = -1;

  BKE_mesh_tessface_ensure(modifier->mesh_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
  totface = modifier->mesh_final->totface;
  totvert = modifier->mesh_final->totvert;

  /* 1. check that everything is ok & updated */
  if (!particlesystem || !totface) {
    return num;
  }

  part = particlesystem->part;
  /* NOTE: only hair, keyed and baked particles may have cached items... */
  totpart = particlesystem->totcached != 0 ? particlesystem->totcached : particlesystem->totpart;
  totchild = particlesystem->totchildcache != 0 ? particlesystem->totchildcache :
                                                  particlesystem->totchild;

  /* can happen for disconnected/global hair */
  if (part->type == PART_HAIR && !particlesystem->childcache) {
    totchild = 0;
  }

  if (particle_no >= totpart + totchild) {
    return num;
  }

  /* 2. get matching face index. */
  if (particle_no < totpart) {
    num = (ELEM(particle->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? particle->num :
                                                                             particle->num_dmcache;

    if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
      if (num != DMCACHE_NOTFOUND && num < totface) {
        *r_fuv = &particle->fuv;
        return num;
      }
    }
    else if (part->from == PART_FROM_VERT) {
      if (num != DMCACHE_NOTFOUND && num < totvert) {
        MFace *mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE);

        *r_fuv = &particle->fuv;

        /* This finds the first face to contain the emitting vertex,
         * this is not ideal, but is mostly fine as UV seams generally
         * map to equal-colored parts of a texture */
        for (int i = 0; i < totface; i++, mface++) {
          if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) {
            return i;
          }
        }
      }
    }
  }
  else {
    ChildParticle *cpa = particlesystem->child + particle_no - totpart;
    num = cpa->num;

    if (part->childtype == PART_CHILD_FACES) {
      if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME, PART_FROM_VERT)) {
        if (num != DMCACHE_NOTFOUND && num < totface) {
          *r_fuv = &cpa->fuv;
          return num;
        }
      }
    }
    else {
      ParticleData *parent = particlesystem->particles + cpa->parent;
      num = parent->num_dmcache;

      if (num == DMCACHE_NOTFOUND) {
        num = parent->num;
      }

      if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
        if (num != DMCACHE_NOTFOUND && num < totface) {
          *r_fuv = &parent->fuv;
          return num;
        }
      }
      else if (part->from == PART_FROM_VERT) {
        if (num != DMCACHE_NOTFOUND && num < totvert) {
          MFace *mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE);

          *r_fuv = &parent->fuv;

          /* This finds the first face to contain the emitting vertex,
           * this is not ideal, but is mostly fine as UV seams generally
           * map to equal-colored parts of a texture */
          for (int i = 0; i < totface; i++, mface++) {
            if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) {
              return i;
            }
          }
        }
      }
    }
  }

  return -1;
}

static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem,
                                             ReportList *reports,
                                             ParticleSystemModifierData *modifier,
                                             ParticleData *particle,
                                             int particle_no,
                                             int uv_no,
                                             float r_uv[2])
{
  if (modifier->mesh_final == NULL) {
    BKE_report(reports, RPT_ERROR, "Object was not yet evaluated");
    zero_v2(r_uv);
    return;
  }
  if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_MLOOPUV)) {
    BKE_report(reports, RPT_ERROR, "Mesh has no UV data");
    zero_v2(r_uv);
    return;
  }

  {
    float(*fuv)[4];
    /* Note all sanity checks are done in this helper func. */
    const int num = rna_ParticleSystem_tessfaceidx_on_emitter(
        particlesystem, modifier, particle, particle_no, &fuv);

    if (num < 0) {
      /* No matching face found. */
      zero_v2(r_uv);
    }
    else {
      MFace *mfaces = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE);
      MFace *mface = &mfaces[num];
      const MTFace *mtface = (const MTFace *)CustomData_get_layer_n(
          &modifier->mesh_final->fdata, CD_MTFACE, uv_no);

      psys_interpolate_uvs(&mtface[num], mface->v4, *fuv, r_uv);
    }
  }
}

static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem,
                                               ReportList *reports,
                                               ParticleSystemModifierData *modifier,
                                               ParticleData *particle,
                                               int particle_no,
                                               int vcol_no,
                                               float r_mcol[3])
{
  if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_PROP_BYTE_COLOR)) {
    BKE_report(reports, RPT_ERROR, "Mesh has no VCol data");
    zero_v3(r_mcol);
    return;
  }

  {
    float(*fuv)[4];
    /* Note all sanity checks are done in this helper func. */
    const int num = rna_ParticleSystem_tessfaceidx_on_emitter(
        particlesystem, modifier, particle, particle_no, &fuv);

    if (num < 0) {
      /* No matching face found. */
      zero_v3(r_mcol);
    }
    else {
      MFace *mfaces = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE);
      MFace *mface = &mfaces[num];
      const MCol *mc = (const MCol *)CustomData_get_layer_n(
          &modifier->mesh_final->fdata, CD_MCOL, vcol_no);
      MCol mcol;

      psys_interpolate_mcol(&mc[num * 4], mface->v4, *fuv, &mcol);
      r_mcol[0] = (float)mcol.b / 255.0f;
      r_mcol[1] = (float)mcol.g / 255.0f;
      r_mcol[2] = (float)mcol.r / 255.0f;
    }
  }
}

static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag)
{
  if (ptr->type == &RNA_ParticleSystem) {
    Object *ob = (Object *)ptr->owner_id;
    ParticleSystem *psys = (ParticleSystem *)ptr->data;

    psys->recalc = flag;

    DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
  }
  else {
    DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY | flag);
  }

  WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
}
static void rna_Particle_redo(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_REDO);
}

static void rna_Particle_redo_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  DEG_relations_tag_update(bmain);
  rna_Particle_redo(bmain, scene, ptr);
}

static void rna_Particle_redo_count(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  ParticleSettings *part = (ParticleSettings *)ptr->data;
  DEG_relations_tag_update(bmain);
  psys_check_group_weights(part);
  particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_REDO);
}

static void rna_Particle_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_RESET);
}

static void rna_Particle_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  DEG_relations_tag_update(bmain);
  rna_Particle_reset(bmain, scene, ptr);
}

static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;

  /* Iterating over all object is slow, but no better solution exists at the moment. */
  for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
    LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
      if (psys->part == part) {
        psys_changed_type(ob, psys);
        psys->recalc |= ID_RECALC_PSYS_RESET;
        DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
      }
    }
  }

  WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
  DEG_relations_tag_update(bmain);
}

static void rna_Particle_change_physics_type(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_RESET | ID_RECALC_PSYS_PHYS);

  ParticleSettings *part = (ParticleSettings *)ptr->data;

  if (part->phystype == PART_PHYS_BOIDS && part->boids == NULL) {
    BoidState *state;

    part->boids = MEM_callocN(sizeof(BoidSettings), "Boid Settings");
    boid_default_settings(part->boids);

    state = boid_new_state(part->boids);
    BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Separate));
    BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Flock));

    ((BoidRule *)state->rules.first)->flag |= BOIDRULE_CURRENT;

    state->flag |= BOIDSTATE_CURRENT;
    BLI_addtail(&part->boids->states, state);
  }
  else if (part->phystype == PART_PHYS_FLUID && part->fluid == NULL) {
    part->fluid = MEM_callocN(sizeof(SPHFluidSettings), "SPH Fluid Settings");
    BKE_particlesettings_fluid_default_settings(part);
  }

  DEG_relations_tag_update(bmain);
}

static void rna_Particle_redo_child(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_CHILD);
}

static void rna_Particle_cloth_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
  Object *ob = (Object *)ptr->owner_id;

  DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
  WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}

static ParticleSystem *rna_particle_system_for_target(Object *ob, ParticleTarget *target)
{
  ParticleSystem *psys;
  ParticleTarget *pt;

  for (psys = ob->particlesystem.first; psys; psys = psys->next) {
    for (pt = psys->targets.first; pt; pt = pt->next) {
      if (pt == target) {
        return psys;
      }
    }
  }

  return NULL;
}

static void rna_Particle_target_reset(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
  if (ptr->type == &RNA_ParticleTarget) {
    Object *ob = (Object *)ptr->owner_id;
    ParticleTarget *pt = (ParticleTarget *)ptr->data;
    ParticleSystem *kpsys = NULL, *psys = rna_particle_system_for_target(ob, pt);

    if (ELEM(pt->ob, ob, NULL)) {
      kpsys = BLI_findlink(&ob->particlesystem, pt->psys - 1);

      if (kpsys) {
        pt->flag |= PTARGET_VALID;
      }
      else {
        pt->flag &= ~PTARGET_VALID;
      }
    }
    else {
      if (pt->ob) {
        kpsys = BLI_findlink(&pt->ob->particlesystem, pt->psys - 1);
      }

      if (kpsys) {
        pt->flag |= PTARGET_VALID;
      }
      else {
        pt->flag &= ~PTARGET_VALID;
      }
    }

    psys->recalc = ID_RECALC_PSYS_RESET;

    DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
    DEG_relations_tag_update(bmain);
  }

  WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
}

static void rna_Particle_target_redo(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
  if (ptr->type == &RNA_ParticleTarget) {
    Object *ob = (Object *)ptr->owner_id;
    ParticleTarget *pt = (ParticleTarget *)ptr->data;
    ParticleSystem *psys = rna_particle_system_for_target(ob, pt);

    psys->recalc = ID_RECALC_PSYS_REDO;

    DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
    WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
  }
}

static void rna_Particle_hair_dynamics_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  Object *ob = (Object *)ptr->owner_id;
  ParticleSystem *psys = (ParticleSystem *)ptr->data;

  if (psys && !psys->clmd) {
    psys->clmd = (ClothModifierData *)BKE_modifier_new(eModifierType_Cloth);
    psys->clmd->sim_parms->goalspring = 0.0f;
    psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS;
    psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
    rna_Particle_redo(bmain, scene, ptr);
  }
  else {
    WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
  }

  DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
  DEG_relations_tag_update(bmain);
}

static PointerRNA rna_particle_settings_get(PointerRNA *ptr)
{
  ParticleSystem *psys = (ParticleSystem *)ptr->data;
  ParticleSettings *part = psys->part;

  return rna_pointer_inherit_refine(ptr, &RNA_ParticleSettings, part);
}

static void rna_particle_settings_set(PointerRNA *ptr,
                                      PointerRNA value,
                                      struct ReportList *UNUSED(reports))
{
  Object *ob = (Object *)ptr->owner_id;
  ParticleSystem *psys = (ParticleSystem *)ptr->data;
  int old_type = 0;

  if (psys->part) {
    old_type = psys->part->type;
    id_us_min(&psys->part->id);
  }

  psys->part = (ParticleSettings *)value.data;

  if (psys->part) {
    id_us_plus(&psys->part->id);
    psys_check_boid_data(psys);
    if (old_type != psys->part->type) {
      psys_changed_type(ob, psys);
    }
  }
}
static void rna_Particle_abspathtime_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;
  float delta = settings->end + settings->lifetime - settings->sta;
  if (settings->draw & PART_ABS_PATH_TIME) {
    settings->path_start = settings->sta + settings->path_start * delta;
    settings->path_end = settings->sta + settings->path_end * delta;
  }
  else {
    settings->path_start = (settings->path_start - settings->sta) / delta;
    settings->path_end = (settings->path_end - settings->sta) / delta;
  }
  rna_Particle_redo(bmain, scene, ptr);
}
static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;

  /* check for clipping */
  if (value > settings->end) {
    settings->end = value;
  }

#  if 0
  if (settings->type==PART_REACTOR && value < 1.0)
    value = 1.0;
  else
#  endif
  if (value < MINAFRAMEF) {
    value = MINAFRAMEF;
  }

  settings->sta = value;
}

static void rna_PartSettings_end_set(struct PointerRNA *ptr, float value)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;

  /* check for clipping */
  if (value < settings->sta) {
    settings->sta = value;
  }

  settings->end = value;
}

static void rna_PartSetings_timestep_set(struct PointerRNA *ptr, float value)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;

  settings->timetweak = value / 0.04f;
}

static float rna_PartSettings_timestep_get(struct PointerRNA *ptr)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;

  return settings->timetweak * 0.04f;
}

static void rna_PartSetting_hairlength_set(struct PointerRNA *ptr, float value)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;
  settings->normfac = value / 4.0f;
}

static float rna_PartSetting_hairlength_get(struct PointerRNA *ptr)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;
  return settings->normfac * 4.0f;
}

static void rna_PartSetting_linelentail_set(struct PointerRNA *ptr, float value)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;
  settings->draw_line[0] = value;
}

static float rna_PartSetting_linelentail_get(struct PointerRNA *ptr)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;
  return settings->draw_line[0];
}
static void rna_PartSetting_pathstartend_range(
    PointerRNA *ptr, float *min, float *max, float *UNUSED(softmin), float *UNUSED(softmax))
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;

  if (settings->type == PART_HAIR) {
    *min = 0.0f;
    *max = (settings->draw & PART_ABS_PATH_TIME) ? 100.0f : 1.0f;
  }
  else {
    *min = (settings->draw & PART_ABS_PATH_TIME) ? settings->sta : 0.0f;
    *max = (settings->draw & PART_ABS_PATH_TIME) ? MAXFRAMEF : 1.0f;
  }
}
static void rna_PartSetting_linelenhead_set(struct PointerRNA *ptr, float value)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;
  settings->draw_line[1] = value;
}

static float rna_PartSetting_linelenhead_get(struct PointerRNA *ptr)
{
  ParticleSettings *settings = (ParticleSettings *)ptr->data;
  return settings->draw_line[1];
}

static bool rna_PartSettings_is_fluid_get(PointerRNA *ptr)
{
  ParticleSettings *part = ptr->data;
  return (ELEM(part->type,
               PART_FLUID,
               PART_FLUID_FLIP,
               PART_FLUID_FOAM,
               PART_FLUID_SPRAY,
               PART_FLUID_BUBBLE,
               PART_FLUID_TRACER,
               PART_FLUID_SPRAYFOAM,
               PART_FLUID_SPRAYBUBBLE,
               PART_FLUID_FOAMBUBBLE,
               PART_FLUID_SPRAYFOAMBUBBLE));
}

static void rna_ParticleSettings_use_clump_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  ParticleSettings *part = ptr->data;

  if (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) {
    if (!part->clumpcurve) {
      BKE_particlesettings_clump_curve_init(part);
    }
  }

  rna_Particle_redo_child(bmain, scene, ptr);
}

static void rna_ParticleSettings_use_roughness_curve_update(Main *bmain,
                                                            Scene *scene,
                                                            PointerRNA *ptr)
{
  ParticleSettings *part = ptr->data;

  if (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) {
    if (!part->roughcurve) {
      BKE_particlesettings_rough_curve_init(part);
    }
  }

  rna_Particle_redo_child(bmain, scene, ptr);
}

static void rna_ParticleSettings_use_twist_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  ParticleSettings *part = ptr->data;

  if (part->child_flag & PART_CHILD_USE_TWIST_CURVE) {
    if (!part->twistcurve) {
      BKE_particlesettings_twist_curve_init(part);
    }
  }

  rna_Particle_redo_child(bmain, scene, ptr);
}

static void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value)
{
  Object *ob = (Object *)ptr->owner_id;
  ParticleSystem *part = (ParticleSystem *)ptr->data;

  /* copy the new name into the name slot */
  BLI_strncpy_utf8(part->name, value, sizeof(part->name));

  BLI_uniquename(&ob->particlesystem,
                 part,
                 DATA_("ParticleSystem"),
                 '.',
                 offsetof(ParticleSystem, name),
                 sizeof(part->name));
}

static PointerRNA rna_ParticleSystem_active_particle_target_get(PointerRNA *ptr)
{
  ParticleSystem *psys = (ParticleSystem *)ptr->data;
  ParticleTarget *pt = psys->targets.first;

  for (; pt; pt = pt->next) {
    if (pt->flag & PTARGET_CURRENT) {
      return rna_pointer_inherit_refine(ptr, &RNA_ParticleTarget, pt);
    }
  }
  return rna_pointer_inherit_refine(ptr, &RNA_ParticleTarget, NULL);
}
static void rna_ParticleSystem_active_particle_target_index_range(
    PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
{
  ParticleSystem *psys = (ParticleSystem *)ptr->data;
  *min = 0;
  *max = max_ii(0, BLI_listbase_count(&psys->targets) - 1);
}

static int rna_ParticleSystem_active_particle_target_index_get(PointerRNA *ptr)
{
  ParticleSystem *psys = (ParticleSystem *)ptr->data;
  ParticleTarget *pt = psys->targets.first;
  int i = 0;

  for (; pt; pt = pt->next, i++) {
    if (pt->flag & PTARGET_CURRENT) {
      return i;
    }
  }

  return 0;
}

static void rna_ParticleSystem_active_particle_target_index_set(struct PointerRNA *ptr, int value)
{
  ParticleSystem *psys = (ParticleSystem *)ptr->data;
  ParticleTarget *pt = psys->targets.first;
  int i = 0;

  for (; pt; pt = pt->next, i++) {
    if (i == value) {
      pt->flag |= PTARGET_CURRENT;
    }
    else {
      pt->flag &= ~PTARGET_CURRENT;
    }
  }
}

static void rna_ParticleTarget_name_get(PointerRNA *ptr, char *str)
{
  ParticleTarget *pt = ptr->data;

  if (pt->flag & PTARGET_VALID) {
    ParticleSystem *psys = NULL;

    if (pt->ob) {
      psys = BLI_findlink(&pt->ob->particlesystem, pt->psys - 1);
    }
    else {
      Object *ob = (Object *)ptr->owner_id;
      psys = BLI_findlink(&ob->particlesystem, pt->psys - 1);
    }

    if (psys) {
      if (pt->ob) {
        BLI_sprintf(str, "%s: %s", pt->ob->id.name + 2, psys->name);
      }
      else {
        strcpy(str, psys->name);
      }
    }
    else {
      strcpy(str, "Invalid target!");
    }
  }
  else {
    strcpy(str, "Invalid target!");
  }
}

static int rna_ParticleTarget_name_length(PointerRNA *ptr)
{
  char tstr[MAX_ID_NAME + MAX_ID_NAME + 64];

  rna_ParticleTarget_name_get(ptr, tstr);

  return strlen(tstr);
}

static int particle_id_check(const PointerRNA *ptr)
{
  const ID *id = ptr->owner_id;

  return (GS(id->name) == ID_PA);
}

static char *rna_SPHFluidSettings_path(const PointerRNA *ptr)
{
  const SPHFluidSettings *fluid = (SPHFluidSettings *)ptr->data;

  if (particle_id_check(ptr)) {
    const ParticleSettings *part = (ParticleSettings *)ptr->owner_id;

    if (part->fluid == fluid) {
      return BLI_strdup("fluid");
    }
  }
  return NULL;
}

static bool rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr)
{
  ParticleSystem *psys = (ParticleSystem *)ptr->data;

  return (psys->ptcaches.first != psys->ptcaches.last);
}
static bool rna_ParticleSystem_editable_get(PointerRNA *ptr)
{
  ParticleSystem *psys = (ParticleSystem *)ptr->data;

  return psys_check_edited(psys);
}
static bool rna_ParticleSystem_edited_get(PointerRNA *ptr)
{
  ParticleSystem *psys = (ParticleSystem *)ptr->data;

  if (psys->part && psys->part->type == PART_HAIR) {
    return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited));
  }
  else {
    return (psys->pointcache->edit && psys->pointcache->edit->edited);
  }
}
static PointerRNA rna_ParticleDupliWeight_active_get(PointerRNA *ptr)
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
  ParticleDupliWeight *dw = part->instance_weights.first;

  for (; dw; dw = dw->next) {
    if (dw->flag & PART_DUPLIW_CURRENT) {
      return rna_pointer_inherit_refine(ptr, &RNA_ParticleDupliWeight, dw);
    }
  }
  return rna_pointer_inherit_refine(ptr, &RNA_ParticleTarget, NULL);
}
static void rna_ParticleDupliWeight_active_index_range(
    PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
  *min = 0;
  *max = max_ii(0, BLI_listbase_count(&part->instance_weights) - 1);
}

static int rna_ParticleDupliWeight_active_index_get(PointerRNA *ptr)
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
  ParticleDupliWeight *dw = part->instance_weights.first;
  int i = 0;

  for (; dw; dw = dw->next, i++) {
    if (dw->flag & PART_DUPLIW_CURRENT) {
      return i;
    }
  }

  return 0;
}

static void rna_ParticleDupliWeight_active_index_set(struct PointerRNA *ptr, int value)
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
  ParticleDupliWeight *dw = part->instance_weights.first;
  int i = 0;

  for (; dw; dw = dw->next, i++) {
    if (i == value) {
      dw->flag |= PART_DUPLIW_CURRENT;
    }
    else {
      dw->flag &= ~PART_DUPLIW_CURRENT;
    }
  }
}

static void rna_ParticleDupliWeight_name_get(PointerRNA *ptr, char *str)
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
  psys_find_group_weights(part);

  ParticleDupliWeight *dw = ptr->data;

  if (dw->ob) {
    BLI_sprintf(str, "%s: %i", dw->ob->id.name + 2, dw->count);
  }
  else {
    strcpy(str, "No object");
  }
}

static int rna_ParticleDupliWeight_name_length(PointerRNA *ptr)
{
  char tstr[MAX_ID_NAME + 64];

  rna_ParticleDupliWeight_name_get(ptr, tstr);

  return strlen(tstr);
}

static const EnumPropertyItem *rna_Particle_type_itemf(bContext *UNUSED(C),
                                                       PointerRNA *ptr,
                                                       PropertyRNA *UNUSED(prop),
                                                       bool *UNUSED(r_free))
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;

  if (ELEM(part->type, PART_HAIR, PART_EMITTER)) {
    return part_type_items;
  }
  else {
    return part_fluid_type_items;
  }
}

static const EnumPropertyItem *rna_Particle_from_itemf(bContext *UNUSED(C),
                                                       PointerRNA *UNUSED(ptr),
                                                       PropertyRNA *UNUSED(prop),
                                                       bool *UNUSED(r_free))
{
#  if 0
  if (part->type == PART_REACTOR) {
    return part_reactor_from_items;
  }
#  endif
  return part_from_items;
}

static const EnumPropertyItem *rna_Particle_dist_itemf(bContext *UNUSED(C),
                                                       PointerRNA *ptr,
                                                       PropertyRNA *UNUSED(prop),
                                                       bool *UNUSED(r_free))
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;

  if (part->type == PART_HAIR) {
    return part_hair_dist_items;
  }
  else {
    return part_dist_items;
  }
}

static const EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *UNUSED(C),
                                                          PointerRNA *ptr,
                                                          PropertyRNA *UNUSED(prop),
                                                          bool *UNUSED(r_free))
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;

  if (part->type == PART_HAIR) {
    return part_hair_draw_as_items;
  }
  else {
    return part_draw_as_items;
  }
}

static const EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *UNUSED(C),
                                                         PointerRNA *ptr,
                                                         PropertyRNA *UNUSED(prop),
                                                         bool *UNUSED(r_free))
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;

  if (part->type == PART_HAIR) {
    return part_hair_ren_as_items;
  }
  else {
    return part_ren_as_items;
  }
}

static PointerRNA rna_Particle_field1_get(PointerRNA *ptr)
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
  return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd);
}

static PointerRNA rna_Particle_field2_get(PointerRNA *ptr)
{
  ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
  return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd2);
}

static void psys_vg_name_get__internal(PointerRNA *ptr, char *value, int index)
{
  Object *ob = (Object *)ptr->owner_id;
  ParticleSystem *psys = (ParticleSystem *)ptr->data;
  const ListBase *defbase = BKE_object_defgroup_list(ob);

  if (psys->vgroup[index] > 0) {
    bDeformGroup *defGroup = BLI_findlink(defbase, psys->vgroup[index] - 1);

    if (defGroup) {
      strcpy(value, defGroup->name);
      return;
    }
  }

  value[0] = '\0';
}
static int psys_vg_name_len__internal(PointerRNA *ptr, int index)
{
  Object *ob = (Object *)ptr->owner_id;
  ParticleSystem *psys = (ParticleSystem *)ptr->data;

  if (psys->vgroup[index] > 0) {
    const ListBase *defbase = BKE_object_defgroup_list(ob);
    bDeformGroup *defGroup = BLI_findlink(defbase, psys->vgroup[index] - 1);

    if (defGroup) {
      return strlen(defGroup->name);
    }
  }
  return 0;
}
static void psys_vg_name_set__internal(PointerRNA *ptr, const char *value, int index)
{
  Object *ob = (Object *)ptr->owner_id;
  ParticleSystem *psys = (ParticleSystem *)ptr->data;

  if (value[0] == '\0') {
    psys->vgroup[index] = 0;
  }
  else {
    int defgrp_index = BKE_object_defgroup_name_index(ob, value);

    if (defgrp_index == -1) {
      return;
    }

    psys->vgroup[index] = defgrp_index + 1;
  }
}

static char *rna_ParticleSystem_path(const PointerRNA *ptr)
{
  const ParticleSystem *psys = (ParticleSystem *)ptr->data;
  char name_esc[sizeof(psys->name) * 2];

  BLI_str_escape(name_esc, psys->name, sizeof(name_esc));
  return BLI_sprintfN("particle_systems[\"%s\"]", name_esc);
}

static void rna_ParticleSettings_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
  ParticleSettings *part = (ParticleSettings *)ptr->data;
  rna_iterator_array_begin(iter, (void *)part->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
}

static PointerRNA rna_ParticleSettings_active_texture_get(PointerRNA *ptr)
{
  ParticleSettings *part = (ParticleSettings *)ptr->data;
  Tex *tex;

  tex = give_current_particle_texture(part);
  return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
}

static void rna_ParticleSettings_active_texture_set(PointerRNA *ptr,
                                                    PointerRNA value,
                                                    struct ReportList *UNUSED(reports))
{
  ParticleSettings *part = (ParticleSettings *)ptr->data;

  set_current_particle_texture(part, value.data);
}

/* irritating string functions for each index :/ */
static void rna_ParticleVGroup_name_get_0(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 0);
}
static void rna_ParticleVGroup_name_get_1(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 1);
}
static void rna_ParticleVGroup_name_get_2(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 2);
}
static void rna_ParticleVGroup_name_get_3(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 3);
}
static void rna_ParticleVGroup_name_get_4(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 4);
}
static void rna_ParticleVGroup_name_get_5(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 5);
}
static void rna_ParticleVGroup_name_get_6(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 6);
}
static void rna_ParticleVGroup_name_get_7(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 7);
}
static void rna_ParticleVGroup_name_get_8(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 8);
}
static void rna_ParticleVGroup_name_get_9(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 9);
}
static void rna_ParticleVGroup_name_get_10(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 10);
}
static void rna_ParticleVGroup_name_get_11(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 11);
}
static void rna_ParticleVGroup_name_get_12(PointerRNA *ptr, char *value)
{
  psys_vg_name_get__internal(ptr, value, 12);
}

static int rna_ParticleVGroup_name_len_0(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 0);
}
static int rna_ParticleVGroup_name_len_1(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 1);
}
static int rna_ParticleVGroup_name_len_2(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 2);
}
static int rna_ParticleVGroup_name_len_3(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 3);
}
static int rna_ParticleVGroup_name_len_4(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 4);
}
static int rna_ParticleVGroup_name_len_5(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 5);
}
static int rna_ParticleVGroup_name_len_6(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 6);
}
static int rna_ParticleVGroup_name_len_7(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 7);
}
static int rna_ParticleVGroup_name_len_8(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 8);
}
static int rna_ParticleVGroup_name_len_9(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 9);
}
static int rna_ParticleVGroup_name_len_10(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 10);
}
static int rna_ParticleVGroup_name_len_11(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 11);
}
static int rna_ParticleVGroup_name_len_12(PointerRNA *ptr)
{
  return psys_vg_name_len__internal(ptr, 12);
}

static void rna_ParticleVGroup_name_set_0(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 0);
}
static void rna_ParticleVGroup_name_set_1(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 1);
}
static void rna_ParticleVGroup_name_set_2(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 2);
}
static void rna_ParticleVGroup_name_set_3(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 3);
}
static void rna_ParticleVGroup_name_set_4(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 4);
}
static void rna_ParticleVGroup_name_set_5(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 5);
}
static void rna_ParticleVGroup_name_set_6(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 6);
}
static void rna_ParticleVGroup_name_set_7(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 7);
}
static void rna_ParticleVGroup_name_set_8(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 8);
}
static void rna_ParticleVGroup_name_set_9(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 9);
}
static void rna_ParticleVGroup_name_set_10(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 10);
}
static void rna_ParticleVGroup_name_set_11(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 11);
}
static void rna_ParticleVGroup_name_set_12(PointerRNA *ptr, const char *value)
{
  psys_vg_name_set__internal(ptr, value, 12);
}

#else

static void rna_def_particle_hair_key(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  FunctionRNA *func;
  PropertyRNA *parm;

  srna = RNA_def_struct(brna, "ParticleHairKey", NULL);
  RNA_def_struct_sdna(srna, "HairKey");
  RNA_def_struct_ui_text(srna, "Particle Hair Key", "Particle key for hair particle system");

  prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
  RNA_def_property_ui_text(prop, "Time", "Relative time of key over hair length");

  prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_UNSIGNED);
  RNA_def_property_range(prop, 0.0, 1.0);
  RNA_def_property_ui_text(prop, "Weight", "Weight for cloth simulation");

  prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
  RNA_def_property_array(prop, 3);
  RNA_def_property_ui_text(
      prop, "Location (Object Space)", "Location of the hair key in object space");
  RNA_def_property_float_funcs(prop,
                               "rna_ParticleHairKey_location_object_get",
                               "rna_ParticleHairKey_location_object_set",
                               NULL);

  prop = RNA_def_property(srna, "co_local", PROP_FLOAT, PROP_TRANSLATION);
  RNA_def_property_float_sdna(prop, NULL, "co");
  RNA_def_property_ui_text(prop,
                           "Location",
                           "Location of the hair key in its local coordinate system, "
                           "relative to the emitting face");

  /* Aided co func */
  func = RNA_def_function(srna, "co_object", "rna_ParticleHairKey_co_object");
  RNA_def_function_ui_description(func, "Obtain hairkey location with particle and modifier data");
  parm = RNA_def_pointer(func, "object", "Object", "", "Object");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_pointer(func, "particle", "Particle", "", "hair particle");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_float_vector(
      func, "co", 3, NULL, -FLT_MAX, FLT_MAX, "Co", "Exported hairkey location", -1e4, 1e4);
  RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
  RNA_def_function_output(func, parm);

  func = RNA_def_function(srna, "co_object_set", "rna_ParticleHairKey_co_object_set");
  RNA_def_function_flag(func, FUNC_USE_SELF_ID);
  RNA_def_function_ui_description(func, "Set hairkey location with particle and modifier data");
  parm = RNA_def_pointer(func, "object", "Object", "", "Object");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_pointer(func, "particle", "Particle", "", "hair particle");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_float_vector(
      func, "co", 3, NULL, -FLT_MAX, FLT_MAX, "Co", "Specified hairkey location", -1e4, 1e4);
  RNA_def_parameter_flags(parm, PROP_THICK_WRAP, PARM_REQUIRED);
}

static void rna_def_particle_key(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  srna = RNA_def_struct(brna, "ParticleKey", NULL);
  RNA_def_struct_ui_text(srna, "Particle Key", "Key location for a particle over time");

  prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
  RNA_def_property_float_sdna(prop, NULL, "co");
  RNA_def_property_ui_text(prop, "Location", "Key location");

  prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "vel");
  RNA_def_property_ui_text(prop, "Velocity", "Key velocity");

  prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION);
  RNA_def_property_float_sdna(prop, NULL, "rot");
  RNA_def_property_ui_text(prop, "Rotation", "Key rotation quaternion");

  prop = RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "ave");
  RNA_def_property_ui_text(prop, "Angular Velocity", "Key angular velocity");

  prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
  RNA_def_property_ui_text(prop, "Time", "Time of key over the simulation");
}

static void rna_def_child_particle(BlenderRNA *brna)
{
  StructRNA *srna;
  // PropertyRNA *prop;

  srna = RNA_def_struct(brna, "ChildParticle", NULL);
  RNA_def_struct_ui_text(
      srna, "Child Particle", "Child particle interpolated from simulated or edited particles");

  /*  int num, parent; */ /* num is face index on the final derived mesh */

  /*  int pa[4]; */             /* nearest particles to the child, used for the interpolation */
  /*  float w[4]; */            /* interpolation weights for the above particles */
  /*  float fuv[4], foffset; */ /* face vertex weights and offset */
  /*  float rand[3]; */
}

static void rna_def_particle(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  FunctionRNA *func;
  PropertyRNA *parm;

  static const EnumPropertyItem alive_items[] = {
      /*{PARS_KILLED, "KILLED", 0, "Killed", ""}, */
      {PARS_DEAD, "DEAD", 0, "Dead", ""},
      {PARS_UNBORN, "UNBORN", 0, "Unborn", ""},
      {PARS_ALIVE, "ALIVE", 0, "Alive", ""},
      {PARS_DYING, "DYING", 0, "Dying", ""},
      {0, NULL, 0, NULL, NULL},
  };

  srna = RNA_def_struct(brna, "Particle", NULL);
  RNA_def_struct_sdna(srna, "ParticleData");
  RNA_def_struct_ui_text(srna, "Particle", "Particle in a particle system");

  /* Particle State & Previous State */
  prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
  RNA_def_property_float_sdna(prop, NULL, "state.co");
  RNA_def_property_ui_text(prop, "Particle Location", "");

  prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "state.vel");
  RNA_def_property_ui_text(prop, "Particle Velocity", "");

  prop = RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "state.ave");
  RNA_def_property_ui_text(prop, "Angular Velocity", "");

  prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION);
  RNA_def_property_float_sdna(prop, NULL, "state.rot");
  RNA_def_property_ui_text(prop, "Rotation", "");

  prop = RNA_def_property(srna, "prev_location", PROP_FLOAT, PROP_TRANSLATION);
  RNA_def_property_float_sdna(prop, NULL, "prev_state.co");
  RNA_def_property_ui_text(prop, "Previous Particle Location", "");

  prop = RNA_def_property(srna, "prev_velocity", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "prev_state.vel");
  RNA_def_property_ui_text(prop, "Previous Particle Velocity", "");

  prop = RNA_def_property(srna, "prev_angular_velocity", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "prev_state.ave");
  RNA_def_property_ui_text(prop, "Previous Angular Velocity", "");

  prop = RNA_def_property(srna, "prev_rotation", PROP_FLOAT, PROP_QUATERNION);
  RNA_def_property_float_sdna(prop, NULL, "prev_state.rot");
  RNA_def_property_ui_text(prop, "Previous Rotation", "");

  /* Hair & Keyed Keys */

  prop = RNA_def_property(srna, "hair_keys", PROP_COLLECTION, PROP_NONE);
  RNA_def_property_collection_sdna(prop, NULL, "hair", "totkey");
  RNA_def_property_struct_type(prop, "ParticleHairKey");
  RNA_def_property_ui_text(prop, "Hair", "");

  prop = RNA_def_property(srna, "particle_keys", PROP_COLLECTION, PROP_NONE);
  RNA_def_property_collection_sdna(prop, NULL, "keys", "totkey");
  RNA_def_property_struct_type(prop, "ParticleKey");
  RNA_def_property_ui_text(prop, "Keyed States", "");
  /* */
  /* float fuv[4], foffset; */ /* Coordinates on face/edge number "num" and depth along. */
                               /* Face normal for volume emission. */

  prop = RNA_def_property(srna, "birth_time", PROP_FLOAT, PROP_TIME);
  RNA_def_property_float_sdna(prop, NULL, "time");
  // RNA_def_property_range(prop, lowerLimitf, upperLimitf);
  RNA_def_property_ui_text(prop, "Birth Time", "");

  prop = RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME);
  // RNA_def_property_range(prop, lowerLimitf, upperLimitf);
  RNA_def_property_ui_text(prop, "Lifetime", "");

  prop = RNA_def_property(srna, "die_time", PROP_FLOAT, PROP_TIME);
  RNA_def_property_float_sdna(prop, NULL, "dietime");
  // RNA_def_property_range(prop, lowerLimitf, upperLimitf);
  RNA_def_property_ui_text(prop, "Die Time", "");

  prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
  // RNA_def_property_range(prop, lowerLimitf, upperLimitf);
  RNA_def_property_ui_text(prop, "Size", "");

  /* */
  /*  int num;                 */ /* index to vert/edge/face */
  /*  int num_dmcache;         */ /* index to derived mesh data (face) to avoid slow lookups */
                                  /*  int pad; */
                                  /* */
                                  /*  int totkey; */

  /* flag */
  prop = RNA_def_property(srna, "is_exist", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PARS_UNEXIST);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Exists", "");

  prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PARS_NO_DISP);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Visible", "");

  prop = RNA_def_property(srna, "alive_state", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "alive");
  RNA_def_property_enum_items(prop, alive_items);
  RNA_def_property_ui_text(prop, "Alive State", "");

  /*  short rt2; */

  /* UVs */
  func = RNA_def_function(srna, "uv_on_emitter", "rna_Particle_uv_on_emitter");
  RNA_def_function_ui_description(func,
                                  "Obtain UV coordinates for a particle on an evaluated mesh.");
  RNA_def_function_flag(func, FUNC_USE_REPORTS);
  parm = RNA_def_pointer(func,
                         "modifier",
                         "ParticleSystemModifier",
                         "",
                         "Particle modifier from an evaluated object");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_property(func, "uv", PROP_FLOAT, PROP_COORDS);
  RNA_def_property_array(parm, 2);
  RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
  RNA_def_function_output(func, parm);
}

static void rna_def_particle_dupliweight(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  srna = RNA_def_struct(brna, "ParticleDupliWeight", NULL);
  RNA_def_struct_ui_text(srna,
                         "Particle Instance Object Weight",
                         "Weight of a particle instance object in a collection");
  RNA_def_struct_sdna(srna, "ParticleDupliWeight");

  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(
      prop, "rna_ParticleDupliWeight_name_get", "rna_ParticleDupliWeight_name_length", NULL);
  RNA_def_property_ui_text(prop, "Name", "Particle instance object name");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_struct_name_property(srna, prop);

  prop = RNA_def_property(srna, "count", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_range(prop, 0, SHRT_MAX);
  RNA_def_property_ui_text(
      prop, "Count", "The number of times this object is repeated with respect to other objects");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");
}

static void rna_def_fluid_settings(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  static const EnumPropertyItem sph_solver_items[] = {
      {SPH_SOLVER_DDR,
       "DDR",
       0,
       "Double-Density",
       "An artistic solver with strong surface tension effects (original)"},
      {SPH_SOLVER_CLASSICAL, "CLASSICAL", 0, "Classical", "A more physically-accurate solver"},
      {0, NULL, 0, NULL, NULL},
  };

  srna = RNA_def_struct(brna, "SPHFluidSettings", NULL);
  RNA_def_struct_path_func(srna, "rna_SPHFluidSettings_path");
  RNA_def_struct_ui_text(srna, "SPH Fluid Settings", "Settings for particle fluids physics");

  /* Fluid settings */
  prop = RNA_def_property(srna, "solver", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "solver");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_items(prop, sph_solver_items);
  RNA_def_property_ui_text(
      prop, "SPH Solver", "The code used to calculate internal forces on particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "spring_force", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "spring_k");
  RNA_def_property_range(prop, 0.0f, 100.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
  RNA_def_property_ui_text(prop, "Spring Force", "Spring force");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "fluid_radius", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "radius");
  RNA_def_property_range(prop, 0.0f, 20.0f);
  RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
  RNA_def_property_ui_text(prop, "Interaction Radius", "Fluid interaction radius");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "rest_length", PROP_FLOAT, PROP_NONE);
  RNA_def_property_range(prop, 0.0f, 2.0f);
  RNA_def_property_ui_text(prop, "Rest Length", "Spring rest length (factor of particle radius)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_viscoelastic_springs", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_VISCOELASTIC_SPRINGS);
  RNA_def_property_ui_text(
      prop, "Viscoelastic Springs", "Use viscoelastic springs instead of Hooke's springs");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_initial_rest_length", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_CURRENT_REST_LENGTH);
  RNA_def_property_ui_text(
      prop,
      "Initial Rest Length",
      "Use the initial length as spring rest length instead of 2 * particle size");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "plasticity", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "plasticity_constant");
  RNA_def_property_range(prop, 0.0f, 100.0f);
  RNA_def_property_ui_text(
      prop,
      "Plasticity",
      "How much the spring rest length can change after the elastic limit is crossed");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "yield_ratio", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "yield_ratio");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(
      prop,
      "Elastic Limit",
      "How much the spring has to be stretched/compressed in order to change its rest length");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "spring_frames", PROP_INT, PROP_NONE);
  RNA_def_property_range(prop, 0.0f, 100.0f);
  RNA_def_property_ui_text(
      prop,
      "Spring Frames",
      "Create springs for this number of frames since particles birth (0 is always)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* Viscosity */
  prop = RNA_def_property(srna, "linear_viscosity", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "viscosity_omega");
  RNA_def_property_range(prop, 0.0f, 100.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
  RNA_def_property_ui_text(prop, "Viscosity", "Linear viscosity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "stiff_viscosity", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "viscosity_beta");
  RNA_def_property_range(prop, 0.0f, 100.0f);
  RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
  RNA_def_property_ui_text(prop, "Stiff Viscosity", "Creates viscosity for expanding fluid");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* Double density relaxation */
  prop = RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "stiffness_k");
  RNA_def_property_range(prop, 0.0f, 1000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
  RNA_def_property_ui_text(prop, "Stiffness", "How incompressible the fluid is (speed of sound)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "repulsion", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "stiffness_knear");
  RNA_def_property_range(prop, 0.0f, 100.0f);
  RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
  RNA_def_property_ui_text(
      prop,
      "Repulsion Factor",
      "How strongly the fluid tries to keep from clustering (factor of stiffness)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "rest_density", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "rest_density");
  RNA_def_property_range(prop, 0.0f, 10000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
  RNA_def_property_ui_text(prop, "Rest Density", "Fluid rest density");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* Buoyancy */
  prop = RNA_def_property(srna, "buoyancy", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "buoyancy");
  RNA_def_property_range(prop, 0.0f, 10.0f);
  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
  RNA_def_property_ui_text(
      prop,
      "Buoyancy",
      "Artificial buoyancy force in negative gravity direction based on pressure "
      "differences inside the fluid");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* Factor flags */

  prop = RNA_def_property(srna, "use_factor_repulsion", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_REPULSION);
  RNA_def_property_ui_text(prop, "Factor Repulsion", "Repulsion is a factor of stiffness");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_factor_density", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_DENSITY);
  RNA_def_property_ui_text(
      prop,
      "Factor Density",
      "Density is calculated as a factor of default density (depends on particle size)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_factor_radius", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_RADIUS);
  RNA_def_property_ui_text(
      prop, "Factor Radius", "Interaction radius is a factor of 4 * particle size");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_factor_stiff_viscosity", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_VISCOSITY);
  RNA_def_property_ui_text(
      prop, "Factor Stiff Viscosity", "Stiff viscosity is a factor of normal viscosity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_factor_rest_length", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_REST_LENGTH);
  RNA_def_property_ui_text(
      prop, "Factor Rest Length", "Spring rest length is a factor of 2 * particle size");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");
}

static void rna_def_particle_settings_mtex(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  static const EnumPropertyItem texco_items[] = {
      {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"},
      {TEXCO_OBJECT,
       "OBJECT",
       0,
       "Object",
       "Use linked object's coordinates for texture coordinates"},
      {TEXCO_UV, "UV", 0, "UV", "Use UV coordinates for texture coordinates"},
      {TEXCO_ORCO,
       "ORCO",
       0,
       "Generated",
       "Use the original undeformed coordinates of the object"},
      {TEXCO_STRAND,
       "STRAND",
       0,
       "Strand / Particle",
       "Use normalized strand texture coordinate (1D) or particle age (X) and trail position (Y)"},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem prop_mapping_items[] = {
      {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
      {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
      {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
      {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem prop_x_mapping_items[] = {
      {0, "NONE", 0, "None", ""},
      {1, "X", 0, "X", ""},
      {2, "Y", 0, "Y", ""},
      {3, "Z", 0, "Z", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem prop_y_mapping_items[] = {
      {0, "NONE", 0, "None", ""},
      {1, "X", 0, "X", ""},
      {2, "Y", 0, "Y", ""},
      {3, "Z", 0, "Z", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem prop_z_mapping_items[] = {
      {0, "NONE", 0, "None", ""},
      {1, "X", 0, "X", ""},
      {2, "Y", 0, "Y", ""},
      {3, "Z", 0, "Z", ""},
      {0, NULL, 0, NULL, NULL},
  };

  srna = RNA_def_struct(brna, "ParticleSettingsTextureSlot", "TextureSlot");
  RNA_def_struct_sdna(srna, "MTex");
  RNA_def_struct_ui_text(srna,
                         "Particle Settings Texture Slot",
                         "Texture slot for textures in a Particle Settings data-block");

  prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "texco");
  RNA_def_property_enum_items(prop, texco_items);
  RNA_def_property_ui_text(prop,
                           "Texture Coordinates",
                           "Texture coordinates used to map the texture onto the background");
  RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");

  prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "object");
  RNA_def_property_struct_type(prop, "Object");
  RNA_def_property_flag(prop, PROP_EDITABLE);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(
      prop, "Object", "Object to use for mapping with Object texture coordinates");
  RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");

  prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
  RNA_def_property_string_sdna(prop, NULL, "uvname");
  RNA_def_property_ui_text(
      prop, "UV Map", "UV map to use for mapping with UV texture coordinates");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "projx");
  RNA_def_property_enum_items(prop, prop_x_mapping_items);
  RNA_def_property_ui_text(prop, "X Mapping", "");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "projy");
  RNA_def_property_enum_items(prop, prop_y_mapping_items);
  RNA_def_property_ui_text(prop, "Y Mapping", "");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "projz");
  RNA_def_property_enum_items(prop, prop_z_mapping_items);
  RNA_def_property_ui_text(prop, "Z Mapping", "");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_items(prop, prop_mapping_items);
  RNA_def_property_ui_text(prop, "Mapping", "");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* map to */
  prop = RNA_def_property(srna, "use_map_time", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_TIME);
  RNA_def_property_ui_text(prop, "Emission Time", "Affect the emission time of the particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_map_life", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_LIFE);
  RNA_def_property_ui_text(prop, "Life Time", "Affect the life time of the particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_map_density", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_DENS);
  RNA_def_property_ui_text(prop, "Density", "Affect the density of the particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_map_size", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_SIZE);
  RNA_def_property_ui_text(prop, "Size", "Affect the particle size");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_map_velocity", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_IVEL);
  RNA_def_property_ui_text(prop, "Initial Velocity", "Affect the particle initial velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_map_field", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_FIELD);
  RNA_def_property_ui_text(prop, "Force Field", "Affect the particle force fields");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_map_gravity", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_GRAVITY);
  RNA_def_property_ui_text(prop, "Gravity", "Affect the particle gravity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_map_damp", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_DAMP);
  RNA_def_property_ui_text(prop, "Damp", "Affect the particle velocity damping");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_map_clump", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_CLUMP);
  RNA_def_property_ui_text(prop, "Clump", "Affect the child clumping");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_map_kink_amp", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_KINK_AMP);
  RNA_def_property_ui_text(prop, "Kink Amplitude", "Affect the child kink amplitude");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_map_kink_freq", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_KINK_FREQ);
  RNA_def_property_ui_text(prop, "Kink Frequency", "Affect the child kink frequency");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_map_rough", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_ROUGH);
  RNA_def_property_ui_text(prop, "Rough", "Affect the child rough");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_map_length", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_LENGTH);
  RNA_def_property_ui_text(prop, "Length", "Affect the child hair length");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_map_twist", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_TWIST);
  RNA_def_property_ui_text(prop, "Twist", "Affect the child twist");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* influence factors */
  prop = RNA_def_property(srna, "time_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "timefac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(
      prop, "Emission Time Factor", "Amount texture affects particle emission time");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "life_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "lifefac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Life Time Factor", "Amount texture affects particle life time");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "density_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "padensfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Density Factor", "Amount texture affects particle density");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "size_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "sizefac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Size Factor", "Amount texture affects physical particle size");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "ivelfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(
      prop, "Velocity Factor", "Amount texture affects particle initial velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "field_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "fieldfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Field Factor", "Amount texture affects particle force fields");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "gravity_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "gravityfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Gravity Factor", "Amount texture affects particle gravity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "damp_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "dampfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Damp Factor", "Amount texture affects particle damping");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "length_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "lengthfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Length Factor", "Amount texture affects child hair length");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "clump_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "clumpfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Clump Factor", "Amount texture affects child clump");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_amp_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "kinkampfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(
      prop, "Kink Amplitude Factor", "Amount texture affects child kink amplitude");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_freq_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "kinkfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(
      prop, "Kink Frequency Factor", "Amount texture affects child kink frequency");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "rough_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "roughfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Rough Factor", "Amount texture affects child roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "twist_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "twistfac");
  RNA_def_property_ui_range(prop, 0, 1, 10, 3);
  RNA_def_property_ui_text(prop, "Twist Factor", "Amount texture affects child twist");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
}

static void rna_def_particle_settings(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  static const EnumPropertyItem phys_type_items[] = {
      {PART_PHYS_NO, "NO", 0, "None", ""},
      {PART_PHYS_NEWTON, "NEWTON", 0, "Newtonian", ""},
      {PART_PHYS_KEYED, "KEYED", 0, "Keyed", ""},
      {PART_PHYS_BOIDS, "BOIDS", 0, "Boids", ""},
      {PART_PHYS_FLUID, "FLUID", 0, "Fluid", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem rot_mode_items[] = {
      {0, "NONE", 0, "None", ""},
      {PART_ROT_NOR, "NOR", 0, "Normal", ""},
      {PART_ROT_NOR_TAN, "NOR_TAN", 0, "Normal-Tangent", ""},
      {PART_ROT_VEL, "VEL", 0, "Velocity / Hair", ""},
      {PART_ROT_GLOB_X, "GLOB_X", 0, "Global X", ""},
      {PART_ROT_GLOB_Y, "GLOB_Y", 0, "Global Y", ""},
      {PART_ROT_GLOB_Z, "GLOB_Z", 0, "Global Z", ""},
      {PART_ROT_OB_X, "OB_X", 0, "Object X", ""},
      {PART_ROT_OB_Y, "OB_Y", 0, "Object Y", ""},
      {PART_ROT_OB_Z, "OB_Z", 0, "Object Z", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem ave_mode_items[] = {
      {0, "NONE", 0, "None", ""},
      {PART_AVE_VELOCITY, "VELOCITY", 0, "Velocity", ""},
      {PART_AVE_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""},
      {PART_AVE_VERTICAL, "VERTICAL", 0, "Vertical", ""},
      {PART_AVE_GLOBAL_X, "GLOBAL_X", 0, "Global X", ""},
      {PART_AVE_GLOBAL_Y, "GLOBAL_Y", 0, "Global Y", ""},
      {PART_AVE_GLOBAL_Z, "GLOBAL_Z", 0, "Global Z", ""},
      {PART_AVE_RAND, "RAND", 0, "Random", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem react_event_items[] = {
      {PART_EVENT_DEATH, "DEATH", 0, "Death", ""},
      {PART_EVENT_COLLIDE, "COLLIDE", 0, "Collision", ""},
      {PART_EVENT_NEAR, "NEAR", 0, "Near", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem child_type_items[] = {
      {0, "NONE", 0, "None", ""},
      {PART_CHILD_PARTICLES, "SIMPLE", 0, "Simple", ""},
      {PART_CHILD_FACES, "INTERPOLATED", 0, "Interpolated", ""},
      {0, NULL, 0, NULL, NULL},
  };

  /* TODO: names, tool-tips. */
  static const EnumPropertyItem integrator_type_items[] = {
      {PART_INT_EULER, "EULER", 0, "Euler", ""},
      {PART_INT_VERLET, "VERLET", 0, "Verlet", ""},
      {PART_INT_MIDPOINT, "MIDPOINT", 0, "Midpoint", ""},
      {PART_INT_RK4, "RK4", 0, "RK4", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem kink_type_items[] = {
      {PART_KINK_NO, "NO", 0, "Nothing", ""},
      {PART_KINK_CURL, "CURL", 0, "Curl", ""},
      {PART_KINK_RADIAL, "RADIAL", 0, "Radial", ""},
      {PART_KINK_WAVE, "WAVE", 0, "Wave", ""},
      {PART_KINK_BRAID, "BRAID", 0, "Braid", ""},
      {PART_KINK_SPIRAL, "SPIRAL", 0, "Spiral", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem draw_col_items[] = {
      {PART_DRAW_COL_NONE, "NONE", 0, "None", ""},
      {PART_DRAW_COL_MAT, "MATERIAL", 0, "Material", ""},
      {PART_DRAW_COL_VEL, "VELOCITY", 0, "Velocity", ""},
      {PART_DRAW_COL_ACC, "ACCELERATION", 0, "Acceleration", ""},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem part_mat_items[] = {
      {0, "DUMMY", 0, "Dummy", ""},
      {0, NULL, 0, NULL, NULL},
  };

  srna = RNA_def_struct(brna, "ParticleSettings", "ID");
  RNA_def_struct_ui_text(
      srna, "Particle Settings", "Particle settings, reusable by multiple particle systems");
  RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA);

  rna_def_mtex_common(brna,
                      srna,
                      "rna_ParticleSettings_mtex_begin",
                      "rna_ParticleSettings_active_texture_get",
                      "rna_ParticleSettings_active_texture_set",
                      NULL,
                      "ParticleSettingsTextureSlot",
                      "ParticleSettingsTextureSlots",
                      "rna_Particle_reset_dependency",
                      NULL);

  /* Fluid particle type can't be checked from the type value in RNA
   * as it's not shown in the menu. */
  prop = RNA_def_property(srna, "is_fluid", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_boolean_funcs(prop, "rna_PartSettings_is_fluid_get", NULL);
  RNA_def_property_ui_text(prop, "Fluid", "Particles were created by a fluid simulation");

  /* flag */
  prop = RNA_def_property(srna, "use_react_start_end", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_REACT_STA_END);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Start/End", "Give birth to unreacted particles eventually");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_react_multiple", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_REACT_MULTIPLE);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Multi React", "React multiple times");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_regrow_hair", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_HAIR_REGROW);
  RNA_def_property_ui_text(prop, "Regrow", "Regrow hair for each frame");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "show_unborn", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_UNBORN);
  RNA_def_property_ui_text(prop, "Unborn", "Show particles before they are emitted");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_dead", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_DIED);
  RNA_def_property_ui_text(prop, "Died", "Show particles after they have died");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_emit_random", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_TRAND);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Random", "Emit in random order of elements");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_even_distribution", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_EDISTR);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop,
                           "Even Distribution",
                           "Use even distribution from faces based on face areas or edge lengths");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_die_on_collision", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_DIE_ON_COL);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(
      prop, "Die on Hit", "Particles die when they collide with a deflector object");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_size_deflect", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SIZE_DEFL);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Size Deflect", "Use particle's size in deflection");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_rotations", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ROTATIONS);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Rotations", "Calculate particle rotations");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_dynamic_rotation", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ROT_DYN);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(
      prop, "Dynamic", "Particle rotations are affected by collisions and effectors");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_multiply_size_mass", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SIZEMASS);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Mass from Size", "Multiply mass by particle size");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_advanced_hair", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PART_HIDE_ADVANCED_HAIR);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Advanced", "Use full physics calculations for growing hair");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "lock_boids_to_surface", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_BOIDS_2D);
  RNA_def_property_ui_text(prop, "Boids 2D", "Constrain boids to a surface");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_hair_bspline", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_HAIR_BSPLINE);
  RNA_def_property_ui_text(prop, "B-Spline", "Interpolate hair using B-Splines");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "invert_grid", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_GRID_INVERT);
  RNA_def_property_ui_text(
      prop, "Invert Grid", "Invert what is considered object and what is not");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "hexagonal_grid", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_GRID_HEXAGONAL);
  RNA_def_property_ui_text(prop, "Hexagonal Grid", "Create the grid in a hexagonal pattern");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "apply_effector_to_children", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_EFFECT);
  RNA_def_property_ui_text(prop, "Effect Children", "Apply effectors to children");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "create_long_hair_children", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_LONG_HAIR);
  RNA_def_property_ui_text(prop, "Long Hair", "Calculate children that suit long hair well");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "apply_guide_to_children", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_GUIDE);
  RNA_def_property_ui_text(prop, "apply_guide_to_children", "");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_self_effect", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SELF_EFFECT);
  RNA_def_property_ui_text(prop, "Self Effect", "Particle effectors affect themselves");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_items(prop, part_type_items);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_type_itemf");
  RNA_def_property_ui_text(prop, "Type", "Particle type");
  RNA_def_property_update(prop, 0, "rna_Particle_change_type");

  prop = RNA_def_property(srna, "emit_from", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "from");
  RNA_def_property_enum_items(prop, part_reactor_from_items);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_from_itemf");
  RNA_def_property_ui_text(prop, "Emit From", "Where to emit particles from");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "distr");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_items(prop, part_dist_items);
  RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_dist_itemf");
  RNA_def_property_ui_text(
      prop, "Distribution", "How to distribute particles on selected element");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* physics modes */
  prop = RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "phystype");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_items(prop, phys_type_items);
  RNA_def_property_ui_text(prop, "Physics Type", "Particle physics type");
  RNA_def_property_update(prop, 0, "rna_Particle_change_physics_type");

  prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "rotmode");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_items(prop, rot_mode_items);
  RNA_def_property_ui_text(
      prop,
      "Orientation Axis",
      "Particle orientation axis (does not affect Explode modifier's results)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "angular_velocity_mode", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "avemode");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_items(prop, ave_mode_items);
  RNA_def_property_ui_text(
      prop, "Angular Velocity Axis", "What axis is used to change particle rotation with time");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "react_event", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "reactevent");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_items(prop, react_event_items);
  RNA_def_property_ui_text(prop, "React On", "The event of target particles to react on");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* Draw flag. */
  prop = RNA_def_property(srna, "show_guide_hairs", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_GUIDE_HAIRS);
  RNA_def_property_ui_text(prop, "Guide Hairs", "Show guide hairs");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "show_hair_grid", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_HAIR_GRID);
  RNA_def_property_ui_text(prop, "Guide Hairs", "Show hair simulation grid");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "show_velocity", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_VEL);
  RNA_def_property_ui_text(prop, "Velocity", "Show particle velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "show_size", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_SIZE);
  RNA_def_property_ui_text(prop, "Size", "Show particle size");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "show_health", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_HEALTH);
  RNA_def_property_ui_text(prop, "Health", "Display boid health");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_absolute_path_time", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_ABS_PATH_TIME);
  RNA_def_property_ui_text(prop, "Absolute Path Time", "Path timing is in absolute frames");
  RNA_def_property_update(prop, 0, "rna_Particle_abspathtime_update");

  prop = RNA_def_property(srna, "use_parent_particles", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_PARENT);
  RNA_def_property_ui_text(prop, "Parents", "Render parent particles");
  RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_PARTICLESETTINGS);
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "show_number", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_NUM);
  RNA_def_property_ui_text(prop, "Number", "Show particle number");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_collection_pick_random", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_RAND_GR);
  RNA_def_property_ui_text(prop, "Pick Random", "Pick objects from collection randomly");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_collection_count", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_COUNT_GR);
  RNA_def_property_ui_text(prop, "Use Count", "Use object multiple times in the same collection");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_count");

  prop = RNA_def_property(srna, "use_global_instance", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_GLOBAL_OB);
  RNA_def_property_ui_text(prop, "Global", "Use object's global coordinates for duplication");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_rotation_instance", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_ROTATE_OB);
  RNA_def_property_ui_text(prop,
                           "Rotation",
                           "Use object's rotation for duplication (global x-axis is aligned "
                           "particle rotation axis)");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_scale_instance", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_negative_sdna(prop, NULL, "draw", PART_DRAW_NO_SCALE_OB);
  RNA_def_property_ui_text(prop, "Scale", "Use object's scale for duplication");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_render_adaptive", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_ADAPT);
  RNA_def_property_ui_text(prop, "Adaptive Render", "Display steps of the particle path");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_velocity_length", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_VEL_LENGTH);
  RNA_def_property_ui_text(prop, "Speed", "Multiply line length by particle speed");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_whole_collection", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_WHOLE_GR);
  RNA_def_property_ui_text(prop, "Whole Collection", "Use whole collection at once");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "use_strand_primitive", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_STRAND);
  RNA_def_property_ui_text(prop, "Strand Render", "Use the strand primitive for rendering");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "display_method", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "draw_as");
  RNA_def_property_enum_items(prop, part_draw_as_items);
  RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_draw_as_itemf");
  RNA_def_property_ui_text(prop, "Particle Display", "How particles are displayed in viewport");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "render_type", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "ren_as");
  RNA_def_property_enum_items(prop, part_ren_as_items);
  RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_ren_as_itemf");
  RNA_def_property_ui_text(prop, "Particle Rendering", "How particles are rendered");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "display_color", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "draw_col");
  RNA_def_property_enum_items(prop, draw_col_items);
  RNA_def_property_ui_text(prop, "Display Color", "Display additional particle data as a color");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "display_size", PROP_FLOAT, PROP_DISTANCE);
  RNA_def_property_float_sdna(prop, NULL, "draw_size");
  RNA_def_property_range(prop, 0, 1000);
  RNA_def_property_ui_range(prop, 0, 100, 1, -1);
  RNA_def_property_ui_text(prop, "Display Size", "Size of particles on viewport");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "child_type", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "childtype");
  RNA_def_property_enum_items(prop, child_type_items);
  RNA_def_property_ui_text(prop, "Children From", "Create child particles");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "display_step", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "draw_step");
  RNA_def_property_range(prop, 0, 10);
  RNA_def_property_ui_range(prop, 0, 7, 1, -1);
  RNA_def_property_ui_text(prop, "Steps", "How many steps paths are displayed with (power of 2)");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "render_step", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "ren_step");
  RNA_def_property_range(prop, 0, 20);
  RNA_def_property_ui_range(prop, 0, 9, 1, -1);
  RNA_def_property_ui_text(prop, "Render", "How many steps paths are rendered with (power of 2)");

  prop = RNA_def_property(srna, "hair_step", PROP_INT, PROP_NONE);
  RNA_def_property_range(prop, 2, SHRT_MAX);
  RNA_def_property_ui_range(prop, 2, 50, 1, 1);
  RNA_def_property_ui_text(prop, "Segments", "Number of hair segments");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "bending_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "bending_random");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Random Bending Stiffness", "Random stiffness of hairs");
  RNA_def_property_update(prop, 0, "rna_Particle_cloth_update");

  /* TODO: not found in UI, read-only? */
  prop = RNA_def_property(srna, "keys_step", PROP_INT, PROP_NONE);
  RNA_def_property_range(prop, 0, SHRT_MAX); /* TODO: min,max. */
  RNA_def_property_ui_text(prop, "Keys Step", "");

  /* adaptive path rendering */
  prop = RNA_def_property(srna, "adaptive_angle", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "adapt_angle");
  RNA_def_property_range(prop, 0, 45);
  RNA_def_property_ui_text(
      prop, "Degrees", "How many degrees path has to curve to make another render segment");

  prop = RNA_def_property(srna, "adaptive_pixel", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "adapt_pix");
  RNA_def_property_range(prop, 0, 50);
  RNA_def_property_ui_text(
      prop, "Pixel", "How many pixels path has to cover to make another render segment");

  prop = RNA_def_property(srna, "display_percentage", PROP_INT, PROP_PERCENTAGE);
  RNA_def_property_int_sdna(prop, NULL, "disp");
  RNA_def_property_range(prop, 0, 100);
  RNA_def_property_ui_text(prop, "Display", "Percentage of particles to display in 3D view");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "material", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "omat");
  RNA_def_property_range(prop, 1, 32767);
  RNA_def_property_ui_text(
      prop, "Material Index", "Index of material slot used for rendering particles");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "material_slot", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "omat");
  RNA_def_property_enum_items(prop, part_mat_items);
  RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_Material_itemf");
  RNA_def_property_ui_text(prop, "Material Slot", "Material slot used for rendering particles");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "integrator", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_items(prop, integrator_type_items);
  RNA_def_property_ui_text(prop,
                           "Integration",
                           "Algorithm used to calculate physics, from the fastest to the "
                           "most stable and accurate: Midpoint, Euler, Verlet, RK4");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "kink", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_items(prop, kink_type_items);
  RNA_def_property_ui_text(prop, "Kink", "Type of periodic offset on the path");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_axis", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
  RNA_def_property_ui_text(prop, "Axis", "Which axis to use for offset");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "color_maximum", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "color_vec_max");
  RNA_def_property_range(prop, 0.01f, 100.0f);
  RNA_def_property_ui_text(prop, "Color Maximum", "Maximum length of the particle color vector");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  /* general values */
  prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME);
  RNA_def_property_float_sdna(prop, NULL, "sta"); /* Optional if prop names are the same. */
  RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_start_set", NULL);
  RNA_def_property_ui_text(prop, "Start", "Frame number to start emitting particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_TIME);
  RNA_def_property_float_sdna(prop, NULL, "end");
  RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);

  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_end_set", NULL);
  RNA_def_property_ui_text(prop, "End", "Frame number to stop emitting particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME);
  RNA_def_property_range(prop, 1.0f, MAXFRAMEF);
  RNA_def_property_ui_text(prop, "Lifetime", "Life span of the particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "lifetime_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "randlife");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Random", "Give the particle life a random variation");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "time_tweak", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "timetweak");
  RNA_def_property_range(prop, 0.0f, 100.0f);
  RNA_def_property_ui_range(prop, 0, 10, 1, 3);
  RNA_def_property_ui_text(
      prop, "Tweak", "A multiplier for physics timestep (1.0 means one frame = 1/25 seconds)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "timestep", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_funcs(
      prop, "rna_PartSettings_timestep_get", "rna_PartSetings_timestep_set", NULL);
  RNA_def_property_range(prop, 0.0001, 100.0);
  RNA_def_property_ui_range(prop, 0.01, 10, 1, 3);
  RNA_def_property_ui_text(
      prop, "Timestep", "The simulation timestep per frame (seconds per frame)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "use_adaptive_subframes", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "time_flag", PART_TIME_AUTOSF);
  RNA_def_property_ui_text(
      prop, "Automatic Subframes", "Automatically set the number of subframes");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE);
  RNA_def_property_range(prop, 0, 1000);
  RNA_def_property_ui_text(
      prop,
      "Subframes",
      "Subframes to simulate for improved stability and finer granularity simulations "
      "(dt = timestep / (subframes + 1))");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "courant_target", PROP_FLOAT, PROP_NONE);
  RNA_def_property_range(prop, 0.0001, 10);
  RNA_def_property_ui_text(
      prop,
      "Adaptive Subframe Threshold",
      "The relative distance a particle can move before requiring more subframes "
      "(target Courant number); 0.01 to 0.3 is the recommended range");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "jitter_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_float_sdna(prop, NULL, "jitfac");
  RNA_def_property_range(prop, 0.0f, 2.0f);
  RNA_def_property_ui_text(prop, "Amount", "Amount of jitter applied to the sampling");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "effect_hair", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "eff_hair");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Stiffness", "Hair stiffness for effectors");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "count", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_int_sdna(prop, NULL, "totpart");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_range(prop, 0, 1000000, 1, -1);
  RNA_def_property_ui_text(prop, "Number", "Total number of particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(
      srna, "userjit", PROP_INT, PROP_UNSIGNED); /* TODO: can we get a better name for userjit? */
  RNA_def_property_int_sdna(prop, NULL, "userjit");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_range(prop, 0, 1000);
  RNA_def_property_ui_text(prop, "Particles/Face", "Emission locations per face (0 = automatic)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "grid_resolution", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_int_sdna(prop, NULL, "grid_res");
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_range(
      prop, 1, 250); /* ~15M particles in a cube (ouch!), but could be very usable in a plane */
  RNA_def_property_ui_range(prop, 1, 50, 1, -1); /* ~100k particles in a cube */
  RNA_def_property_ui_text(prop, "Resolution", "The resolution of the particle grid");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "grid_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "grid_rand");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Grid Randomness", "Add random offset to the grid locations");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "effector_amount", PROP_INT, PROP_UNSIGNED);
  /* In theory PROP_ANIMATABLE perhaps should be cleared,
   * but animating this can give some interesting results! */
  RNA_def_property_range(prop, 0, 10000); /* 10000 effectors will bel SLOW, but who knows */
  RNA_def_property_ui_range(prop, 0, 100, 1, -1);
  RNA_def_property_ui_text(
      prop, "Effector Number", "How many particles are effectors (0 is all particles)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* initial velocity factors */
  prop = RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "normfac"); /* Optional if prop names are the same. */
  RNA_def_property_range(prop, -1000.0f, 1000.0f);
  RNA_def_property_ui_range(prop, 0, 100, 1, 3);
  RNA_def_property_ui_text(
      prop, "Normal", "Let the surface normal give the particle a starting velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "object_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "obfac");
  RNA_def_property_range(prop, -200.0f, 200.0f);
  RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.1, 3);
  RNA_def_property_ui_text(
      prop, "Object Velocity", "Let the object give the particle a starting velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "factor_random", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "randfac"); /* Optional if prop names are the same. */
  RNA_def_property_range(prop, 0.0f, 200.0f);
  RNA_def_property_ui_range(prop, 0, 100, 1, 3);
  RNA_def_property_ui_text(prop, "Random", "Give the starting velocity a random variation");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "particle_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "partfac");
  RNA_def_property_range(prop, -200.0f, 200.0f);
  RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.1, 3);
  RNA_def_property_ui_text(
      prop, "Particle", "Let the target particle give the particle a starting velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "tangent_factor", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "tanfac");
  RNA_def_property_range(prop, -1000.0f, 1000.0f);
  RNA_def_property_ui_range(prop, -100, 100, 1, 2);
  RNA_def_property_ui_text(
      prop, "Tangent", "Let the surface tangent give the particle a starting velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "tangent_phase", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "tanphase");
  RNA_def_property_range(prop, -1.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Rotation", "Rotate the surface tangent");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "reactor_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "reactfac");
  RNA_def_property_range(prop, -10.0f, 10.0f);
  RNA_def_property_ui_text(
      prop,
      "Reactor",
      "Let the vector away from the target particle's location give the particle "
      "a starting velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "object_align_factor", PROP_FLOAT, PROP_VELOCITY);
  RNA_def_property_float_sdna(prop, NULL, "ob_vel");
  RNA_def_property_array(prop, 3);
  RNA_def_property_range(prop, -200.0f, 200.0f);
  RNA_def_property_ui_range(prop, -100, 100, 1, 3);
  RNA_def_property_ui_text(
      prop,
      "Object Aligned",
      "Let the emitter object orientation give the particle a starting velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "angular_velocity_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "avefac");
  RNA_def_property_range(prop, -200.0f, 200.0f);
  RNA_def_property_ui_range(prop, -100, 100, 10, 3);
  RNA_def_property_ui_text(
      prop, "Angular Velocity", "Angular velocity amount (in radians per second)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "phase_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "phasefac");
  RNA_def_property_range(prop, -1.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Phase", "Rotation around the chosen orientation axis");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "rotation_factor_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "randrotfac");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Random Orientation", "Randomize particle orientation");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "phase_factor_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "randphasefac");
  RNA_def_property_range(prop, 0.0f, 2.0f);
  RNA_def_property_ui_text(
      prop, "Random Phase", "Randomize rotation around the chosen orientation axis");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "hair_length", PROP_FLOAT, PROP_DISTANCE);
  RNA_def_property_float_funcs(
      prop, "rna_PartSetting_hairlength_get", "rna_PartSetting_hairlength_set", NULL);
  RNA_def_property_range(prop, 0.0f, 1000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
  RNA_def_property_ui_text(prop, "Hair Length", "Length of the hair");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* physical properties */
  prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
  RNA_def_property_range(prop, 0.00000001f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.01, 100, 1, 4);
  RNA_def_property_ui_text(prop, "Mass", "Mass of the particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "particle_size", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "size");
  RNA_def_property_range(prop, 0.001f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.01, 100, 1, 3);
  RNA_def_property_ui_text(prop, "Size", "The size of the particles");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "size_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "randsize");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Random Size", "Give the particle size a random variation");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "collision_collection", PROP_POINTER, PROP_NONE);
  RNA_def_property_struct_type(prop, "Collection");
  RNA_def_property_pointer_sdna(prop, NULL, "collision_group");
  RNA_def_property_flag(prop, PROP_EDITABLE);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this collection");
  RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");

  /* global physical properties */
  prop = RNA_def_property(srna, "drag_factor", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "dragfac");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Drag", "Amount of air drag");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "brownian_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "brownfac");
  RNA_def_property_range(prop, 0.0f, 200.0f);
  RNA_def_property_ui_range(prop, 0, 20, 1, 3);
  RNA_def_property_ui_text(prop, "Brownian", "Amount of random, erratic particle movement");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "dampfac");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Damp", "Amount of damping");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* random length */
  prop = RNA_def_property(srna, "length_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "randlength");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Random Length", "Give path length a random variation");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  /* children */

  /* NOTE(@campbellbarton): name is not following conventions: `nbr`.
   * Could be changed next major version. */
  prop = RNA_def_property(srna, "child_nbr", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(
      prop, NULL, "child_percent"); /* Optional if prop names are the same. */
  RNA_def_property_range(prop, 0, 100000);
  RNA_def_property_ui_range(prop, 0, 1000, 1, -1);
  RNA_def_property_ui_text(prop, "Children Per Parent", "Number of children per parent");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "rendered_child_count", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "child_render_percent");
  RNA_def_property_range(prop, 0, 100000);
  RNA_def_property_ui_range(prop, 0, 10000, 1, -1);
  RNA_def_property_ui_text(
      prop, "Rendered Children", "Number of children per parent for rendering");

  prop = RNA_def_property(srna, "virtual_parents", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "parents");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Virtual Parents", "Relative amount of virtual parents");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "child_size", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "childsize");
  RNA_def_property_range(prop, 0.001f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.01f, 100.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Child Size", "A multiplier for the child particle size");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "child_size_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "childrandsize");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(
      prop, "Random Child Size", "Random variation to the size of the child particles");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "child_radius", PROP_FLOAT, PROP_DISTANCE);
  RNA_def_property_float_sdna(prop, NULL, "childrad");
  RNA_def_property_range(prop, 0.0f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Child Radius", "Radius of children around parent");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "child_roundness", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "childflat");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Child Roundness", "Roundness of children around parent");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* clumping */
  prop = RNA_def_property(srna, "clump_factor", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "clumpfac");
  RNA_def_property_range(prop, -1.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Clump", "Amount of clumping");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "clump_shape", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "clumppow");
  RNA_def_property_range(prop, -0.999f, 0.999f);
  RNA_def_property_ui_text(prop, "Shape", "Shape of clumping");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_clump_curve", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_CLUMP_CURVE);
  RNA_def_property_ui_text(prop, "Use Clump Curve", "Use a curve to define clump tapering");
  RNA_def_property_update(prop, 0, "rna_ParticleSettings_use_clump_curve_update");

  prop = RNA_def_property(srna, "clump_curve", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "clumpcurve");
  RNA_def_property_struct_type(prop, "CurveMapping");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Clump Curve", "Curve defining clump tapering");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_clump_noise", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_CLUMP_NOISE);
  RNA_def_property_ui_text(prop, "Use Clump Noise", "Create random clumps around the parent");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "clump_noise_size", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "clump_noise_size");
  RNA_def_property_range(prop, 0.00001f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.1f, 3);
  RNA_def_property_ui_text(prop, "Clump Noise Size", "Size of clump noise");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* kink */
  prop = RNA_def_property(srna, "kink_amplitude", PROP_FLOAT, PROP_DISTANCE);
  RNA_def_property_float_sdna(prop, NULL, "kink_amp");
  RNA_def_property_range(prop, -100000.0f, 100000.0f);
  RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Amplitude", "The amplitude of the offset");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_amplitude_clump", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "kink_amp_clump");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Amplitude Clump", "How much clump affects kink amplitude");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_amplitude_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "kink_amp_random");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Amplitude Random", "Random variation of the amplitude");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_frequency", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "kink_freq");
  RNA_def_property_range(prop, -100000.0f, 100000.0f);
  RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Frequency", "The frequency of the offset (1/total length)");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_shape", PROP_FLOAT, PROP_NONE);
  RNA_def_property_range(prop, -0.999f, 0.999f);
  RNA_def_property_ui_text(prop, "Shape", "Adjust the offset to the beginning/end");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_flat", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Flatness", "How flat the hairs are");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_extra_steps", PROP_INT, PROP_NONE);
  RNA_def_property_range(prop, 1, INT_MAX);
  RNA_def_property_ui_range(prop, 1, 100, 1, -1);
  RNA_def_property_ui_text(
      prop, "Extra Steps", "Extra steps for resolution of special kink features");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "kink_axis_random", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Axis Random", "Random variation of the orientation");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* rough */
  prop = RNA_def_property(srna, "roughness_1", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "rough1");
  RNA_def_property_range(prop, 0.0f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Roughness 1", "Amount of location dependent roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "roughness_1_size", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "rough1_size");
  RNA_def_property_range(prop, 0.01f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Size 1", "Size of location dependent roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "roughness_2", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "rough2");
  RNA_def_property_range(prop, 0.0f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Roughness 2", "Amount of random roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "roughness_2_size", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "rough2_size");
  RNA_def_property_range(prop, 0.01f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Size 2", "Size of random roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "roughness_2_threshold", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "rough2_thres");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(
      prop, "Threshold", "Amount of particles left untouched by random roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "roughness_endpoint", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "rough_end");
  RNA_def_property_range(prop, 0.0f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Roughness Endpoint", "Amount of endpoint roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "roughness_end_shape", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "rough_end_shape");
  RNA_def_property_range(prop, 0.0f, 10.0f);
  RNA_def_property_ui_text(prop, "Shape", "Shape of endpoint roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_roughness_curve", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_ROUGH_CURVE);
  RNA_def_property_ui_text(prop, "Use Roughness Curve", "Use a curve to define roughness");
  RNA_def_property_update(prop, 0, "rna_ParticleSettings_use_roughness_curve_update");

  prop = RNA_def_property(srna, "roughness_curve", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "roughcurve");
  RNA_def_property_struct_type(prop, "CurveMapping");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Roughness Curve", "Curve defining roughness");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "child_length", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "clength");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Length", "Length of child paths");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "child_length_threshold", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "clength_thres");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(
      prop, "Threshold", "Amount of particles left untouched by child path length");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* parting */
  prop = RNA_def_property(srna, "child_parting_factor", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "parting_fac");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(
      prop, "Parting Factor", "Create parting in the children based on parent strands");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "child_parting_min", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "parting_min");
  RNA_def_property_range(prop, 0.0f, 180.0f);
  RNA_def_property_ui_text(prop,
                           "Parting Minimum",
                           "Minimum root to tip angle (tip distance/root distance for long hair)");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "child_parting_max", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "parting_max");
  RNA_def_property_range(prop, 0.0f, 180.0f);
  RNA_def_property_ui_text(prop,
                           "Parting Maximum",
                           "Maximum root to tip angle (tip distance/root distance for long hair)");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* branching */
  prop = RNA_def_property(srna, "branch_threshold", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_float_sdna(prop, NULL, "branch_thres");
  RNA_def_property_range(prop, 0.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Threshold", "Threshold of branching");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* drawing stuff */
  prop = RNA_def_property(srna, "line_length_tail", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_funcs(
      prop, "rna_PartSetting_linelentail_get", "rna_PartSetting_linelentail_set", NULL);
  RNA_def_property_range(prop, 0.0f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Tail", "Length of the line's tail");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "line_length_head", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_funcs(
      prop, "rna_PartSetting_linelenhead_get", "rna_PartSetting_linelenhead_set", NULL);
  RNA_def_property_range(prop, 0.0f, 100000.0f);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Head", "Length of the line's head");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "path_start", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "path_start");
  RNA_def_property_float_funcs(prop, NULL, NULL, "rna_PartSetting_pathstartend_range");
  RNA_def_property_ui_text(prop, "Path Start", "Starting time of path");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "path_end", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "path_end");
  RNA_def_property_float_funcs(prop, NULL, NULL, "rna_PartSetting_pathstartend_range");
  RNA_def_property_ui_text(prop, "Path End", "End time of path");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "trail_count", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "trail_count");
  RNA_def_property_range(prop, 1, 100000);
  RNA_def_property_ui_range(prop, 1, 100, 1, -1);
  RNA_def_property_ui_text(prop, "Trail Count", "Number of trail particles");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  /* keyed particles */
  prop = RNA_def_property(srna, "keyed_loops", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "keyed_loops");
  RNA_def_property_range(prop, 1.0f, 10000.0f);
  RNA_def_property_ui_range(prop, 1.0f, 100.0f, 1, 3);
  RNA_def_property_ui_text(prop, "Loop Count", "Number of times the keys are looped");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  /* Evaluated mesh support. */
  prop = RNA_def_property(srna, "use_modifier_stack", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "use_modifier_stack", 0);
  RNA_def_property_ui_text(
      prop,
      "Use Modifier Stack",
      "Emit particles from mesh with modifiers applied "
      "(must use same subdivision surface level for viewport and render for correct results)");
  RNA_def_property_update(prop, 0, "rna_Particle_change_type");

  /* draw objects & collections */
  prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "instance_collection");
  RNA_def_property_struct_type(prop, "Collection");
  RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(
      prop, "Instance Collection", "Show objects in this collection in place of particles");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_count");

  prop = RNA_def_property(srna, "instance_weights", PROP_COLLECTION, PROP_NONE);
  RNA_def_property_collection_sdna(prop, NULL, "instance_weights", NULL);
  RNA_def_property_struct_type(prop, "ParticleDupliWeight");
  RNA_def_property_ui_text(prop,
                           "Instance Collection Weights",
                           "Weights for all of the objects in the instance collection");

  prop = RNA_def_property(srna, "active_instanceweight", PROP_POINTER, PROP_NONE);
  RNA_def_property_struct_type(prop, "ParticleDupliWeight");
  RNA_def_property_pointer_funcs(prop, "rna_ParticleDupliWeight_active_get", NULL, NULL, NULL);
  RNA_def_property_ui_text(prop, "Active Instance Object", "");

  prop = RNA_def_property(srna, "active_instanceweight_index", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_int_funcs(prop,
                             "rna_ParticleDupliWeight_active_index_get",
                             "rna_ParticleDupliWeight_active_index_set",
                             "rna_ParticleDupliWeight_active_index_range");
  RNA_def_property_ui_text(prop, "Active Instance Object Index", "");

  prop = RNA_def_property(srna, "instance_object", PROP_POINTER, PROP_NONE);
  RNA_def_property_struct_type(prop, "Object");
  RNA_def_property_flag(prop, PROP_EDITABLE);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(prop, "Instance Object", "Show this object in place of particles");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_dependency");

  /* boids */
  prop = RNA_def_property(srna, "boids", PROP_POINTER, PROP_NONE);
  RNA_def_property_struct_type(prop, "BoidSettings");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Boid Settings", "");

  /* Fluid particles */
  prop = RNA_def_property(srna, "fluid", PROP_POINTER, PROP_NONE);
  RNA_def_property_struct_type(prop, "SPHFluidSettings");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "SPH Fluid Settings", "");

  /* Effector weights */
  prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
  RNA_def_property_struct_type(prop, "EffectorWeights");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(prop, "Effector Weights", "");

  /* animation here? */
  rna_def_animdata_common(srna);

  prop = RNA_def_property(srna, "force_field_1", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "pd");
  RNA_def_property_struct_type(prop, "FieldSettings");
  RNA_def_property_pointer_funcs(prop, "rna_Particle_field1_get", NULL, NULL, NULL);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(prop, "Force Field 1", "");

  prop = RNA_def_property(srna, "force_field_2", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "pd2");
  RNA_def_property_struct_type(prop, "FieldSettings");
  RNA_def_property_pointer_funcs(prop, "rna_Particle_field2_get", NULL, NULL, NULL);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(prop, "Force Field 2", "");

  /* twist */
  prop = RNA_def_property(srna, "twist", PROP_FLOAT, PROP_NONE);
  RNA_def_property_range(prop, -100000.0f, 100000.0f);
  RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 3);
  RNA_def_property_ui_text(prop, "Twist", "Number of turns around parent along the strand");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "use_twist_curve", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_TWIST_CURVE);
  RNA_def_property_ui_text(prop, "Use Twist Curve", "Use a curve to define twist");
  RNA_def_property_update(prop, 0, "rna_ParticleSettings_use_twist_curve_update");

  prop = RNA_def_property(srna, "twist_curve", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "twistcurve");
  RNA_def_property_struct_type(prop, "CurveMapping");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Twist Curve", "Curve defining twist");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* hair shape */
  prop = RNA_def_property(srna, "use_close_tip", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "shape_flag", PART_SHAPE_CLOSE_TIP);
  RNA_def_property_ui_text(prop, "Close Tip", "Set tip radius to zero");
  RNA_def_property_update(
      prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */

  prop = RNA_def_property(srna, "shape", PROP_FLOAT, PROP_FACTOR);
  RNA_def_property_range(prop, -1.0f, 1.0f);
  RNA_def_property_ui_text(prop, "Shape", "Strand shape parameter");
  RNA_def_property_update(
      prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */

  prop = RNA_def_property(srna, "root_radius", PROP_FLOAT, PROP_DISTANCE);
  RNA_def_property_float_sdna(prop, NULL, "rad_root");
  RNA_def_property_range(prop, 0.0f, FLT_MAX);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
  RNA_def_property_ui_text(prop, "Root Diameter", "Strand diameter width at the root");
  RNA_def_property_update(
      prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */

  prop = RNA_def_property(srna, "tip_radius", PROP_FLOAT, PROP_DISTANCE);
  RNA_def_property_float_sdna(prop, NULL, "rad_tip");
  RNA_def_property_range(prop, 0.0f, FLT_MAX);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
  RNA_def_property_ui_text(prop, "Tip Diameter", "Strand diameter width at the tip");
  RNA_def_property_update(
      prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */

  prop = RNA_def_property(srna, "radius_scale", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "rad_scale");
  RNA_def_property_range(prop, 0.0f, FLT_MAX);
  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
  RNA_def_property_ui_text(prop, "Diameter Scale", "Multiplier of diameter properties");
  RNA_def_property_update(
      prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
}

static void rna_def_particle_target(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  static const EnumPropertyItem mode_items[] = {
      {PTARGET_MODE_FRIEND, "FRIEND", 0, "Friend", ""},
      {PTARGET_MODE_NEUTRAL, "NEUTRAL", 0, "Neutral", ""},
      {PTARGET_MODE_ENEMY, "ENEMY", 0, "Enemy", ""},
      {0, NULL, 0, NULL, NULL},
  };

  srna = RNA_def_struct(brna, "ParticleTarget", NULL);
  RNA_def_struct_ui_text(srna, "Particle Target", "Target particle system");

  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(
      prop, "rna_ParticleTarget_name_get", "rna_ParticleTarget_name_length", NULL);
  RNA_def_property_ui_text(prop, "Name", "Particle target name");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_struct_name_property(srna, prop);

  prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "ob");
  RNA_def_property_flag(prop, PROP_EDITABLE);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(
      prop,
      "Target Object",
      "The object that has the target particle system (empty if same object)");
  RNA_def_property_update(prop, 0, "rna_Particle_target_reset");

  prop = RNA_def_property(srna, "system", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_int_sdna(prop, NULL, "psys");
  RNA_def_property_range(prop, 1, INT_MAX);
  RNA_def_property_ui_text(
      prop, "Target Particle System", "The index of particle system on the target object");
  RNA_def_property_update(prop, 0, "rna_Particle_target_reset");

  prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_TIME);
  RNA_def_property_float_sdna(prop, NULL, "time");
  RNA_def_property_range(prop, 0.0, MAXFRAMEF);
  RNA_def_property_ui_text(prop, "Time", "");
  RNA_def_property_update(prop, 0, "rna_Particle_target_redo");

  prop = RNA_def_property(srna, "duration", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "duration");
  RNA_def_property_range(prop, 0.0, MAXFRAMEF);
  RNA_def_property_ui_text(prop, "Duration", "");
  RNA_def_property_update(prop, 0, "rna_Particle_target_redo");

  prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PTARGET_VALID);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Valid", "Keyed particles target is valid");

  prop = RNA_def_property(srna, "alliance", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_sdna(prop, NULL, "mode");
  RNA_def_property_enum_items(prop, mode_items);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Mode", "");
  RNA_def_property_update(prop, 0, "rna_Particle_target_reset");
}
static void rna_def_particle_system(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  FunctionRNA *func;
  PropertyRNA *parm;

  srna = RNA_def_struct(brna, "ParticleSystem", NULL);
  RNA_def_struct_ui_text(srna, "Particle System", "Particle system in an object");
  RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA);

  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
  RNA_def_property_ui_text(prop, "Name", "Particle system name");
  RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL);
  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ParticleSystem_name_set");
  RNA_def_struct_name_property(srna, prop);

  RNA_define_lib_overridable(true);

  /* access to particle settings is redirected through functions */
  /* to allow proper id-buttons functionality */
  prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
  // RNA_def_property_pointer_sdna(prop, NULL, "part");
  RNA_def_property_struct_type(prop, "ParticleSettings");
  RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
  RNA_def_property_pointer_funcs(
      prop, "rna_particle_settings_get", "rna_particle_settings_set", NULL, NULL);
  RNA_def_property_ui_text(prop, "Settings", "Particle system settings");
  RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");

  prop = RNA_def_property(srna, "particles", PROP_COLLECTION, PROP_NONE);
  RNA_def_property_collection_sdna(prop, NULL, "particles", "totpart");
  RNA_def_property_struct_type(prop, "Particle");
  RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
  RNA_def_property_ui_text(prop, "Particles", "Particles generated by the particle system");

  prop = RNA_def_property(srna, "child_particles", PROP_COLLECTION, PROP_NONE);
  RNA_def_property_collection_sdna(prop, NULL, "child", "totchild");
  RNA_def_property_struct_type(prop, "ChildParticle");
  RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
  RNA_def_property_ui_text(
      prop, "Child Particles", "Child particles generated by the particle system");

  prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_ui_text(
      prop, "Seed", "Offset in the random number table, to get a different randomized result");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "child_seed", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_ui_text(
      prop,
      "Child Seed",
      "Offset in the random number table for child particles, to get a different "
      "randomized result");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* hair */
  prop = RNA_def_property(srna, "is_global_hair", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_GLOBAL_HAIR);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Global Hair", "Hair keys are in global coordinate space");

  prop = RNA_def_property(srna, "use_hair_dynamics", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_HAIR_DYNAMICS);
  RNA_def_property_ui_text(prop, "Hair Dynamics", "Enable hair dynamics using cloth simulation");
  RNA_def_property_update(prop, 0, "rna_Particle_hair_dynamics_update");

  prop = RNA_def_property(srna, "cloth", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "clmd");
  RNA_def_property_struct_type(prop, "ClothModifier");
  RNA_def_property_flag(prop, PROP_NEVER_NULL);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Cloth", "Cloth dynamics for hair");

  /* reactor */
  prop = RNA_def_property(srna, "reactor_target_object", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "target_ob");
  RNA_def_property_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop,
                           "Reactor Target Object",
                           "For reactor systems, the object that has the target particle system "
                           "(empty if same object)");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "reactor_target_particle_system", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_int_sdna(prop, NULL, "target_psys");
  RNA_def_property_range(prop, 1, SHRT_MAX);
  RNA_def_property_ui_text(prop,
                           "Reactor Target Particle System",
                           "For reactor systems, index of particle system on the target object");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  /* keyed */
  prop = RNA_def_property(srna, "use_keyed_timing", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_KEYED_TIMING);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "Keyed Timing", "Use key times");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
  RNA_def_property_struct_type(prop, "ParticleTarget");
  RNA_def_property_ui_text(prop, "Targets", "Target particle systems");

  prop = RNA_def_property(srna, "active_particle_target", PROP_POINTER, PROP_NONE);
  RNA_def_property_struct_type(prop, "ParticleTarget");
  RNA_def_property_pointer_funcs(
      prop, "rna_ParticleSystem_active_particle_target_get", NULL, NULL, NULL);
  RNA_def_property_ui_text(prop, "Active Particle Target", "");

  prop = RNA_def_property(srna, "active_particle_target_index", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_int_funcs(prop,
                             "rna_ParticleSystem_active_particle_target_index_get",
                             "rna_ParticleSystem_active_particle_target_index_set",
                             "rna_ParticleSystem_active_particle_target_index_range");
  RNA_def_property_ui_text(prop, "Active Particle Target Index", "");

  /* vertex groups */

  /* NOTE: internally store as ints, access as strings. */
#  if 0 /* int access. works ok but isn't useful for the UI */
  prop = RNA_def_property(srna, "vertex_group_density", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "vgroup[0]");
  RNA_def_property_ui_text(prop, "Vertex Group Density", "Vertex group to control density");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");
#  endif

  prop = RNA_def_property(srna, "vertex_group_density", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_0",
                                "rna_ParticleVGroup_name_len_0",
                                "rna_ParticleVGroup_name_set_0");
  RNA_def_property_ui_text(prop, "Vertex Group Density", "Vertex group to control density");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "invert_vertex_group_density", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_DENSITY));
  RNA_def_property_ui_text(
      prop, "Vertex Group Density Negate", "Negate the effect of the density vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "vertex_group_velocity", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_1",
                                "rna_ParticleVGroup_name_len_1",
                                "rna_ParticleVGroup_name_set_1");
  RNA_def_property_ui_text(prop, "Vertex Group Velocity", "Vertex group to control velocity");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "invert_vertex_group_velocity", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_VEL));
  RNA_def_property_ui_text(
      prop, "Vertex Group Velocity Negate", "Negate the effect of the velocity vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "vertex_group_length", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_2",
                                "rna_ParticleVGroup_name_len_2",
                                "rna_ParticleVGroup_name_set_2");
  RNA_def_property_ui_text(prop, "Vertex Group Length", "Vertex group to control length");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "invert_vertex_group_length", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_LENGTH));
  RNA_def_property_ui_text(
      prop, "Vertex Group Length Negate", "Negate the effect of the length vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  prop = RNA_def_property(srna, "vertex_group_clump", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_3",
                                "rna_ParticleVGroup_name_len_3",
                                "rna_ParticleVGroup_name_set_3");
  RNA_def_property_ui_text(prop, "Vertex Group Clump", "Vertex group to control clump");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "invert_vertex_group_clump", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_CLUMP));
  RNA_def_property_ui_text(
      prop, "Vertex Group Clump Negate", "Negate the effect of the clump vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "vertex_group_kink", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_4",
                                "rna_ParticleVGroup_name_len_4",
                                "rna_ParticleVGroup_name_set_4");
  RNA_def_property_ui_text(prop, "Vertex Group Kink", "Vertex group to control kink");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "invert_vertex_group_kink", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_KINK));
  RNA_def_property_ui_text(
      prop, "Vertex Group Kink Negate", "Negate the effect of the kink vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "vertex_group_roughness_1", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_5",
                                "rna_ParticleVGroup_name_len_5",
                                "rna_ParticleVGroup_name_set_5");
  RNA_def_property_ui_text(
      prop, "Vertex Group Roughness 1", "Vertex group to control roughness 1");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "invert_vertex_group_roughness_1", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGH1));
  RNA_def_property_ui_text(prop,
                           "Vertex Group Roughness 1 Negate",
                           "Negate the effect of the roughness 1 vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "vertex_group_roughness_2", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_6",
                                "rna_ParticleVGroup_name_len_6",
                                "rna_ParticleVGroup_name_set_6");
  RNA_def_property_ui_text(
      prop, "Vertex Group Roughness 2", "Vertex group to control roughness 2");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "invert_vertex_group_roughness_2", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGH2));
  RNA_def_property_ui_text(prop,
                           "Vertex Group Roughness 2 Negate",
                           "Negate the effect of the roughness 2 vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "vertex_group_roughness_end", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_7",
                                "rna_ParticleVGroup_name_len_7",
                                "rna_ParticleVGroup_name_set_7");
  RNA_def_property_ui_text(
      prop, "Vertex Group Roughness End", "Vertex group to control roughness end");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "invert_vertex_group_roughness_end", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGHE));
  RNA_def_property_ui_text(prop,
                           "Vertex Group Roughness End Negate",
                           "Negate the effect of the roughness end vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "vertex_group_size", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_8",
                                "rna_ParticleVGroup_name_len_8",
                                "rna_ParticleVGroup_name_set_8");
  RNA_def_property_ui_text(prop, "Vertex Group Size", "Vertex group to control size");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "invert_vertex_group_size", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_SIZE));
  RNA_def_property_ui_text(
      prop, "Vertex Group Size Negate", "Negate the effect of the size vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "vertex_group_tangent", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_9",
                                "rna_ParticleVGroup_name_len_9",
                                "rna_ParticleVGroup_name_set_9");
  RNA_def_property_ui_text(prop, "Vertex Group Tangent", "Vertex group to control tangent");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "invert_vertex_group_tangent", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_TAN));
  RNA_def_property_ui_text(
      prop, "Vertex Group Tangent Negate", "Negate the effect of the tangent vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "vertex_group_rotation", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_10",
                                "rna_ParticleVGroup_name_len_10",
                                "rna_ParticleVGroup_name_set_10");
  RNA_def_property_ui_text(prop, "Vertex Group Rotation", "Vertex group to control rotation");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "invert_vertex_group_rotation", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROT));
  RNA_def_property_ui_text(
      prop, "Vertex Group Rotation Negate", "Negate the effect of the rotation vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "vertex_group_field", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_11",
                                "rna_ParticleVGroup_name_len_11",
                                "rna_ParticleVGroup_name_set_11");
  RNA_def_property_ui_text(prop, "Vertex Group Field", "Vertex group to control field");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "invert_vertex_group_field", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_EFFECTOR));
  RNA_def_property_ui_text(
      prop, "Vertex Group Field Negate", "Negate the effect of the field vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_reset");

  prop = RNA_def_property(srna, "vertex_group_twist", PROP_STRING, PROP_NONE);
  RNA_def_property_string_funcs(prop,
                                "rna_ParticleVGroup_name_get_12",
                                "rna_ParticleVGroup_name_len_12",
                                "rna_ParticleVGroup_name_set_12");
  RNA_def_property_ui_text(prop, "Vertex Group Twist", "Vertex group to control twist");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  prop = RNA_def_property(srna, "invert_vertex_group_twist", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_TWIST));
  RNA_def_property_ui_text(
      prop, "Vertex Group Twist Negate", "Negate the effect of the twist vertex group");
  RNA_def_property_update(prop, 0, "rna_Particle_redo_child");

  /* pointcache */
  prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
  RNA_def_property_flag(prop, PROP_NEVER_NULL);
  RNA_def_property_pointer_sdna(prop, NULL, "pointcache");
  RNA_def_property_struct_type(prop, "PointCache");
  RNA_def_property_ui_text(prop, "Point Cache", "");

  prop = RNA_def_property(srna, "has_multiple_caches", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_multiple_caches_get", NULL);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Multiple Caches", "Particle system has multiple point caches");

  /* offset ob */
  prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "parent");
  RNA_def_property_flag(prop, PROP_EDITABLE);
  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
  RNA_def_property_ui_text(
      prop, "Parent", "Use this object's coordinate system instead of global coordinate system");
  RNA_def_property_update(prop, 0, "rna_Particle_redo");

  /* hair or cache editing */
  prop = RNA_def_property(srna, "is_editable", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_editable_get", NULL);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Editable", "Particle system can be edited in particle mode");

  prop = RNA_def_property(srna, "is_edited", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_edited_get", NULL);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop, "Edited", "Particle system has been edited in particle mode");

  /* Read-only: this is calculated internally. Changing it would only affect
   * the next time-step. The user should change ParticlSettings.subframes or
   * ParticleSettings.courant_target instead. */
  prop = RNA_def_property(srna, "dt_frac", PROP_FLOAT, PROP_NONE);
  RNA_def_property_range(prop, 1.0f / 101.0f, 1.0f);
  RNA_def_property_ui_text(
      prop, "Timestep", "The current simulation time step size, as a fraction of a frame");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);

  RNA_define_lib_overridable(false);

  RNA_def_struct_path_func(srna, "rna_ParticleSystem_path");

  /* extract cached hair location data */
  func = RNA_def_function(srna, "co_hair", "rna_ParticleSystem_co_hair");
  RNA_def_function_ui_description(func, "Obtain cache hair data");
  parm = RNA_def_pointer(func, "object", "Object", "", "Object");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  RNA_def_int(func, "particle_no", 0, INT_MIN, INT_MAX, "Particle no", "", INT_MIN, INT_MAX);
  RNA_def_int(func, "step", 0, INT_MIN, INT_MAX, "step no", "", INT_MIN, INT_MAX);
  parm = RNA_def_float_vector(
      func, "co", 3, NULL, -FLT_MAX, FLT_MAX, "Co", "Exported hairkey location", -1e4, 1e4);
  RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
  RNA_def_function_output(func, parm);

  /* extract hair UVs */
  func = RNA_def_function(srna, "uv_on_emitter", "rna_ParticleSystem_uv_on_emitter");
  RNA_def_function_ui_description(func, "Obtain uv for all particles");
  RNA_def_function_flag(func, FUNC_USE_REPORTS);
  parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_pointer(func, "particle", "Particle", "", "Particle");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  RNA_def_int(func, "particle_no", 0, INT_MIN, INT_MAX, "Particle no", "", INT_MIN, INT_MAX);
  RNA_def_int(func, "uv_no", 0, INT_MIN, INT_MAX, "UV no", "", INT_MIN, INT_MAX);
  parm = RNA_def_property(func, "uv", PROP_FLOAT, PROP_COORDS);
  RNA_def_property_array(parm, 2);
  RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
  RNA_def_function_output(func, parm);

  /* extract hair mcols */
  func = RNA_def_function(srna, "mcol_on_emitter", "rna_ParticleSystem_mcol_on_emitter");
  RNA_def_function_flag(func, FUNC_USE_REPORTS);
  RNA_def_function_ui_description(func, "Obtain mcol for all particles");
  parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  parm = RNA_def_pointer(func, "particle", "Particle", "", "Particle");
  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
  RNA_def_int(func, "particle_no", 0, INT_MIN, INT_MAX, "Particle no", "", INT_MIN, INT_MAX);
  RNA_def_int(func, "vcol_no", 0, INT_MIN, INT_MAX, "vcol no", "", INT_MIN, INT_MAX);
  parm = RNA_def_property(func, "mcol", PROP_FLOAT, PROP_COLOR);
  RNA_def_property_array(parm, 3);
  RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
  RNA_def_function_output(func, parm);
}

void RNA_def_particle(BlenderRNA *brna)
{
  rna_def_particle_target(brna);
  rna_def_fluid_settings(brna);
  rna_def_particle_hair_key(brna);
  rna_def_particle_key(brna);

  rna_def_child_particle(brna);
  rna_def_particle(brna);
  rna_def_particle_dupliweight(brna);
  rna_def_particle_system(brna);
  rna_def_particle_settings_mtex(brna);
  rna_def_particle_settings(brna);
}

#endif