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
|
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/** \file
* \ingroup blenloader
*/
/* allow readfile to use deprecated functionality */
#define DNA_DEPRECATED_ALLOW
#include <string.h>
#include <float.h>
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_mempool.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
#include "DNA_collection_types.h"
#include "DNA_constraint_types.h"
#include "DNA_gpu_types.h"
#include "DNA_light_types.h"
#include "DNA_layer_types.h"
#include "DNA_lightprobe_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
#include "DNA_genfile.h"
#include "DNA_gpencil_types.h"
#include "DNA_workspace_types.h"
#include "DNA_key_types.h"
#include "DNA_curve_types.h"
#include "DNA_armature_types.h"
#include "DNA_text_types.h"
#include "BKE_action.h"
#include "BKE_animsys.h"
#include "BKE_cloth.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
#include "BKE_colortools.h"
#include "BKE_customdata.h"
#include "BKE_fcurve.h"
#include "BKE_freestyle.h"
#include "BKE_gpencil.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_library.h"
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_pointcache.h"
#include "BKE_report.h"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
#include "BKE_studiolight.h"
#include "BKE_unit.h"
#include "BKE_workspace.h"
/* Only for IMB_BlendMode */
#include "IMB_imbuf.h"
#include "DEG_depsgraph.h"
#include "BLT_translation.h"
#include "BLO_readfile.h"
#include "readfile.h"
#include "MEM_guardedalloc.h"
static bScreen *screen_parent_find(const bScreen *screen)
{
/* Can avoid lookup if screen state isn't maximized/full
* (parent and child store the same state). */
if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) {
for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->full && sa->full != screen) {
BLI_assert(sa->full->state == screen->state);
return sa->full;
}
}
}
return NULL;
}
static void do_version_workspaces_create_from_screens(Main *bmain)
{
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
const bScreen *screen_parent = screen_parent_find(screen);
WorkSpace *workspace;
if (screen->temp) {
continue;
}
if (screen_parent) {
/* Full-screen with "Back to Previous" option, don't create
* a new workspace, add layout workspace containing parent. */
workspace = BLI_findstring(
&bmain->workspaces, screen_parent->id.name + 2, offsetof(ID, name) + 2);
}
else {
workspace = BKE_workspace_add(bmain, screen->id.name + 2);
}
if (workspace == NULL) {
continue; /* Not much we can do.. */
}
BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2);
}
}
static void do_version_area_change_space_to_space_action(ScrArea *area, const Scene *scene)
{
SpaceType *stype = BKE_spacetype_from_id(SPACE_ACTION);
SpaceAction *saction = (SpaceAction *)stype->new (area, scene);
ARegion *region_channels;
/* Properly free current regions */
for (ARegion *region = area->regionbase.first; region; region = region->next) {
BKE_area_region_free(area->type, region);
}
BLI_freelistN(&area->regionbase);
area->type = stype;
area->spacetype = stype->spaceid;
BLI_addhead(&area->spacedata, saction);
area->regionbase = saction->regionbase;
BLI_listbase_clear(&saction->regionbase);
/* Different defaults for timeline */
region_channels = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS);
region_channels->flag |= RGN_FLAG_HIDDEN;
saction->mode = SACTCONT_TIMELINE;
saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED;
saction->ads.filterflag |= ADS_FILTER_SUMMARY;
}
/**
* \brief After lib-link versioning for new workspace design.
*
* - Adds a workspace for (almost) each screen of the old file
* and adds the needed workspace-layout to wrap the screen.
* - Active screen isn't stored directly in window anymore, but in the active workspace.
* - Active scene isn't stored in screen anymore, but in window.
* - Create workspace instance hook for each window.
*
* \note Some of the created workspaces might be deleted again
* in case of reading the default `startup.blend`.
*/
static void do_version_workspaces_after_lib_link(Main *bmain)
{
BLI_assert(BLI_listbase_is_empty(&bmain->workspaces));
do_version_workspaces_create_from_screens(bmain);
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
for (wmWindow *win = wm->windows.first; win; win = win->next) {
bScreen *screen_parent = screen_parent_find(win->screen);
bScreen *screen = screen_parent ? screen_parent : win->screen;
if (screen->temp) {
/* We do not generate a new workspace for those screens...
* still need to set some data in win. */
win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
win->scene = screen->scene;
/* Deprecated from now on! */
win->screen = NULL;
continue;
}
WorkSpace *workspace = BLI_findstring(
&bmain->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
BLI_assert(workspace != NULL);
WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, win->screen);
BLI_assert(layout != NULL);
win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
BKE_workspace_active_set(win->workspace_hook, workspace);
BKE_workspace_active_layout_set(win->workspace_hook, layout);
/* Move scene and view layer to window. */
Scene *scene = screen->scene;
ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay);
if (!layer) {
layer = BKE_view_layer_default_view(scene);
}
win->scene = scene;
STRNCPY(win->view_layer_name, layer->name);
/* Deprecated from now on! */
win->screen = NULL;
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
/* Deprecated from now on! */
BLI_freelistN(&screen->scene->transform_spaces);
screen->scene = NULL;
}
}
#ifdef USE_COLLECTION_COMPAT_28
enum {
COLLECTION_DEPRECATED_VISIBLE = (1 << 0),
COLLECTION_DEPRECATED_VIEWPORT = (1 << 0),
COLLECTION_DEPRECATED_SELECTABLE = (1 << 1),
COLLECTION_DEPRECATED_DISABLED = (1 << 2),
COLLECTION_DEPRECATED_RENDER = (1 << 3),
};
static void do_version_view_layer_visibility(ViewLayer *view_layer)
{
/* Convert from deprecated VISIBLE flag to DISABLED */
LayerCollection *lc;
for (lc = view_layer->layer_collections.first; lc; lc = lc->next) {
if (lc->flag & COLLECTION_DEPRECATED_DISABLED) {
lc->flag &= ~COLLECTION_DEPRECATED_DISABLED;
}
if ((lc->flag & COLLECTION_DEPRECATED_VISIBLE) == 0) {
lc->flag |= COLLECTION_DEPRECATED_DISABLED;
}
lc->flag |= COLLECTION_DEPRECATED_VIEWPORT | COLLECTION_DEPRECATED_RENDER;
}
}
static void do_version_layer_collection_pre(ViewLayer *view_layer,
ListBase *lb,
GSet *enabled_set,
GSet *selectable_set)
{
/* Convert from deprecated DISABLED to new layer collection and collection flags */
for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
if (lc->scene_collection) {
if (!(lc->flag & COLLECTION_DEPRECATED_DISABLED)) {
BLI_gset_insert(enabled_set, lc->scene_collection);
}
if (lc->flag & COLLECTION_DEPRECATED_SELECTABLE) {
BLI_gset_insert(selectable_set, lc->scene_collection);
}
}
do_version_layer_collection_pre(
view_layer, &lc->layer_collections, enabled_set, selectable_set);
}
}
static void do_version_layer_collection_post(ViewLayer *view_layer,
ListBase *lb,
GSet *enabled_set,
GSet *selectable_set,
GHash *collection_map)
{
/* Apply layer collection exclude flags. */
for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
if (!(lc->collection->flag & COLLECTION_IS_MASTER)) {
SceneCollection *sc = BLI_ghash_lookup(collection_map, lc->collection);
const bool enabled = (sc && BLI_gset_haskey(enabled_set, sc));
const bool selectable = (sc && BLI_gset_haskey(selectable_set, sc));
if (!enabled) {
lc->flag |= LAYER_COLLECTION_EXCLUDE;
}
if (enabled && !selectable) {
lc->collection->flag |= COLLECTION_RESTRICT_SELECT;
}
}
do_version_layer_collection_post(
view_layer, &lc->layer_collections, enabled_set, selectable_set, collection_map);
}
}
static void do_version_scene_collection_convert(
Main *bmain, ID *id, SceneCollection *sc, Collection *collection, GHash *collection_map)
{
if (collection_map) {
BLI_ghash_insert(collection_map, collection, sc);
}
for (SceneCollection *nsc = sc->scene_collections.first; nsc;) {
SceneCollection *nsc_next = nsc->next;
Collection *ncollection = BKE_collection_add(bmain, collection, nsc->name);
ncollection->id.lib = id->lib;
do_version_scene_collection_convert(bmain, id, nsc, ncollection, collection_map);
nsc = nsc_next;
}
for (LinkData *link = sc->objects.first; link; link = link->next) {
Object *ob = link->data;
if (ob) {
BKE_collection_object_add(bmain, collection, ob);
id_us_min(&ob->id);
}
}
BLI_freelistN(&sc->objects);
MEM_freeN(sc);
}
static void do_version_group_collection_to_collection(Main *bmain, Collection *group)
{
/* Convert old 2.8 group collections to new unified collections. */
if (group->collection) {
do_version_scene_collection_convert(bmain, &group->id, group->collection, group, NULL);
}
group->collection = NULL;
group->view_layer = NULL;
id_fake_user_set(&group->id);
}
static void do_version_scene_collection_to_collection(Main *bmain, Scene *scene)
{
/* Convert old 2.8 scene collections to new unified collections. */
/* Temporarily clear view layers so we don't do any layer collection syncing
* and destroy old flags that we want to restore. */
ListBase view_layers = scene->view_layers;
BLI_listbase_clear(&scene->view_layers);
if (!scene->master_collection) {
scene->master_collection = BKE_collection_master_add();
}
/* Convert scene collections. */
GHash *collection_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
if (scene->collection) {
do_version_scene_collection_convert(
bmain, &scene->id, scene->collection, scene->master_collection, collection_map);
scene->collection = NULL;
}
scene->view_layers = view_layers;
/* Convert layer collections. */
ViewLayer *view_layer;
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
GSet *enabled_set = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
GSet *selectable_set = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
do_version_layer_collection_pre(
view_layer, &view_layer->layer_collections, enabled_set, selectable_set);
BKE_layer_collection_sync(scene, view_layer);
do_version_layer_collection_post(
view_layer, &view_layer->layer_collections, enabled_set, selectable_set, collection_map);
BLI_gset_free(enabled_set, NULL);
BLI_gset_free(selectable_set, NULL);
BKE_layer_collection_sync(scene, view_layer);
}
BLI_ghash_free(collection_map, NULL, NULL);
}
#endif
static void do_version_layers_to_collections(Main *bmain, Scene *scene)
{
/* Since we don't have access to FileData we check the (always valid) first
* render layer instead. */
if (!scene->master_collection) {
scene->master_collection = BKE_collection_master_add();
}
if (scene->view_layers.first) {
return;
}
/* Create collections from layers. */
Collection *collection_master = scene->master_collection;
Collection *collections[20] = {NULL};
for (int layer = 0; layer < 20; layer++) {
for (Base *base = scene->base.first; base; base = base->next) {
if (base->lay & (1 << layer)) {
/* Create collections when needed only. */
if (collections[layer] == NULL) {
char name[MAX_NAME];
BLI_snprintf(
name, sizeof(collection_master->id.name), DATA_("Collection %d"), layer + 1);
Collection *collection = BKE_collection_add(bmain, collection_master, name);
collection->id.lib = scene->id.lib;
if (collection->id.lib != NULL) {
collection->id.tag |= LIB_TAG_INDIRECT;
}
collections[layer] = collection;
if (!(scene->lay & (1 << layer))) {
collection->flag |= COLLECTION_RESTRICT_VIEWPORT | COLLECTION_RESTRICT_RENDER;
}
}
/* Note usually this would do slow collection syncing for view layers,
* but since no view layers exists yet at this point it's fast. */
BKE_collection_object_add(bmain, collections[layer], base->object);
}
if (base->flag & SELECT) {
base->object->flag |= SELECT;
}
else {
base->object->flag &= ~SELECT;
}
}
}
/* Handle legacy render layers. */
bool have_override = false;
const bool need_default_renderlayer = scene->r.layers.first == NULL;
for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
ViewLayer *view_layer = BKE_view_layer_add(scene, srl->name);
if (srl->layflag & SCE_LAY_DISABLE) {
view_layer->flag &= ~VIEW_LAYER_RENDER;
}
if ((srl->layflag & SCE_LAY_FRS) == 0) {
view_layer->flag &= ~VIEW_LAYER_FREESTYLE;
}
view_layer->layflag = srl->layflag;
view_layer->passflag = srl->passflag;
view_layer->pass_alpha_threshold = srl->pass_alpha_threshold;
view_layer->samples = srl->samples;
view_layer->mat_override = srl->mat_override;
BKE_freestyle_config_free(&view_layer->freestyle_config, true);
view_layer->freestyle_config = srl->freestyleConfig;
view_layer->id_properties = srl->prop;
/* Set exclusion and overrides. */
for (int layer = 0; layer < 20; layer++) {
Collection *collection = collections[layer];
if (collection) {
LayerCollection *lc = BKE_layer_collection_first_from_scene_collection(view_layer,
collection);
if (srl->lay_exclude & (1 << layer)) {
/* Disable excluded layer. */
have_override = true;
lc->flag |= LAYER_COLLECTION_EXCLUDE;
for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
nlc->flag |= LAYER_COLLECTION_EXCLUDE;
}
}
else {
if (srl->lay_zmask & (1 << layer)) {
have_override = true;
lc->flag |= LAYER_COLLECTION_HOLDOUT;
}
if ((srl->lay & (1 << layer)) == 0) {
have_override = true;
lc->flag |= LAYER_COLLECTION_INDIRECT_ONLY;
}
}
}
}
/* for convenience set the same active object in all the layers */
if (scene->basact) {
view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
}
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) {
base->flag |= BASE_SELECTED;
}
}
}
BLI_freelistN(&scene->r.layers);
/* If render layers included overrides, or there are no render layers,
* we also create a vanilla viewport layer. */
if (have_override || need_default_renderlayer) {
ViewLayer *view_layer = BKE_view_layer_add(scene, "Viewport");
/* If we ported all the original render layers,
* we don't need to make the viewport layer renderable. */
if (!BLI_listbase_is_single(&scene->view_layers)) {
view_layer->flag &= ~VIEW_LAYER_RENDER;
}
/* convert active base */
if (scene->basact) {
view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
}
/* convert selected bases */
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) {
base->flag |= BASE_SELECTED;
}
/* keep lay around for forward compatibility (open those files in 2.79) */
base->lay = base->object->lay;
}
}
/* remove bases once and for all */
for (Base *base = scene->base.first; base; base = base->next) {
id_us_min(&base->object->id);
}
BLI_freelistN(&scene->base);
scene->basact = NULL;
}
static void do_version_collection_propagate_lib_to_children(Collection *collection)
{
if (collection->id.lib != NULL) {
for (CollectionChild *collection_child = collection->children.first; collection_child != NULL;
collection_child = collection_child->next) {
if (collection_child->collection->id.lib == NULL) {
collection_child->collection->id.lib = collection->id.lib;
}
do_version_collection_propagate_lib_to_children(collection_child->collection);
}
}
}
/** convert old annotations colors */
static void do_versions_fix_annotations(bGPdata *gpd)
{
for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
/* fix layers */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* unlock/unhide layer */
gpl->flag &= ~GP_LAYER_LOCKED;
gpl->flag &= ~GP_LAYER_HIDE;
/* set opacity to 1 */
gpl->opacity = 1.0f;
/* disable tint */
gpl->tintcolor[3] = 0.0f;
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
if ((gps->colorname[0] != '\0') && (STREQ(gps->colorname, palcolor->info))) {
/* copy color settings */
copy_v4_v4(gpl->color, palcolor->color);
}
}
}
}
}
}
}
static void do_versions_remove_region(ListBase *regionbase, int regiontype)
{
ARegion *ar, *ar_next;
for (ar = regionbase->first; ar; ar = ar_next) {
ar_next = ar->next;
if (ar->regiontype == regiontype) {
BLI_freelinkN(regionbase, ar);
}
}
}
static ARegion *do_versions_find_region_or_null(ListBase *regionbase, int regiontype)
{
for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == regiontype) {
return ar;
}
}
return NULL;
}
static ARegion *do_versions_find_region(ListBase *regionbase, int regiontype)
{
ARegion *ar = do_versions_find_region_or_null(regionbase, regiontype);
if (ar == NULL) {
BLI_assert(!"Did not find expected region in versioning");
}
return ar;
}
static ARegion *do_versions_add_region(int regiontype, const char *name)
{
ARegion *ar = MEM_callocN(sizeof(ARegion), name);
ar->regiontype = regiontype;
return ar;
}
static void do_version_bones_split_bbone_scale(ListBase *lb)
{
for (Bone *bone = lb->first; bone; bone = bone->next) {
bone->scale_in_y = bone->scale_in_x;
bone->scale_out_y = bone->scale_out_x;
do_version_bones_split_bbone_scale(&bone->childbase);
}
}
static void do_version_bones_inherit_scale(ListBase *lb)
{
for (Bone *bone = lb->first; bone; bone = bone->next) {
if (bone->flag & BONE_NO_SCALE) {
bone->inherit_scale_mode = BONE_INHERIT_SCALE_NONE_LEGACY;
bone->flag &= ~BONE_NO_SCALE;
}
do_version_bones_inherit_scale(&bone->childbase);
}
}
static bool replace_bbone_scale_rnapath(char **p_old_path)
{
char *old_path = *p_old_path;
if (old_path == NULL) {
return false;
}
if (BLI_str_endswith(old_path, "bbone_scalein") ||
BLI_str_endswith(old_path, "bbone_scaleout")) {
*p_old_path = BLI_strdupcat(old_path, "x");
MEM_freeN(old_path);
return true;
}
return false;
}
static void do_version_bbone_scale_fcurve_fix(ListBase *curves, FCurve *fcu)
{
/* Update driver variable paths. */
if (fcu->driver) {
LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
replace_bbone_scale_rnapath(&dtar->rna_path);
}
DRIVER_TARGETS_LOOPER_END;
}
}
/* Update F-Curve's path. */
if (replace_bbone_scale_rnapath(&fcu->rna_path)) {
/* If matched, duplicate the curve and tweak name. */
FCurve *second = copy_fcurve(fcu);
second->rna_path[strlen(second->rna_path) - 1] = 'y';
BLI_insertlinkafter(curves, fcu, second);
/* Add to the curve group. */
second->grp = fcu->grp;
if (fcu->grp != NULL && fcu->grp->channels.last == fcu) {
fcu->grp->channels.last = second;
}
}
}
static void do_version_bbone_scale_animdata_cb(ID *UNUSED(id),
AnimData *adt,
void *UNUSED(wrapper_data))
{
LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &adt->drivers) {
do_version_bbone_scale_fcurve_fix(&adt->drivers, fcu);
}
}
static void do_version_constraints_maintain_volume_mode_uniform(ListBase *lb)
{
for (bConstraint *con = lb->first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_SAMEVOL) {
bSameVolumeConstraint *data = (bSameVolumeConstraint *)con->data;
data->mode = SAMEVOL_UNIFORM;
}
}
}
static void do_version_constraints_copy_scale_power(ListBase *lb)
{
for (bConstraint *con = lb->first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_SIZELIKE) {
bSizeLikeConstraint *data = (bSizeLikeConstraint *)con->data;
data->power = 1.0f;
}
}
}
static void do_versions_seq_alloc_transform_and_crop(ListBase *seqbase)
{
for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) == 0) {
if (seq->strip->transform == NULL) {
seq->strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform");
}
if (seq->strip->crop == NULL) {
seq->strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop");
}
if (seq->seqbase.first != NULL) {
do_versions_seq_alloc_transform_and_crop(&seq->seqbase);
}
}
}
}
/* Return true if there is something to convert. */
static void do_versions_material_convert_legacy_blend_mode(bNodeTree *ntree, char blend_method)
{
bool need_update = false;
/* Iterate backwards from end so we don't encounter newly added links. */
bNodeLink *prevlink;
for (bNodeLink *link = ntree->links.last; link; link = prevlink) {
prevlink = link->prev;
/* Detect link to replace. */
bNode *fromnode = link->fromnode;
bNodeSocket *fromsock = link->fromsock;
bNode *tonode = link->tonode;
bNodeSocket *tosock = link->tosock;
if (!(tonode->type == SH_NODE_OUTPUT_MATERIAL && STREQ(tosock->identifier, "Surface"))) {
continue;
}
/* Only do outputs that are enabled for EEVEE */
if (!ELEM(tonode->custom1, SHD_OUTPUT_ALL, SHD_OUTPUT_EEVEE)) {
continue;
}
if (blend_method == 1 /* MA_BM_ADD */) {
nodeRemLink(ntree, link);
bNode *add_node = nodeAddStaticNode(NULL, ntree, SH_NODE_ADD_SHADER);
add_node->locx = 0.5f * (fromnode->locx + tonode->locx);
add_node->locy = 0.5f * (fromnode->locy + tonode->locy);
bNodeSocket *shader1_socket = add_node->inputs.first;
bNodeSocket *shader2_socket = add_node->inputs.last;
bNodeSocket *add_socket = nodeFindSocket(add_node, SOCK_OUT, "Shader");
bNode *transp_node = nodeAddStaticNode(NULL, ntree, SH_NODE_BSDF_TRANSPARENT);
transp_node->locx = add_node->locx;
transp_node->locy = add_node->locy - 110.0f;
bNodeSocket *transp_socket = nodeFindSocket(transp_node, SOCK_OUT, "BSDF");
/* Link to input and material output node. */
nodeAddLink(ntree, fromnode, fromsock, add_node, shader1_socket);
nodeAddLink(ntree, transp_node, transp_socket, add_node, shader2_socket);
nodeAddLink(ntree, add_node, add_socket, tonode, tosock);
need_update = true;
}
else if (blend_method == 2 /* MA_BM_MULTIPLY */) {
nodeRemLink(ntree, link);
bNode *transp_node = nodeAddStaticNode(NULL, ntree, SH_NODE_BSDF_TRANSPARENT);
bNodeSocket *color_socket = nodeFindSocket(transp_node, SOCK_IN, "Color");
bNodeSocket *transp_socket = nodeFindSocket(transp_node, SOCK_OUT, "BSDF");
/* If incomming link is from a closure socket, we need to convert it. */
if (fromsock->type == SOCK_SHADER) {
transp_node->locx = 0.33f * fromnode->locx + 0.66f * tonode->locx;
transp_node->locy = 0.33f * fromnode->locy + 0.66f * tonode->locy;
bNode *shtorgb_node = nodeAddStaticNode(NULL, ntree, SH_NODE_SHADERTORGB);
shtorgb_node->locx = 0.66f * fromnode->locx + 0.33f * tonode->locx;
shtorgb_node->locy = 0.66f * fromnode->locy + 0.33f * tonode->locy;
bNodeSocket *shader_socket = nodeFindSocket(shtorgb_node, SOCK_IN, "Shader");
bNodeSocket *rgba_socket = nodeFindSocket(shtorgb_node, SOCK_OUT, "Color");
nodeAddLink(ntree, fromnode, fromsock, shtorgb_node, shader_socket);
nodeAddLink(ntree, shtorgb_node, rgba_socket, transp_node, color_socket);
}
else {
transp_node->locx = 0.5f * (fromnode->locx + tonode->locx);
transp_node->locy = 0.5f * (fromnode->locy + tonode->locy);
nodeAddLink(ntree, fromnode, fromsock, transp_node, color_socket);
}
/* Link to input and material output node. */
nodeAddLink(ntree, transp_node, transp_socket, tonode, tosock);
need_update = true;
}
}
if (need_update) {
ntreeUpdateTree(NULL, ntree);
}
}
void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
{
bool use_collection_compat_28 = true;
if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
use_collection_compat_28 = false;
/* Convert group layer visibility flags to hidden nested collection. */
for (Collection *collection = bmain->collections.first; collection;
collection = collection->id.next) {
/* Add fake user for all existing groups. */
id_fake_user_set(&collection->id);
if (collection->flag & (COLLECTION_RESTRICT_VIEWPORT | COLLECTION_RESTRICT_RENDER)) {
continue;
}
Collection *hidden_collection_array[20] = {NULL};
for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob;
cob = cob_next) {
cob_next = cob->next;
Object *ob = cob->ob;
if (!(ob->lay & collection->layer)) {
/* Find or create hidden collection matching object's first layer. */
Collection **collection_hidden = NULL;
int coll_idx = 0;
for (; coll_idx < 20; coll_idx++) {
if (ob->lay & (1 << coll_idx)) {
collection_hidden = &hidden_collection_array[coll_idx];
break;
}
}
BLI_assert(collection_hidden != NULL);
if (*collection_hidden == NULL) {
char name[MAX_ID_NAME];
BLI_snprintf(name, sizeof(name), DATA_("Hidden %d"), coll_idx + 1);
*collection_hidden = BKE_collection_add(bmain, collection, name);
(*collection_hidden)->flag |= COLLECTION_RESTRICT_VIEWPORT |
COLLECTION_RESTRICT_RENDER;
}
BKE_collection_object_add(bmain, *collection_hidden, ob);
BKE_collection_object_remove(bmain, collection, ob, true);
}
}
}
/* We need to assign lib pointer to generated hidden collections *after* all have been created,
* otherwise we'll end up with several data-blocks sharing same name/library,
* which is FORBIDDEN!
* Note: we need this to be recursive,
* since a child collection may be sorted before its parent in bmain. */
for (Collection *collection = bmain->collections.first; collection != NULL;
collection = collection->id.next) {
do_version_collection_propagate_lib_to_children(collection);
}
/* Convert layers to collections. */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
do_version_layers_to_collections(bmain, scene);
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
/* same render-layer as do_version_workspaces_after_lib_link will activate,
* so same layer as BKE_view_layer_default_view would return */
ViewLayer *layer = screen->scene->view_layers.first;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *space = sa->spacedata.first; space; space = space->next) {
if (space->spacetype == SPACE_OUTLINER) {
SpaceOutliner *soutliner = (SpaceOutliner *)space;
soutliner->outlinevis = SO_VIEW_LAYER;
if (BLI_listbase_count_at_most(&layer->layer_collections, 2) == 1) {
if (soutliner->treestore == NULL) {
soutliner->treestore = BLI_mempool_create(
sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
}
/* Create a tree store element for the collection. This is normally
* done in check_persistent (outliner_tree.c), but we need to access
* it here :/ (expand element if it's the only one) */
TreeStoreElem *tselem = BLI_mempool_calloc(soutliner->treestore);
tselem->type = TSE_LAYER_COLLECTION;
tselem->id = layer->layer_collections.first;
tselem->nr = tselem->used = 0;
tselem->flag &= ~TSE_CLOSED;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *space = sa->spacedata.first; space; space = space->next) {
if (space->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)space;
if ((sima) && (sima->gpd)) {
sima->gpd->flag |= GP_DATA_ANNOTATIONS;
do_versions_fix_annotations(sima->gpd);
}
}
if (space->spacetype == SPACE_CLIP) {
SpaceClip *spclip = (SpaceClip *)space;
MovieClip *clip = spclip->clip;
if ((clip) && (clip->gpd)) {
clip->gpd->flag |= GP_DATA_ANNOTATIONS;
do_versions_fix_annotations(clip->gpd);
}
}
}
}
}
}
/* New workspace design */
if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
do_version_workspaces_after_lib_link(bmain);
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
/* Cleanup any remaining SceneRenderLayer data for files that were created
* with Blender 2.8 before the SceneRenderLayer > RenderLayer refactor. */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
if (srl->prop) {
IDP_FreeProperty(srl->prop);
}
BKE_freestyle_config_free(&srl->freestyleConfig, true);
}
BLI_freelistN(&scene->r.layers);
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
/* Due to several changes to particle RNA and draw code particles from older files may
* no longer be visible.
* Here we correct this by setting a default draw size for those files. */
for (Object *object = bmain->objects.first; object; object = object->id.next) {
for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
if (psys->part->draw_size == 0.0f) {
psys->part->draw_size = 0.1f;
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 4)) {
for (Object *object = bmain->objects.first; object; object = object->id.next) {
if (object->particlesystem.first) {
object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
if (psys->part->draw & PART_DRAW_EMITTER) {
object->duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER;
break;
}
}
}
else if (object->transflag & OB_DUPLI) {
object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
}
else {
object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT | OB_DUPLI_FLAG_RENDER;
}
}
/* Cleanup deprecated flag from particlesettings data-blocks. */
for (ParticleSettings *part = bmain->particles.first; part; part = part->id.next) {
part->draw &= ~PART_DRAW_EMITTER;
}
}
/* SpaceTime & SpaceLogic removal/replacing */
if (!MAIN_VERSION_ATLEAST(bmain, 280, 9)) {
const wmWindowManager *wm = bmain->wm.first;
const Scene *scene = bmain->scenes.first;
if (wm != NULL) {
/* Action editors need a scene for creation. First, update active
* screens using the active scene of the window they're displayed in.
* Next, update remaining screens using first scene in main listbase. */
for (wmWindow *win = wm->windows.first; win; win = win->next) {
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
do_version_area_change_space_to_space_action(area, win->scene);
/* Don't forget to unset! */
area->butspacetype = SPACE_EMPTY;
}
}
}
}
if (scene != NULL) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
/* Areas that were already handled won't be handled again */
do_version_area_change_space_to_space_action(area, scene);
/* Don't forget to unset! */
area->butspacetype = SPACE_EMPTY;
}
}
}
}
}
#ifdef USE_COLLECTION_COMPAT_28
if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
for (Collection *group = bmain->collections.first; group; group = group->id.next) {
do_version_group_collection_to_collection(bmain, group);
}
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
do_version_scene_collection_to_collection(bmain, scene);
}
}
#endif
/* Update Curve object Shape Key data layout to include the Radius property */
if (!MAIN_VERSION_ATLEAST(bmain, 280, 23)) {
for (Curve *cu = bmain->curves.first; cu; cu = cu->id.next) {
if (!cu->key || cu->key->elemsize != sizeof(float[4])) {
continue;
}
cu->key->elemstr[0] = 3; /*KEYELEM_ELEM_SIZE_CURVE*/
cu->key->elemsize = sizeof(float[3]);
int new_count = BKE_keyblock_curve_element_count(&cu->nurb);
for (KeyBlock *block = cu->key->block.first; block; block = block->next) {
int old_count = block->totelem;
void *old_data = block->data;
if (!old_data || old_count <= 0) {
continue;
}
block->totelem = new_count;
block->data = MEM_callocN(sizeof(float[3]) * new_count, __func__);
float *oldptr = old_data;
float(*newptr)[3] = block->data;
for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
if (nu->bezt) {
BezTriple *bezt = nu->bezt;
for (int a = 0; a < nu->pntsu; a++, bezt++) {
if ((old_count -= 3) < 0) {
memcpy(newptr, bezt->vec, sizeof(float[3][3]));
newptr[3][0] = bezt->tilt;
}
else {
memcpy(newptr, oldptr, sizeof(float[3][4]));
}
newptr[3][1] = bezt->radius;
oldptr += 3 * 4;
newptr += 4; /*KEYELEM_ELEM_LEN_BEZTRIPLE*/
}
}
else if (nu->bp) {
BPoint *bp = nu->bp;
for (int a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
if (--old_count < 0) {
copy_v3_v3(newptr[0], bp->vec);
newptr[1][0] = bp->tilt;
}
else {
memcpy(newptr, oldptr, sizeof(float[4]));
}
newptr[1][1] = bp->radius;
oldptr += 4;
newptr += 2; /*KEYELEM_ELEM_LEN_BPOINT*/
}
}
}
MEM_freeN(old_data);
}
}
}
/* Move B-Bone custom handle settings from bPoseChannel to Bone. */
if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
bArmature *arm = ob->data;
/* If it is an armature from the same file. */
if (ob->pose && arm && arm->id.lib == ob->id.lib) {
bool rebuild = false;
for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* If the 2.7 flag is enabled, processing is needed. */
if (pchan->bone && (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES)) {
/* If the settings in the Bone are not set, copy. */
if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO &&
pchan->bone->bbone_next_type == BBONE_HANDLE_AUTO &&
pchan->bone->bbone_prev == NULL && pchan->bone->bbone_next == NULL) {
pchan->bone->bbone_prev_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_START_REL) ?
BBONE_HANDLE_RELATIVE :
BBONE_HANDLE_ABSOLUTE;
pchan->bone->bbone_next_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_END_REL) ?
BBONE_HANDLE_RELATIVE :
BBONE_HANDLE_ABSOLUTE;
if (pchan->bbone_prev) {
pchan->bone->bbone_prev = pchan->bbone_prev->bone;
}
if (pchan->bbone_next) {
pchan->bone->bbone_next = pchan->bbone_next->bone;
}
}
rebuild = true;
pchan->bboneflag = 0;
}
}
/* Tag pose rebuild for all objects that use this armature. */
if (rebuild) {
for (Object *ob2 = bmain->objects.first; ob2; ob2 = ob2->id.next) {
if (ob2->pose && ob2->data == arm) {
ob2->pose->flag |= POSE_RECALC;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 30)) {
for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
if (brush->gpencil_settings != NULL) {
brush->gpencil_tool = brush->gpencil_settings->brush_type;
}
}
BKE_paint_toolslots_init_from_main(bmain);
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 38)) {
/* Ensure we get valid rigidbody object/constraint data in relevant collections' objects. */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
RigidBodyWorld *rbw = scene->rigidbody_world;
if (rbw == NULL) {
continue;
}
BKE_rigidbody_objects_collection_validate(scene, rbw);
BKE_rigidbody_constraints_collection_validate(scene, rbw);
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 69)) {
/* Unify DOF settings (EEVEE part only) */
const int SCE_EEVEE_DOF_ENABLED = (1 << 7);
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
if (STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE)) {
if (scene->eevee.flag & SCE_EEVEE_DOF_ENABLED) {
Object *cam_ob = scene->camera;
if (cam_ob && cam_ob->type == OB_CAMERA) {
Camera *cam = cam_ob->data;
cam->dof.flag |= CAM_DOF_ENABLED;
}
}
}
}
LISTBASE_FOREACH (Camera *, camera, &bmain->cameras) {
camera->dof.focus_object = camera->dof_ob;
camera->dof.focus_distance = camera->dof_distance;
camera->dof.aperture_fstop = camera->gpu_dof.fstop;
camera->dof.aperture_rotation = camera->gpu_dof.rotation;
camera->dof.aperture_ratio = camera->gpu_dof.ratio;
camera->dof.aperture_blades = camera->gpu_dof.num_blades;
camera->dof_ob = NULL;
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 281, 2)) {
/* Replace Multiply and Additive blend mode by Alpha Blend
* now that we use dualsource blending. */
/* We take care of doing only nodetrees that are always part of materials
* with old blending modes. */
for (Material *ma = bmain->materials.first; ma; ma = ma->id.next) {
bNodeTree *ntree = ma->nodetree;
if (ma->blend_method == 1 /* MA_BM_ADD */) {
if (ma->use_nodes) {
do_versions_material_convert_legacy_blend_mode(ntree, 1 /* MA_BM_ADD */);
}
ma->blend_method = MA_BM_BLEND;
}
else if (ma->blend_method == 2 /* MA_BM_MULTIPLY */) {
if (ma->use_nodes) {
do_versions_material_convert_legacy_blend_mode(ntree, 2 /* MA_BM_MULTIPLY */);
}
ma->blend_method = MA_BM_BLEND;
}
}
}
}
/* NOTE: This version patch is intended for versions < 2.52.2,
* but was initially introduced in 2.27 already.
* But in 2.79 another case generating non-unique names was discovered
* (see T55668, involving Meta strips). */
static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbasep)
{
for (Sequence *seq = seqbasep->first; seq != NULL; seq = seq->next) {
BKE_sequence_base_unique_name_recursive(&sce->ed->seqbase, seq);
if (seq->seqbase.first != NULL) {
do_versions_seq_unique_name_all_strips(sce, &seq->seqbase);
}
}
}
static void do_versions_seq_set_cache_defaults(Editing *ed)
{
ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
ed->cache_flag |= SEQ_CACHE_VIEW_FINAL_OUT;
ed->cache_flag |= SEQ_CACHE_VIEW_ENABLE;
ed->recycle_max_cost = 10.0f;
}
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
bool use_collection_compat_28 = true;
if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
use_collection_compat_28 = false;
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->r.gauss = 1.5f;
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "bleedexp")) {
for (Light *la = bmain->lights.first; la; la = la->id.next) {
la->bleedexp = 2.5f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", "ratio")) {
for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
ca->gpu_dof.ratio = 1.0f;
}
}
/* MTexPoly now removed. */
if (DNA_struct_find(fd->filesdna, "MTexPoly")) {
for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
/* If we have UV's, so this file will have MTexPoly layers too! */
if (me->mloopuv != NULL) {
CustomData_update_typemap(&me->pdata);
CustomData_free_layers(&me->pdata, CD_MTEXPOLY, me->totpoly);
BKE_mesh_update_customdata_pointers(me, false);
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "cascade_max_dist")) {
for (Light *la = bmain->lights.first; la; la = la->id.next) {
la->cascade_max_dist = 1000.0f;
la->cascade_count = 4;
la->cascade_exponent = 0.8f;
la->cascade_fade = 0.1f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "contact_dist")) {
for (Light *la = bmain->lights.first; la; la = la->id.next) {
la->contact_dist = 0.2f;
la->contact_bias = 0.03f;
la->contact_spread = 0.2f;
la->contact_thickness = 0.2f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "vis_bias")) {
for (LightProbe *probe = bmain->lightprobes.first; probe; probe = probe->id.next) {
probe->vis_bias = 1.0f;
probe->vis_blur = 0.2f;
}
}
typedef enum eNTreeDoVersionErrors {
NTREE_DOVERSION_NO_ERROR = 0,
NTREE_DOVERSION_NEED_OUTPUT = (1 << 0),
NTREE_DOVERSION_TRANSPARENCY_EMISSION = (1 << 1),
} eNTreeDoVersionErrors;
/* Eevee shader nodes renamed because of the output node system.
* Note that a new output node is not being added here, because it would be overkill
* to handle this case in lib_verify_nodetree.
*
* Also, metallic node is now unified into the principled node. */
eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR;
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
for (bNode *node = ntree->nodes.first; node; node = node->next) {
if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
STREQ(node->idname, "ShaderNodeOutputMetallic")) {
BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname));
error |= NTREE_DOVERSION_NEED_OUTPUT;
}
else if (node->type == SH_NODE_EEVEE_SPECULAR &&
STREQ(node->idname, "ShaderNodeOutputSpecular")) {
BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname));
error |= NTREE_DOVERSION_NEED_OUTPUT;
}
else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ &&
STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) {
node->type = SH_NODE_OUTPUT_MATERIAL;
BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname));
}
else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
STREQ(node->idname, "ShaderNodeEeveeMetallic")) {
node->type = SH_NODE_BSDF_PRINCIPLED;
BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname));
node->custom1 = SHD_GLOSSY_MULTI_GGX;
error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION;
}
}
}
}
FOREACH_NODETREE_END;
if (error & NTREE_DOVERSION_NEED_OUTPUT) {
BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
printf(
"You need to connect Principled and Eevee Specular shader nodes to new material output "
"nodes.\n");
}
if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) {
BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
printf(
"You need to combine transparency and emission shaders to the converted Principled "
"shader nodes.\n");
}
#ifdef USE_COLLECTION_COMPAT_28
if (use_collection_compat_28 &&
(DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") ==
false) &&
DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
ViewLayer *view_layer;
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
view_layer->flag |= VIEW_LAYER_FREESTYLE;
view_layer->layflag = 0x7FFF; /* solid ztra halo edge strand */
view_layer->passflag = SCE_PASS_COMBINED | SCE_PASS_Z;
view_layer->pass_alpha_threshold = 0.5f;
BKE_freestyle_config_init(&view_layer->freestyle_config);
}
}
}
#endif
{
/* Grease pencil sculpt and paint cursors */
if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "weighttype")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* sculpt brushes */
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if (gset) {
gset->weighttype = GP_SCULPT_TYPE_WEIGHT;
}
}
}
{
float curcolor_add[3], curcolor_sub[3];
ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
GP_Sculpt_Data *gp_brush;
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
/* sculpt brushes */
GP_Sculpt_Settings *gset = &ts->gp_sculpt;
for (int i = 0; i < GP_SCULPT_TYPE_MAX; ++i) {
gp_brush = &gset->brush[i];
gp_brush->flag |= GP_SCULPT_FLAG_ENABLE_CURSOR;
copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
}
}
}
/* Init grease pencil edit line color */
if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "line_color[4]")) {
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f);
}
}
/* Init grease pencil pixel size factor */
if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "pixfactor")) {
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
}
}
/* Grease pencil multiframe falloff curve */
if (!DNA_struct_elem_find(
fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_falloff")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* sculpt brushes */
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if ((gset) && (gset->cur_falloff == NULL)) {
gset->cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
BKE_curvemapping_initialize(gset->cur_falloff);
BKE_curvemap_reset(gset->cur_falloff->cm,
&gset->cur_falloff->clipr,
CURVE_PRESET_GAUSS,
CURVEMAP_SLOPE_POSITIVE);
}
}
}
}
/* 2.79 style Maintain Volume mode. */
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
do_version_constraints_maintain_volume_mode_uniform(&ob->constraints);
if (ob->pose) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
do_version_constraints_maintain_volume_mode_uniform(&pchan->constraints);
}
}
}
}
#ifdef USE_COLLECTION_COMPAT_28
if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
ViewLayer *view_layer;
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
do_version_view_layer_visibility(view_layer);
}
}
for (Collection *group = bmain->collections.first; group; group = group->id.next) {
if (group->view_layer != NULL) {
do_version_view_layer_visibility(group->view_layer);
}
}
}
#endif
if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
/* init grease pencil grids and paper */
if (!DNA_struct_elem_find(
fd->filesdna, "gp_paper_opacity", "float", "gpencil_paper_color[3]")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_paper_opacity = 0.5f;
v3d->overlay.gpencil_grid_opacity = 0.9f;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) {
if (DNA_struct_elem_find(fd->filesdna, "SpaceOutliner", "int", "filter") == false) {
bScreen *sc;
ScrArea *sa;
SpaceLink *sl;
/* Update files using invalid (outdated) outlinevis Outliner values. */
for (sc = bmain->screens.first; sc; sc = sc->id.next) {
for (sa = sc->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
SpaceOutliner *so = (SpaceOutliner *)sl;
if (!ELEM(so->outlinevis,
SO_SCENES,
SO_LIBRARIES,
SO_SEQUENCE,
SO_DATA_API,
SO_ID_ORPHANS)) {
so->outlinevis = SO_VIEW_LAYER;
}
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "intensity")) {
for (LightProbe *probe = bmain->lightprobes.first; probe; probe = probe->id.next) {
probe->intensity = 1.0f;
}
}
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
bConstraint *con, *con_next;
con = ob->constraints.first;
while (con) {
con_next = con->next;
if (con->type == 17) { /* CONSTRAINT_TYPE_RIGIDBODYJOINT */
BLI_remlink(&ob->constraints, con);
BKE_constraint_free_data(con);
MEM_freeN(con);
}
con = con_next;
}
}
for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.light = V3D_LIGHTING_STUDIO;
v3d->shading.flag |= V3D_SHADING_OBJECT_OUTLINE;
/* Assume (demo) files written with 2.8 want to show
* Eevee renders in the viewport. */
if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
v3d->drawtype = OB_MATERIAL;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 7)) {
/* Render engine storage moved elsewhere and back during 2.8
* development, we assume any files saved in 2.8 had Eevee set
* as scene render engine. */
if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 8)) {
/* Blender Internal removal */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (STREQ(scene->r.engine, "BLENDER_RENDER") || STREQ(scene->r.engine, "BLENDER_GAME")) {
BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
}
scene->r.bake_mode = 0;
}
for (Tex *tex = bmain->textures.first; tex; tex = tex->id.next) {
/* Removed envmap, pointdensity, voxeldata, ocean textures. */
if (ELEM(tex->type, 10, 14, 15, 16)) {
tex->type = 0;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
/* Remove info editor, but only if at the top of the window. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
/* Calculate window width/height from screen vertices */
int win_width = 0, win_height = 0;
for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) {
win_width = MAX2(win_width, vert->vec.x);
win_height = MAX2(win_height, vert->vec.y);
}
for (ScrArea *area = screen->areabase.first, *area_next; area; area = area_next) {
area_next = area->next;
if (area->spacetype == SPACE_INFO) {
if ((area->v2->vec.y == win_height) && (area->v1->vec.x == 0) &&
(area->v4->vec.x == win_width)) {
BKE_screen_area_free(area);
BLI_remlink(&screen->areabase, area);
BKE_screen_remove_double_scredges(screen);
BKE_screen_remove_unused_scredges(screen);
BKE_screen_remove_unused_scrverts(screen);
MEM_freeN(area);
}
}
/* AREA_TEMP_INFO is deprecated from now on, it should only be set for info areas
* which are deleted above, so don't need to unset it. Its slot/bit can be reused */
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
for (Light *la = bmain->lights.first; la; la = la->id.next) {
if (la->mode & (1 << 13)) { /* LA_SHAD_RAY */
la->mode |= LA_SHADOW;
la->mode &= ~(1 << 13);
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 12)) {
/* Remove tool property regions. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
for (ARegion *region = regionbase->first, *region_next; region; region = region_next) {
region_next = region->next;
if (region->regiontype == RGN_TYPE_TOOL_PROPS) {
BKE_area_region_free(NULL, region);
BLI_freelinkN(regionbase, region);
}
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 13)) {
/* Initialize specular factor. */
if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "spec_fac")) {
for (Light *la = bmain->lights.first; la; la = la->id.next) {
la->spec_fac = 1.0f;
}
}
/* Initialize new view3D options. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.light = V3D_LIGHTING_STUDIO;
v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR;
copy_v3_fl(v3d->shading.single_color, 0.8f);
v3d->shading.shadow_intensity = 0.5;
v3d->overlay.backwire_opacity = 0.5f;
v3d->overlay.normals_length = 0.1f;
v3d->overlay.flag = 0;
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
if (!DNA_struct_elem_find(fd->filesdna, "Scene", "SceneDisplay", "display")) {
/* Initialize new scene.SceneDisplay */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
copy_v3_v3(scene->display.light_direction, (float[3]){-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3});
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_shift")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->display.shadow_shift = 0.1;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "transform_pivot_point")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->toolsettings->transform_pivot_point = V3D_AROUND_CENTER_MEDIAN;
}
}
if (!DNA_struct_find(fd->filesdna, "SceneEEVEE")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* First set the default for all the properties. */
scene->eevee.gi_diffuse_bounces = 3;
scene->eevee.gi_cubemap_resolution = 512;
scene->eevee.gi_visibility_resolution = 32;
scene->eevee.taa_samples = 16;
scene->eevee.taa_render_samples = 64;
scene->eevee.sss_samples = 7;
scene->eevee.sss_jitter_threshold = 0.3f;
scene->eevee.ssr_quality = 0.25f;
scene->eevee.ssr_max_roughness = 0.5f;
scene->eevee.ssr_thickness = 0.2f;
scene->eevee.ssr_border_fade = 0.075f;
scene->eevee.ssr_firefly_fac = 10.0f;
scene->eevee.volumetric_start = 0.1f;
scene->eevee.volumetric_end = 100.0f;
scene->eevee.volumetric_tile_size = 8;
scene->eevee.volumetric_samples = 64;
scene->eevee.volumetric_sample_distribution = 0.8f;
scene->eevee.volumetric_light_clamp = 0.0f;
scene->eevee.volumetric_shadow_samples = 16;
scene->eevee.gtao_distance = 0.2f;
scene->eevee.gtao_factor = 1.0f;
scene->eevee.gtao_quality = 0.25f;
scene->eevee.bokeh_max_size = 100.0f;
scene->eevee.bokeh_threshold = 1.0f;
copy_v3_fl(scene->eevee.bloom_color, 1.0f);
scene->eevee.bloom_threshold = 0.8f;
scene->eevee.bloom_knee = 0.5f;
scene->eevee.bloom_intensity = 0.05f;
scene->eevee.bloom_radius = 6.5f;
scene->eevee.bloom_clamp = 0.0f;
scene->eevee.motion_blur_samples = 8;
scene->eevee.motion_blur_shutter = 0.5f;
scene->eevee.shadow_method = SHADOW_ESM;
scene->eevee.shadow_cube_size = 512;
scene->eevee.shadow_cascade_size = 1024;
scene->eevee.flag = SCE_EEVEE_VOLUMETRIC_LIGHTS | SCE_EEVEE_GTAO_BENT_NORMALS |
SCE_EEVEE_GTAO_BOUNCE | SCE_EEVEE_TAA_REPROJECTION |
SCE_EEVEE_SSR_HALF_RESOLUTION;
/* If the file is pre-2.80 move on. */
if (scene->layer_properties == NULL) {
continue;
}
/* Now we handle eventual properties that may be set in the file. */
#define EEVEE_GET_BOOL(_props, _name, _flag) \
{ \
IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
if (_idprop != NULL) { \
const int _value = IDP_Int(_idprop); \
if (_value) { \
scene->eevee.flag |= _flag; \
} \
else { \
scene->eevee.flag &= ~_flag; \
} \
} \
} \
((void)0)
#define EEVEE_GET_INT(_props, _name) \
{ \
IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
if (_idprop != NULL) { \
scene->eevee._name = IDP_Int(_idprop); \
} \
} \
((void)0)
#define EEVEE_GET_FLOAT(_props, _name) \
{ \
IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
if (_idprop != NULL) { \
scene->eevee._name = IDP_Float(_idprop); \
} \
} \
((void)0)
#define EEVEE_GET_FLOAT_ARRAY(_props, _name, _length) \
{ \
IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
if (_idprop != NULL) { \
const float *_values = IDP_Array(_idprop); \
for (int _i = 0; _i < _length; _i++) { \
scene->eevee._name[_i] = _values[_i]; \
} \
} \
} \
((void)0)
const int SCE_EEVEE_DOF_ENABLED = (1 << 7);
IDProperty *props = IDP_GetPropertyFromGroup(scene->layer_properties,
RE_engine_id_BLENDER_EEVEE);
// EEVEE_GET_BOOL(props, volumetric_enable, SCE_EEVEE_VOLUMETRIC_ENABLED);
EEVEE_GET_BOOL(props, volumetric_lights, SCE_EEVEE_VOLUMETRIC_LIGHTS);
EEVEE_GET_BOOL(props, volumetric_shadows, SCE_EEVEE_VOLUMETRIC_SHADOWS);
EEVEE_GET_BOOL(props, gtao_enable, SCE_EEVEE_GTAO_ENABLED);
EEVEE_GET_BOOL(props, gtao_use_bent_normals, SCE_EEVEE_GTAO_BENT_NORMALS);
EEVEE_GET_BOOL(props, gtao_bounce, SCE_EEVEE_GTAO_BOUNCE);
EEVEE_GET_BOOL(props, dof_enable, SCE_EEVEE_DOF_ENABLED);
EEVEE_GET_BOOL(props, bloom_enable, SCE_EEVEE_BLOOM_ENABLED);
EEVEE_GET_BOOL(props, motion_blur_enable, SCE_EEVEE_MOTION_BLUR_ENABLED);
EEVEE_GET_BOOL(props, shadow_high_bitdepth, SCE_EEVEE_SHADOW_HIGH_BITDEPTH);
EEVEE_GET_BOOL(props, taa_reprojection, SCE_EEVEE_TAA_REPROJECTION);
// EEVEE_GET_BOOL(props, sss_enable, SCE_EEVEE_SSS_ENABLED);
// EEVEE_GET_BOOL(props, sss_separate_albedo, SCE_EEVEE_SSS_SEPARATE_ALBEDO);
EEVEE_GET_BOOL(props, ssr_enable, SCE_EEVEE_SSR_ENABLED);
EEVEE_GET_BOOL(props, ssr_refraction, SCE_EEVEE_SSR_REFRACTION);
EEVEE_GET_BOOL(props, ssr_halfres, SCE_EEVEE_SSR_HALF_RESOLUTION);
EEVEE_GET_INT(props, gi_diffuse_bounces);
EEVEE_GET_INT(props, gi_diffuse_bounces);
EEVEE_GET_INT(props, gi_cubemap_resolution);
EEVEE_GET_INT(props, gi_visibility_resolution);
EEVEE_GET_INT(props, taa_samples);
EEVEE_GET_INT(props, taa_render_samples);
EEVEE_GET_INT(props, sss_samples);
EEVEE_GET_FLOAT(props, sss_jitter_threshold);
EEVEE_GET_FLOAT(props, ssr_quality);
EEVEE_GET_FLOAT(props, ssr_max_roughness);
EEVEE_GET_FLOAT(props, ssr_thickness);
EEVEE_GET_FLOAT(props, ssr_border_fade);
EEVEE_GET_FLOAT(props, ssr_firefly_fac);
EEVEE_GET_FLOAT(props, volumetric_start);
EEVEE_GET_FLOAT(props, volumetric_end);
EEVEE_GET_INT(props, volumetric_tile_size);
EEVEE_GET_INT(props, volumetric_samples);
EEVEE_GET_FLOAT(props, volumetric_sample_distribution);
EEVEE_GET_FLOAT(props, volumetric_light_clamp);
EEVEE_GET_INT(props, volumetric_shadow_samples);
EEVEE_GET_FLOAT(props, gtao_distance);
EEVEE_GET_FLOAT(props, gtao_factor);
EEVEE_GET_FLOAT(props, gtao_quality);
EEVEE_GET_FLOAT(props, bokeh_max_size);
EEVEE_GET_FLOAT(props, bokeh_threshold);
EEVEE_GET_FLOAT_ARRAY(props, bloom_color, 3);
EEVEE_GET_FLOAT(props, bloom_threshold);
EEVEE_GET_FLOAT(props, bloom_knee);
EEVEE_GET_FLOAT(props, bloom_intensity);
EEVEE_GET_FLOAT(props, bloom_radius);
EEVEE_GET_FLOAT(props, bloom_clamp);
EEVEE_GET_INT(props, motion_blur_samples);
EEVEE_GET_FLOAT(props, motion_blur_shutter);
EEVEE_GET_INT(props, shadow_method);
EEVEE_GET_INT(props, shadow_cube_size);
EEVEE_GET_INT(props, shadow_cascade_size);
/* Cleanup. */
IDP_FreeProperty(scene->layer_properties);
scene->layer_properties = NULL;
#undef EEVEE_GET_FLOAT_ARRAY
#undef EEVEE_GET_FLOAT
#undef EEVEE_GET_INT
#undef EEVEE_GET_BOOL
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 15)) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->display.matcap_ssao_distance = 0.2f;
scene->display.matcap_ssao_attenuation = 1.0f;
scene->display.matcap_ssao_samples = 16;
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
SpaceOutliner *soops = (SpaceOutliner *)sl;
soops->filter_id_type = ID_GR;
soops->outlinevis = SO_VIEW_LAYER;
}
}
}
}
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
switch (scene->toolsettings->snap_mode) {
case 0:
scene->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT;
break;
case 1:
scene->toolsettings->snap_mode = SCE_SNAP_MODE_VERTEX;
break;
case 2:
scene->toolsettings->snap_mode = SCE_SNAP_MODE_EDGE;
break;
case 3:
scene->toolsettings->snap_mode = SCE_SNAP_MODE_FACE;
break;
case 4:
scene->toolsettings->snap_mode = SCE_SNAP_MODE_VOLUME;
break;
}
switch (scene->toolsettings->snap_node_mode) {
case 5:
scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X;
break;
case 6:
scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_Y;
break;
case 7:
scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y;
break;
case 8:
scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
break;
}
switch (scene->toolsettings->snap_uv_mode) {
case 0:
scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_INCREMENT;
break;
case 1:
scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_VERTEX;
break;
}
}
ParticleSettings *part;
for (part = bmain->particles.first; part; part = part->id.next) {
part->shape_flag = PART_SHAPE_CLOSE_TIP;
part->shape = 0.0f;
part->rad_root = 1.0f;
part->rad_tip = 0.0f;
part->rad_scale = 0.01f;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 18)) {
if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "roughness")) {
for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
if (mat->use_nodes) {
if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
mat->roughness = mat->gloss_mir;
}
else {
mat->roughness = 0.25f;
}
}
else {
mat->roughness = 1.0f - mat->gloss_mir;
}
mat->metallic = mat->ray_mirror;
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.xray_alpha = 0.5f;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "matcap[256]")) {
StudioLight *default_matcap = BKE_studiolight_find_default(STUDIOLIGHT_TYPE_MATCAP);
/* when loading the internal file is loaded before the matcaps */
if (default_matcap) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE);
}
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.wireframe_threshold = 0.5f;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "cavity_valley_factor")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.cavity_valley_factor = 1.0f;
v3d->shading.cavity_ridge_factor = 1.0f;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "xray_alpha_bone")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.xray_alpha_bone = 0.5f;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 19)) {
if (!DNA_struct_elem_find(fd->filesdna, "Image", "ListBase", "renderslot")) {
for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
if (ima->type == IMA_TYPE_R_RESULT) {
for (int i = 0; i < 8; i++) {
RenderSlot *slot = MEM_callocN(sizeof(RenderSlot), "Image Render Slot Init");
BLI_snprintf(slot->name, sizeof(slot->name), "Slot %d", i + 1);
BLI_addtail(&ima->renderslots, slot);
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SpaceAction", "char", "mode_prev")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
/* "Dopesheet" should be default here,
* unless it looks like the Action Editor was active instead. */
if ((saction->mode_prev == 0) && (saction->action == NULL)) {
saction->mode_prev = SACTCONT_DOPESHEET;
}
}
}
}
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
if (v3d->drawtype == OB_TEXTURE) {
v3d->drawtype = OB_SOLID;
v3d->shading.light = V3D_LIGHTING_STUDIO;
v3d->shading.color_type = V3D_SHADING_TEXTURE_COLOR;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 21)) {
for (Scene *sce = bmain->scenes.first; sce != NULL; sce = sce->id.next) {
if (sce->ed != NULL && sce->ed->seqbase.first != NULL) {
do_versions_seq_unique_name_all_strips(sce, &sce->ed->seqbase);
}
}
if (!DNA_struct_elem_find(
fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
enum {
V3D_SHOW_MODE_SHADE_OVERRIDE = (1 << 15),
};
View3D *v3d = (View3D *)sl;
float alpha = v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE ? 0.0f : 1.0f;
v3d->overlay.texture_paint_mode_opacity = alpha;
v3d->overlay.vertex_paint_mode_opacity = alpha;
v3d->overlay.weight_paint_mode_opacity = alpha;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "background_type")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
copy_v3_fl(v3d->shading.background_color, 0.05f);
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_cubemap_draw_size")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->eevee.gi_irradiance_draw_size = 0.1f;
scene->eevee.gi_cubemap_draw_size = 0.3f;
}
}
if (!DNA_struct_elem_find(
fd->filesdna, "RigidBodyWorld", "RigidBodyWorld_Shared", "*shared")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
RigidBodyWorld *rbw = scene->rigidbody_world;
if (rbw == NULL) {
continue;
}
if (rbw->shared == NULL) {
rbw->shared = MEM_callocN(sizeof(*rbw->shared), "RigidBodyWorld_Shared");
}
/* Move shared pointers from deprecated location to current location */
rbw->shared->pointcache = rbw->pointcache;
rbw->shared->ptcaches = rbw->ptcaches;
rbw->pointcache = NULL;
BLI_listbase_clear(&rbw->ptcaches);
if (rbw->shared->pointcache == NULL) {
rbw->shared->pointcache = BKE_ptcache_add(&(rbw->shared->ptcaches));
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SoftBody", "SoftBody_Shared", "*shared")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
SoftBody *sb = ob->soft;
if (sb == NULL) {
continue;
}
if (sb->shared == NULL) {
sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared");
}
/* Move shared pointers from deprecated location to current location */
sb->shared->pointcache = sb->pointcache;
sb->shared->ptcaches = sb->ptcaches;
sb->pointcache = NULL;
BLI_listbase_clear(&sb->ptcaches);
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
if (v3d->drawtype == OB_RENDER) {
v3d->drawtype = OB_SOLID;
}
v3d->shading.type = v3d->drawtype;
v3d->shading.prev_type = OB_SOLID;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
BKE_screen_view3d_shading_init(&scene->display.shading);
}
}
/* initialize grease pencil view data */
if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) {
for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->vertex_opacity = 1.0f;
v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 22)) {
if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "annotate_v3d_align")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->toolsettings->annotate_v3d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
scene->toolsettings->annotate_thickness = 3;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "short", "line_change")) {
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
gpl->line_change = gpl->thickness;
if ((gpl->thickness < 1) || (gpl->thickness > 10)) {
gpl->thickness = 3;
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_paper_opacity = 0.5f;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_opacity")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_grid_opacity = 0.5f;
}
}
}
}
}
/* default loc axis */
if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "lock_axis")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* lock axis */
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if (gset) {
gset->lock_axis = GP_LOCKAXIS_Y;
}
}
}
/* Versioning code for Subsurf modifier. */
if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
for (ModifierData *md = object->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
if (smd->flags & eSubsurfModifierFlag_SubsurfUv_DEPRECATED) {
smd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
}
else {
smd->uv_smooth = SUBSURF_UV_SMOOTH_NONE;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "quality")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
for (ModifierData *md = object->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
smd->quality = min_ii(smd->renderLevels, 3);
}
}
}
}
/* Versioning code for Multires modifier. */
if (!DNA_struct_elem_find(fd->filesdna, "MultiresModifier", "short", "quality")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
for (ModifierData *md = object->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Multires) {
MultiresModifierData *mmd = (MultiresModifierData *)md;
mmd->quality = 3;
if (mmd->flags & eMultiresModifierFlag_PlainUv_DEPRECATED) {
mmd->uv_smooth = SUBSURF_UV_SMOOTH_NONE;
}
else {
mmd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "short", "bending_model")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
ClothModifierData *clmd = NULL;
if (md->type == eModifierType_Cloth) {
clmd = (ClothModifierData *)md;
}
else if (md->type == eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
ParticleSystem *psys = psmd->psys;
clmd = psys->clmd;
}
if (clmd != NULL) {
clmd->sim_parms->bending_model = CLOTH_BENDING_LINEAR;
clmd->sim_parms->tension = clmd->sim_parms->structural;
clmd->sim_parms->compression = clmd->sim_parms->structural;
clmd->sim_parms->shear = clmd->sim_parms->structural;
clmd->sim_parms->max_tension = clmd->sim_parms->max_struct;
clmd->sim_parms->max_compression = clmd->sim_parms->max_struct;
clmd->sim_parms->max_shear = clmd->sim_parms->max_struct;
clmd->sim_parms->vgroup_shear = clmd->sim_parms->vgroup_struct;
clmd->sim_parms->tension_damp = clmd->sim_parms->Cdis;
clmd->sim_parms->compression_damp = clmd->sim_parms->Cdis;
clmd->sim_parms->shear_damp = clmd->sim_parms->Cdis;
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "era_strength_f")) {
for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
if (brush->gpencil_settings != NULL) {
BrushGpencilSettings *gp = brush->gpencil_settings;
if (gp->brush_type == GPAINT_TOOL_ERASE) {
gp->era_strength_f = 100.0f;
gp->era_thickness_f = 10.0f;
}
}
}
}
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)) {
clmd->sim_parms->vgroup_mass = 0;
}
if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING)) {
clmd->sim_parms->vgroup_struct = 0;
clmd->sim_parms->vgroup_shear = 0;
clmd->sim_parms->vgroup_bend = 0;
}
if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW)) {
clmd->sim_parms->shrink_min = 0.0f;
clmd->sim_parms->vgroup_shrink = 0;
}
if (!(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED)) {
clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 24)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS |
V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE |
V3D_OVERLAY_EDIT_FREESTYLE_FACE | V3D_OVERLAY_EDIT_EDGES |
V3D_OVERLAY_EDIT_CREASES | V3D_OVERLAY_EDIT_BWEIGHTS |
V3D_OVERLAY_EDIT_CU_HANDLES | V3D_OVERLAY_EDIT_CU_NORMALS;
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "ShrinkwrapModifierData", "char", "shrinkMode")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Shrinkwrap) {
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
if (smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) {
smd->shrinkMode = MOD_SHRINKWRAP_ABOVE_SURFACE;
smd->shrinkOpts &= ~MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "PartDeflect", "float", "pdef_cfrict")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->pd) {
ob->pd->pdef_cfrict = 5.0f;
}
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
clmd->coll_parms->selfepsilon = 0.015f;
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha_wire")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.flag |= V3D_SHADING_XRAY_WIREFRAME;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
UnitSettings *unit = &scene->unit;
if (unit->system != USER_UNIT_NONE) {
unit->length_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_LENGTH);
unit->mass_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_MASS);
}
unit->time_unit = bUnit_GetBaseUnitOfType(USER_UNIT_NONE, B_UNIT_TIME);
}
/* gpencil grid settings */
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
ARRAY_SET_ITEMS(gpd->grid.color, 0.5f, 0.5f, 0.5f); // Color
ARRAY_SET_ITEMS(gpd->grid.scale, 1.0f, 1.0f); // Scale
gpd->grid.lines = GP_DEFAULT_GRID_LINES; // Number of lines
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 28)) {
for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
BKE_mesh_calc_edges_loose(mesh);
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 29)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
enum { V3D_OCCLUDE_WIRE = (1 << 14) };
View3D *v3d = (View3D *)sl;
if (v3d->flag2 & V3D_OCCLUDE_WIRE) {
v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_OCCLUDE_WIRE;
v3d->flag2 &= ~V3D_OCCLUDE_WIRE;
}
}
}
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_PROPERTIES) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
ARegion *ar = MEM_callocN(sizeof(ARegion), "navigation bar for properties");
ARegion *ar_header = NULL;
for (ar_header = regionbase->first; ar_header; ar_header = ar_header->next) {
if (ar_header->regiontype == RGN_TYPE_HEADER) {
break;
}
}
BLI_assert(ar_header);
BLI_insertlinkafter(regionbase, ar_header, ar);
ar->regiontype = RGN_TYPE_NAV_BAR;
ar->alignment = RGN_ALIGN_LEFT;
}
}
}
}
/* grease pencil fade layer opacity */
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_fade_layer")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_fade_layer = 0.5f;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 30)) {
/* grease pencil main material show switches */
for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
if (mat->gp_style) {
mat->gp_style->flag |= GP_STYLE_STROKE_SHOW;
mat->gp_style->flag |= GP_STYLE_FILL_SHOW;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 33)) {
/* Grease pencil reset sculpt brushes after struct rename */
if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "weighttype")) {
float curcolor_add[3], curcolor_sub[3];
ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* sculpt brushes */
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if (gset) {
for (int i = 0; i < GP_SCULPT_TYPE_MAX; i++) {
GP_Sculpt_Data *gp_brush = &gset->brush[i];
gp_brush->size = 30;
gp_brush->strength = 0.5f;
gp_brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_ENABLE_CURSOR;
copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "overscan")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->eevee.overscan = 3.0f;
}
}
for (Light *la = bmain->lights.first; la; la = la->id.next) {
/* Removed Hemi lights. */
if (!ELEM(la->type, LA_LOCAL, LA_SUN, LA_SPOT, LA_AREA)) {
la->type = LA_SUN;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "light_threshold")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->eevee.light_threshold = 0.01f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_irradiance_smoothing")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->eevee.gi_irradiance_smoothing = 0.1f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_filter_quality")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->eevee.gi_filter_quality = 1.0f;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "att_dist")) {
for (Light *la = bmain->lights.first; la; la = la->id.next) {
la->att_dist = la->clipend;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "Brush", "char", "weightpaint_tool")) {
/* Magic defines from old files (2.7x) */
#define PAINT_BLEND_MIX 0
#define PAINT_BLEND_ADD 1
#define PAINT_BLEND_SUB 2
#define PAINT_BLEND_MUL 3
#define PAINT_BLEND_BLUR 4
#define PAINT_BLEND_LIGHTEN 5
#define PAINT_BLEND_DARKEN 6
#define PAINT_BLEND_AVERAGE 7
#define PAINT_BLEND_SMEAR 8
#define PAINT_BLEND_COLORDODGE 9
#define PAINT_BLEND_DIFFERENCE 10
#define PAINT_BLEND_SCREEN 11
#define PAINT_BLEND_HARDLIGHT 12
#define PAINT_BLEND_OVERLAY 13
#define PAINT_BLEND_SOFTLIGHT 14
#define PAINT_BLEND_EXCLUSION 15
#define PAINT_BLEND_LUMINOSITY 16
#define PAINT_BLEND_SATURATION 17
#define PAINT_BLEND_HUE 18
#define PAINT_BLEND_ALPHA_SUB 19
#define PAINT_BLEND_ALPHA_ADD 20
for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
if (brush->ob_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
const char tool_init = brush->vertexpaint_tool;
bool is_blend = false;
{
char tool = tool_init;
switch (tool_init) {
case PAINT_BLEND_MIX:
tool = VPAINT_TOOL_DRAW;
break;
case PAINT_BLEND_BLUR:
tool = VPAINT_TOOL_BLUR;
break;
case PAINT_BLEND_AVERAGE:
tool = VPAINT_TOOL_AVERAGE;
break;
case PAINT_BLEND_SMEAR:
tool = VPAINT_TOOL_SMEAR;
break;
default:
tool = VPAINT_TOOL_DRAW;
is_blend = true;
break;
}
brush->vertexpaint_tool = tool;
}
if (is_blend == false) {
brush->blend = IMB_BLEND_MIX;
}
else {
short blend = IMB_BLEND_MIX;
switch (tool_init) {
case PAINT_BLEND_ADD:
blend = IMB_BLEND_ADD;
break;
case PAINT_BLEND_SUB:
blend = IMB_BLEND_SUB;
break;
case PAINT_BLEND_MUL:
blend = IMB_BLEND_MUL;
break;
case PAINT_BLEND_LIGHTEN:
blend = IMB_BLEND_LIGHTEN;
break;
case PAINT_BLEND_DARKEN:
blend = IMB_BLEND_DARKEN;
break;
case PAINT_BLEND_COLORDODGE:
blend = IMB_BLEND_COLORDODGE;
break;
case PAINT_BLEND_DIFFERENCE:
blend = IMB_BLEND_DIFFERENCE;
break;
case PAINT_BLEND_SCREEN:
blend = IMB_BLEND_SCREEN;
break;
case PAINT_BLEND_HARDLIGHT:
blend = IMB_BLEND_HARDLIGHT;
break;
case PAINT_BLEND_OVERLAY:
blend = IMB_BLEND_OVERLAY;
break;
case PAINT_BLEND_SOFTLIGHT:
blend = IMB_BLEND_SOFTLIGHT;
break;
case PAINT_BLEND_EXCLUSION:
blend = IMB_BLEND_EXCLUSION;
break;
case PAINT_BLEND_LUMINOSITY:
blend = IMB_BLEND_LUMINOSITY;
break;
case PAINT_BLEND_SATURATION:
blend = IMB_BLEND_SATURATION;
break;
case PAINT_BLEND_HUE:
blend = IMB_BLEND_HUE;
break;
case PAINT_BLEND_ALPHA_SUB:
blend = IMB_BLEND_ERASE_ALPHA;
break;
case PAINT_BLEND_ALPHA_ADD:
blend = IMB_BLEND_ADD_ALPHA;
break;
}
brush->blend = blend;
}
}
/* For now these match, in the future new items may not. */
brush->weightpaint_tool = brush->vertexpaint_tool;
}
#undef PAINT_BLEND_MIX
#undef PAINT_BLEND_ADD
#undef PAINT_BLEND_SUB
#undef PAINT_BLEND_MUL
#undef PAINT_BLEND_BLUR
#undef PAINT_BLEND_LIGHTEN
#undef PAINT_BLEND_DARKEN
#undef PAINT_BLEND_AVERAGE
#undef PAINT_BLEND_SMEAR
#undef PAINT_BLEND_COLORDODGE
#undef PAINT_BLEND_DIFFERENCE
#undef PAINT_BLEND_SCREEN
#undef PAINT_BLEND_HARDLIGHT
#undef PAINT_BLEND_OVERLAY
#undef PAINT_BLEND_SOFTLIGHT
#undef PAINT_BLEND_EXCLUSION
#undef PAINT_BLEND_LUMINOSITY
#undef PAINT_BLEND_SATURATION
#undef PAINT_BLEND_HUE
#undef PAINT_BLEND_ALPHA_SUB
#undef PAINT_BLEND_ALPHA_ADD
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 34)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) {
if (slink->spacetype == SPACE_USERPREF) {
ARegion *navigation_region = BKE_spacedata_find_region_type(
slink, area, RGN_TYPE_NAV_BAR);
if (!navigation_region) {
ARegion *main_region = BKE_spacedata_find_region_type(slink, area, RGN_TYPE_WINDOW);
ListBase *regionbase = (slink == area->spacedata.first) ? &area->regionbase :
&slink->regionbase;
navigation_region = MEM_callocN(sizeof(ARegion),
"userpref navigation-region do_versions");
/* Order matters, addhead not addtail! */
BLI_insertlinkbefore(regionbase, main_region, navigation_region);
navigation_region->regiontype = RGN_TYPE_NAV_BAR;
navigation_region->alignment = RGN_ALIGN_LEFT;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 36)) {
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "curvature_ridge_factor")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.curvature_ridge_factor = 1.0f;
v3d->shading.curvature_valley_factor = 1.0f;
}
}
}
}
}
/* Rename OpenGL to Workbench. */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (STREQ(scene->r.engine, "BLENDER_OPENGL")) {
STRNCPY(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH);
}
}
/* init Annotations onion skin */
if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "int", "gstep")) {
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.302f, 0.851f, 0.302f);
ARRAY_SET_ITEMS(gpl->gcolor_next, 0.250f, 0.1f, 1.0f);
}
}
}
/* Move studio_light selection to lookdev_light. */
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "lookdev_light[256]")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256);
}
}
}
}
}
/* Change Solid mode shadow orientation. */
if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_focus")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
float *dir = scene->display.light_direction;
SWAP(float, dir[2], dir[1]);
dir[2] = -dir[2];
dir[0] = -dir[0];
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 37)) {
for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
ca->drawsize *= 2.0f;
}
/* Grease pencil primitive curve */
if (!DNA_struct_elem_find(
fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_primitive")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if ((gset) && (gset->cur_primitive == NULL)) {
gset->cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
BKE_curvemapping_initialize(gset->cur_primitive);
BKE_curvemap_reset(gset->cur_primitive->cm,
&gset->cur_primitive->clipr,
CURVE_PRESET_BELL,
CURVEMAP_SLOPE_POSITIVE);
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 38)) {
if (DNA_struct_elem_find(fd->filesdna, "Object", "char", "empty_image_visibility_flag")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
ob->empty_image_visibility_flag ^= (OB_EMPTY_IMAGE_HIDE_PERSPECTIVE |
OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC |
OB_EMPTY_IMAGE_HIDE_BACK);
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
switch (sl->spacetype) {
case SPACE_IMAGE: {
SpaceImage *sima = (SpaceImage *)sl;
sima->flag &= ~(SI_FLAG_UNUSED_0 | SI_FLAG_UNUSED_1 | SI_FLAG_UNUSED_3 |
SI_FLAG_UNUSED_6 | SI_FLAG_UNUSED_7 | SI_FLAG_UNUSED_8 |
SI_FLAG_UNUSED_17 | SI_FLAG_UNUSED_18 | SI_FLAG_UNUSED_23 |
SI_FLAG_UNUSED_24);
break;
}
case SPACE_VIEW3D: {
View3D *v3d = (View3D *)sl;
v3d->flag &= ~(V3D_FLAG_UNUSED_0 | V3D_FLAG_UNUSED_1 | V3D_FLAG_UNUSED_10 |
V3D_FLAG_UNUSED_12);
v3d->flag2 &= ~(V3D_FLAG2_UNUSED_3 | V3D_FLAG2_UNUSED_6 | V3D_FLAG2_UNUSED_12 |
V3D_FLAG2_UNUSED_13 | V3D_FLAG2_UNUSED_14 | V3D_FLAG2_UNUSED_15);
break;
}
case SPACE_OUTLINER: {
SpaceOutliner *so = (SpaceOutliner *)sl;
so->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 | SO_FILTER_UNUSED_12);
so->storeflag &= ~(SO_TREESTORE_UNUSED_1);
break;
}
case SPACE_FILE: {
SpaceFile *sfile = (SpaceFile *)sl;
if (sfile->params) {
sfile->params->flag &= ~(FILE_PARAMS_FLAG_UNUSED_1 | FILE_PARAMS_FLAG_UNUSED_6 |
FILE_PARAMS_FLAG_UNUSED_9);
}
break;
}
case SPACE_NODE: {
SpaceNode *snode = (SpaceNode *)sl;
snode->flag &= ~(SNODE_FLAG_UNUSED_6 | SNODE_FLAG_UNUSED_10 | SNODE_FLAG_UNUSED_11);
break;
}
case SPACE_PROPERTIES: {
SpaceProperties *sbuts = (SpaceProperties *)sl;
sbuts->flag &= ~(SB_FLAG_UNUSED_2 | SB_FLAG_UNUSED_3);
break;
}
case SPACE_NLA: {
SpaceNla *snla = (SpaceNla *)sl;
snla->flag &= ~(SNLA_FLAG_UNUSED_0 | SNLA_FLAG_UNUSED_1 | SNLA_FLAG_UNUSED_3);
break;
}
}
}
}
}
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->r.mode &= ~(R_MODE_UNUSED_1 | R_MODE_UNUSED_2 | R_MODE_UNUSED_3 | R_MODE_UNUSED_4 |
R_MODE_UNUSED_5 | R_MODE_UNUSED_6 | R_MODE_UNUSED_7 | R_MODE_UNUSED_8 |
R_MODE_UNUSED_10 | R_MODE_UNUSED_13 | R_MODE_UNUSED_16 |
R_MODE_UNUSED_17 | R_MODE_UNUSED_18 | R_MODE_UNUSED_19 |
R_MODE_UNUSED_20 | R_MODE_UNUSED_21 | R_MODE_UNUSED_27);
scene->r.scemode &= ~(R_SCEMODE_UNUSED_8 | R_SCEMODE_UNUSED_11 | R_SCEMODE_UNUSED_13 |
R_SCEMODE_UNUSED_16 | R_SCEMODE_UNUSED_17 | R_SCEMODE_UNUSED_19);
if (scene->toolsettings->sculpt) {
scene->toolsettings->sculpt->flags &= ~(SCULPT_FLAG_UNUSED_0 | SCULPT_FLAG_UNUSED_1 |
SCULPT_FLAG_UNUSED_2);
}
if (scene->ed) {
Sequence *seq;
SEQ_BEGIN (scene->ed, seq) {
seq->flag &= ~(SEQ_FLAG_UNUSED_6 | SEQ_FLAG_UNUSED_18 | SEQ_FLAG_UNUSED_19 |
SEQ_FLAG_UNUSED_21);
if (seq->type == SEQ_TYPE_SPEED) {
SpeedControlVars *s = (SpeedControlVars *)seq->effectdata;
s->flags &= ~(SEQ_SPEED_UNUSED_1);
}
}
SEQ_END;
}
}
for (World *world = bmain->worlds.first; world; world = world->id.next) {
world->flag &= ~(WO_MODE_UNUSED_1 | WO_MODE_UNUSED_2 | WO_MODE_UNUSED_3 | WO_MODE_UNUSED_4 |
WO_MODE_UNUSED_5 | WO_MODE_UNUSED_7);
}
for (Image *image = bmain->images.first; image; image = image->id.next) {
image->flag &= ~(IMA_FLAG_UNUSED_0 | IMA_FLAG_UNUSED_1 | IMA_FLAG_UNUSED_4 |
IMA_FLAG_UNUSED_6 | IMA_FLAG_UNUSED_8 | IMA_FLAG_UNUSED_15 |
IMA_FLAG_UNUSED_16);
}
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
ob->flag &= ~(OB_FLAG_UNUSED_11 | OB_FLAG_UNUSED_12);
ob->transflag &= ~(OB_TRANSFLAG_UNUSED_0 | OB_TRANSFLAG_UNUSED_1);
ob->shapeflag &= ~OB_SHAPE_FLAG_UNUSED_1;
}
for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
me->flag &= ~(ME_FLAG_UNUSED_0 | ME_FLAG_UNUSED_1 | ME_FLAG_UNUSED_3 | ME_FLAG_UNUSED_4 |
ME_FLAG_UNUSED_6 | ME_FLAG_UNUSED_7 | ME_FLAG_UNUSED_8);
}
for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
mat->blend_flag &= ~(1 << 2); /* UNUSED */
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 40)) {
if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "snap_transform_mode_flag")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->toolsettings->snap_transform_mode_flag = SCE_SNAP_TRANSFORM_MODE_TRANSLATE;
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
switch (sl->spacetype) {
case SPACE_VIEW3D: {
enum { V3D_BACKFACE_CULLING = (1 << 10) };
View3D *v3d = (View3D *)sl;
if (v3d->flag2 & V3D_BACKFACE_CULLING) {
v3d->flag2 &= ~V3D_BACKFACE_CULLING;
v3d->shading.flag |= V3D_SHADING_BACKFACE_CULLING;
}
break;
}
}
}
}
}
if (!DNA_struct_find(fd->filesdna, "TransformOrientationSlot")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
for (int i = 0; i < ARRAY_SIZE(scene->orientation_slots); i++) {
scene->orientation_slots[i].index_custom = -1;
}
}
}
/* Grease pencil target weight */
if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "float", "weight")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* sculpt brushes */
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if (gset) {
for (int i = 0; i < GP_SCULPT_TYPE_MAX; i++) {
GP_Sculpt_Data *gp_brush = &gset->brush[i];
gp_brush->weight = 1.0f;
}
}
}
}
/* Grease pencil cutter/select segment intersection threshold */
if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "float", "isect_threshold")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if (gset) {
gset->isect_threshold = 0.1f;
}
}
}
/* Fix anamorphic bokeh eevee rna limits.*/
for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
if (ca->gpu_dof.ratio < 0.01f) {
ca->gpu_dof.ratio = 0.01f;
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_USERPREF) {
ARegion *execute_region = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_EXECUTE);
if (!execute_region) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
ARegion *ar_navbar = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_NAV_BAR);
execute_region = MEM_callocN(sizeof(ARegion), "execute region for properties");
BLI_assert(ar_navbar);
BLI_insertlinkafter(regionbase, ar_navbar, execute_region);
execute_region->regiontype = RGN_TYPE_EXECUTE;
execute_region->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
execute_region->flag |= RGN_FLAG_DYNAMIC_SIZE;
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 43)) {
ListBase *lb = which_libbase(bmain, ID_BR);
BKE_main_id_repair_duplicate_names_listbase(lb);
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 44)) {
if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "a")) {
for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
mat->a = 1.0f;
}
}
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
enum {
R_ALPHAKEY = 2,
};
scene->r.seq_flag &= ~(R_SEQ_UNUSED_0 | R_SEQ_UNUSED_1 | R_SEQ_UNUSED_2);
scene->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT_UNUSED_1;
if (scene->r.alphamode == R_ALPHAKEY) {
scene->r.alphamode = R_ADDSKY;
}
ToolSettings *ts = scene->toolsettings;
ts->particle.flag &= ~PE_UNUSED_6;
if (ts->sculpt != NULL) {
ts->sculpt->flags &= ~SCULPT_FLAG_UNUSED_6;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 45)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = (SpaceSeq *)sl;
sseq->flag |= SEQ_SHOW_MARKER_LINES;
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 46)) {
/* Add wireframe color. */
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "wire_color_type")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.wire_color_type = V3D_SHADING_SINGLE_COLOR;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DCursor", "short", "rotation_mode")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (is_zero_v3(scene->cursor.rotation_axis)) {
scene->cursor.rotation_mode = ROT_MODE_XYZ;
scene->cursor.rotation_quaternion[0] = 1.0f;
scene->cursor.rotation_axis[1] = 1.0f;
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 47)) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
ParticleEditSettings *pset = &scene->toolsettings->particle;
if (pset->brushtype < 0) {
pset->brushtype = PE_BRUSH_COMB;
}
}
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
{
enum { PARCURVE = 1, PARKEY = 2, PAR_DEPRECATED = 16 };
if (ELEM(ob->partype, PARCURVE, PARKEY, PAR_DEPRECATED)) {
ob->partype = PAROBJECT;
}
}
{
enum { OB_WAVE = 21, OB_LIFE = 23, OB_SECTOR = 24 };
if (ELEM(ob->type, OB_WAVE, OB_LIFE, OB_SECTOR)) {
ob->type = OB_EMPTY;
}
}
ob->transflag &= ~(OB_TRANSFLAG_UNUSED_0 | OB_TRANSFLAG_UNUSED_1 | OB_TRANSFLAG_UNUSED_3 |
OB_TRANSFLAG_UNUSED_6 | OB_TRANSFLAG_UNUSED_12);
ob->nlaflag &= ~(OB_ADS_UNUSED_1 | OB_ADS_UNUSED_2);
}
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
arm->flag &= ~(ARM_FLAG_UNUSED_1 | ARM_FLAG_UNUSED_5 | ARM_FLAG_UNUSED_6 |
ARM_FLAG_UNUSED_7 | ARM_FLAG_UNUSED_12);
}
LISTBASE_FOREACH (Text *, text, &bmain->texts) {
text->flags &= ~(TXT_FLAG_UNUSED_8 | TXT_FLAG_UNUSED_9);
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 48)) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* Those are not currently used, but are accessible through RNA API and were not
* properly initialized previously. This is mere copy of BKE_init_scene() code. */
if (scene->r.im_format.view_settings.look[0] == '\0') {
BKE_color_managed_display_settings_init(&scene->r.im_format.display_settings);
BKE_color_managed_view_settings_init_render(
&scene->r.im_format.view_settings, &scene->r.im_format.display_settings, "Filmic");
}
if (scene->r.bake.im_format.view_settings.look[0] == '\0') {
BKE_color_managed_display_settings_init(&scene->r.bake.im_format.display_settings);
BKE_color_managed_view_settings_init_render(&scene->r.bake.im_format.view_settings,
&scene->r.bake.im_format.display_settings,
"Filmic");
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 49)) {
/* All tool names changed, reset to defaults. */
for (WorkSpace *workspace = bmain->workspaces.first; workspace;
workspace = workspace->id.next) {
while (!BLI_listbase_is_empty(&workspace->tools)) {
BKE_workspace_tool_remove(workspace, workspace->tools.first);
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 52)) {
LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
/* Replace deprecated PART_DRAW_BB by PART_DRAW_NOT */
if (part->ren_as == PART_DRAW_BB) {
part->ren_as = PART_DRAW_NOT;
}
if (part->draw_as == PART_DRAW_BB) {
part->draw_as = PART_DRAW_NOT;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "min_vertices")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Triangulate) {
TriangulateModifierData *smd = (TriangulateModifierData *)md;
smd->min_vertices = 4;
}
}
}
}
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
for (bNode *node = ntree->nodes.first; node; node = node->next) {
/* Fix missing version patching from earlier changes. */
if (STREQ(node->idname, "ShaderNodeOutputLamp")) {
STRNCPY(node->idname, "ShaderNodeOutputLight");
}
if (node->type == SH_NODE_BSDF_PRINCIPLED && node->custom2 == 0) {
node->custom2 = SHD_SUBSURFACE_BURLEY;
}
}
}
}
FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 53)) {
for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
/* Eevee: Keep material appearance consistent with previous behavior. */
if (!mat->use_nodes || !mat->nodetree || mat->blend_method == MA_BM_SOLID) {
mat->blend_shadow = MA_BS_SOLID;
}
}
/* grease pencil default animation channel color */
{
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
if (gpd->flag & GP_DATA_ANNOTATIONS) {
continue;
}
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* default channel color */
ARRAY_SET_ITEMS(gpl->color, 0.2f, 0.2f, 0.2f);
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 54)) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
bool is_first_subdiv = true;
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
if (is_first_subdiv) {
smd->flags |= eSubsurfModifierFlag_UseCrease;
}
else {
smd->flags &= ~eSubsurfModifierFlag_UseCrease;
}
is_first_subdiv = false;
}
else if (md->type == eModifierType_Multires) {
MultiresModifierData *mmd = (MultiresModifierData *)md;
if (is_first_subdiv) {
mmd->flags |= eMultiresModifierFlag_UseCrease;
}
else {
mmd->flags &= ~eMultiresModifierFlag_UseCrease;
}
is_first_subdiv = false;
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 55)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_TEXT) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
/* Remove multiple footers that were added by mistake. */
do_versions_remove_region(regionbase, RGN_TYPE_FOOTER);
/* Add footer. */
ARegion *ar = do_versions_add_region(RGN_TYPE_FOOTER, "footer for text");
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
BLI_insertlinkafter(regionbase, ar_header, ar);
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 56)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->gizmo_show_armature = V3D_GIZMO_SHOW_ARMATURE_BBONE |
V3D_GIZMO_SHOW_ARMATURE_ROLL;
v3d->gizmo_show_empty = V3D_GIZMO_SHOW_EMPTY_IMAGE | V3D_GIZMO_SHOW_EMPTY_FORCE_FIELD;
v3d->gizmo_show_light = V3D_GIZMO_SHOW_LIGHT_SIZE | V3D_GIZMO_SHOW_LIGHT_LOOK_AT;
v3d->gizmo_show_camera = V3D_GIZMO_SHOW_CAMERA_LENS | V3D_GIZMO_SHOW_CAMERA_DOF_DIST;
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 57)) {
/* Enable Show Interpolation in dopesheet by default. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
if ((saction->flag & SACTION_SHOW_EXTREMES) == 0) {
saction->flag |= SACTION_SHOW_INTERPOLATION;
}
}
}
}
}
/* init grease pencil brush gradients */
if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "gradient_f")) {
for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
if (brush->gpencil_settings != NULL) {
BrushGpencilSettings *gp = brush->gpencil_settings;
gp->gradient_f = 1.0f;
gp->gradient_s[0] = 1.0f;
gp->gradient_s[1] = 1.0f;
}
}
}
/* init grease pencil stroke gradients */
if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "float", "gradient_f")) {
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
gps->gradient_f = 1.0f;
gps->gradient_s[0] = 1.0f;
gps->gradient_s[1] = 1.0f;
}
}
}
}
}
/* enable the axis aligned ortho grid by default */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->gridflag |= V3D_SHOW_ORTHO_GRID;
}
}
}
}
}
/* Keep un-versioned until we're finished adding space types. */
{
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
/* All spaces that use tools must be eventually added. */
ARegion *ar = NULL;
if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE) &&
((ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER)) == NULL)) {
/* Add tool header. */
ar = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header");
ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
BLI_insertlinkbefore(regionbase, ar_header, ar);
/* Hide by default, enable for painting workspaces (startup only). */
ar->flag |= RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
}
if (ar != NULL) {
SET_FLAG_FROM_TEST(ar->flag, ar->flag & RGN_FLAG_HIDDEN_BY_USER, RGN_FLAG_HIDDEN);
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 60)) {
if (!DNA_struct_elem_find(fd->filesdna, "bSplineIKConstraint", "short", "yScaleMode")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->pose) {
for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (bConstraint *con = pchan->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
if ((data->flag & CONSTRAINT_SPLINEIK_SCALE_LIMITED) == 0) {
data->yScaleMode = CONSTRAINT_SPLINEIK_YS_FIT_CURVE;
}
}
}
}
}
}
}
if (!DNA_struct_elem_find(
fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "char", "render_aa")) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
scene->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8;
scene->display.viewport_aa = SCE_DISPLAY_AA_FXAA;
}
}
/* Split bbone_scalein/bbone_scaleout into x and y fields. */
if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scale_out_y")) {
/* Update armature data and pose channels. */
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
do_version_bones_split_bbone_scale(&arm->bonebase);
}
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
if (ob->pose) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
pchan->scale_in_y = pchan->scale_in_x;
pchan->scale_out_y = pchan->scale_out_x;
}
}
}
/* Update action curves and drivers. */
LISTBASE_FOREACH (bAction *, act, &bmain->actions) {
LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &act->curves) {
do_version_bbone_scale_fcurve_fix(&act->curves, fcu);
}
}
BKE_animdata_main_cb(bmain, do_version_bbone_scale_animdata_cb, NULL);
}
for (Scene *sce = bmain->scenes.first; sce != NULL; sce = sce->id.next) {
if (sce->ed != NULL) {
do_versions_seq_set_cache_defaults(sce->ed);
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 61)) {
/* Added a power option to Copy Scale. */
if (!DNA_struct_elem_find(fd->filesdna, "bSizeLikeConstraint", "float", "power")) {
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
do_version_constraints_copy_scale_power(&ob->constraints);
if (ob->pose) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
do_version_constraints_copy_scale_power(&pchan->constraints);
}
}
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (ELEM(sl->spacetype, SPACE_CLIP, SPACE_GRAPH, SPACE_SEQ)) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
ARegion *ar = NULL;
if (sl->spacetype == SPACE_CLIP) {
if (((SpaceClip *)sl)->view == SC_VIEW_GRAPH) {
ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_PREVIEW);
}
}
else {
ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_WINDOW);
}
if (ar != NULL) {
ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
ar->v2d.scroll |= V2D_SCROLL_RIGHT;
}
}
}
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype != SPACE_OUTLINER) {
continue;
}
SpaceOutliner *so = (SpaceOutliner *)sl;
so->filter &= ~SO_FLAG_UNUSED_1;
so->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE;
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 69)) {
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
arm->flag &= ~(ARM_FLAG_UNUSED_7 | ARM_FLAG_UNUSED_9);
}
/* Initializes sun lights with the new angular diameter property */
if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "sun_angle")) {
LISTBASE_FOREACH (Light *, light, &bmain->lights) {
light->sun_angle = 2.0f * atanf(light->area_size);
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 70)) {
/* New image alpha modes. */
LISTBASE_FOREACH (Image *, image, &bmain->images) {
const int IMA_IGNORE_ALPHA = (1 << 12);
if (image->flag & IMA_IGNORE_ALPHA) {
image->alpha_mode = IMA_ALPHA_IGNORE;
image->flag &= ~IMA_IGNORE_ALPHA;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 71)) {
/* This assumes the Blender builtin config. Depending on the OCIO
* environment variable for versioning is weak, and these deprecated view
* transforms and look names don't seem to exist in other commonly used
* OCIO configs so .blend files created for those would be unaffected. */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
ColorManagedViewSettings *view_settings;
view_settings = &scene->view_settings;
if (STREQ(view_settings->view_transform, "Default")) {
STRNCPY(view_settings->view_transform, "Standard");
}
else if (STREQ(view_settings->view_transform, "RRT") ||
STREQ(view_settings->view_transform, "Film")) {
STRNCPY(view_settings->view_transform, "Filmic");
}
else if (STREQ(view_settings->view_transform, "Log")) {
STRNCPY(view_settings->view_transform, "Filmic Log");
}
if (STREQ(view_settings->look, "Filmic - Base Contrast")) {
STRNCPY(view_settings->look, "None");
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 74)) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (scene->ed != NULL) {
do_versions_seq_alloc_transform_and_crop(&scene->ed->seqbase);
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 75)) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (scene->master_collection != NULL) {
scene->master_collection->flag &= ~(COLLECTION_RESTRICT_VIEWPORT |
COLLECTION_RESTRICT_SELECT |
COLLECTION_RESTRICT_RENDER);
}
UnitSettings *unit = &scene->unit;
if (unit->system == USER_UNIT_NONE) {
unit->length_unit = (char)USER_UNIT_ADAPTIVE;
unit->mass_unit = (char)USER_UNIT_ADAPTIVE;
}
RenderData *render_data = &scene->r;
switch (render_data->ffcodecdata.ffmpeg_preset) {
case FFM_PRESET_ULTRAFAST:
case FFM_PRESET_SUPERFAST:
render_data->ffcodecdata.ffmpeg_preset = FFM_PRESET_REALTIME;
break;
case FFM_PRESET_VERYFAST:
case FFM_PRESET_FASTER:
case FFM_PRESET_FAST:
case FFM_PRESET_MEDIUM:
render_data->ffcodecdata.ffmpeg_preset = FFM_PRESET_GOOD;
break;
case FFM_PRESET_SLOW:
case FFM_PRESET_SLOWER:
case FFM_PRESET_VERYSLOW:
render_data->ffcodecdata.ffmpeg_preset = FFM_PRESET_BEST;
}
}
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
arm->flag &= ~(ARM_FLAG_UNUSED_6);
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 281, 1)) {
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_DataTransfer) {
/* Now datatransfer's mix factor is multiplied with weights when any,
* instead of being ignored,
* we need to take care of that to keep 'old' files compatible. */
DataTransferModifierData *dtmd = (DataTransferModifierData *)md;
if (dtmd->defgrp_name[0] != '\0') {
dtmd->mix_factor = 1.0f;
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 281, 3)) {
if (U.view_rotate_sensitivity_turntable == 0) {
U.view_rotate_sensitivity_turntable = DEG2RADF(0.4f);
U.view_rotate_sensitivity_trackball = 1.0f;
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_TEXT) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
ARegion *ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_UI);
if (ar) {
ar->alignment = RGN_ALIGN_RIGHT;
}
}
/* Mark outliners as dirty for syncing and enable synced selection */
if (sl->spacetype == SPACE_OUTLINER) {
SpaceOutliner *soutliner = (SpaceOutliner *)sl;
soutliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
soutliner->flag |= SO_SYNC_SELECT;
}
}
}
}
for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
if (mesh->remesh_voxel_size == 0.0f) {
mesh->remesh_voxel_size = 0.1f;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 281, 4)) {
ID *id;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
bNodeTree *ntree = ntreeFromID(id);
if (ntree) {
ntree->id.flag |= LIB_PRIVATE_DATA;
}
}
FOREACH_MAIN_ID_END;
}
if (!MAIN_VERSION_ATLEAST(bmain, 281, 5)) {
for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
if (br->ob_mode & OB_MODE_SCULPT && br->normal_radius_factor == 0.0f) {
br->normal_radius_factor = 0.5f;
}
}
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
/* Older files do not have a master collection, which is then added through
* `BKE_collection_master_add()`, so everything is fine. */
if (scene->master_collection != NULL) {
scene->master_collection->id.flag |= LIB_PRIVATE_DATA;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 281, 6)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.flag |= V3D_SHADING_SCENE_LIGHTS_RENDER | V3D_SHADING_SCENE_WORLD_RENDER;
/* files by default don't have studio lights selected unless interacted
* with the shading popover. When no studiolight could be read, we will
* select the default world one. */
StudioLight *studio_light = BKE_studiolight_find(v3d->shading.lookdev_light,
STUDIOLIGHT_TYPE_WORLD);
if (studio_light != NULL) {
STRNCPY(v3d->shading.lookdev_light, studio_light->name);
}
}
}
}
}
}
{
/* Versioning code until next subversion bump goes here. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_FILE) {
SpaceFile *sfile = (SpaceFile *)sl;
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
ARegion *ar_ui = do_versions_find_region(regionbase, RGN_TYPE_UI);
ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
ARegion *ar_toolprops = do_versions_find_region_or_null(regionbase,
RGN_TYPE_TOOL_PROPS);
/* Reinsert UI region so that it spawns entire area width */
BLI_remlink(regionbase, ar_ui);
BLI_insertlinkafter(regionbase, ar_header, ar_ui);
ar_ui->flag |= RGN_FLAG_DYNAMIC_SIZE;
if (ar_toolprops && (ar_toolprops->alignment == (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV))) {
SpaceType *stype = BKE_spacetype_from_id(sl->spacetype);
/* Remove empty region at old location. */
BLI_assert(sfile->op == NULL);
BKE_area_region_free(stype, ar_toolprops);
BLI_freelinkN(regionbase, ar_toolprops);
}
if (sfile->params) {
sfile->params->details_flags |= FILE_DETAILS_SIZE | FILE_DETAILS_DATETIME;
}
}
}
}
}
/* Convert the BONE_NO_SCALE flag to inherit_scale_mode enum. */
if (!DNA_struct_elem_find(fd->filesdna, "Bone", "char", "inherit_scale_mode")) {
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
do_version_bones_inherit_scale(&arm->bonebase);
}
}
}
}
|