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
|
/**
* @file llpanelobject.cpp
* @brief Object editing (position, scale, etc.) in the tools floater
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
// file include
#include "llpanelobject.h"
// linden library includes
#include "llerror.h"
#include "llfontgl.h"
#include "llpermissionsflags.h"
#include "llstring.h"
#include "llvolume.h"
#include "m3math.h"
// project includes
#include "llagent.h"
#include "llbutton.h"
#include "llcalc.h"
#include "llcheckboxctrl.h"
#include "llcolorswatch.h"
#include "llcombobox.h"
#include "llfocusmgr.h"
#include "llmanipscale.h"
#include "llmenubutton.h"
#include "llpreviewscript.h"
#include "llresmgr.h"
#include "llselectmgr.h"
#include "llspinctrl.h"
#include "lltexturectrl.h"
#include "lltextbox.h"
#include "lltool.h"
#include "lltoolcomp.h"
#include "lltoolmgr.h"
#include "llui.h"
#include "llviewerobject.h"
#include "llviewerregion.h"
#include "llviewerwindow.h"
#include "llvovolume.h"
#include "llworld.h"
#include "pipeline.h"
#include "llviewercontrol.h"
#include "lluictrlfactory.h"
//#include "llfirstuse.h"
#include "lldrawpool.h"
//
// Constants
//
enum {
MI_BOX,
MI_CYLINDER,
MI_PRISM,
MI_SPHERE,
MI_TORUS,
MI_TUBE,
MI_RING,
MI_SCULPT,
MI_NONE,
MI_VOLUME_COUNT
};
enum {
MI_HOLE_SAME,
MI_HOLE_CIRCLE,
MI_HOLE_SQUARE,
MI_HOLE_TRIANGLE,
MI_HOLE_COUNT
};
const F32 MAX_ATTACHMENT_DIST = 3.5f; // meters
//static const std::string LEGACY_FULLBRIGHT_DESC =LLTrans::getString("Fullbright");
BOOL LLPanelObject::postBuild()
{
setMouseOpaque(FALSE);
//--------------------------------------------------------
// Top
//--------------------------------------------------------
// Lock checkbox
mCheckLock = getChild<LLCheckBoxCtrl>("checkbox locked");
childSetCommitCallback("checkbox locked",onCommitLock,this);
// Physical checkbox
mCheckPhysics = getChild<LLCheckBoxCtrl>("Physical Checkbox Ctrl");
childSetCommitCallback("Physical Checkbox Ctrl",onCommitPhysics,this);
// Temporary checkbox
mCheckTemporary = getChild<LLCheckBoxCtrl>("Temporary Checkbox Ctrl");
childSetCommitCallback("Temporary Checkbox Ctrl",onCommitTemporary,this);
// Phantom checkbox
mCheckPhantom = getChild<LLCheckBoxCtrl>("Phantom Checkbox Ctrl");
childSetCommitCallback("Phantom Checkbox Ctrl",onCommitPhantom,this);
// Position
mMenuClipboardPos = getChild<LLMenuButton>("clipboard_pos_btn");
mLabelPosition = getChild<LLTextBox>("label position");
mCtrlPosX = getChild<LLSpinCtrl>("Pos X");
childSetCommitCallback("Pos X",onCommitPosition,this);
mCtrlPosY = getChild<LLSpinCtrl>("Pos Y");
childSetCommitCallback("Pos Y",onCommitPosition,this);
mCtrlPosZ = getChild<LLSpinCtrl>("Pos Z");
childSetCommitCallback("Pos Z",onCommitPosition,this);
// Scale
mMenuClipboardSize = getChild<LLMenuButton>("clipboard_size_btn");
mLabelSize = getChild<LLTextBox>("label size");
mCtrlScaleX = getChild<LLSpinCtrl>("Scale X");
childSetCommitCallback("Scale X",onCommitScale,this);
// Scale Y
mCtrlScaleY = getChild<LLSpinCtrl>("Scale Y");
childSetCommitCallback("Scale Y",onCommitScale,this);
// Scale Z
mCtrlScaleZ = getChild<LLSpinCtrl>("Scale Z");
childSetCommitCallback("Scale Z",onCommitScale,this);
// Rotation
mMenuClipboardRot = getChild<LLMenuButton>("clipboard_rot_btn");
mLabelRotation = getChild<LLTextBox>("label rotation");
mCtrlRotX = getChild<LLSpinCtrl>("Rot X");
childSetCommitCallback("Rot X",onCommitRotation,this);
mCtrlRotY = getChild<LLSpinCtrl>("Rot Y");
childSetCommitCallback("Rot Y",onCommitRotation,this);
mCtrlRotZ = getChild<LLSpinCtrl>("Rot Z");
childSetCommitCallback("Rot Z",onCommitRotation,this);
//--------------------------------------------------------
// Base Type
mComboBaseType = getChild<LLComboBox>("comboBaseType");
childSetCommitCallback("comboBaseType",onCommitParametric,this);
mMenuClipboardParams = getChild<LLMenuButton>("clipboard_obj_params_btn");
// Cut
mLabelCut = getChild<LLTextBox>("text cut");
mSpinCutBegin = getChild<LLSpinCtrl>("cut begin");
childSetCommitCallback("cut begin",onCommitParametric,this);
mSpinCutBegin->setValidateBeforeCommit( precommitValidate );
mSpinCutEnd = getChild<LLSpinCtrl>("cut end");
childSetCommitCallback("cut end",onCommitParametric,this);
mSpinCutEnd->setValidateBeforeCommit( &precommitValidate );
// Hollow / Skew
mLabelHollow = getChild<LLTextBox>("text hollow");
mLabelSkew = getChild<LLTextBox>("text skew");
mSpinHollow = getChild<LLSpinCtrl>("Scale 1");
childSetCommitCallback("Scale 1",onCommitParametric,this);
mSpinHollow->setValidateBeforeCommit( &precommitValidate );
mSpinSkew = getChild<LLSpinCtrl>("Skew");
childSetCommitCallback("Skew",onCommitParametric,this);
mSpinSkew->setValidateBeforeCommit( &precommitValidate );
mLabelHoleType = getChild<LLTextBox>("Hollow Shape");
// Hole Type
mComboHoleType = getChild<LLComboBox>("hole");
childSetCommitCallback("hole",onCommitParametric,this);
// Twist
mLabelTwist = getChild<LLTextBox>("text twist");
mSpinTwistBegin = getChild<LLSpinCtrl>("Twist Begin");
childSetCommitCallback("Twist Begin",onCommitParametric,this);
mSpinTwistBegin->setValidateBeforeCommit( precommitValidate );
mSpinTwist = getChild<LLSpinCtrl>("Twist End");
childSetCommitCallback("Twist End",onCommitParametric,this);
mSpinTwist->setValidateBeforeCommit( &precommitValidate );
// Scale
mSpinScaleX = getChild<LLSpinCtrl>("Taper Scale X");
childSetCommitCallback("Taper Scale X",onCommitParametric,this);
mSpinScaleX->setValidateBeforeCommit( &precommitValidate );
mSpinScaleY = getChild<LLSpinCtrl>("Taper Scale Y");
childSetCommitCallback("Taper Scale Y",onCommitParametric,this);
mSpinScaleY->setValidateBeforeCommit( &precommitValidate );
// Shear
mLabelShear = getChild<LLTextBox>("text topshear");
mSpinShearX = getChild<LLSpinCtrl>("Shear X");
childSetCommitCallback("Shear X",onCommitParametric,this);
mSpinShearX->setValidateBeforeCommit( &precommitValidate );
mSpinShearY = getChild<LLSpinCtrl>("Shear Y");
childSetCommitCallback("Shear Y",onCommitParametric,this);
mSpinShearY->setValidateBeforeCommit( &precommitValidate );
// Path / Profile
mCtrlPathBegin = getChild<LLSpinCtrl>("Path Limit Begin");
childSetCommitCallback("Path Limit Begin",onCommitParametric,this);
mCtrlPathBegin->setValidateBeforeCommit( &precommitValidate );
mCtrlPathEnd = getChild<LLSpinCtrl>("Path Limit End");
childSetCommitCallback("Path Limit End",onCommitParametric,this);
mCtrlPathEnd->setValidateBeforeCommit( &precommitValidate );
// Taper
mLabelTaper = getChild<LLTextBox>("text taper2");
mSpinTaperX = getChild<LLSpinCtrl>("Taper X");
childSetCommitCallback("Taper X",onCommitParametric,this);
mSpinTaperX->setValidateBeforeCommit( precommitValidate );
mSpinTaperY = getChild<LLSpinCtrl>("Taper Y");
childSetCommitCallback("Taper Y",onCommitParametric,this);
mSpinTaperY->setValidateBeforeCommit( precommitValidate );
// Radius Offset / Revolutions
mLabelRadiusOffset = getChild<LLTextBox>("text radius delta");
mLabelRevolutions = getChild<LLTextBox>("text revolutions");
mSpinRadiusOffset = getChild<LLSpinCtrl>("Radius Offset");
childSetCommitCallback("Radius Offset",onCommitParametric,this);
mSpinRadiusOffset->setValidateBeforeCommit( &precommitValidate );
mSpinRevolutions = getChild<LLSpinCtrl>("Revolutions");
childSetCommitCallback("Revolutions",onCommitParametric,this);
mSpinRevolutions->setValidateBeforeCommit( &precommitValidate );
// Sculpt
mCtrlSculptTexture = getChild<LLTextureCtrl>("sculpt texture control");
if (mCtrlSculptTexture)
{
mCtrlSculptTexture->setDefaultImageAssetID(LLUUID(SCULPT_DEFAULT_TEXTURE));
mCtrlSculptTexture->setCommitCallback( boost::bind(&LLPanelObject::onCommitSculpt, this, _2 ));
mCtrlSculptTexture->setOnCancelCallback( boost::bind(&LLPanelObject::onCancelSculpt, this, _2 ));
mCtrlSculptTexture->setOnSelectCallback( boost::bind(&LLPanelObject::onSelectSculpt, this, _2 ));
mCtrlSculptTexture->setDropCallback( boost::bind(&LLPanelObject::onDropSculpt, this, _2 ));
// Don't allow (no copy) or (no transfer) textures to be selected during immediate mode
mCtrlSculptTexture->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER);
mCtrlSculptTexture->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);
LLAggregatePermissions texture_perms;
if (LLSelectMgr::getInstance()->selectGetAggregateTexturePermissions(texture_perms))
{
BOOL can_copy =
texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_EMPTY ||
texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_ALL;
BOOL can_transfer =
texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_EMPTY ||
texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_ALL;
mCtrlSculptTexture->setCanApplyImmediately(can_copy && can_transfer);
}
else
{
mCtrlSculptTexture->setCanApplyImmediately(FALSE);
}
}
mLabelSculptType = getChild<LLTextBox>("label sculpt type");
mCtrlSculptType = getChild<LLComboBox>("sculpt type control");
childSetCommitCallback("sculpt type control", onCommitSculptType, this);
mCtrlSculptMirror = getChild<LLCheckBoxCtrl>("sculpt mirror control");
childSetCommitCallback("sculpt mirror control", onCommitSculptType, this);
mCtrlSculptInvert = getChild<LLCheckBoxCtrl>("sculpt invert control");
childSetCommitCallback("sculpt invert control", onCommitSculptType, this);
// Start with everyone disabled
clearCtrls();
return TRUE;
}
LLPanelObject::LLPanelObject()
: LLPanel(),
mIsPhysical(FALSE),
mIsTemporary(FALSE),
mIsPhantom(FALSE),
mSelectedType(MI_BOX),
mSculptTextureRevert(LLUUID::null),
mSculptTypeRevert(0),
mHasClipboardPos(false),
mHasClipboardSize(false),
mHasClipboardRot(false),
mSizeChanged(FALSE)
{
mCommitCallbackRegistrar.add("PanelObject.menuDoToSelected", boost::bind(&LLPanelObject::menuDoToSelected, this, _2));
mEnableCallbackRegistrar.add("PanelObject.menuEnable", boost::bind(&LLPanelObject::menuEnableItem, this, _2));
}
LLPanelObject::~LLPanelObject()
{
// Children all cleaned up by default view destructor.
}
void LLPanelObject::getState( )
{
LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
LLViewerObject* root_objectp = objectp;
if(!objectp)
{
objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
// *FIX: shouldn't we just keep the child?
if (objectp)
{
LLViewerObject* parentp = objectp->getRootEdit();
if (parentp)
{
root_objectp = parentp;
}
else
{
root_objectp = objectp;
}
}
}
LLCalc* calcp = LLCalc::getInstance();
LLVOVolume *volobjp = NULL;
if ( objectp && (objectp->getPCode() == LL_PCODE_VOLUME))
{
volobjp = (LLVOVolume *)objectp;
}
if( !objectp )
{
//forfeit focus
if (gFocusMgr.childHasKeyboardFocus(this))
{
gFocusMgr.setKeyboardFocus(NULL);
}
// Disable all text input fields
clearCtrls();
calcp->clearAllVariables();
return;
}
S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount();
BOOL single_volume = (LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME ))
&& (selected_count == 1);
bool enable_move;
bool enable_modify;
LLSelectMgr::getInstance()->selectGetEditMoveLinksetPermissions(enable_move, enable_modify);
BOOL enable_scale = enable_modify;
BOOL enable_rotate = enable_move; // already accounts for a case of children, which needs permModify() as well
LLVector3 vec;
if (enable_move)
{
vec = objectp->getPositionEdit();
mCtrlPosX->set( vec.mV[VX] );
mCtrlPosY->set( vec.mV[VY] );
mCtrlPosZ->set( vec.mV[VZ] );
calcp->setVar(LLCalc::X_POS, vec.mV[VX]);
calcp->setVar(LLCalc::Y_POS, vec.mV[VY]);
calcp->setVar(LLCalc::Z_POS, vec.mV[VZ]);
}
else
{
mCtrlPosX->clear();
mCtrlPosY->clear();
mCtrlPosZ->clear();
calcp->clearVar(LLCalc::X_POS);
calcp->clearVar(LLCalc::Y_POS);
calcp->clearVar(LLCalc::Z_POS);
}
mMenuClipboardPos->setEnabled(enable_move);
mLabelPosition->setEnabled( enable_move );
mCtrlPosX->setEnabled(enable_move);
mCtrlPosY->setEnabled(enable_move);
mCtrlPosZ->setEnabled(enable_move);
if (enable_scale)
{
vec = objectp->getScale();
mCtrlScaleX->set( vec.mV[VX] );
mCtrlScaleY->set( vec.mV[VY] );
mCtrlScaleZ->set( vec.mV[VZ] );
calcp->setVar(LLCalc::X_SCALE, vec.mV[VX]);
calcp->setVar(LLCalc::Y_SCALE, vec.mV[VY]);
calcp->setVar(LLCalc::Z_SCALE, vec.mV[VZ]);
}
else
{
mCtrlScaleX->clear();
mCtrlScaleY->clear();
mCtrlScaleZ->clear();
calcp->setVar(LLCalc::X_SCALE, 0.f);
calcp->setVar(LLCalc::Y_SCALE, 0.f);
calcp->setVar(LLCalc::Z_SCALE, 0.f);
}
mMenuClipboardSize->setEnabled(enable_scale);
mLabelSize->setEnabled( enable_scale );
mCtrlScaleX->setEnabled( enable_scale );
mCtrlScaleY->setEnabled( enable_scale );
mCtrlScaleZ->setEnabled( enable_scale );
LLQuaternion object_rot = objectp->getRotationEdit();
object_rot.getEulerAngles(&(mCurEulerDegrees.mV[VX]), &(mCurEulerDegrees.mV[VY]), &(mCurEulerDegrees.mV[VZ]));
mCurEulerDegrees *= RAD_TO_DEG;
mCurEulerDegrees.mV[VX] = fmod(ll_round(mCurEulerDegrees.mV[VX], OBJECT_ROTATION_PRECISION) + 360.f, 360.f);
mCurEulerDegrees.mV[VY] = fmod(ll_round(mCurEulerDegrees.mV[VY], OBJECT_ROTATION_PRECISION) + 360.f, 360.f);
mCurEulerDegrees.mV[VZ] = fmod(ll_round(mCurEulerDegrees.mV[VZ], OBJECT_ROTATION_PRECISION) + 360.f, 360.f);
if (enable_rotate)
{
mCtrlRotX->set( mCurEulerDegrees.mV[VX] );
mCtrlRotY->set( mCurEulerDegrees.mV[VY] );
mCtrlRotZ->set( mCurEulerDegrees.mV[VZ] );
calcp->setVar(LLCalc::X_ROT, mCurEulerDegrees.mV[VX]);
calcp->setVar(LLCalc::Y_ROT, mCurEulerDegrees.mV[VY]);
calcp->setVar(LLCalc::Z_ROT, mCurEulerDegrees.mV[VZ]);
}
else
{
mCtrlRotX->clear();
mCtrlRotY->clear();
mCtrlRotZ->clear();
calcp->clearVar(LLCalc::X_ROT);
calcp->clearVar(LLCalc::Y_ROT);
calcp->clearVar(LLCalc::Z_ROT);
}
mMenuClipboardRot->setEnabled(enable_rotate);
mLabelRotation->setEnabled( enable_rotate );
mCtrlRotX->setEnabled( enable_rotate );
mCtrlRotY->setEnabled( enable_rotate );
mCtrlRotZ->setEnabled( enable_rotate );
LLUUID owner_id;
std::string owner_name;
LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name);
// BUG? Check for all objects being editable?
S32 roots_selected = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount();
BOOL editable = root_objectp->permModify();
BOOL is_flexible = volobjp && volobjp->isFlexible();
BOOL is_permanent = root_objectp->flagObjectPermanent();
BOOL is_permanent_enforced = root_objectp->isPermanentEnforced();
BOOL is_character = root_objectp->flagCharacter();
llassert(!is_permanent || !is_character); // should never have a permanent object that is also a character
// Lock checkbox - only modifiable if you own the object.
BOOL self_owned = (gAgent.getID() == owner_id);
mCheckLock->setEnabled( roots_selected > 0 && self_owned && !is_permanent_enforced);
// More lock and debit checkbox - get the values
BOOL valid;
U32 owner_mask_on;
U32 owner_mask_off;
valid = LLSelectMgr::getInstance()->selectGetPerm(PERM_OWNER, &owner_mask_on, &owner_mask_off);
if(valid)
{
if(owner_mask_on & PERM_MOVE)
{
// owner can move, so not locked
mCheckLock->set(FALSE);
mCheckLock->setTentative(FALSE);
}
else if(owner_mask_off & PERM_MOVE)
{
// owner can't move, so locked
mCheckLock->set(TRUE);
mCheckLock->setTentative(FALSE);
}
else
{
// some locked, some not locked
mCheckLock->set(FALSE);
mCheckLock->setTentative(TRUE);
}
}
// Physics checkbox
mIsPhysical = root_objectp->flagUsePhysics();
llassert(!is_permanent || !mIsPhysical); // should never have a permanent object that is also physical
mCheckPhysics->set( mIsPhysical );
mCheckPhysics->setEnabled( roots_selected>0
&& (editable || gAgent.isGodlike())
&& !is_flexible && !is_permanent);
mIsTemporary = root_objectp->flagTemporaryOnRez();
llassert(!is_permanent || !mIsTemporary); // should never has a permanent object that is also temporary
mCheckTemporary->set( mIsTemporary );
mCheckTemporary->setEnabled( roots_selected>0 && editable && !is_permanent);
mIsPhantom = root_objectp->flagPhantom();
BOOL is_volume_detect = root_objectp->flagVolumeDetect();
llassert(!is_character || !mIsPhantom); // should never have a character that is also a phantom
mCheckPhantom->set( mIsPhantom );
mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible && !is_permanent_enforced && !is_character && !is_volume_detect);
//----------------------------------------------------------------------------
S32 selected_item = MI_BOX;
S32 selected_hole = MI_HOLE_SAME;
BOOL enabled = FALSE;
BOOL hole_enabled = FALSE;
F32 scale_x=1.f, scale_y=1.f;
BOOL isMesh = FALSE;
if( !objectp || !objectp->getVolume() || !editable || !single_volume)
{
// Clear out all geometry fields.
mComboBaseType->clear();
mSpinHollow->clear();
mSpinCutBegin->clear();
mSpinCutEnd->clear();
mCtrlPathBegin->clear();
mCtrlPathEnd->clear();
mSpinScaleX->clear();
mSpinScaleY->clear();
mSpinTwist->clear();
mSpinTwistBegin->clear();
mComboHoleType->clear();
mSpinShearX->clear();
mSpinShearY->clear();
mSpinTaperX->clear();
mSpinTaperY->clear();
mSpinRadiusOffset->clear();
mSpinRevolutions->clear();
mSpinSkew->clear();
mSelectedType = MI_NONE;
}
else
{
// Only allowed to change these parameters for objects
// that you have permissions on AND are not attachments.
enabled = root_objectp->permModify() && !root_objectp->isPermanentEnforced();
// Volume type
const LLVolumeParams &volume_params = objectp->getVolume()->getParams();
U8 path = volume_params.getPathParams().getCurveType();
U8 profile_and_hole = volume_params.getProfileParams().getCurveType();
U8 profile = profile_and_hole & LL_PCODE_PROFILE_MASK;
U8 hole = profile_and_hole & LL_PCODE_HOLE_MASK;
// Scale goes first so we can differentiate between a sphere and a torus,
// which have the same profile and path types.
// Scale
scale_x = volume_params.getRatioX();
scale_y = volume_params.getRatioY();
BOOL linear_path = (path == LL_PCODE_PATH_LINE) || (path == LL_PCODE_PATH_FLEXIBLE);
if ( linear_path && profile == LL_PCODE_PROFILE_CIRCLE )
{
selected_item = MI_CYLINDER;
}
else if ( linear_path && profile == LL_PCODE_PROFILE_SQUARE )
{
selected_item = MI_BOX;
}
else if ( linear_path && profile == LL_PCODE_PROFILE_ISOTRI )
{
selected_item = MI_PRISM;
}
else if ( linear_path && profile == LL_PCODE_PROFILE_EQUALTRI )
{
selected_item = MI_PRISM;
}
else if ( linear_path && profile == LL_PCODE_PROFILE_RIGHTTRI )
{
selected_item = MI_PRISM;
}
else if (path == LL_PCODE_PATH_FLEXIBLE) // shouldn't happen
{
selected_item = MI_CYLINDER; // reasonable default
}
else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_CIRCLE && scale_y > 0.75f)
{
selected_item = MI_SPHERE;
}
else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_CIRCLE && scale_y <= 0.75f)
{
selected_item = MI_TORUS;
}
else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_CIRCLE_HALF)
{
selected_item = MI_SPHERE;
}
else if ( path == LL_PCODE_PATH_CIRCLE2 && profile == LL_PCODE_PROFILE_CIRCLE )
{
// Spirals aren't supported. Make it into a sphere. JC
selected_item = MI_SPHERE;
}
else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_EQUALTRI )
{
selected_item = MI_RING;
}
else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_SQUARE && scale_y <= 0.75f)
{
selected_item = MI_TUBE;
}
else
{
LL_INFOS("FloaterTools") << "Unknown path " << (S32) path << " profile " << (S32) profile << " in getState" << LL_ENDL;
selected_item = MI_BOX;
}
if (objectp->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT))
{
selected_item = MI_SCULPT;
//LLFirstUse::useSculptedPrim();
}
mComboBaseType ->setCurrentByIndex( selected_item );
mSelectedType = selected_item;
// Grab S path
F32 begin_s = volume_params.getBeginS();
F32 end_s = volume_params.getEndS();
// Compute cut and advanced cut from S and T
F32 begin_t = volume_params.getBeginT();
F32 end_t = volume_params.getEndT();
// Hollowness
F32 hollow = 100.f * volume_params.getHollow();
mSpinHollow->set( hollow );
calcp->setVar(LLCalc::HOLLOW, hollow);
// All hollow objects allow a shape to be selected.
if (hollow > 0.f)
{
switch (hole)
{
case LL_PCODE_HOLE_CIRCLE:
selected_hole = MI_HOLE_CIRCLE;
break;
case LL_PCODE_HOLE_SQUARE:
selected_hole = MI_HOLE_SQUARE;
break;
case LL_PCODE_HOLE_TRIANGLE:
selected_hole = MI_HOLE_TRIANGLE;
break;
case LL_PCODE_HOLE_SAME:
default:
selected_hole = MI_HOLE_SAME;
break;
}
mComboHoleType->setCurrentByIndex( selected_hole );
hole_enabled = enabled;
}
else
{
mComboHoleType->setCurrentByIndex( MI_HOLE_SAME );
hole_enabled = FALSE;
}
// Cut interpretation varies based on base object type
F32 cut_begin, cut_end, adv_cut_begin, adv_cut_end;
if ( selected_item == MI_SPHERE || selected_item == MI_TORUS ||
selected_item == MI_TUBE || selected_item == MI_RING )
{
cut_begin = begin_t;
cut_end = end_t;
adv_cut_begin = begin_s;
adv_cut_end = end_s;
}
else
{
cut_begin = begin_s;
cut_end = end_s;
adv_cut_begin = begin_t;
adv_cut_end = end_t;
}
mSpinCutBegin ->set( cut_begin );
mSpinCutEnd ->set( cut_end );
mCtrlPathBegin ->set( adv_cut_begin );
mCtrlPathEnd ->set( adv_cut_end );
calcp->setVar(LLCalc::CUT_BEGIN, cut_begin);
calcp->setVar(LLCalc::CUT_END, cut_end);
calcp->setVar(LLCalc::PATH_BEGIN, adv_cut_begin);
calcp->setVar(LLCalc::PATH_END, adv_cut_end);
// Twist
F32 twist = volume_params.getTwist();
F32 twist_begin = volume_params.getTwistBegin();
// Check the path type for conversion.
if (path == LL_PCODE_PATH_LINE || path == LL_PCODE_PATH_FLEXIBLE)
{
twist *= OBJECT_TWIST_LINEAR_MAX;
twist_begin *= OBJECT_TWIST_LINEAR_MAX;
}
else
{
twist *= OBJECT_TWIST_MAX;
twist_begin *= OBJECT_TWIST_MAX;
}
mSpinTwist ->set( twist );
mSpinTwistBegin ->set( twist_begin );
calcp->setVar(LLCalc::TWIST_END, twist);
calcp->setVar(LLCalc::TWIST_BEGIN, twist_begin);
// Shear
F32 shear_x = volume_params.getShearX();
F32 shear_y = volume_params.getShearY();
mSpinShearX->set( shear_x );
mSpinShearY->set( shear_y );
calcp->setVar(LLCalc::X_SHEAR, shear_x);
calcp->setVar(LLCalc::Y_SHEAR, shear_y);
// Taper
F32 taper_x = volume_params.getTaperX();
F32 taper_y = volume_params.getTaperY();
mSpinTaperX->set( taper_x );
mSpinTaperY->set( taper_y );
calcp->setVar(LLCalc::X_TAPER, taper_x);
calcp->setVar(LLCalc::Y_TAPER, taper_y);
// Radius offset.
F32 radius_offset = volume_params.getRadiusOffset();
// Limit radius offset, based on taper and hole size y.
F32 radius_mag = fabs(radius_offset);
F32 hole_y_mag = fabs(scale_y);
F32 taper_y_mag = fabs(taper_y);
// Check to see if the taper effects us.
if ( (radius_offset > 0.f && taper_y < 0.f) ||
(radius_offset < 0.f && taper_y > 0.f) )
{
// The taper does not help increase the radius offset range.
taper_y_mag = 0.f;
}
F32 max_radius_mag = 1.f - hole_y_mag * (1.f - taper_y_mag) / (1.f - hole_y_mag);
// Enforce the maximum magnitude.
if (radius_mag > max_radius_mag)
{
// Check radius offset sign.
if (radius_offset < 0.f)
{
radius_offset = -max_radius_mag;
}
else
{
radius_offset = max_radius_mag;
}
}
mSpinRadiusOffset->set( radius_offset);
calcp->setVar(LLCalc::RADIUS_OFFSET, radius_offset);
// Revolutions
F32 revolutions = volume_params.getRevolutions();
mSpinRevolutions->set( revolutions );
calcp->setVar(LLCalc::REVOLUTIONS, revolutions);
// Skew
F32 skew = volume_params.getSkew();
// Limit skew, based on revolutions hole size x.
F32 skew_mag= fabs(skew);
F32 min_skew_mag = 1.0f - 1.0f / (revolutions * scale_x + 1.0f);
// Discontinuity; A revolution of 1 allows skews below 0.5.
if ( fabs(revolutions - 1.0f) < 0.001)
min_skew_mag = 0.0f;
// Clip skew.
if (skew_mag < min_skew_mag)
{
// Check skew sign.
if (skew < 0.0f)
{
skew = -min_skew_mag;
}
else
{
skew = min_skew_mag;
}
}
mSpinSkew->set( skew );
calcp->setVar(LLCalc::SKEW, skew);
}
// Compute control visibility, label names, and twist range.
// Start with defaults.
BOOL cut_visible = TRUE;
BOOL hollow_visible = TRUE;
BOOL top_size_x_visible = TRUE;
BOOL top_size_y_visible = TRUE;
BOOL top_shear_x_visible = TRUE;
BOOL top_shear_y_visible = TRUE;
BOOL twist_visible = TRUE;
BOOL advanced_cut_visible = FALSE;
BOOL taper_visible = FALSE;
BOOL skew_visible = FALSE;
BOOL radius_offset_visible = FALSE;
BOOL revolutions_visible = FALSE;
BOOL sculpt_texture_visible = FALSE;
F32 twist_min = OBJECT_TWIST_LINEAR_MIN;
F32 twist_max = OBJECT_TWIST_LINEAR_MAX;
F32 twist_inc = OBJECT_TWIST_LINEAR_INC;
BOOL advanced_is_dimple = FALSE;
BOOL advanced_is_slice = FALSE;
BOOL size_is_hole = FALSE;
// Tune based on overall volume type
switch (selected_item)
{
case MI_SPHERE:
top_size_x_visible = FALSE;
top_size_y_visible = FALSE;
top_shear_x_visible = FALSE;
top_shear_y_visible = FALSE;
//twist_visible = FALSE;
advanced_cut_visible = TRUE;
advanced_is_dimple = TRUE;
twist_min = OBJECT_TWIST_MIN;
twist_max = OBJECT_TWIST_MAX;
twist_inc = OBJECT_TWIST_INC;
break;
case MI_TORUS:
case MI_TUBE:
case MI_RING:
//top_size_x_visible = FALSE;
//top_size_y_visible = FALSE;
size_is_hole = TRUE;
skew_visible = TRUE;
advanced_cut_visible = TRUE;
taper_visible = TRUE;
radius_offset_visible = TRUE;
revolutions_visible = TRUE;
twist_min = OBJECT_TWIST_MIN;
twist_max = OBJECT_TWIST_MAX;
twist_inc = OBJECT_TWIST_INC;
break;
case MI_SCULPT:
cut_visible = FALSE;
hollow_visible = FALSE;
twist_visible = FALSE;
top_size_x_visible = FALSE;
top_size_y_visible = FALSE;
top_shear_x_visible = FALSE;
top_shear_y_visible = FALSE;
skew_visible = FALSE;
advanced_cut_visible = FALSE;
taper_visible = FALSE;
radius_offset_visible = FALSE;
revolutions_visible = FALSE;
sculpt_texture_visible = TRUE;
break;
case MI_BOX:
advanced_cut_visible = TRUE;
advanced_is_slice = TRUE;
break;
case MI_CYLINDER:
advanced_cut_visible = TRUE;
advanced_is_slice = TRUE;
break;
case MI_PRISM:
advanced_cut_visible = TRUE;
advanced_is_slice = TRUE;
break;
default:
break;
}
// Check if we need to change top size/hole size params.
switch (selected_item)
{
case MI_SPHERE:
case MI_TORUS:
case MI_TUBE:
case MI_RING:
mSpinScaleX->set( scale_x );
mSpinScaleY->set( scale_y );
calcp->setVar(LLCalc::X_HOLE, scale_x);
calcp->setVar(LLCalc::Y_HOLE, scale_y);
mSpinScaleX->setMinValue(OBJECT_MIN_HOLE_SIZE);
mSpinScaleX->setMaxValue(OBJECT_MAX_HOLE_SIZE_X);
mSpinScaleY->setMinValue(OBJECT_MIN_HOLE_SIZE);
mSpinScaleY->setMaxValue(OBJECT_MAX_HOLE_SIZE_Y);
break;
default:
if (editable && single_volume)
{
mSpinScaleX->set( 1.f - scale_x );
mSpinScaleY->set( 1.f - scale_y );
mSpinScaleX->setMinValue(-1.f);
mSpinScaleX->setMaxValue(1.f);
mSpinScaleY->setMinValue(-1.f);
mSpinScaleY->setMaxValue(1.f);
// Torus' Hole Size is Box/Cyl/Prism's Taper
calcp->setVar(LLCalc::X_TAPER, 1.f - scale_x);
calcp->setVar(LLCalc::Y_TAPER, 1.f - scale_y);
// Box/Cyl/Prism have no hole size
calcp->setVar(LLCalc::X_HOLE, 0.f);
calcp->setVar(LLCalc::Y_HOLE, 0.f);
}
break;
}
// Check if we need to limit the hollow based on the hole type.
if ( selected_hole == MI_HOLE_SQUARE &&
( selected_item == MI_CYLINDER || selected_item == MI_TORUS ||
selected_item == MI_PRISM || selected_item == MI_RING ||
selected_item == MI_SPHERE ) )
{
mSpinHollow->setMinValue(0.f);
mSpinHollow->setMaxValue(70.f);
}
else
{
mSpinHollow->setMinValue(0.f);
mSpinHollow->setMaxValue(95.f);
}
// Update field enablement
mComboBaseType ->setEnabled( enabled );
mMenuClipboardParams->setEnabled(enabled);
mLabelCut ->setEnabled( enabled );
mSpinCutBegin ->setEnabled( enabled );
mSpinCutEnd ->setEnabled( enabled );
mLabelHollow ->setEnabled( enabled );
mSpinHollow ->setEnabled( enabled );
mLabelHoleType ->setEnabled( hole_enabled );
mComboHoleType ->setEnabled( hole_enabled );
mLabelTwist ->setEnabled( enabled );
mSpinTwist ->setEnabled( enabled );
mSpinTwistBegin ->setEnabled( enabled );
mLabelSkew ->setEnabled( enabled );
mSpinSkew ->setEnabled( enabled );
getChildView("scale_hole")->setVisible( FALSE);
getChildView("scale_taper")->setVisible( FALSE);
if (top_size_x_visible || top_size_y_visible)
{
if (size_is_hole)
{
getChildView("scale_hole")->setVisible( TRUE);
getChildView("scale_hole")->setEnabled(enabled);
}
else
{
getChildView("scale_taper")->setVisible( TRUE);
getChildView("scale_taper")->setEnabled(enabled);
}
}
mSpinScaleX ->setEnabled( enabled );
mSpinScaleY ->setEnabled( enabled );
mLabelShear ->setEnabled( enabled );
mSpinShearX ->setEnabled( enabled );
mSpinShearY ->setEnabled( enabled );
getChildView("advanced_cut")->setVisible( FALSE);
getChildView("advanced_dimple")->setVisible( FALSE);
getChildView("advanced_slice")->setVisible( FALSE);
if (advanced_cut_visible)
{
if (advanced_is_dimple)
{
getChildView("advanced_dimple")->setVisible( TRUE);
getChildView("advanced_dimple")->setEnabled(enabled);
}
else if (advanced_is_slice)
{
getChildView("advanced_slice")->setVisible( TRUE);
getChildView("advanced_slice")->setEnabled(enabled);
}
else
{
getChildView("advanced_cut")->setVisible( TRUE);
getChildView("advanced_cut")->setEnabled(enabled);
}
}
mCtrlPathBegin ->setEnabled( enabled );
mCtrlPathEnd ->setEnabled( enabled );
mLabelTaper ->setEnabled( enabled );
mSpinTaperX ->setEnabled( enabled );
mSpinTaperY ->setEnabled( enabled );
mLabelRadiusOffset->setEnabled( enabled );
mSpinRadiusOffset ->setEnabled( enabled );
mLabelRevolutions->setEnabled( enabled );
mSpinRevolutions ->setEnabled( enabled );
// Update field visibility
mLabelCut ->setVisible( cut_visible );
mSpinCutBegin ->setVisible( cut_visible );
mSpinCutEnd ->setVisible( cut_visible );
mLabelHollow ->setVisible( hollow_visible );
mSpinHollow ->setVisible( hollow_visible );
mLabelHoleType ->setVisible( hollow_visible );
mComboHoleType ->setVisible( hollow_visible );
mLabelTwist ->setVisible( twist_visible );
mSpinTwist ->setVisible( twist_visible );
mSpinTwistBegin ->setVisible( twist_visible );
mSpinTwist ->setMinValue( twist_min );
mSpinTwist ->setMaxValue( twist_max );
mSpinTwist ->setIncrement( twist_inc );
mSpinTwistBegin ->setMinValue( twist_min );
mSpinTwistBegin ->setMaxValue( twist_max );
mSpinTwistBegin ->setIncrement( twist_inc );
mSpinScaleX ->setVisible( top_size_x_visible );
mSpinScaleY ->setVisible( top_size_y_visible );
mLabelSkew ->setVisible( skew_visible );
mSpinSkew ->setVisible( skew_visible );
mLabelShear ->setVisible( top_shear_x_visible || top_shear_y_visible );
mSpinShearX ->setVisible( top_shear_x_visible );
mSpinShearY ->setVisible( top_shear_y_visible );
mCtrlPathBegin ->setVisible( advanced_cut_visible );
mCtrlPathEnd ->setVisible( advanced_cut_visible );
mLabelTaper ->setVisible( taper_visible );
mSpinTaperX ->setVisible( taper_visible );
mSpinTaperY ->setVisible( taper_visible );
mLabelRadiusOffset->setVisible( radius_offset_visible );
mSpinRadiusOffset ->setVisible( radius_offset_visible );
mLabelRevolutions->setVisible( revolutions_visible );
mSpinRevolutions ->setVisible( revolutions_visible );
mCtrlSculptTexture->setVisible(sculpt_texture_visible);
mLabelSculptType->setVisible(sculpt_texture_visible);
mCtrlSculptType->setVisible(sculpt_texture_visible);
// sculpt texture
if (selected_item == MI_SCULPT)
{
LLUUID id;
LLSculptParams *sculpt_params = (LLSculptParams *)objectp->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
if (sculpt_params) // if we have a legal sculpt param block for this object:
{
if (mObject != objectp) // we've just selected a new object, so save for undo
{
mSculptTextureRevert = sculpt_params->getSculptTexture();
mSculptTypeRevert = sculpt_params->getSculptType();
}
U8 sculpt_type = sculpt_params->getSculptType();
U8 sculpt_stitching = sculpt_type & LL_SCULPT_TYPE_MASK;
BOOL sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT;
BOOL sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR;
isMesh = (sculpt_stitching == LL_SCULPT_TYPE_MESH);
LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("sculpt texture control");
if(mTextureCtrl)
{
mTextureCtrl->setTentative(FALSE);
mTextureCtrl->setEnabled(editable && !isMesh);
if (editable)
mTextureCtrl->setImageAssetID(sculpt_params->getSculptTexture());
else
mTextureCtrl->setImageAssetID(LLUUID::null);
}
mComboBaseType->setEnabled(!isMesh);
mMenuClipboardParams->setEnabled(!isMesh);
if (mCtrlSculptType)
{
if (sculpt_stitching == LL_SCULPT_TYPE_NONE)
{
// since 'None' is no longer an option in the combo box
// use 'Plane' as an equivalent sculpt type
mCtrlSculptType->setSelectedByValue(LLSD(LL_SCULPT_TYPE_PLANE), true);
}
else
{
mCtrlSculptType->setSelectedByValue(LLSD(sculpt_stitching), true);
}
mCtrlSculptType->setEnabled(editable && !isMesh);
}
if (mCtrlSculptMirror)
{
mCtrlSculptMirror->set(sculpt_mirror);
mCtrlSculptMirror->setEnabled(editable && !isMesh);
}
if (mCtrlSculptInvert)
{
mCtrlSculptInvert->set(sculpt_invert);
mCtrlSculptInvert->setEnabled(editable);
}
if (mLabelSculptType)
{
mLabelSculptType->setEnabled(TRUE);
}
}
}
else
{
mSculptTextureRevert = LLUUID::null;
}
mCtrlSculptMirror->setVisible(sculpt_texture_visible && !isMesh);
mCtrlSculptInvert->setVisible(sculpt_texture_visible && !isMesh);
//----------------------------------------------------------------------------
mObject = objectp;
mRootObject = root_objectp;
}
// static
bool LLPanelObject::precommitValidate( const LLSD& data )
{
// TODO: Richard will fill this in later.
return TRUE; // FALSE means that validation failed and new value should not be commited.
}
void LLPanelObject::sendIsPhysical()
{
BOOL value = mCheckPhysics->get();
if( mIsPhysical != value )
{
LLSelectMgr::getInstance()->selectionUpdatePhysics(value);
mIsPhysical = value;
LL_INFOS("FloaterTools") << "update physics sent" << LL_ENDL;
}
else
{
LL_INFOS("FloaterTools") << "update physics not changed" << LL_ENDL;
}
}
void LLPanelObject::sendIsTemporary()
{
BOOL value = mCheckTemporary->get();
if( mIsTemporary != value )
{
LLSelectMgr::getInstance()->selectionUpdateTemporary(value);
mIsTemporary = value;
LL_INFOS("FloaterTools") << "update temporary sent" << LL_ENDL;
}
else
{
LL_INFOS("FloaterTools") << "update temporary not changed" << LL_ENDL;
}
}
void LLPanelObject::sendIsPhantom()
{
BOOL value = mCheckPhantom->get();
if( mIsPhantom != value )
{
LLSelectMgr::getInstance()->selectionUpdatePhantom(value);
mIsPhantom = value;
LL_INFOS("FloaterTools") << "update phantom sent" << LL_ENDL;
}
else
{
LL_INFOS("FloaterTools") << "update phantom not changed" << LL_ENDL;
}
}
// static
void LLPanelObject::onCommitParametric( LLUICtrl* ctrl, void* userdata )
{
LLPanelObject* self = (LLPanelObject*) userdata;
if (self->mObject.isNull())
{
return;
}
if (self->mObject->getPCode() != LL_PCODE_VOLUME)
{
// Don't allow modification of non-volume objects.
return;
}
LLVolume *volume = self->mObject->getVolume();
if (!volume)
{
return;
}
LLVolumeParams volume_params;
self->getVolumeParams(volume_params);
// set sculpting
S32 selected_type = self->mComboBaseType->getCurrentIndex();
if (selected_type == MI_SCULPT)
{
self->mObject->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, TRUE);
LLSculptParams *sculpt_params = (LLSculptParams *)self->mObject->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
if (sculpt_params)
volume_params.setSculptID(sculpt_params->getSculptTexture(), sculpt_params->getSculptType());
}
else
{
LLSculptParams *sculpt_params = (LLSculptParams *)self->mObject->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
if (sculpt_params)
self->mObject->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, FALSE, TRUE);
}
// Update the volume, if necessary.
self->mObject->updateVolume(volume_params);
// This was added to make sure thate when changes are made, the UI
// adjusts to present valid options.
// *FIX: only some changes, ie, hollow or primitive type changes,
// require a refresh.
self->refresh();
}
void LLPanelObject::getVolumeParams(LLVolumeParams& volume_params)
{
// Figure out what type of volume to make
S32 was_selected_type = mSelectedType;
S32 selected_type = mComboBaseType->getCurrentIndex();
U8 profile;
U8 path;
switch ( selected_type )
{
case MI_CYLINDER:
profile = LL_PCODE_PROFILE_CIRCLE;
path = LL_PCODE_PATH_LINE;
break;
case MI_BOX:
profile = LL_PCODE_PROFILE_SQUARE;
path = LL_PCODE_PATH_LINE;
break;
case MI_PRISM:
profile = LL_PCODE_PROFILE_EQUALTRI;
path = LL_PCODE_PATH_LINE;
break;
case MI_SPHERE:
profile = LL_PCODE_PROFILE_CIRCLE_HALF;
path = LL_PCODE_PATH_CIRCLE;
break;
case MI_TORUS:
profile = LL_PCODE_PROFILE_CIRCLE;
path = LL_PCODE_PATH_CIRCLE;
break;
case MI_TUBE:
profile = LL_PCODE_PROFILE_SQUARE;
path = LL_PCODE_PATH_CIRCLE;
break;
case MI_RING:
profile = LL_PCODE_PROFILE_EQUALTRI;
path = LL_PCODE_PATH_CIRCLE;
break;
case MI_SCULPT:
profile = LL_PCODE_PROFILE_CIRCLE;
path = LL_PCODE_PATH_CIRCLE;
break;
default:
LL_WARNS("FloaterTools") << "Unknown base type " << selected_type
<< " in getVolumeParams()" << LL_ENDL;
// assume a box
selected_type = MI_BOX;
profile = LL_PCODE_PROFILE_SQUARE;
path = LL_PCODE_PATH_LINE;
break;
}
if (path == LL_PCODE_PATH_LINE)
{
LLVOVolume *volobjp = (LLVOVolume *)(LLViewerObject*)(mObject);
if (volobjp->isFlexible())
{
path = LL_PCODE_PATH_FLEXIBLE;
}
}
S32 selected_hole = mComboHoleType->getCurrentIndex();
U8 hole;
switch (selected_hole)
{
case MI_HOLE_CIRCLE:
hole = LL_PCODE_HOLE_CIRCLE;
break;
case MI_HOLE_SQUARE:
hole = LL_PCODE_HOLE_SQUARE;
break;
case MI_HOLE_TRIANGLE:
hole = LL_PCODE_HOLE_TRIANGLE;
break;
case MI_HOLE_SAME:
default:
hole = LL_PCODE_HOLE_SAME;
break;
}
volume_params.setType(profile | hole, path);
mSelectedType = selected_type;
// Compute cut start/end
F32 cut_begin = mSpinCutBegin->get();
F32 cut_end = mSpinCutEnd->get();
// Make sure at least OBJECT_CUT_INC of the object survives
if (cut_begin > cut_end - OBJECT_MIN_CUT_INC)
{
cut_begin = cut_end - OBJECT_MIN_CUT_INC;
mSpinCutBegin->set(cut_begin);
}
F32 adv_cut_begin = mCtrlPathBegin->get();
F32 adv_cut_end = mCtrlPathEnd->get();
// Make sure at least OBJECT_CUT_INC of the object survives
if (adv_cut_begin > adv_cut_end - OBJECT_MIN_CUT_INC)
{
adv_cut_begin = adv_cut_end - OBJECT_MIN_CUT_INC;
mCtrlPathBegin->set(adv_cut_begin);
}
F32 begin_s, end_s;
F32 begin_t, end_t;
if (selected_type == MI_SPHERE || selected_type == MI_TORUS ||
selected_type == MI_TUBE || selected_type == MI_RING)
{
begin_s = adv_cut_begin;
end_s = adv_cut_end;
begin_t = cut_begin;
end_t = cut_end;
}
else
{
begin_s = cut_begin;
end_s = cut_end;
begin_t = adv_cut_begin;
end_t = adv_cut_end;
}
volume_params.setBeginAndEndS(begin_s, end_s);
volume_params.setBeginAndEndT(begin_t, end_t);
// Hollowness
F32 hollow = mSpinHollow->get() / 100.f;
if ( selected_hole == MI_HOLE_SQUARE &&
( selected_type == MI_CYLINDER || selected_type == MI_TORUS ||
selected_type == MI_PRISM || selected_type == MI_RING ||
selected_type == MI_SPHERE ) )
{
if (hollow > 0.7f) hollow = 0.7f;
}
volume_params.setHollow( hollow );
// Twist Begin,End
F32 twist_begin = mSpinTwistBegin->get();
F32 twist = mSpinTwist->get();
// Check the path type for twist conversion.
if (path == LL_PCODE_PATH_LINE || path == LL_PCODE_PATH_FLEXIBLE)
{
twist_begin /= OBJECT_TWIST_LINEAR_MAX;
twist /= OBJECT_TWIST_LINEAR_MAX;
}
else
{
twist_begin /= OBJECT_TWIST_MAX;
twist /= OBJECT_TWIST_MAX;
}
volume_params.setTwistBegin(twist_begin);
volume_params.setTwist(twist);
// Scale X,Y
F32 scale_x = mSpinScaleX->get();
F32 scale_y = mSpinScaleY->get();
if ( was_selected_type == MI_BOX || was_selected_type == MI_CYLINDER || was_selected_type == MI_PRISM)
{
scale_x = 1.f - scale_x;
scale_y = 1.f - scale_y;
}
// Skew
F32 skew = mSpinSkew->get();
// Taper X,Y
F32 taper_x = mSpinTaperX->get();
F32 taper_y = mSpinTaperY->get();
// Radius offset
F32 radius_offset = mSpinRadiusOffset->get();
// Revolutions
F32 revolutions = mSpinRevolutions->get();
if ( selected_type == MI_SPHERE )
{
// Snap values to valid sphere parameters.
scale_x = 1.0f;
scale_y = 1.0f;
skew = 0.0f;
taper_x = 0.0f;
taper_y = 0.0f;
radius_offset = 0.0f;
revolutions = 1.0f;
}
else if ( selected_type == MI_TORUS || selected_type == MI_TUBE ||
selected_type == MI_RING )
{
scale_x = llclamp(
scale_x,
OBJECT_MIN_HOLE_SIZE,
OBJECT_MAX_HOLE_SIZE_X);
scale_y = llclamp(
scale_y,
OBJECT_MIN_HOLE_SIZE,
OBJECT_MAX_HOLE_SIZE_Y);
// Limit radius offset, based on taper and hole size y.
F32 radius_mag = fabs(radius_offset);
F32 hole_y_mag = fabs(scale_y);
F32 taper_y_mag = fabs(taper_y);
// Check to see if the taper effects us.
if ( (radius_offset > 0.f && taper_y < 0.f) ||
(radius_offset < 0.f && taper_y > 0.f) )
{
// The taper does not help increase the radius offset range.
taper_y_mag = 0.f;
}
F32 max_radius_mag = 1.f - hole_y_mag * (1.f - taper_y_mag) / (1.f - hole_y_mag);
// Enforce the maximum magnitude.
if (radius_mag > max_radius_mag)
{
// Check radius offset sign.
if (radius_offset < 0.f)
{
radius_offset = -max_radius_mag;
}
else
{
radius_offset = max_radius_mag;
}
}
// Check the skew value against the revolutions.
F32 skew_mag= fabs(skew);
F32 min_skew_mag = 1.0f - 1.0f / (revolutions * scale_x + 1.0f);
// Discontinuity; A revolution of 1 allows skews below 0.5.
if ( fabs(revolutions - 1.0f) < 0.001)
min_skew_mag = 0.0f;
// Clip skew.
if (skew_mag < min_skew_mag)
{
// Check skew sign.
if (skew < 0.0f)
{
skew = -min_skew_mag;
}
else
{
skew = min_skew_mag;
}
}
}
volume_params.setRatio( scale_x, scale_y );
volume_params.setSkew(skew);
volume_params.setTaper( taper_x, taper_y );
volume_params.setRadiusOffset(radius_offset);
volume_params.setRevolutions(revolutions);
// Shear X,Y
F32 shear_x = mSpinShearX->get();
F32 shear_y = mSpinShearY->get();
volume_params.setShear( shear_x, shear_y );
if (selected_type == MI_SCULPT)
{
volume_params.setSculptID(LLUUID::null, 0);
volume_params.setBeginAndEndT (0, 1);
volume_params.setBeginAndEndS (0, 1);
volume_params.setHollow (0);
volume_params.setTwistBegin (0);
volume_params.setTwistEnd (0);
volume_params.setRatio (1, 0.5);
volume_params.setShear (0, 0);
volume_params.setTaper (0, 0);
volume_params.setRevolutions (1);
volume_params.setRadiusOffset (0);
volume_params.setSkew (0);
}
}
// BUG: Make work with multiple objects
void LLPanelObject::sendRotation(BOOL btn_down)
{
if (mObject.isNull()) return;
LLVector3 new_rot(mCtrlRotX->get(), mCtrlRotY->get(), mCtrlRotZ->get());
new_rot.mV[VX] = ll_round(new_rot.mV[VX], OBJECT_ROTATION_PRECISION);
new_rot.mV[VY] = ll_round(new_rot.mV[VY], OBJECT_ROTATION_PRECISION);
new_rot.mV[VZ] = ll_round(new_rot.mV[VZ], OBJECT_ROTATION_PRECISION);
// Note: must compare before conversion to radians
LLVector3 delta = new_rot - mCurEulerDegrees;
if (delta.magVec() >= 0.0005f)
{
mCurEulerDegrees = new_rot;
new_rot *= DEG_TO_RAD;
LLQuaternion rotation;
rotation.setQuat(new_rot.mV[VX], new_rot.mV[VY], new_rot.mV[VZ]);
if (mRootObject != mObject)
{
rotation = rotation * ~mRootObject->getRotationRegion();
}
// To include avatars into movements and rotation
// If false, all children are selected anyway - move avatar
// If true, not all children are selected - save positions
bool individual_selection = gSavedSettings.getBOOL("EditLinkedParts");
std::vector<LLVector3>& child_positions = mObject->mUnselectedChildrenPositions ;
std::vector<LLQuaternion> child_rotations;
if (mObject->isRootEdit() && individual_selection)
{
mObject->saveUnselectedChildrenRotation(child_rotations) ;
mObject->saveUnselectedChildrenPosition(child_positions) ;
}
mObject->setRotation(rotation);
LLManip::rebuild(mObject) ;
// for individually selected roots, we need to counterrotate all the children
if (mObject->isRootEdit() && individual_selection)
{
mObject->resetChildrenRotationAndPosition(child_rotations, child_positions) ;
}
if(!btn_down)
{
child_positions.clear() ;
LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_ROTATION | UPD_POSITION);
}
}
}
// BUG: Make work with multiple objects
void LLPanelObject::sendScale(BOOL btn_down)
{
if (mObject.isNull()) return;
LLVector3 newscale(mCtrlScaleX->get(), mCtrlScaleY->get(), mCtrlScaleZ->get());
LLVector3 delta = newscale - mObject->getScale();
if (delta.magVec() >= 0.0005f || (mSizeChanged && !btn_down))
{
// scale changed by more than 1/2 millimeter
mSizeChanged = btn_down;
// check to see if we aren't scaling the textures
// (in which case the tex coord's need to be recomputed)
BOOL dont_stretch_textures = !LLManipScale::getStretchTextures();
if (dont_stretch_textures)
{
LLSelectMgr::getInstance()->saveSelectedObjectTransform(SELECT_ACTION_TYPE_SCALE);
}
mObject->setScale(newscale, TRUE);
if(!btn_down)
{
LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_SCALE | UPD_POSITION);
}
LLSelectMgr::getInstance()->adjustTexturesByScale(TRUE, !dont_stretch_textures);
// LL_INFOS() << "scale sent" << LL_ENDL;
}
else
{
// LL_INFOS() << "scale not changed" << LL_ENDL;
}
}
void LLPanelObject::sendPosition(BOOL btn_down)
{
if (mObject.isNull()) return;
LLVector3 newpos(mCtrlPosX->get(), mCtrlPosY->get(), mCtrlPosZ->get());
LLViewerRegion* regionp = mObject->getRegion();
if (!regionp) return;
if (!mObject->isAttachment())
{
// Clamp the Z height
const F32 height = newpos.mV[VZ];
const F32 min_height = LLWorld::getInstance()->getMinAllowedZ(mObject, mObject->getPositionGlobal());
const F32 max_height = LLWorld::getInstance()->getRegionMaxHeight();
if ( height < min_height)
{
newpos.mV[VZ] = min_height;
mCtrlPosZ->set( min_height );
}
else if ( height > max_height )
{
newpos.mV[VZ] = max_height;
mCtrlPosZ->set( max_height );
}
// Grass is always drawn on the ground, so clamp its position to the ground
if (mObject->getPCode() == LL_PCODE_LEGACY_GRASS)
{
mCtrlPosZ->set(LLWorld::getInstance()->resolveLandHeightAgent(newpos) + 1.f);
}
}
else
{
if (newpos.length() > MAX_ATTACHMENT_DIST)
{
newpos.clampLength(MAX_ATTACHMENT_DIST);
mCtrlPosX->set(newpos.mV[VX]);
mCtrlPosY->set(newpos.mV[VY]);
mCtrlPosZ->set(newpos.mV[VZ]);
}
}
// Make sure new position is in a valid region, so the object
// won't get dumped by the simulator.
LLVector3d new_pos_global = regionp->getPosGlobalFromRegion(newpos);
bool is_valid_pos = true;
if (mObject->isAttachment())
{
LLVector3 delta_pos = mObject->getPositionEdit() - newpos;
LLVector3d attachment_pos = regionp->getPosGlobalFromRegion(mObject->getPositionRegion() + delta_pos);
is_valid_pos = LLWorld::getInstance()->positionRegionValidGlobal(attachment_pos);
}
else
{
is_valid_pos = LLWorld::getInstance()->positionRegionValidGlobal(new_pos_global);
}
if (is_valid_pos)
{
// send only if the position is changed, that is, the delta vector is not zero
LLVector3d old_pos_global = mObject->getPositionGlobal();
LLVector3d delta = new_pos_global - old_pos_global;
// moved more than 1/2 millimeter
if (delta.magVec() >= 0.0005f)
{
if (mRootObject != mObject)
{
newpos = newpos - mRootObject->getPositionRegion();
newpos = newpos * ~mRootObject->getRotationRegion();
mObject->setPositionParent(newpos);
}
else
{
mObject->setPositionEdit(newpos);
}
LLManip::rebuild(mObject) ;
// for individually selected roots, we need to counter-translate all unselected children
if (mObject->isRootEdit())
{
// only offset by parent's translation
mObject->resetChildrenPosition(LLVector3(-delta), TRUE, TRUE) ;
}
if(!btn_down)
{
LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_POSITION);
}
LLSelectMgr::getInstance()->updateSelectionCenter();
}
}
else
{
// move failed, so we update the UI with the correct values
LLVector3 vec = mRootObject->getPositionRegion();
mCtrlPosX->set(vec.mV[VX]);
mCtrlPosY->set(vec.mV[VY]);
mCtrlPosZ->set(vec.mV[VZ]);
}
}
void LLPanelObject::sendSculpt()
{
if (mObject.isNull())
return;
LLSculptParams sculpt_params;
LLUUID sculpt_id = LLUUID::null;
if (mCtrlSculptTexture)
sculpt_id = mCtrlSculptTexture->getImageAssetID();
U8 sculpt_type = 0;
if (mCtrlSculptType)
sculpt_type |= mCtrlSculptType->getValue().asInteger();
bool enabled = sculpt_type != LL_SCULPT_TYPE_MESH;
if (mCtrlSculptMirror)
{
mCtrlSculptMirror->setEnabled(enabled ? TRUE : FALSE);
}
if (mCtrlSculptInvert)
{
mCtrlSculptInvert->setEnabled(enabled ? TRUE : FALSE);
}
if ((mCtrlSculptMirror) && (mCtrlSculptMirror->get()))
sculpt_type |= LL_SCULPT_FLAG_MIRROR;
if ((mCtrlSculptInvert) && (mCtrlSculptInvert->get()))
sculpt_type |= LL_SCULPT_FLAG_INVERT;
sculpt_params.setSculptTexture(sculpt_id, sculpt_type);
mObject->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt_params, TRUE);
}
void LLPanelObject::refresh()
{
getState();
if (mObject.notNull() && mObject->isDead())
{
mObject = NULL;
}
if (mRootObject.notNull() && mRootObject->isDead())
{
mRootObject = NULL;
}
F32 max_scale = get_default_max_prim_scale(LLPickInfo::isFlora(mObject));
getChild<LLSpinCtrl>("Scale X")->setMaxValue(max_scale);
getChild<LLSpinCtrl>("Scale Y")->setMaxValue(max_scale);
getChild<LLSpinCtrl>("Scale Z")->setMaxValue(max_scale);
}
void LLPanelObject::draw()
{
const LLColor4 white( 1.0f, 1.0f, 1.0f, 1);
const LLColor4 red( 1.0f, 0.25f, 0.f, 1);
const LLColor4 green( 0.f, 1.0f, 0.f, 1);
const LLColor4 blue( 0.f, 0.5f, 1.0f, 1);
// Tune the colors of the labels
LLTool* tool = LLToolMgr::getInstance()->getCurrentTool();
if (tool == LLToolCompTranslate::getInstance())
{
mCtrlPosX ->setLabelColor(red);
mCtrlPosY ->setLabelColor(green);
mCtrlPosZ ->setLabelColor(blue);
mCtrlScaleX ->setLabelColor(white);
mCtrlScaleY ->setLabelColor(white);
mCtrlScaleZ ->setLabelColor(white);
mCtrlRotX ->setLabelColor(white);
mCtrlRotY ->setLabelColor(white);
mCtrlRotZ ->setLabelColor(white);
}
else if ( tool == LLToolCompScale::getInstance() )
{
mCtrlPosX ->setLabelColor(white);
mCtrlPosY ->setLabelColor(white);
mCtrlPosZ ->setLabelColor(white);
mCtrlScaleX ->setLabelColor(red);
mCtrlScaleY ->setLabelColor(green);
mCtrlScaleZ ->setLabelColor(blue);
mCtrlRotX ->setLabelColor(white);
mCtrlRotY ->setLabelColor(white);
mCtrlRotZ ->setLabelColor(white);
}
else if ( tool == LLToolCompRotate::getInstance() )
{
mCtrlPosX ->setLabelColor(white);
mCtrlPosY ->setLabelColor(white);
mCtrlPosZ ->setLabelColor(white);
mCtrlScaleX ->setLabelColor(white);
mCtrlScaleY ->setLabelColor(white);
mCtrlScaleZ ->setLabelColor(white);
mCtrlRotX ->setLabelColor(red);
mCtrlRotY ->setLabelColor(green);
mCtrlRotZ ->setLabelColor(blue);
}
else
{
mCtrlPosX ->setLabelColor(white);
mCtrlPosY ->setLabelColor(white);
mCtrlPosZ ->setLabelColor(white);
mCtrlScaleX ->setLabelColor(white);
mCtrlScaleY ->setLabelColor(white);
mCtrlScaleZ ->setLabelColor(white);
mCtrlRotX ->setLabelColor(white);
mCtrlRotY ->setLabelColor(white);
mCtrlRotZ ->setLabelColor(white);
}
LLPanel::draw();
}
// virtual
void LLPanelObject::clearCtrls()
{
LLPanel::clearCtrls();
mCheckLock ->set(FALSE);
mCheckLock ->setEnabled( FALSE );
mCheckPhysics ->set(FALSE);
mCheckPhysics ->setEnabled( FALSE );
mCheckTemporary ->set(FALSE);
mCheckTemporary ->setEnabled( FALSE );
mCheckPhantom ->set(FALSE);
mCheckPhantom ->setEnabled( FALSE );
// Disable text labels
mLabelPosition ->setEnabled( FALSE );
mLabelSize ->setEnabled( FALSE );
mLabelRotation ->setEnabled( FALSE );
mLabelCut ->setEnabled( FALSE );
mLabelHollow ->setEnabled( FALSE );
mLabelHoleType ->setEnabled( FALSE );
mLabelTwist ->setEnabled( FALSE );
mLabelSkew ->setEnabled( FALSE );
mLabelShear ->setEnabled( FALSE );
mLabelTaper ->setEnabled( FALSE );
mLabelRadiusOffset->setEnabled( FALSE );
mLabelRevolutions->setEnabled( FALSE );
getChildView("scale_hole")->setEnabled(FALSE);
getChildView("scale_taper")->setEnabled(FALSE);
getChildView("advanced_cut")->setEnabled(FALSE);
getChildView("advanced_dimple")->setEnabled(FALSE);
getChildView("advanced_slice")->setVisible( FALSE);
}
//
// Static functions
//
// static
void LLPanelObject::onCommitLock(LLUICtrl *ctrl, void *data)
{
// Checkbox will have toggled itself
LLPanelObject *self = (LLPanelObject *)data;
if(self->mRootObject.isNull()) return;
BOOL new_state = self->mCheckLock->get();
LLSelectMgr::getInstance()->selectionSetObjectPermissions(PERM_OWNER, !new_state, PERM_MOVE | PERM_MODIFY);
}
// static
void LLPanelObject::onCommitPosition( LLUICtrl* ctrl, void* userdata )
{
LLPanelObject* self = (LLPanelObject*) userdata;
BOOL btn_down = ((LLSpinCtrl*)ctrl)->isMouseHeldDown() ;
self->sendPosition(btn_down);
}
// static
void LLPanelObject::onCommitScale( LLUICtrl* ctrl, void* userdata )
{
LLPanelObject* self = (LLPanelObject*) userdata;
BOOL btn_down = ((LLSpinCtrl*)ctrl)->isMouseHeldDown() ;
self->sendScale(btn_down);
}
// static
void LLPanelObject::onCommitRotation( LLUICtrl* ctrl, void* userdata )
{
LLPanelObject* self = (LLPanelObject*) userdata;
BOOL btn_down = ((LLSpinCtrl*)ctrl)->isMouseHeldDown() ;
self->sendRotation(btn_down);
}
// static
void LLPanelObject::onCommitPhysics( LLUICtrl* ctrl, void* userdata )
{
LLPanelObject* self = (LLPanelObject*) userdata;
self->sendIsPhysical();
}
// static
void LLPanelObject::onCommitTemporary( LLUICtrl* ctrl, void* userdata )
{
LLPanelObject* self = (LLPanelObject*) userdata;
self->sendIsTemporary();
}
// static
void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
{
LLPanelObject* self = (LLPanelObject*) userdata;
self->sendIsPhantom();
}
void LLPanelObject::onSelectSculpt(const LLSD& data)
{
LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("sculpt texture control");
if (mTextureCtrl)
{
mSculptTextureRevert = mTextureCtrl->getImageAssetID();
}
sendSculpt();
}
void LLPanelObject::onCommitSculpt( const LLSD& data )
{
sendSculpt();
}
BOOL LLPanelObject::onDropSculpt(LLInventoryItem* item)
{
LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("sculpt texture control");
if (mTextureCtrl)
{
LLUUID asset = item->getAssetUUID();
mTextureCtrl->setImageAssetID(asset);
mSculptTextureRevert = asset;
}
return TRUE;
}
void LLPanelObject::onCancelSculpt(const LLSD& data)
{
LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("sculpt texture control");
if(!mTextureCtrl)
return;
if(mSculptTextureRevert == LLUUID::null)
{
mSculptTextureRevert = LLUUID(SCULPT_DEFAULT_TEXTURE);
}
mTextureCtrl->setImageAssetID(mSculptTextureRevert);
sendSculpt();
}
// static
void LLPanelObject::onCommitSculptType(LLUICtrl *ctrl, void* userdata)
{
LLPanelObject* self = (LLPanelObject*) userdata;
self->sendSculpt();
}
void LLPanelObject::menuDoToSelected(const LLSD& userdata)
{
std::string command = userdata.asString();
// paste
if (command == "psr_paste")
{
onPastePos();
onPasteSize();
onPasteRot();
}
else if (command == "pos_paste")
{
onPastePos();
}
else if (command == "size_paste")
{
onPasteSize();
}
else if (command == "rot_paste")
{
onPasteRot();
}
else if (command == "params_paste")
{
onPasteParams();
}
// copy
else if (command == "psr_copy")
{
onCopyPos();
onCopySize();
onCopyRot();
}
else if (command == "pos_copy")
{
onCopyPos();
}
else if (command == "size_copy")
{
onCopySize();
}
else if (command == "rot_copy")
{
onCopyRot();
}
else if (command == "params_copy")
{
onCopyParams();
}
}
bool LLPanelObject::menuEnableItem(const LLSD& userdata)
{
std::string command = userdata.asString();
// paste options
if (command == "psr_paste")
{
S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount();
BOOL single_volume = (LLSelectMgr::getInstance()->selectionAllPCode(LL_PCODE_VOLUME))
&& (selected_count == 1);
if (!single_volume)
{
return false;
}
bool enable_move;
bool enable_modify;
LLSelectMgr::getInstance()->selectGetEditMoveLinksetPermissions(enable_move, enable_modify);
return enable_move && enable_modify && mHasClipboardPos && mHasClipboardSize && mHasClipboardRot;
}
else if (command == "pos_paste")
{
// assumes that menu won't be active if there is no move permission
return mHasClipboardPos;
}
else if (command == "size_paste")
{
return mHasClipboardSize;
}
else if (command == "rot_paste")
{
return mHasClipboardRot;
}
else if (command == "params_paste")
{
return mClipboardParams.isMap() && (mClipboardParams.size() != 0);
}
// copy options
else if (command == "psr_copy")
{
S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount();
BOOL single_volume = (LLSelectMgr::getInstance()->selectionAllPCode(LL_PCODE_VOLUME))
&& (selected_count == 1);
if (!single_volume)
{
return false;
}
bool enable_move;
bool enable_modify;
LLSelectMgr::getInstance()->selectGetEditMoveLinksetPermissions(enable_move, enable_modify);
// since we forbid seeing values we also should forbid copying them
return enable_move && enable_modify;
}
return false;
}
void LLPanelObject::onCopyPos()
{
mClipboardPos = LLVector3(mCtrlPosX->get(), mCtrlPosY->get(), mCtrlPosZ->get());
std::string stringVec = llformat("<%g, %g, %g>", mClipboardPos.mV[VX], mClipboardPos.mV[VY], mClipboardPos.mV[VZ]);
LLView::getWindow()->copyTextToClipboard(utf8str_to_wstring(stringVec));
mHasClipboardPos = true;
}
void LLPanelObject::onCopySize()
{
mClipboardSize = LLVector3(mCtrlScaleX->get(), mCtrlScaleY->get(), mCtrlScaleZ->get());
std::string stringVec = llformat("<%g, %g, %g>", mClipboardSize.mV[VX], mClipboardSize.mV[VY], mClipboardSize.mV[VZ]);
LLView::getWindow()->copyTextToClipboard(utf8str_to_wstring(stringVec));
mHasClipboardSize = true;
}
void LLPanelObject::onCopyRot()
{
mClipboardRot = LLVector3(mCtrlRotX->get(), mCtrlRotY->get(), mCtrlRotZ->get());
std::string stringVec = llformat("<%g, %g, %g>", mClipboardRot.mV[VX], mClipboardRot.mV[VY], mClipboardRot.mV[VZ]);
LLView::getWindow()->copyTextToClipboard(utf8str_to_wstring(stringVec));
mHasClipboardRot = true;
}
void LLPanelObject::onPastePos()
{
if (!mHasClipboardPos) return;
if (mObject.isNull()) return;
LLViewerRegion* regionp = mObject->getRegion();
if (!regionp) return;
// Clamp pos on non-attachments, just keep the prims within the region
if (!mObject->isAttachment())
{
F32 max_width = regionp->getWidth(); // meters
mClipboardPos.mV[VX] = llclamp(mClipboardPos.mV[VX], 0.f, max_width);
mClipboardPos.mV[VY] = llclamp(mClipboardPos.mV[VY], 0.f, max_width);
//height will get properly clamped by sendPosition
}
else
{
mClipboardPos.clampLength(MAX_ATTACHMENT_DIST);
}
mCtrlPosX->set( mClipboardPos.mV[VX] );
mCtrlPosY->set( mClipboardPos.mV[VY] );
mCtrlPosZ->set( mClipboardPos.mV[VZ] );
sendPosition(FALSE);
}
void LLPanelObject::onPasteSize()
{
if (!mHasClipboardSize) return;
mClipboardSize.mV[VX] = llclamp(mClipboardSize.mV[VX], MIN_PRIM_SCALE, DEFAULT_MAX_PRIM_SCALE);
mClipboardSize.mV[VY] = llclamp(mClipboardSize.mV[VY], MIN_PRIM_SCALE, DEFAULT_MAX_PRIM_SCALE);
mClipboardSize.mV[VZ] = llclamp(mClipboardSize.mV[VZ], MIN_PRIM_SCALE, DEFAULT_MAX_PRIM_SCALE);
mCtrlScaleX->set(mClipboardSize.mV[VX]);
mCtrlScaleY->set(mClipboardSize.mV[VY]);
mCtrlScaleZ->set(mClipboardSize.mV[VZ]);
sendScale(FALSE);
}
void LLPanelObject::onPasteRot()
{
if (!mHasClipboardRot) return;
mCtrlRotX->set(mClipboardRot.mV[VX]);
mCtrlRotY->set(mClipboardRot.mV[VY]);
mCtrlRotZ->set(mClipboardRot.mV[VZ]);
sendRotation(FALSE);
}
void LLPanelObject::onCopyParams()
{
LLViewerObject* objectp = mObject;
if (!objectp || objectp->isMesh())
{
return;
}
mClipboardParams.clear();
// Parametrics
LLVolumeParams params;
getVolumeParams(params);
mClipboardParams["volume_params"] = params.asLLSD();
// Sculpted Prim
if (objectp->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT))
{
LLSculptParams *sculpt_params = (LLSculptParams *)objectp->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
LLUUID texture_id = sculpt_params->getSculptTexture();
if (get_can_copy_texture(texture_id))
{
LL_DEBUGS("FloaterTools") << "Recording texture" << LL_ENDL;
mClipboardParams["sculpt"]["id"] = texture_id;
}
else
{
mClipboardParams["sculpt"]["id"] = LLUUID(SCULPT_DEFAULT_TEXTURE);
}
mClipboardParams["sculpt"]["type"] = sculpt_params->getSculptType();
}
}
void LLPanelObject::onPasteParams()
{
LLViewerObject* objectp = mObject;
if (!objectp)
{
return;
}
// Sculpted Prim
if (mClipboardParams.has("sculpt"))
{
LLSculptParams sculpt_params;
LLUUID sculpt_id = mClipboardParams["sculpt"]["id"].asUUID();
U8 sculpt_type = (U8)mClipboardParams["sculpt"]["type"].asInteger();
sculpt_params.setSculptTexture(sculpt_id, sculpt_type);
objectp->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt_params, TRUE);
}
else
{
LLSculptParams *sculpt_params = (LLSculptParams *)objectp->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
if (sculpt_params)
{
objectp->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, FALSE, TRUE);
}
}
// volume params
// make sure updateVolume() won't affect flexible
if (mClipboardParams.has("volume_params"))
{
LLVolumeParams params;
params.fromLLSD(mClipboardParams["volume_params"]);
LLVOVolume *volobjp = (LLVOVolume *)objectp;
if (volobjp->isFlexible())
{
if (params.getPathParams().getCurveType() == LL_PCODE_PATH_LINE)
{
params.getPathParams().setCurveType(LL_PCODE_PATH_FLEXIBLE);
}
}
else if (params.getPathParams().getCurveType() == LL_PCODE_PATH_FLEXIBLE)
{
params.getPathParams().setCurveType(LL_PCODE_PATH_LINE);
}
objectp->updateVolume(params);
}
}
|