Compare commits
667 Commits
tmp-Timeli
...
temp-keyma
Author | SHA1 | Date | |
---|---|---|---|
3edc6ece77 | |||
929c78e33c | |||
![]() |
08b8fa0863 | ||
![]() |
85d845ef98 | ||
![]() |
5eda9732b3 | ||
![]() |
e2bac484e0 | ||
36e9ed98e7 | |||
f98c838b71 | |||
d5889f57ae | |||
8f670dd855 | |||
f7af08b5fe | |||
9d037153f7 | |||
44b99d1052 | |||
43584f4a41 | |||
![]() |
bc54823376 | ||
8b24f45e6b | |||
03b0495d04 | |||
756b70c6c3 | |||
d4ac65d003 | |||
643259415d | |||
a0b08e7b66 | |||
2bb4977c4a | |||
77e32e8819 | |||
c72a204001 | |||
6946c41340 | |||
d6a4b23f8b | |||
3ad9a94c9d | |||
9450792bf2 | |||
4e5d5b3a9e | |||
eb2491363a | |||
359469a39a | |||
9b1a15d8f8 | |||
3c1483cf1e | |||
5d1a172783 | |||
81060ff6b2 | |||
![]() |
66577c8732 | ||
cf60939a59 | |||
69d3a08557 | |||
e63fbc992d | |||
e9cf3b5347 | |||
46d7c55b17 | |||
f8d0447dfb | |||
f36315dd34 | |||
98d4d4ce58 | |||
42d6b8efc0 | |||
d2f8b48f01 | |||
2f56bf3535 | |||
272ca5772d | |||
9b6a30d2cb | |||
765fd29d68 | |||
ce5fa2deca | |||
1d320f10ac | |||
4045730d58 | |||
e673be1ebc | |||
dc0eed178a | |||
95c5d1193f | |||
fd2c48726f | |||
9c8da50106 | |||
e7010a05be | |||
38cb29d67e | |||
1863883a24 | |||
edce44d693 | |||
47f2b3b80d | |||
56254a42e0 | |||
4ca4e64d25 | |||
9a74b60367 | |||
474971f3d8 | |||
bc3727a943 | |||
198be6f37b | |||
06cb460cd7 | |||
12a9e9ae33 | |||
7a0699db34 | |||
48155c210a | |||
aefc793a81 | |||
60ddea7758 | |||
975828e23a | |||
8df99a5d8a | |||
c883f09fa8 | |||
975eac0b07 | |||
0c9974c8cd | |||
ef502854fe | |||
44935fdfa3 | |||
2241a61aab | |||
6b38fa8cab | |||
581b021a1f | |||
c9c95ed25f | |||
75355ef426 | |||
0d559a6730 | |||
6ebcf98943 | |||
3e3f6754b4 | |||
33e45658eb | |||
c9db7ceff2 | |||
bae880dc9e | |||
857e4e04d8 | |||
64ee6f4e9f | |||
c9f7a3b32a | |||
4dee702332 | |||
![]() |
768706c6a5 | ||
a3a069f493 | |||
9dca74f0e5 | |||
562cf573d3 | |||
1bf2a7709f | |||
8a73ea7af2 | |||
988a14aa14 | |||
51926de7f0 | |||
c0f9f69c7e | |||
5901c1ca42 | |||
dd22080b9a | |||
572a9619b9 | |||
40638e1970 | |||
657fedbbee | |||
8510472198 | |||
14b51b3974 | |||
![]() |
dc26ef081b | ||
45e7d609ce | |||
2cc53227ab | |||
b11a1d5da2 | |||
e9908134e8 | |||
![]() |
fbc65c6b28 | ||
8a78a53e3b | |||
d8a6c1d316 | |||
ba6abd83b0 | |||
f243390bd6 | |||
03a80facfc | |||
08da2826e0 | |||
9812943931 | |||
e31b8303ed | |||
230943be2d | |||
ef22d2e8ad | |||
d02335a195 | |||
2a6e4f7157 | |||
a79252d8c7 | |||
f04cadd83e | |||
bc9b202e65 | |||
51b2622814 | |||
b611cecf4e | |||
1be4eba27b | |||
a0dbaf1d9d | |||
302fea6b61 | |||
5e1021f78f | |||
c72b576aab | |||
357199375b | |||
5a431be629 | |||
d209fa6e35 | |||
0983d97ab9 | |||
5e2f9c5c67 | |||
5db7f2c1ee | |||
b4a8b81399 | |||
b04b933acf | |||
bef08e63d7 | |||
0864a4c1ea | |||
8ea4539542 | |||
f7c75e8bd7 | |||
12b261be41 | |||
1cf17b257d | |||
132cda3925 | |||
7a88a7742b | |||
b2ee8e1cba | |||
72f4bdf604 | |||
6862762685 | |||
d638ad3b20 | |||
5505ba8d47 | |||
![]() |
e8c8ff4f86 | ||
8d9faf840b | |||
10e43c0aef | |||
58fadb379a | |||
ad9278fdad | |||
![]() |
ec809d0cbf | ||
44bab06960 | |||
![]() |
9406a1f195 | ||
d64fbe9456 | |||
0d768cca65 | |||
40dfb3eed6 | |||
72039cd7cc | |||
c788bd0211 | |||
fe820eba92 | |||
dfb959b6c3 | |||
b4106ed170 | |||
39aea50155 | |||
![]() |
c1361d2651 | ||
cb3c9cba49 | |||
8766ab7526 | |||
b2a2983d14 | |||
70a3b7e70c | |||
![]() |
2d05f91bea | ||
3820237ddb | |||
7762522ecd | |||
e561eef3ff | |||
a709e8d6bb | |||
5df8a6eb94 | |||
153c7746ab | |||
d7824de8e4 | |||
1318660b04 | |||
569a5e0d7c | |||
3e9b592b08 | |||
54f2e58452 | |||
5ee965eea5 | |||
d78894eb3e | |||
176e18436c | |||
![]() |
6f20fcd598 | ||
7b58073dc0 | |||
67598d39b4 | |||
6955add502 | |||
![]() |
401e975c61 | ||
933a083587 | |||
b642b510e1 | |||
b6725d3cbf | |||
e2a827c848 | |||
3fb38d664b | |||
342d94c375 | |||
7e7680e33b | |||
84c3b175f6 | |||
485990e4aa | |||
0cc2666605 | |||
9cb2b9b523 | |||
d185f5be09 | |||
d1e8d8f40f | |||
a3ad55b346 | |||
57b47ebb28 | |||
83ed0df1c2 | |||
![]() |
ccabb26082 | ||
4a2213dc9a | |||
a455e35343 | |||
![]() |
1ecfe42d37 | ||
b4b745b720 | |||
6afccf6348 | |||
1c572b7412 | |||
c44ccbc518 | |||
e71b12048c | |||
b4b569feeb | |||
c0ac479134 | |||
7c5e174871 | |||
37b947c7ef | |||
07dee0f79c | |||
b20449cc08 | |||
d59b74adb3 | |||
858e8f453d | |||
![]() |
909d548d56 | ||
5667822876 | |||
8dc564096f | |||
8d92873230 | |||
e92baab348 | |||
d886e32270 | |||
37b5c52f11 | |||
8ac8ef8ec7 | |||
44f78c95be | |||
f5f66d4901 | |||
17aef80207 | |||
647232f7f1 | |||
504cbc1954 | |||
103a31f712 | |||
062ee07b7f | |||
78a26f28aa | |||
e6c27b4dab | |||
8aebcf8b7d | |||
2fb9a50a4f | |||
c080c096ce | |||
6e8d4bcd01 | |||
3ada840e65 | |||
3c44c67e96 | |||
66d18d93c4 | |||
76ece90d4a | |||
f5d911f8b0 | |||
e89fa4c85b | |||
6953c57d2c | |||
1b164cf81e | |||
8644eef5c3 | |||
397665dea3 | |||
6573af5211 | |||
c685c19df9 | |||
6f127b22e6 | |||
6781fac42e | |||
ab19609233 | |||
53d1ec95ea | |||
96a7ed8a15 | |||
298f8042ef | |||
cc9513d944 | |||
d97471ddf7 | |||
dfe088c5d9 | |||
ff19b527e8 | |||
c7df618263 | |||
bc46034752 | |||
0d2aa1a7bb | |||
f99197fb2d | |||
47b9d7494e | |||
e12df10120 | |||
7f714fdbb2 | |||
9fc5a0c95e | |||
0c1676f388 | |||
6974afba82 | |||
bb45381bc2 | |||
28c20fc393 | |||
4e14437cb0 | |||
c7903f17a2 | |||
ee1327a84c | |||
99f994e7ed | |||
17778ddeb7 | |||
ac476375b1 | |||
67cf4cb5ec | |||
feabab6a9e | |||
612364181a | |||
161ab6109e | |||
9f66d00287 | |||
13d2df32c7 | |||
f0fda91a55 | |||
20bafbd550 | |||
605e184167 | |||
08ba057eef | |||
f14e4510ac | |||
575437ac90 | |||
fbe73d1f31 | |||
3b1b625ead | |||
3102821c9c | |||
bdc3335016 | |||
882daeffc5 | |||
21777533fb | |||
6d8aa85051 | |||
9f2ae547c0 | |||
0e9605f44d | |||
4198c18f15 | |||
698dbd6500 | |||
351c6d4346 | |||
12a60265cd | |||
94fd828d75 | |||
768a152883 | |||
e7895bac07 | |||
46514cf865 | |||
8e0953eb49 | |||
d3def53be5 | |||
4bbb1d4e5e | |||
7a28dea1e1 | |||
2c6106247b | |||
ef90d46700 | |||
24cc976d55 | |||
687f09a8ad | |||
883cb58355 | |||
4308602d6a | |||
8cb6ede2bf | |||
7959617fb6 | |||
12eb29fe35 | |||
96a3a62861 | |||
0492e56fec | |||
aca892832a | |||
006b8e6092 | |||
4a0dea88bf | |||
6ba28ff8b1 | |||
06737a8258 | |||
e65643b9a3 | |||
7cbf5db248 | |||
d3c89f50a0 | |||
671797e22e | |||
ddebf1ea3b | |||
e785048ef3 | |||
4df99bd601 | |||
a0b03d3fb2 | |||
e7d2a4718d | |||
1fd11dd3ba | |||
ffaf55be94 | |||
de7635f607 | |||
30673ff325 | |||
f9547ab313 | |||
c2d5411cbf | |||
6a782ed767 | |||
00071d78bc | |||
29595334f0 | |||
d712dd2f19 | |||
2d6bfb5b63 | |||
a3070474e2 | |||
db2c966e2c | |||
6776a55464 | |||
d7ba8611e2 | |||
6a64556ba1 | |||
47949fd764 | |||
83c2febaee | |||
e077285745 | |||
4d19f24ba7 | |||
6e48afeb23 | |||
5e7a21a5f5 | |||
1cc4ab481e | |||
b167bc2f00 | |||
cb50c288d4 | |||
17bd5c9d4b | |||
70aec3732d | |||
fbcdd07c98 | |||
b6a2dbbec2 | |||
17852b079c | |||
6e40b2de7a | |||
1cf0930e89 | |||
2451a1951e | |||
278e3f7d5f | |||
987d1df571 | |||
8faa594413 | |||
f7e7769260 | |||
8b9db543fd | |||
bffa9b8012 | |||
96fba1e101 | |||
3af4a46a18 | |||
50e3af8899 | |||
b0c8d35142 | |||
486ff7e52c | |||
54a9136569 | |||
0e0d99161a | |||
b290048257 | |||
b46c707ec2 | |||
cadbfa590a | |||
170dd30881 | |||
3b6a0f5fe0 | |||
edf6676a77 | |||
20cc14e2b7 | |||
9edc64e255 | |||
a2438373b3 | |||
c48a3afb16 | |||
![]() |
0ef23786fe | ||
2e635b6500 | |||
75321a3d24 | |||
6d706dc8c7 | |||
1f3143fcc7 | |||
773a60d8f8 | |||
ca1f1043d3 | |||
12e523d12c | |||
35a298db52 | |||
ba4d215139 | |||
41cba97f47 | |||
efe3042368 | |||
4b18858660 | |||
d038f4651e | |||
![]() |
07b03ff74d | ||
![]() |
83e35b682c | ||
![]() |
e51bf11b15 | ||
![]() |
09e419fa8d | ||
![]() |
15c2801aac | ||
![]() |
d8dca3c3b0 | ||
b4648ee379 | |||
91d3a5c1f7 | |||
f6601e2deb | |||
9abb4b555a | |||
527c9af48f | |||
5ed702dc9c | |||
1b4916054e | |||
f785fb299a | |||
df963a47fb | |||
5308e31e41 | |||
48645e55e1 | |||
34c98e3d41 | |||
bcfe075f89 | |||
a25856f2a8 | |||
a3f4c72ec9 | |||
c332e6e0d6 | |||
f1a5fd90ba | |||
e862bcd6c8 | |||
def1c3eb4b | |||
76b5e38a76 | |||
739c3e8102 | |||
eacf63c96f | |||
1b2ba24749 | |||
f0c0d11ea2 | |||
2ba0951e52 | |||
6a4ba9133c | |||
![]() |
b0cfd7a9b8 | ||
2e4c1346bd | |||
d9e04cb594 | |||
7fd44e2498 | |||
1bb9ccf887 | |||
d095eea19c | |||
dbe4189dcd | |||
46aec45b2a | |||
![]() |
807afedf6c | ||
dffd37877d | |||
f7c37c8344 | |||
c43dbc2bc2 | |||
fee50f830d | |||
9bcddeca7a | |||
b6a822d726 | |||
a6e804eaee | |||
ca8e9c881f | |||
d0b62ce041 | |||
b79fea28e3 | |||
0a8d6bd893 | |||
9619a90da1 | |||
599bf05c56 | |||
bf0d16e30e | |||
7a69c59b35 | |||
4461be1b72 | |||
50c29e2391 | |||
717dd4cecd | |||
a2dd6fa58b | |||
439ccd27e6 | |||
ca028f1387 | |||
747326ed25 | |||
c3282cb746 | |||
53c6d3399a | |||
![]() |
9439df1ab8 | ||
![]() |
4f8b6428bc | ||
3d1f5cb9a2 | |||
92d4fbf5cc | |||
13b2ba4fdd | |||
8c44e182f0 | |||
77d6c09ddd | |||
91504ed26e | |||
fda05127db | |||
5d879c5d42 | |||
83155cce5b | |||
2d0efe2e78 | |||
a104c41759 | |||
ed0901b47e | |||
f43d33d3a4 | |||
4f5bcc30d3 | |||
e57ba1daf5 | |||
f4fd1f1f4b | |||
e83cee73eb | |||
fe01430f74 | |||
e5560e8d56 | |||
c5f469da5e | |||
aa312621dc | |||
979c48fd66 | |||
361bc2bc50 | |||
f25be56bc7 | |||
06e9048ade | |||
7cbb85675a | |||
e0b0f7afa0 | |||
b6e3430417 | |||
87cd4de3ba | |||
a95d417db0 | |||
10fe8ec68f | |||
bcf6cc1f6b | |||
197af58baa | |||
4d5b7696cb | |||
13dfa72f26 | |||
c6bceffc4f | |||
3f20105622 | |||
8021ac986a | |||
95e7559bb6 | |||
b3d4f99d48 | |||
e0903e20a7 | |||
3eb9cc69f2 | |||
f1bc899146 | |||
9636cab009 | |||
55b241d32a | |||
0fb80cebec | |||
52cb62d502 | |||
ae8225ba6d | |||
ce27d11595 | |||
04fa65e356 | |||
c3b061278e | |||
b2b8e1444a | |||
bac9c2dc7d | |||
e159ec8bc1 | |||
bf7c46cae0 | |||
8cbf402eb6 | |||
70a60061e5 | |||
![]() |
7cb2d55bd4 | ||
627a783784 | |||
b0f61ea6db | |||
![]() |
b1dae7bd6f | ||
![]() |
fc7316fb54 | ||
![]() |
de2d642c84 | ||
2b09062def | |||
788488b1aa | |||
2bf4654052 | |||
![]() |
b1d016bc12 | ||
![]() |
90c9458b2f | ||
![]() |
4043e4b820 | ||
9e4709e9a5 | |||
e5b53fb28c | |||
eabfd031fa | |||
63c2397171 | |||
e33016c77e | |||
![]() |
3ebe389605 | ||
bf73628978 | |||
80ccad07cc | |||
5205a0f671 | |||
![]() |
b942106c73 | ||
![]() |
016ba0f38b | ||
261d78a2c6 | |||
0cfe9f95df | |||
![]() |
e1cee0ac71 | ||
51341dafc3 | |||
6a0d7f9e41 | |||
258c5f2c0f | |||
783bb4e1cd | |||
50bab7eb8a | |||
95869f5838 | |||
379c3e46d5 | |||
f78ba4bcfe | |||
43ee4d5d7c | |||
66f0c10f84 | |||
c1d737eb95 | |||
a0c564f86a | |||
2c1396b6cb | |||
0c1c69d8df | |||
402442997a | |||
ddf308b04a | |||
dc4f94783d | |||
e0a4624acd | |||
913bba5038 | |||
3767c01269 | |||
d21043ba83 | |||
c40c2b5ab7 | |||
680bdef12a | |||
64245e735c | |||
![]() |
a23995f42a | ||
![]() |
5717612f7c | ||
5bad5f996f | |||
![]() |
94a62853ae | ||
a8e8e08bc6 | |||
9606d28d40 | |||
7a2e271e54 | |||
3469e623d3 | |||
343c2e94f5 | |||
1ec48f8042 | |||
06a786f12d | |||
e7ee9cfd9e | |||
e1772dac70 | |||
cee39da318 | |||
03281c080c | |||
0414b0a0be | |||
ece3634497 | |||
03e14bfeb6 | |||
9d677212ee | |||
59c6487e93 | |||
b99d064e91 | |||
7a56d31af3 | |||
6c6a394373 | |||
9c212399c6 | |||
0d9f77d954 | |||
375c6a7967 | |||
5be0dfe086 | |||
d25ec499d8 | |||
2dc5a84fad | |||
f9cfb221d6 | |||
74a08cf128 | |||
894639f9a5 | |||
f897d95372 | |||
1422c0650c | |||
e0a561be1f | |||
67dda3611f | |||
817bb5d40d | |||
7c1171c246 | |||
7e74916562 | |||
90b2e4ce28 | |||
b4010005de | |||
570455fb83 | |||
d1b969a0cd | |||
ea43130504 | |||
c35af3b056 | |||
f410e83b2c | |||
dcc55c89fa | |||
df2de43459 | |||
4dc91ebf81 | |||
1813f00b94 | |||
c84b8d4801 | |||
be8add5d50 | |||
e4f75f97ba | |||
6aca3e43ec | |||
bd30a6350b | |||
f197134426 | |||
5503e2565b | |||
0a7736a2e9 | |||
f3f309c7f8 | |||
9df6978211 | |||
194cba8ba4 | |||
925e775818 | |||
73a7885ab3 | |||
ef49a587d4 | |||
10b9c86c80 | |||
054d837e65 | |||
d5c1c0b10d |
@@ -66,21 +66,12 @@ endif()
|
|||||||
# set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
|
# set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
|
||||||
|
|
||||||
# global compile definitions since add_definitions() adds for all.
|
# global compile definitions since add_definitions() adds for all.
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
if(NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
$<$<CONFIG:Debug>:DEBUG;_DEBUG>
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
|
$<$<CONFIG:Release>:NDEBUG>
|
||||||
$<$<CONFIG:Debug>:DEBUG;_DEBUG>
|
$<$<CONFIG:MinSizeRel>:NDEBUG>
|
||||||
$<$<CONFIG:Release>:NDEBUG>
|
$<$<CONFIG:RelWithDebInfo>:NDEBUG>
|
||||||
$<$<CONFIG:MinSizeRel>:NDEBUG>
|
)
|
||||||
$<$<CONFIG:RelWithDebInfo>:NDEBUG>
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
# keep until CMake-3.0 is min requirement
|
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG _DEBUG)
|
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE NDEBUG)
|
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL NDEBUG)
|
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO NDEBUG)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Set policy
|
# Set policy
|
||||||
@@ -520,6 +511,45 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
|||||||
mark_as_advanced(WITH_LINKER_GOLD)
|
mark_as_advanced(WITH_LINKER_GOLD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
|
option(WITH_COMPILER_ASAN "Build and link against address sanitizer (only for Debug & RelWithDebInfo targets)." OFF)
|
||||||
|
mark_as_advanced(WITH_COMPILER_ASAN)
|
||||||
|
|
||||||
|
if(WITH_COMPILER_ASAN)
|
||||||
|
set(_asan_defaults "\
|
||||||
|
-fsanitize=address \
|
||||||
|
-fsanitize=bool \
|
||||||
|
-fsanitize=bounds \
|
||||||
|
-fsanitize=enum \
|
||||||
|
-fsanitize=float-cast-overflow \
|
||||||
|
-fsanitize=float-divide-by-zero \
|
||||||
|
-fsanitize=leak \
|
||||||
|
-fsanitize=nonnull-attribute \
|
||||||
|
-fsanitize=object-size \
|
||||||
|
-fsanitize=returns-nonnull-attribute \
|
||||||
|
-fsanitize=signed-integer-overflow \
|
||||||
|
-fsanitize=undefined \
|
||||||
|
-fsanitize=vla-bound \
|
||||||
|
-fno-sanitize=alignment \
|
||||||
|
")
|
||||||
|
|
||||||
|
set(COMPILER_ASAN_CFLAGS "${_asan_defaults}" CACHE STRING "C flags for address sanitizer")
|
||||||
|
mark_as_advanced(COMPILER_ASAN_CFLAGS)
|
||||||
|
set(COMPILER_ASAN_CXXFLAGS "${_asan_defaults}" CACHE STRING "C++ flags for address sanitizer")
|
||||||
|
mark_as_advanced(COMPILER_ASAN_CXXFLAGS)
|
||||||
|
|
||||||
|
unset(_asan_defaults)
|
||||||
|
|
||||||
|
find_library(COMPILER_ASAN_LIBRARY asan ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
|
||||||
|
mark_as_advanced(COMPILER_ASAN_LIBRARY)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Dependency graph
|
||||||
|
option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
|
||||||
|
mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# Use hardcoded paths or find_package to find externals
|
# Use hardcoded paths or find_package to find externals
|
||||||
option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF)
|
option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF)
|
||||||
@@ -780,6 +810,15 @@ set(PLATFORM_LINKLIBS "")
|
|||||||
set(PLATFORM_LINKFLAGS "")
|
set(PLATFORM_LINKFLAGS "")
|
||||||
set(PLATFORM_LINKFLAGS_DEBUG "")
|
set(PLATFORM_LINKFLAGS_DEBUG "")
|
||||||
|
|
||||||
|
if(WITH_COMPILER_ASAN)
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMPILER_ASAN_CFLAGS}")
|
||||||
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CFLAGS}")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}")
|
||||||
|
|
||||||
|
set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY}")
|
||||||
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
#Platform specifics
|
#Platform specifics
|
||||||
@@ -1509,7 +1548,12 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Visual Studio has all standards it supports available by default
|
# Visual Studio has all standards it supports available by default
|
||||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Intel")
|
# Clang on windows copies this behavior and does not support these switches
|
||||||
|
if(
|
||||||
|
CMAKE_COMPILER_IS_GNUCC OR
|
||||||
|
(CMAKE_C_COMPILER_ID MATCHES "Clang" AND (NOT MSVC)) OR
|
||||||
|
(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
||||||
|
)
|
||||||
# Use C99 + GNU extensions, works with GCC, Clang, ICC
|
# Use C99 + GNU extensions, works with GCC, Clang, ICC
|
||||||
if(WITH_C11)
|
if(WITH_C11)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
|
||||||
|
@@ -103,6 +103,7 @@ ExternalProject_Add(external_ffmpeg
|
|||||||
--disable-indev=jack
|
--disable-indev=jack
|
||||||
--disable-indev=alsa
|
--disable-indev=alsa
|
||||||
--disable-outdev=alsa
|
--disable-outdev=alsa
|
||||||
|
--disable-crystalhd
|
||||||
PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/ffmpeg/src/external_ffmpeg < ${PATCH_DIR}/ffmpeg.diff
|
PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/ffmpeg/src/external_ffmpeg < ${PATCH_DIR}/ffmpeg.diff
|
||||||
BUILD_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make -j${MAKE_THREADS}
|
BUILD_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make -j${MAKE_THREADS}
|
||||||
INSTALL_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make install
|
INSTALL_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make install
|
||||||
|
@@ -13,3 +13,25 @@
|
|||||||
-# pragma message("Unknown compiler version - please run the configure tests and report the results")
|
-# pragma message("Unknown compiler version - please run the configure tests and report the results")
|
||||||
-# endif
|
-# endif
|
||||||
-#endif
|
-#endif
|
||||||
|
--- a/boost/type_traits/has_nothrow_assign.hpp 2015-12-13 05:49:42 -0700
|
||||||
|
+++ b/boost/type_traits/has_nothrow_assign.hpp 2018-05-27 11:11:02 -0600
|
||||||
|
@@ -24,7 +24,7 @@
|
||||||
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
-#if defined(__GNUC__) || defined(__SUNPRO_CC)
|
||||||
|
+#if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__clang__)
|
||||||
|
#include <boost/type_traits/is_const.hpp>
|
||||||
|
#include <boost/type_traits/is_volatile.hpp>
|
||||||
|
#include <boost/type_traits/is_assignable.hpp>
|
||||||
|
--- a/boost/type_traits/has_nothrow_constructor.hpp 2015-12-13 05:49:42 -0700
|
||||||
|
+++ b/boost/type_traits/has_nothrow_constructor.hpp 2018-05-27 11:11:02 -0600
|
||||||
|
@@ -17,7 +17,7 @@
|
||||||
|
#if defined(BOOST_MSVC) || defined(BOOST_INTEL)
|
||||||
|
#include <boost/type_traits/has_trivial_constructor.hpp>
|
||||||
|
#endif
|
||||||
|
-#if defined(__GNUC__ ) || defined(__SUNPRO_CC)
|
||||||
|
+#if defined(__GNUC__ ) || defined(__SUNPRO_CC) || defined(__clang__)
|
||||||
|
#include <boost/type_traits/is_default_constructible.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@@ -10,3 +10,29 @@ diff -Naur osl/src/external_osl/src/cmake/flexbison.cmake osl_bak/src/external_o
|
|||||||
MAIN_DEPENDENCY ${flexsrc}
|
MAIN_DEPENDENCY ${flexsrc}
|
||||||
DEPENDS ${${compiler_headers}}
|
DEPENDS ${${compiler_headers}}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||||
|
--- a/src/include/OSL/oslconfig.h 2016-10-31 16:48:19 -0600
|
||||||
|
+++ b/src/include/OSL/oslconfig.h 2018-05-27 11:18:08 -0600
|
||||||
|
@@ -44,12 +44,18 @@
|
||||||
|
// same if another packages is compiling against OSL and using these headers
|
||||||
|
// (OSL may be C++11 but the client package may be older, or vice versa --
|
||||||
|
// use these two symbols to differentiate these cases, when important).
|
||||||
|
-#if (__cplusplus >= 201402L)
|
||||||
|
-# define OSL_CPLUSPLUS_VERSION 14
|
||||||
|
-#elif (__cplusplus >= 201103L)
|
||||||
|
-# define OSL_CPLUSPLUS_VERSION 11
|
||||||
|
+
|
||||||
|
+// Force C++03 for MSVC in blender since svn the libraries are build with that
|
||||||
|
+#if !defined(_MSC_VER)
|
||||||
|
+ #if (__cplusplus >= 201402L)
|
||||||
|
+ # define OSL_CPLUSPLUS_VERSION 14
|
||||||
|
+ #elif (__cplusplus >= 201103L)
|
||||||
|
+ # define OSL_CPLUSPLUS_VERSION 11
|
||||||
|
+ #else
|
||||||
|
+ # define OSL_CPLUSPLUS_VERSION 3 /* presume C++03 */
|
||||||
|
+ #endif
|
||||||
|
#else
|
||||||
|
-# define OSL_CPLUSPLUS_VERSION 3 /* presume C++03 */
|
||||||
|
+ # define OSL_CPLUSPLUS_VERSION 3 /* presume C++03 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Symbol export defines
|
||||||
|
@@ -581,6 +581,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
|
|||||||
bf_editor_space_outliner
|
bf_editor_space_outliner
|
||||||
bf_editor_space_script
|
bf_editor_space_script
|
||||||
bf_editor_space_sequencer
|
bf_editor_space_sequencer
|
||||||
|
bf_editor_space_statusbar
|
||||||
bf_editor_space_text
|
bf_editor_space_text
|
||||||
bf_editor_space_time
|
bf_editor_space_time
|
||||||
bf_editor_space_topbar
|
bf_editor_space_topbar
|
||||||
|
@@ -358,7 +358,7 @@ if(WITH_LLVM)
|
|||||||
execute_process(COMMAND ${LLVM_CONFIG} --libfiles
|
execute_process(COMMAND ${LLVM_CONFIG} --libfiles
|
||||||
OUTPUT_VARIABLE LLVM_LIBRARY
|
OUTPUT_VARIABLE LLVM_LIBRARY
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
|
string(REPLACE ".a /" ".a;/" LLVM_LIBRARY ${LLVM_LIBRARY})
|
||||||
else()
|
else()
|
||||||
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lLLVM-3.4")
|
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lLLVM-3.4")
|
||||||
endif()
|
endif()
|
||||||
@@ -418,7 +418,7 @@ if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
|
|||||||
endif()
|
endif()
|
||||||
# Get rid of eventually clashes, we export some symbols explicite as local
|
# Get rid of eventually clashes, we export some symbols explicite as local
|
||||||
set(PLATFORM_LINKFLAGS
|
set(PLATFORM_LINKFLAGS
|
||||||
"${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map"
|
"${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker '${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map'"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
|
@@ -29,7 +29,15 @@ if(NOT MSVC)
|
|||||||
message(FATAL_ERROR "Compiler is unsupported")
|
message(FATAL_ERROR "Compiler is unsupported")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Libraries configuration for Windows when compiling with MSVC.
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
|
set(MSVC_CLANG On)
|
||||||
|
set(MSVC_REDIST_DIR $ENV{VCToolsRedistDir})
|
||||||
|
if (DEFINED MSVC_REDIST_DIR)
|
||||||
|
file(TO_CMAKE_PATH ${MSVC_REDIST_DIR} MSVC_REDIST_DIR)
|
||||||
|
else()
|
||||||
|
message("Unable to detect the Visual Studio redist directory, copying of the runtime dlls will not work, try running from the visual studio developer prompt.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ${WINDOWS_USE_VISUAL_STUDIO_FOLDERS})
|
set_property(GLOBAL PROPERTY USE_FOLDERS ${WINDOWS_USE_VISUAL_STUDIO_FOLDERS})
|
||||||
|
|
||||||
@@ -119,8 +127,18 @@ set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
|
|||||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
|
||||||
include(InstallRequiredSystemLibraries)
|
include(InstallRequiredSystemLibraries)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc")
|
remove_cc_flag("/MDd" "/MD")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP")
|
|
||||||
|
if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
|
||||||
|
if(NOT WITH_CXX11) # C++11 is on by default in clang-cl and can't be turned off, if c++11 is not enabled in blender repress some c++11 related warnings.
|
||||||
|
set(CXX_WARN_FLAGS "-Wno-inconsistent-missing-override")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference ")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference")
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
|
||||||
|
17
build_files/windows/autodetect_msvc.cmd
Normal file
17
build_files/windows/autodetect_msvc.cmd
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
echo No explicit msvc version requested, autodetecting version.
|
||||||
|
|
||||||
|
call "%~dp0\detect_msvc2013.cmd"
|
||||||
|
if %ERRORLEVEL% EQU 0 goto DetectionComplete
|
||||||
|
|
||||||
|
call "%~dp0\detect_msvc2015.cmd"
|
||||||
|
if %ERRORLEVEL% EQU 0 goto DetectionComplete
|
||||||
|
|
||||||
|
call "%~dp0\detect_msvc2017.cmd"
|
||||||
|
if %ERRORLEVEL% EQU 0 goto DetectionComplete
|
||||||
|
|
||||||
|
echo Compiler Detection failed. Use verbose switch for more information.
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:DetectionComplete
|
||||||
|
echo Compiler Detection successfull, detected VS%BUILD_VS_YEAR%
|
||||||
|
exit /b 0
|
26
build_files/windows/build_msbuild.cmd
Normal file
26
build_files/windows/build_msbuild.cmd
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
if "%NOBUILD%"=="1" goto EOF
|
||||||
|
echo %TIME% > %BUILD_DIR%\buildtime.txt
|
||||||
|
msbuild ^
|
||||||
|
%BUILD_DIR%\Blender.sln ^
|
||||||
|
/target:build ^
|
||||||
|
/property:Configuration=%BUILD_TYPE% ^
|
||||||
|
/maxcpucount:2 ^
|
||||||
|
/verbosity:minimal ^
|
||||||
|
/p:platform=%MSBUILD_PLATFORM% ^
|
||||||
|
/flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo Error during build, see %BUILD_DIR%\Build.log for details
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
msbuild ^
|
||||||
|
%BUILD_DIR%\INSTALL.vcxproj ^
|
||||||
|
/property:Configuration=%BUILD_TYPE% ^
|
||||||
|
/verbosity:minimal ^
|
||||||
|
/p:platform=%MSBUILD_PLATFORM%
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo Error during install phase
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
echo %TIME% >> %BUILD_DIR%\buildtime.txt
|
||||||
|
:EOF
|
16
build_files/windows/build_ninja.cmd
Normal file
16
build_files/windows/build_ninja.cmd
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
if "%NOBUILD%"=="1" goto EOF
|
||||||
|
set HAS_ERROR=
|
||||||
|
cd %BUILD_DIR%
|
||||||
|
echo %TIME% > buildtime.txt
|
||||||
|
ninja install
|
||||||
|
if errorlevel 1 (
|
||||||
|
set HAS_ERROR=1
|
||||||
|
)
|
||||||
|
echo %TIME% >>buildtime.txt
|
||||||
|
cd %BLENDER_DIR%
|
||||||
|
|
||||||
|
if "%HAS_ERROR%" == "1" (
|
||||||
|
echo Error during build
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
:EOF
|
54
build_files/windows/check_libraries.cmd
Normal file
54
build_files/windows/check_libraries.cmd
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
if "%BUILD_VS_YEAR%"=="2013" set BUILD_VS_LIBDIRPOST=vc12
|
||||||
|
if "%BUILD_VS_YEAR%"=="2015" set BUILD_VS_LIBDIRPOST=vc14
|
||||||
|
if "%BUILD_VS_YEAR%"=="2017" set BUILD_VS_LIBDIRPOST=vc14
|
||||||
|
|
||||||
|
if "%BUILD_ARCH%"=="x64" (
|
||||||
|
set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
|
||||||
|
) else if "%BUILD_ARCH%"=="x86" (
|
||||||
|
set BUILD_VS_SVNDIR=windows_%BUILD_VS_LIBDIRPOST%
|
||||||
|
)
|
||||||
|
set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"
|
||||||
|
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Library Directory = "%BUILD_VS_LIBDIR%"
|
||||||
|
)
|
||||||
|
if NOT EXIST %BUILD_VS_LIBDIR% (
|
||||||
|
rem libs not found, but svn is on the system
|
||||||
|
echo
|
||||||
|
if not "%SVN%"=="" (
|
||||||
|
echo.
|
||||||
|
echo The required external libraries in %BUILD_VS_LIBDIR% are missing
|
||||||
|
echo.
|
||||||
|
set /p GetLibs= "Would you like to download them? (y/n)"
|
||||||
|
if /I "!GetLibs!"=="Y" (
|
||||||
|
echo.
|
||||||
|
echo Downloading %BUILD_VS_SVNDIR% libraries, please wait.
|
||||||
|
echo.
|
||||||
|
:RETRY
|
||||||
|
"%SVN%" checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/%BUILD_VS_SVNDIR% %BUILD_VS_LIBDIR%
|
||||||
|
if errorlevel 1 (
|
||||||
|
set /p LibRetry= "Error during donwload, retry? y/n"
|
||||||
|
if /I "!LibRetry!"=="Y" (
|
||||||
|
cd %BUILD_VS_LIBDIR%
|
||||||
|
"%SVN%" cleanup
|
||||||
|
cd %BLENDER_DIR%
|
||||||
|
goto RETRY
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
echo Error: Download of external libraries failed.
|
||||||
|
echo This is needed for building, please manually run 'svn cleanup' and 'svn update' in
|
||||||
|
echo %BUILD_VS_LIBDIR% , until this is resolved you CANNOT make a successfull blender build
|
||||||
|
echo.
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT EXIST %BUILD_VS_LIBDIR% (
|
||||||
|
echo.
|
||||||
|
echo Error: Required libraries not found at "%BUILD_VS_LIBDIR%"
|
||||||
|
echo This is needed for building, aborting!
|
||||||
|
echo.
|
||||||
|
exit /b 1
|
||||||
|
)
|
6
build_files/windows/check_spaces_in_path.cmd
Normal file
6
build_files/windows/check_spaces_in_path.cmd
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
set BLENDER_DIR_NOSPACES=%BLENDER_DIR: =%
|
||||||
|
|
||||||
|
if not "%BLENDER_DIR%"=="%BLENDER_DIR_NOSPACES%" (
|
||||||
|
echo There are spaces detected in the build path "%BLENDER_DIR%", this is currently not supported, exiting....
|
||||||
|
exit /b 1
|
||||||
|
)
|
20
build_files/windows/check_submodules.cmd
Normal file
20
build_files/windows/check_submodules.cmd
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
if NOT exist "%BLENDER_DIR%/source/tools" (
|
||||||
|
echo Checking out sub-modules
|
||||||
|
if not "%GIT%" == "" (
|
||||||
|
"%GIT%" submodule update --init --recursive --progress
|
||||||
|
if errorlevel 1 goto FAIL
|
||||||
|
"%GIT%" submodule foreach git checkout master
|
||||||
|
if errorlevel 1 goto FAIL
|
||||||
|
"%GIT%" submodule foreach git pull --rebase origin master
|
||||||
|
if errorlevel 1 goto FAIL
|
||||||
|
goto EOF
|
||||||
|
) else (
|
||||||
|
echo Blender submodules not found, and git not found in path to retrieve them.
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
goto EOF
|
||||||
|
|
||||||
|
:FAIL
|
||||||
|
exit /b 1
|
||||||
|
:EOF
|
67
build_files/windows/configure_msbuild.cmd
Normal file
67
build_files/windows/configure_msbuild.cmd
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%" %TESTS_CMAKE_ARGS%
|
||||||
|
|
||||||
|
if "%BUILD_ARCH%"=="x64" (
|
||||||
|
set MSBUILD_PLATFORM=x64
|
||||||
|
) else if "%BUILD_ARCH%"=="x86" (
|
||||||
|
set MSBUILD_PLATFORM=win32
|
||||||
|
if "%WITH_CLANG%"=="1" (
|
||||||
|
echo Clang not supported for X86
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%WITH_CLANG%"=="1" (
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -T"LLVM-vs2017"
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT EXIST %BUILD_DIR%\nul (
|
||||||
|
mkdir %BUILD_DIR%
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%MUST_CLEAN%"=="1" (
|
||||||
|
echo Cleaning %BUILD_DIR%
|
||||||
|
msbuild ^
|
||||||
|
%BUILD_DIR%\Blender.sln ^
|
||||||
|
/target:clean ^
|
||||||
|
/property:Configuration=%BUILD_TYPE% ^
|
||||||
|
/verbosity:minimal ^
|
||||||
|
/p:platform=%MSBUILD_PLATFORM%
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1
|
||||||
|
if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
|
||||||
|
|
||||||
|
if "%MUST_CONFIGURE%"=="1" (
|
||||||
|
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo %CMAKE% %BUILD_CMAKE_ARGS% -H%BLENDER_DIR% -B%BUILD_DIR%
|
||||||
|
)
|
||||||
|
|
||||||
|
cmake ^
|
||||||
|
%BUILD_CMAKE_ARGS% ^
|
||||||
|
-H%BLENDER_DIR% ^
|
||||||
|
-B%BUILD_DIR%
|
||||||
|
|
||||||
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo "Configuration Failed"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
echo call "%VCVARS%" %BUILD_ARCH% > %BUILD_DIR%\rebuild.cmd
|
||||||
|
echo "%CMAKE%" . >> %BUILD_DIR%\rebuild.cmd
|
||||||
|
echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
|
||||||
|
echo msbuild ^
|
||||||
|
%BUILD_DIR%\Blender.sln ^
|
||||||
|
/target:build ^
|
||||||
|
/property:Configuration=%BUILD_TYPE% ^
|
||||||
|
/maxcpucount:2 ^
|
||||||
|
/verbosity:minimal ^
|
||||||
|
/p:platform=%MSBUILD_PLATFORM% ^
|
||||||
|
/flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log >> %BUILD_DIR%\rebuild.cmd
|
||||||
|
echo msbuild ^
|
||||||
|
%BUILD_DIR%\INSTALL.vcxproj ^
|
||||||
|
/property:Configuration=%BUILD_TYPE% ^
|
||||||
|
/verbosity:minimal ^
|
||||||
|
/p:platform=%MSBUILD_PLATFORM% >> %BUILD_DIR%\rebuild.cmd
|
||||||
|
echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
|
64
build_files/windows/configure_ninja.cmd
Normal file
64
build_files/windows/configure_ninja.cmd
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Ninja" %TESTS_CMAKE_ARGS% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
|
||||||
|
|
||||||
|
if "%WITH_CLANG%" == "1" (
|
||||||
|
set LLVM_DIR=
|
||||||
|
for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM\LLVM" /ve 2^>nul`) DO set LLVM_DIR=%%C
|
||||||
|
if DEFINED LLVM_DIR (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo LLVM Detected at "%LLVM_DIR%"
|
||||||
|
)
|
||||||
|
goto DetectionComplete
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Check 32 bits
|
||||||
|
for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\LLVM\LLVM" /ve 2^>nul`) DO set LLVM_DIR=%%C
|
||||||
|
if DEFINED LLVM_DIR (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo LLVM Detected at "%LLVM_DIR%"
|
||||||
|
)
|
||||||
|
goto DetectionComplete
|
||||||
|
)
|
||||||
|
echo LLVM not found
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:DetectionComplete
|
||||||
|
set CC=%LLVM_DIR%\bin\clang-cl
|
||||||
|
set CXX=%LLVM_DIR%\bin\clang-cl
|
||||||
|
rem build and tested against 2017 15.7
|
||||||
|
set CFLAGS=-m64 -fmsc-version=1914
|
||||||
|
set CXXFLAGS=-m64 -fmsc-version=1914
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS%
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT EXIST %BUILD_DIR%\nul (
|
||||||
|
mkdir %BUILD_DIR%
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%MUST_CLEAN%"=="1" (
|
||||||
|
echo Cleaning %BUILD_DIR%
|
||||||
|
cd %BUILD_DIR%
|
||||||
|
%CMAKE% cmake --build . --config Clean
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1
|
||||||
|
if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
|
||||||
|
|
||||||
|
if "%MUST_CONFIGURE%"=="1" (
|
||||||
|
cmake ^
|
||||||
|
%BUILD_CMAKE_ARGS% ^
|
||||||
|
-H%BLENDER_DIR% ^
|
||||||
|
-B%BUILD_DIR%
|
||||||
|
|
||||||
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo "Configuration Failed"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
echo call "%VCVARS%" %BUILD_ARCH% > %BUILD_DIR%\rebuild.cmd
|
||||||
|
echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
|
||||||
|
echo ninja install >> %BUILD_DIR%\rebuild.cmd
|
||||||
|
echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
|
16
build_files/windows/detect_architecture.cmd
Normal file
16
build_files/windows/detect_architecture.cmd
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
if "%BUILD_ARCH%"=="" (
|
||||||
|
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
|
||||||
|
set WINDOWS_ARCH= Win64
|
||||||
|
set BUILD_ARCH=x64
|
||||||
|
) else if "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
|
||||||
|
set WINDOWS_ARCH= Win64
|
||||||
|
set BUILD_ARCH=x64
|
||||||
|
) else (
|
||||||
|
set WINDOWS_ARCH=
|
||||||
|
set BUILD_ARCH=x86
|
||||||
|
)
|
||||||
|
) else if "%BUILD_ARCH%"=="x64" (
|
||||||
|
set WINDOWS_ARCH= Win64
|
||||||
|
) else if "%BUILD_ARCH%"=="x86" (
|
||||||
|
set WINDOWS_ARCH=
|
||||||
|
)
|
3
build_files/windows/detect_msvc2013.cmd
Normal file
3
build_files/windows/detect_msvc2013.cmd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
set BUILD_VS_VER=12
|
||||||
|
set BUILD_VS_YEAR=2013
|
||||||
|
call "%~dp0\detect_msvc_classic.cmd"
|
3
build_files/windows/detect_msvc2015.cmd
Normal file
3
build_files/windows/detect_msvc2015.cmd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
set BUILD_VS_VER=14
|
||||||
|
set BUILD_VS_YEAR=2015
|
||||||
|
call "%~dp0\detect_msvc_classic.cmd"
|
70
build_files/windows/detect_msvc2017.cmd
Normal file
70
build_files/windows/detect_msvc2017.cmd
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Detecting msvc 2017
|
||||||
|
)
|
||||||
|
set BUILD_VS_VER=15
|
||||||
|
set ProgramFilesX86=%ProgramFiles(x86)%
|
||||||
|
if not exist "%ProgramFilesX86%" set ProgramFilesX86=%ProgramFiles%
|
||||||
|
|
||||||
|
set vs_where=%ProgramFilesX86%\Microsoft Visual Studio\Installer\vswhere.exe
|
||||||
|
if not exist "%vs_where%" (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio 2017 ^(15.2 or newer^) is not detected
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
for /f "usebackq tokens=1* delims=: " %%i in (`"%vs_where%" -latest %VSWHERE_ARGS% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64`) do (
|
||||||
|
if /i "%%i"=="installationPath" set VS_InstallDir=%%j
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%VS_InstallDir%"=="" (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio is detected but the "Desktop development with C++" workload has not been instlled
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
set VCVARS=%VS_InstallDir%\VC\Auxiliary\Build\vcvarsall.bat
|
||||||
|
if exist "%VCVARS%" (
|
||||||
|
call "%VCVARS%" %BUILD_ARCH%
|
||||||
|
) else (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo "%VCVARS%" not found
|
||||||
|
)
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
|
||||||
|
rem try msbuild
|
||||||
|
msbuild /version > NUL
|
||||||
|
if errorlevel 1 (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% msbuild not found
|
||||||
|
)
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% msbuild found
|
||||||
|
)
|
||||||
|
|
||||||
|
REM try the c++ compiler
|
||||||
|
cl 2> NUL 1>&2
|
||||||
|
if errorlevel 1 (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler not found
|
||||||
|
)
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler found
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio 2017 is detected successfully
|
||||||
|
)
|
||||||
|
goto EOF
|
||||||
|
|
||||||
|
:FAIL
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:EOF
|
69
build_files/windows/detect_msvc_classic.cmd
Normal file
69
build_files/windows/detect_msvc_classic.cmd
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Detecting msvc %BUILD_VS_YEAR%
|
||||||
|
)
|
||||||
|
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
|
||||||
|
for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v ProductDir 2^>nul`) DO set MSVC_VC_DIR=%%C
|
||||||
|
if DEFINED MSVC_VC_DIR (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% on Win64 detected at "%MSVC_VC_DIR%"
|
||||||
|
)
|
||||||
|
goto msvc_detect_finally
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Check 32 bits
|
||||||
|
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
|
||||||
|
for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v ProductDir 2^>nul`) DO set MSVC_VC_DIR=%%C
|
||||||
|
if DEFINED MSVC_VC_DIR (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% on Win32 detected at "%MSVC_VC_DIR%"
|
||||||
|
)
|
||||||
|
goto msvc_detect_finally
|
||||||
|
)
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% not found.
|
||||||
|
)
|
||||||
|
goto FAIL
|
||||||
|
:msvc_detect_finally
|
||||||
|
set VCVARS=%MSVC_VC_DIR%\vcvarsall.bat
|
||||||
|
if not exist "%VCVARS%" (
|
||||||
|
echo "%VCVARS%" not found.
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
|
||||||
|
call "%vcvars%" %BUILD_ARCH%
|
||||||
|
|
||||||
|
rem try msbuild
|
||||||
|
msbuild /version > NUL
|
||||||
|
if errorlevel 1 (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% msbuild not found
|
||||||
|
)
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% msbuild found
|
||||||
|
)
|
||||||
|
|
||||||
|
REM try the c++ compiler
|
||||||
|
cl 2> NUL 1>&2
|
||||||
|
if errorlevel 1 (
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler not found
|
||||||
|
)
|
||||||
|
goto FAIL
|
||||||
|
)
|
||||||
|
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler found
|
||||||
|
)
|
||||||
|
goto DetectionComplete
|
||||||
|
|
||||||
|
:FAIL
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:DetectionComplete
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo Visual Studio %BUILD_VS_YEAR% Detected successfuly
|
||||||
|
)
|
||||||
|
exit /b 0
|
13
build_files/windows/find_dependencies.cmd
Normal file
13
build_files/windows/find_dependencies.cmd
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
REM find all dependencies and set the corresponding environement variables.
|
||||||
|
for %%X in (svn.exe) do (set SVN=%%~$PATH:X)
|
||||||
|
for %%X in (cmake.exe) do (set CMAKE=%%~$PATH:X)
|
||||||
|
for %%X in (git.exe) do (set GIT=%%~$PATH:X)
|
||||||
|
if NOT "%verbose%" == "" (
|
||||||
|
echo svn : %SVN%
|
||||||
|
echo cmake : %CMAKE%
|
||||||
|
echo git : %GIT%
|
||||||
|
)
|
||||||
|
if "%CMAKE%" == "" (
|
||||||
|
echo Cmake not found in path, required for building, exiting...
|
||||||
|
exit /b 1
|
||||||
|
)
|
82
build_files/windows/parse_arguments.cmd
Normal file
82
build_files/windows/parse_arguments.cmd
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
set BUILD_DIR=%BLENDER_DIR%..\build_windows
|
||||||
|
set BUILD_TYPE=Release
|
||||||
|
:argv_loop
|
||||||
|
if NOT "%1" == "" (
|
||||||
|
|
||||||
|
REM Help Message
|
||||||
|
if "%1" == "help" (
|
||||||
|
set SHOW_HELP=1
|
||||||
|
goto EOF
|
||||||
|
)
|
||||||
|
REM Build Types
|
||||||
|
if "%1" == "debug" (
|
||||||
|
set BUILD_TYPE=Debug
|
||||||
|
REM Build Configurations
|
||||||
|
) else if "%1" == "noge" (
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_GAMEENGINE=OFF -DWITH_PLAYER=OFF
|
||||||
|
set BUILD_NGE=_noge
|
||||||
|
) else if "%1" == "builddir" (
|
||||||
|
set BUILD_DIR_OVERRRIDE="%BLENDER_DIR%..\%2"
|
||||||
|
shift /1
|
||||||
|
) else if "%1" == "with_tests" (
|
||||||
|
set TESTS_CMAKE_ARGS=-DWITH_GTESTS=On
|
||||||
|
) else if "%1" == "full" (
|
||||||
|
set TARGET=Full
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
|
||||||
|
-C"%BLENDER_DIR%\build_files\cmake\config\blender_full.cmake"
|
||||||
|
) else if "%1" == "lite" (
|
||||||
|
set TARGET=Lite
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_lite.cmake"
|
||||||
|
) else if "%1" == "cycles" (
|
||||||
|
set TARGET=Cycles
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\cycles_standalone.cmake"
|
||||||
|
) else if "%1" == "headless" (
|
||||||
|
set TARGET=Headless
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_headless.cmake"
|
||||||
|
) else if "%1" == "bpy" (
|
||||||
|
set TARGET=Bpy
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\bpy_module.cmake"
|
||||||
|
) else if "%1" == "clang" (
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS%
|
||||||
|
set WITH_CLANG=1
|
||||||
|
) else if "%1" == "release" (
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake"
|
||||||
|
set TARGET=Release
|
||||||
|
) else if "%1" == "x86" (
|
||||||
|
set BUILD_ARCH=x86
|
||||||
|
) else if "%1" == "x64" (
|
||||||
|
set BUILD_ARCH=x64
|
||||||
|
) else if "%1" == "2017" (
|
||||||
|
set BUILD_VS_YEAR=2017
|
||||||
|
) else if "%1" == "2017pre" (
|
||||||
|
set BUILD_VS_YEAR=2017
|
||||||
|
set VSWHERE_ARGS=-prerelease
|
||||||
|
) else if "%1" == "2015" (
|
||||||
|
set BUILD_VS_YEAR=2015
|
||||||
|
) else if "%1" == "2013" (
|
||||||
|
set BUILD_VS_YEAR=2013
|
||||||
|
) else if "%1" == "packagename" (
|
||||||
|
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2"
|
||||||
|
shift /1
|
||||||
|
) else if "%1" == "nobuild" (
|
||||||
|
set NOBUILD=1
|
||||||
|
) else if "%1" == "showhash" (
|
||||||
|
SET BUILD_SHOW_HASHES=1
|
||||||
|
REM Non-Build Commands
|
||||||
|
) else if "%1" == "update" (
|
||||||
|
SET BUILD_UPDATE=1
|
||||||
|
) else if "%1" == "ninja" (
|
||||||
|
SET BUILD_WITH_NINJA=1
|
||||||
|
) else if "%1" == "clean" (
|
||||||
|
set MUST_CLEAN=1
|
||||||
|
) else if "%1" == "verbose" (
|
||||||
|
set VERBOSE=1
|
||||||
|
) else (
|
||||||
|
echo Command "%1" unknown, aborting!
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
shift /1
|
||||||
|
goto argv_loop
|
||||||
|
)
|
||||||
|
:EOF
|
||||||
|
exit /b 0
|
24
build_files/windows/reset_variables.cmd
Normal file
24
build_files/windows/reset_variables.cmd
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
rem reset all variables so they do not get accidentally get carried over from previous builds
|
||||||
|
set BUILD_DIR_OVERRRIDE=
|
||||||
|
set BUILD_CMAKE_ARGS=
|
||||||
|
set BUILD_ARCH=
|
||||||
|
set BUILD_VS_VER=
|
||||||
|
set BUILD_VS_YEAR=
|
||||||
|
set BUILD_VS_LIBDIRPOST=
|
||||||
|
set BUILD_VS_LIBDIR=
|
||||||
|
set BUILD_VS_SVNDIR=
|
||||||
|
set BUILD_NGE=
|
||||||
|
set KEY_NAME=
|
||||||
|
set MSBUILD_PLATFORM=
|
||||||
|
set MUST_CLEAN=
|
||||||
|
set NOBUILD=
|
||||||
|
set TARGET=
|
||||||
|
set VERBOSE=
|
||||||
|
set WINDOWS_ARCH=
|
||||||
|
set TESTS_CMAKE_ARGS=
|
||||||
|
set VSWHERE_ARGS=
|
||||||
|
set BUILD_UPDATE=
|
||||||
|
set BUILD_SHOW_HASHES=
|
||||||
|
set SHOW_HELP=
|
||||||
|
set BUILD_WITH_NINJA=
|
||||||
|
set WITH_CLANG=
|
4
build_files/windows/set_build_dir.cmd
Normal file
4
build_files/windows/set_build_dir.cmd
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
set BUILD_DIR=%BUILD_DIR%_%TARGET%%BUILD_NGE%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
|
||||||
|
if NOT "%BUILD_DIR_OVERRRIDE%"=="" (
|
||||||
|
set BUILD_DIR=%BUILD_DIR_OVERRRIDE%
|
||||||
|
)
|
12
build_files/windows/show_hashes.cmd
Normal file
12
build_files/windows/show_hashes.cmd
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
if "%GIT%" == "" (
|
||||||
|
echo Git not found, cannot show hashes.
|
||||||
|
goto EOF
|
||||||
|
)
|
||||||
|
cd "%BLENDER_DIR%"
|
||||||
|
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Branch_hash=%%i
|
||||||
|
cd "%BLENDER_DIR%/release/datafiles/locale"
|
||||||
|
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Locale_hash=%%i
|
||||||
|
cd "%BLENDER_DIR%/release/scripts/addons"
|
||||||
|
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Addons_Hash=%%i
|
||||||
|
cd "%BLENDER_DIR%"
|
||||||
|
:EOF
|
29
build_files/windows/show_help.cmd
Normal file
29
build_files/windows/show_help.cmd
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
echo.
|
||||||
|
echo Convenience targets
|
||||||
|
echo - release ^(identical to the official blender.org builds^)
|
||||||
|
echo - full ^(same as release minus the cuda kernels^)
|
||||||
|
echo - lite
|
||||||
|
echo - headless
|
||||||
|
echo - cycles
|
||||||
|
echo - bpy
|
||||||
|
echo.
|
||||||
|
echo Utilities ^(not associated with building^)
|
||||||
|
echo - clean ^(Target must be set^)
|
||||||
|
echo - update
|
||||||
|
echo - nobuild ^(only generate project files^)
|
||||||
|
echo - showhash ^(Show git hashes of source tree^)
|
||||||
|
echo.
|
||||||
|
echo Configuration options
|
||||||
|
echo - verbose ^(enable diagnostic output during configuration^)
|
||||||
|
echo - with_tests ^(enable building unit tests^)
|
||||||
|
echo - noge ^(disable building game enginge and player^)
|
||||||
|
echo - debug ^(Build an unoptimized debuggable build^)
|
||||||
|
echo - packagename [newname] ^(override default cpack package name^)
|
||||||
|
echo - buildir [newdir] ^(override default build folder^)
|
||||||
|
echo - x86 ^(override host auto-detect and build 32 bit code^)
|
||||||
|
echo - x64 ^(override host auto-detect and build 64 bit code^)
|
||||||
|
echo - 2013 ^(build with visual studio 2013^)
|
||||||
|
echo - 2015 ^(build with visual studio 2015^) [EXPERIMENTAL]
|
||||||
|
echo - 2017 ^(build with visual studio 2017^) [EXPERIMENTAL]
|
||||||
|
echo - 2017pre ^(build with visual studio 2017 pre-release^) [EXPERIMENTAL]
|
||||||
|
echo.
|
16
build_files/windows/update_sources.cmd
Normal file
16
build_files/windows/update_sources.cmd
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
if "%SVN%" == "" (
|
||||||
|
echo svn not found, cannot update libraries
|
||||||
|
goto UPDATE_GIT
|
||||||
|
)
|
||||||
|
"%SVN%" up "%BLENDER_DIR%/../lib/*"
|
||||||
|
|
||||||
|
:UPDATE_GIT
|
||||||
|
|
||||||
|
if "%GIT%" == "" (
|
||||||
|
echo Git not found, cannot update code
|
||||||
|
goto EOF
|
||||||
|
)
|
||||||
|
"%GIT%" pull --rebase
|
||||||
|
"%GIT%" submodule foreach git pull --rebase origin master
|
||||||
|
|
||||||
|
:EOF
|
@@ -20,6 +20,6 @@ The execution context is one of:
|
|||||||
'EXEC_SCREEN')
|
'EXEC_SCREEN')
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# group add popup
|
# collection add popup
|
||||||
import bpy
|
import bpy
|
||||||
bpy.ops.object.group_instance_add('INVOKE_DEFAULT')
|
bpy.ops.object.collection_instance_add('INVOKE_DEFAULT')
|
||||||
|
@@ -335,7 +335,7 @@ template<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr) { _mm_p
|
|||||||
template<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
|
template<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
|
||||||
template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
|
template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(_WIN64) && !defined(__INTEL_COMPILER)
|
#if defined(_MSC_VER) && defined(_WIN64) && !defined(__INTEL_COMPILER) && !defined(__clang__)
|
||||||
// The temporary variable fixes an internal compilation error in vs <= 2008 and a wrong-result bug in vs 2010
|
// The temporary variable fixes an internal compilation error in vs <= 2008 and a wrong-result bug in vs 2010
|
||||||
// Direct of the struct members fixed bug #62.
|
// Direct of the struct members fixed bug #62.
|
||||||
template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { return a.m128_f32[0]; }
|
template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { return a.m128_f32[0]; }
|
||||||
|
12
extern/Eigen3/patches/blender.diff
vendored
Normal file
12
extern/Eigen3/patches/blender.diff
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
diff -Naur c:\blender-git\blender\extern\Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h k:\BlenderGit\blender\extern\Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
|
||||||
|
--- c:\blender-git\blender\extern\Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h 2018-05-25 13:29:14 -0600
|
||||||
|
+++ k:\BlenderGit\blender\extern\Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h 2018-05-26 19:56:36 -0600
|
||||||
|
@@ -335,7 +335,7 @@
|
||||||
|
template<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
|
||||||
|
template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
|
||||||
|
|
||||||
|
-#if defined(_MSC_VER) && defined(_WIN64) && !defined(__INTEL_COMPILER)
|
||||||
|
+#if defined(_MSC_VER) && defined(_WIN64) && !defined(__INTEL_COMPILER) && !defined(__clang__)
|
||||||
|
// The temporary variable fixes an internal compilation error in vs <= 2008 and a wrong-result bug in vs 2010
|
||||||
|
// Direct of the struct members fixed bug #62.
|
||||||
|
template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { return a.m128_f32[0]; }
|
31
extern/bullet2/patches/blender.patch
vendored
31
extern/bullet2/patches/blender.patch
vendored
@@ -1,3 +1,34 @@
|
|||||||
|
diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
|
||||||
|
--- a/extern/bullet2/src/LinearMath/btScalar.h
|
||||||
|
+++ b/extern/bullet2/src/LinearMath/btScalar.h
|
||||||
|
@@ -16,6 +16,9 @@
|
||||||
|
|
||||||
|
#ifndef BT_SCALAR_H
|
||||||
|
#define BT_SCALAR_H
|
||||||
|
+#if defined(_MSC_VER) && defined(__clang__) /* clang supplies it's own overloads already */
|
||||||
|
+#define BT_NO_SIMD_OPERATOR_OVERLOADS
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#ifdef BT_MANAGED_CODE
|
||||||
|
//Aligned data types not supported in managed code
|
||||||
|
@@ -83,7 +86,7 @@
|
||||||
|
#ifdef BT_USE_SSE
|
||||||
|
|
||||||
|
#if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default)
|
||||||
|
- #define BT_ALLOW_SSE4
|
||||||
|
+ //#define BT_ALLOW_SSE4 //disable this cause blender targets sse2
|
||||||
|
#endif //(_MSC_FULL_VER >= 160040219)
|
||||||
|
|
||||||
|
//BT_USE_SSE_IN_API is disabled under Windows by default, because
|
||||||
|
@@ -102,7 +105,7 @@
|
||||||
|
#endif //__MINGW32__
|
||||||
|
|
||||||
|
#ifdef BT_DEBUG
|
||||||
|
- #ifdef _MSC_VER
|
||||||
|
+ #if defined(_MSC_VER) && !defined(__clang__)
|
||||||
|
#include <stdio.h>
|
||||||
|
#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
|
||||||
|
#else//_MSC_VER
|
||||||
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
|
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
|
||||||
index be9eca6..ec40c96 100644
|
index be9eca6..ec40c96 100644
|
||||||
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
|
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
|
||||||
|
7
extern/bullet2/src/LinearMath/btScalar.h
vendored
7
extern/bullet2/src/LinearMath/btScalar.h
vendored
@@ -16,6 +16,9 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#ifndef BT_SCALAR_H
|
#ifndef BT_SCALAR_H
|
||||||
#define BT_SCALAR_H
|
#define BT_SCALAR_H
|
||||||
|
#if defined(_MSC_VER) && defined(__clang__) /* clang supplies it's own overloads already */
|
||||||
|
#define BT_NO_SIMD_OPERATOR_OVERLOADS
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BT_MANAGED_CODE
|
#ifdef BT_MANAGED_CODE
|
||||||
//Aligned data types not supported in managed code
|
//Aligned data types not supported in managed code
|
||||||
@@ -83,7 +86,7 @@ inline int btGetVersion()
|
|||||||
#ifdef BT_USE_SSE
|
#ifdef BT_USE_SSE
|
||||||
|
|
||||||
#if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default)
|
#if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default)
|
||||||
#define BT_ALLOW_SSE4
|
//#define BT_ALLOW_SSE4 //disable this cause blender targets sse2
|
||||||
#endif //(_MSC_FULL_VER >= 160040219)
|
#endif //(_MSC_FULL_VER >= 160040219)
|
||||||
|
|
||||||
//BT_USE_SSE_IN_API is disabled under Windows by default, because
|
//BT_USE_SSE_IN_API is disabled under Windows by default, because
|
||||||
@@ -102,7 +105,7 @@ inline int btGetVersion()
|
|||||||
#endif //__MINGW32__
|
#endif //__MINGW32__
|
||||||
|
|
||||||
#ifdef BT_DEBUG
|
#ifdef BT_DEBUG
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
|
#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
|
||||||
#else//_MSC_VER
|
#else//_MSC_VER
|
||||||
|
@@ -40,7 +40,11 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
|
||||||
/******************************************************************************/
|
#if defined (__clang__)
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* 64-bit operations. */
|
/* 64-bit operations. */
|
||||||
#if (LG_SIZEOF_PTR == 8 || LG_SIZEOF_INT == 8)
|
#if (LG_SIZEOF_PTR == 8 || LG_SIZEOF_INT == 8)
|
||||||
/* Unsigned */
|
/* Unsigned */
|
||||||
@@ -205,4 +209,9 @@ ATOMIC_INLINE int8_t atomic_fetch_and_or_int8(int8_t *p, int8_t b)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__clang__)
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __ATOMIC_OPS_MSVC_H__ */
|
#endif /* __ATOMIC_OPS_MSVC_H__ */
|
||||||
|
@@ -146,6 +146,7 @@ void CLG_exit(void);
|
|||||||
void CLG_output_set(void *file_handle);
|
void CLG_output_set(void *file_handle);
|
||||||
void CLG_output_use_basename_set(int value);
|
void CLG_output_use_basename_set(int value);
|
||||||
void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle));
|
void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle));
|
||||||
|
void CLG_backtrace_fn_set(void (*fatal_fn)(void *file_handle));
|
||||||
|
|
||||||
void CLG_type_filter_include(const char *type_filter, int type_filter_len);
|
void CLG_type_filter_include(const char *type_filter, int type_filter_len);
|
||||||
void CLG_type_filter_exclude(const char *type_filter, int type_filter_len);
|
void CLG_type_filter_exclude(const char *type_filter, int type_filter_len);
|
||||||
|
@@ -81,6 +81,7 @@ typedef struct CLogContext {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
void (*fatal_fn)(void *file_handle);
|
void (*fatal_fn)(void *file_handle);
|
||||||
|
void (*backtrace_fn)(void *file_handle);
|
||||||
} callbacks;
|
} callbacks;
|
||||||
} CLogContext;
|
} CLogContext;
|
||||||
|
|
||||||
@@ -328,15 +329,23 @@ static CLG_LogType *clg_ctx_type_register(CLogContext *ctx, const char *identifi
|
|||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clg_ctx_fatal_action(CLogContext *ctx, FILE *file_handle)
|
static void clg_ctx_fatal_action(CLogContext *ctx)
|
||||||
{
|
{
|
||||||
if (ctx->callbacks.fatal_fn != NULL) {
|
if (ctx->callbacks.fatal_fn != NULL) {
|
||||||
ctx->callbacks.fatal_fn(file_handle);
|
ctx->callbacks.fatal_fn(ctx->output_file);
|
||||||
}
|
}
|
||||||
fflush(file_handle);
|
fflush(ctx->output_file);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clg_ctx_backtrace(CLogContext *ctx)
|
||||||
|
{
|
||||||
|
/* Note: we avoid writing fo 'FILE', for backtrace we make an exception,
|
||||||
|
* if necessary we could have a version of the callback that writes to file descriptor all at once. */
|
||||||
|
ctx->callbacks.backtrace_fn(ctx->output_file);
|
||||||
|
fflush(ctx->output_file);
|
||||||
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
@@ -404,12 +413,17 @@ void CLG_log_str(
|
|||||||
clg_str_append(&cstr, "\n");
|
clg_str_append(&cstr, "\n");
|
||||||
|
|
||||||
/* could be optional */
|
/* could be optional */
|
||||||
write(lg->ctx->output, cstr.data, cstr.len);
|
int bytes_written = write(lg->ctx->output, cstr.data, cstr.len);
|
||||||
|
(void)bytes_written;
|
||||||
|
|
||||||
clg_str_free(&cstr);
|
clg_str_free(&cstr);
|
||||||
|
|
||||||
|
if (lg->ctx->callbacks.backtrace_fn) {
|
||||||
|
clg_ctx_backtrace(lg->ctx);
|
||||||
|
}
|
||||||
|
|
||||||
if (severity == CLG_SEVERITY_FATAL) {
|
if (severity == CLG_SEVERITY_FATAL) {
|
||||||
clg_ctx_fatal_action(lg->ctx, lg->ctx->output_file);
|
clg_ctx_fatal_action(lg->ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,12 +449,17 @@ void CLG_logf(
|
|||||||
clg_str_append(&cstr, "\n");
|
clg_str_append(&cstr, "\n");
|
||||||
|
|
||||||
/* could be optional */
|
/* could be optional */
|
||||||
write(lg->ctx->output, cstr.data, cstr.len);
|
int bytes_written = write(lg->ctx->output, cstr.data, cstr.len);
|
||||||
|
(void)bytes_written;
|
||||||
|
|
||||||
clg_str_free(&cstr);
|
clg_str_free(&cstr);
|
||||||
|
|
||||||
|
if (lg->ctx->callbacks.backtrace_fn) {
|
||||||
|
clg_ctx_backtrace(lg->ctx);
|
||||||
|
}
|
||||||
|
|
||||||
if (severity == CLG_SEVERITY_FATAL) {
|
if (severity == CLG_SEVERITY_FATAL) {
|
||||||
clg_ctx_fatal_action(lg->ctx, lg->ctx->output_file);
|
clg_ctx_fatal_action(lg->ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,6 +489,11 @@ static void CLG_ctx_fatal_fn_set(CLogContext *ctx, void (*fatal_fn)(void *file_h
|
|||||||
ctx->callbacks.fatal_fn = fatal_fn;
|
ctx->callbacks.fatal_fn = fatal_fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CLG_ctx_backtrace_fn_set(CLogContext *ctx, void (*backtrace_fn)(void *file_handle))
|
||||||
|
{
|
||||||
|
ctx->callbacks.backtrace_fn = backtrace_fn;
|
||||||
|
}
|
||||||
|
|
||||||
static void clg_ctx_type_filter_append(CLG_IDFilter **flt_list, const char *type_match, int type_match_len)
|
static void clg_ctx_type_filter_append(CLG_IDFilter **flt_list, const char *type_match, int type_match_len)
|
||||||
{
|
{
|
||||||
if (type_match_len == 0) {
|
if (type_match_len == 0) {
|
||||||
@@ -567,6 +591,11 @@ void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle))
|
|||||||
CLG_ctx_fatal_fn_set(g_ctx, fatal_fn);
|
CLG_ctx_fatal_fn_set(g_ctx, fatal_fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CLG_backtrace_fn_set(void (*fatal_fn)(void *file_handle))
|
||||||
|
{
|
||||||
|
CLG_ctx_backtrace_fn_set(g_ctx, fatal_fn);
|
||||||
|
}
|
||||||
|
|
||||||
void CLG_type_filter_exclude(const char *type_match, int type_match_len)
|
void CLG_type_filter_exclude(const char *type_match, int type_match_len)
|
||||||
{
|
{
|
||||||
CLG_ctx_type_filter_exclude(g_ctx, type_match, type_match_len);
|
CLG_ctx_type_filter_exclude(g_ctx, type_match, type_match_len);
|
||||||
|
@@ -31,7 +31,7 @@ elseif(NOT WITH_CPU_SSE)
|
|||||||
set(CXX_HAS_SSE FALSE)
|
set(CXX_HAS_SSE FALSE)
|
||||||
set(CXX_HAS_AVX FALSE)
|
set(CXX_HAS_AVX FALSE)
|
||||||
set(CXX_HAS_AVX2 FALSE)
|
set(CXX_HAS_AVX2 FALSE)
|
||||||
elseif(WIN32 AND MSVC)
|
elseif(WIN32 AND MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set(CXX_HAS_SSE TRUE)
|
set(CXX_HAS_SSE TRUE)
|
||||||
set(CXX_HAS_AVX TRUE)
|
set(CXX_HAS_AVX TRUE)
|
||||||
set(CXX_HAS_AVX2 TRUE)
|
set(CXX_HAS_AVX2 TRUE)
|
||||||
@@ -306,7 +306,7 @@ if(WITH_CYCLES_CUDA_BINARIES AND (NOT WITH_CYCLES_CUBIN_COMPILER))
|
|||||||
elseif(${CUDA_VERSION} EQUAL "9.1")
|
elseif(${CUDA_VERSION} EQUAL "9.1")
|
||||||
set(MAX_MSVC 1911)
|
set(MAX_MSVC 1911)
|
||||||
endif()
|
endif()
|
||||||
if(NOT MSVC_VERSION LESS ${MAX_MSVC})
|
if(NOT MSVC_VERSION LESS ${MAX_MSVC} OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
message(STATUS "nvcc not supported for this compiler version, using cycles_cubin_cc instead.")
|
message(STATUS "nvcc not supported for this compiler version, using cycles_cubin_cc instead.")
|
||||||
set(WITH_CYCLES_CUBIN_COMPILER ON)
|
set(WITH_CYCLES_CUBIN_COMPILER ON)
|
||||||
endif()
|
endif()
|
||||||
|
@@ -66,31 +66,32 @@ class CyclesRender(bpy.types.RenderEngine):
|
|||||||
engine.free(self)
|
engine.free(self)
|
||||||
|
|
||||||
# final render
|
# final render
|
||||||
def update(self, data, scene):
|
def update(self, data, depsgraph):
|
||||||
if not self.session:
|
if not self.session:
|
||||||
if self.is_preview:
|
if self.is_preview:
|
||||||
cscene = bpy.context.scene.cycles
|
cscene = bpy.context.scene.cycles
|
||||||
use_osl = cscene.shading_system and cscene.device == 'CPU'
|
use_osl = cscene.shading_system and cscene.device == 'CPU'
|
||||||
|
|
||||||
engine.create(self, data, scene,
|
engine.create(self, data, preview_osl=use_osl)
|
||||||
None, None, None, use_osl)
|
|
||||||
else:
|
else:
|
||||||
engine.create(self, data, scene)
|
engine.create(self, data)
|
||||||
else:
|
|
||||||
engine.reset(self, data, scene)
|
engine.reset(self, data, depsgraph)
|
||||||
|
|
||||||
def render_to_image(self, depsgraph):
|
def render_to_image(self, depsgraph):
|
||||||
engine.render(self, depsgraph)
|
engine.render(self, depsgraph)
|
||||||
|
|
||||||
def bake(self, depsgraph, scene, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
|
def bake(self, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
|
||||||
engine.bake(self, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result)
|
engine.bake(self, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result)
|
||||||
|
|
||||||
# viewport render
|
# viewport render
|
||||||
def view_update(self, context):
|
def view_update(self, context):
|
||||||
if not self.session:
|
if not self.session:
|
||||||
engine.create(self, context.blend_data, context.scene,
|
engine.create(self, context.blend_data,
|
||||||
context.region, context.space_data, context.region_data)
|
context.region, context.space_data, context.region_data)
|
||||||
engine.update(self, context.depsgraph, context.blend_data, context.scene)
|
|
||||||
|
engine.reset(self, context.blend_data, context.depsgraph)
|
||||||
|
engine.sync(self, context.depsgraph, context.blend_data)
|
||||||
|
|
||||||
def render_to_view(self, context):
|
def render_to_view(self, context):
|
||||||
engine.draw(self, context.depsgraph, context.region, context.space_data, context.region_data)
|
engine.draw(self, context.depsgraph, context.region, context.space_data, context.region_data)
|
||||||
|
@@ -123,13 +123,12 @@ def exit():
|
|||||||
_cycles.exit()
|
_cycles.exit()
|
||||||
|
|
||||||
|
|
||||||
def create(engine, data, scene, region=None, v3d=None, rv3d=None, preview_osl=False):
|
def create(engine, data, region=None, v3d=None, rv3d=None, preview_osl=False):
|
||||||
import bpy
|
|
||||||
import _cycles
|
import _cycles
|
||||||
|
import bpy
|
||||||
|
|
||||||
data = data.as_pointer()
|
data = data.as_pointer()
|
||||||
userpref = bpy.context.user_preferences.as_pointer()
|
userpref = bpy.context.user_preferences.as_pointer()
|
||||||
scene = scene.as_pointer()
|
|
||||||
if region:
|
if region:
|
||||||
region = region.as_pointer()
|
region = region.as_pointer()
|
||||||
if v3d:
|
if v3d:
|
||||||
@@ -137,13 +136,8 @@ def create(engine, data, scene, region=None, v3d=None, rv3d=None, preview_osl=Fa
|
|||||||
if rv3d:
|
if rv3d:
|
||||||
rv3d = rv3d.as_pointer()
|
rv3d = rv3d.as_pointer()
|
||||||
|
|
||||||
if bpy.app.debug_value == 256:
|
|
||||||
_cycles.debug_flags_update(scene)
|
|
||||||
else:
|
|
||||||
_cycles.debug_flags_reset()
|
|
||||||
|
|
||||||
engine.session = _cycles.create(
|
engine.session = _cycles.create(
|
||||||
engine.as_pointer(), userpref, data, scene, region, v3d, rv3d, preview_osl)
|
engine.as_pointer(), userpref, data, region, v3d, rv3d, preview_osl)
|
||||||
|
|
||||||
|
|
||||||
def free(engine):
|
def free(engine):
|
||||||
@@ -167,14 +161,21 @@ def bake(engine, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array,
|
|||||||
_cycles.bake(engine.session, depsgraph.as_pointer(), obj.as_pointer(), pass_type, pass_filter, object_id, pixel_array.as_pointer(), num_pixels, depth, result.as_pointer())
|
_cycles.bake(engine.session, depsgraph.as_pointer(), obj.as_pointer(), pass_type, pass_filter, object_id, pixel_array.as_pointer(), num_pixels, depth, result.as_pointer())
|
||||||
|
|
||||||
|
|
||||||
def reset(engine, data, scene):
|
def reset(engine, data, depsgraph):
|
||||||
import _cycles
|
import _cycles
|
||||||
|
import bpy
|
||||||
|
|
||||||
|
if bpy.app.debug_value == 256:
|
||||||
|
_cycles.debug_flags_update(depsgraph.scene)
|
||||||
|
else:
|
||||||
|
_cycles.debug_flags_reset()
|
||||||
|
|
||||||
data = data.as_pointer()
|
data = data.as_pointer()
|
||||||
scene = scene.as_pointer()
|
depsgraph = depsgraph.as_pointer()
|
||||||
_cycles.reset(engine.session, data, scene)
|
_cycles.reset(engine.session, data, depsgraph)
|
||||||
|
|
||||||
|
|
||||||
def update(engine, depsgraph, data, scene):
|
def sync(engine, depsgraph, data):
|
||||||
import _cycles
|
import _cycles
|
||||||
_cycles.sync(engine.session, depsgraph.as_pointer())
|
_cycles.sync(engine.session, depsgraph.as_pointer())
|
||||||
|
|
||||||
|
@@ -112,7 +112,8 @@ def update_script_node(node, report):
|
|||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
# now update node with new sockets
|
# now update node with new sockets
|
||||||
ok = _cycles.osl_update_node(node.id_data.as_pointer(), node.as_pointer(), oso_path)
|
data = bpy.data.as_pointer()
|
||||||
|
ok = _cycles.osl_update_node(data, node.id_data.as_pointer(), node.as_pointer(), oso_path)
|
||||||
|
|
||||||
if not ok:
|
if not ok:
|
||||||
report({'ERROR'}, "OSL query failed to open " + oso_path)
|
report({'ERROR'}, "OSL query failed to open " + oso_path)
|
||||||
|
@@ -909,9 +909,9 @@ class CYCLES_LAMP_PT_lamp(CyclesButtonsPanel, Panel):
|
|||||||
col.prop(lamp, "shape", text="")
|
col.prop(lamp, "shape", text="")
|
||||||
sub = col.column(align=True)
|
sub = col.column(align=True)
|
||||||
|
|
||||||
if lamp.shape == 'SQUARE':
|
if lamp.shape in {'SQUARE', 'DISK'}:
|
||||||
sub.prop(lamp, "size")
|
sub.prop(lamp, "size")
|
||||||
elif lamp.shape == 'RECTANGLE':
|
elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
|
||||||
sub.prop(lamp, "size", text="Size X")
|
sub.prop(lamp, "size", text="Size X")
|
||||||
sub.prop(lamp, "size_y", text="Size Y")
|
sub.prop(lamp, "size_y", text="Size Y")
|
||||||
|
|
||||||
@@ -1604,7 +1604,7 @@ classes = (
|
|||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
|
|
||||||
bpy.types.RENDER_PT_render.append(draw_device)
|
bpy.types.RENDER_PT_context.append(draw_device)
|
||||||
bpy.types.VIEW3D_HT_header.append(draw_pause)
|
bpy.types.VIEW3D_HT_header.append(draw_pause)
|
||||||
|
|
||||||
for panel in get_panels():
|
for panel in get_panels():
|
||||||
@@ -1617,7 +1617,7 @@ def register():
|
|||||||
def unregister():
|
def unregister():
|
||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
|
|
||||||
bpy.types.RENDER_PT_render.remove(draw_device)
|
bpy.types.RENDER_PT_context.remove(draw_device)
|
||||||
bpy.types.VIEW3D_HT_header.remove(draw_pause)
|
bpy.types.VIEW3D_HT_header.remove(draw_pause)
|
||||||
|
|
||||||
for panel in get_panels():
|
for panel in get_panels():
|
||||||
|
@@ -95,8 +95,8 @@ static void blender_camera_init(BlenderCamera *bcam,
|
|||||||
bcam->type = CAMERA_PERSPECTIVE;
|
bcam->type = CAMERA_PERSPECTIVE;
|
||||||
bcam->zoom = 1.0f;
|
bcam->zoom = 1.0f;
|
||||||
bcam->pixelaspect = make_float2(1.0f, 1.0f);
|
bcam->pixelaspect = make_float2(1.0f, 1.0f);
|
||||||
bcam->sensor_width = 32.0f;
|
bcam->sensor_width = 36.0f;
|
||||||
bcam->sensor_height = 18.0f;
|
bcam->sensor_height = 24.0f;
|
||||||
bcam->sensor_fit = BlenderCamera::AUTO;
|
bcam->sensor_fit = BlenderCamera::AUTO;
|
||||||
bcam->shuttertime = 1.0f;
|
bcam->shuttertime = 1.0f;
|
||||||
bcam->motion_position = Camera::MOTION_POSITION_CENTER;
|
bcam->motion_position = Camera::MOTION_POSITION_CENTER;
|
||||||
|
@@ -1189,7 +1189,7 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
|
|||||||
BL::Mesh b_mesh = object_to_mesh(b_data,
|
BL::Mesh b_mesh = object_to_mesh(b_data,
|
||||||
b_ob,
|
b_ob,
|
||||||
b_depsgraph,
|
b_depsgraph,
|
||||||
true,
|
false,
|
||||||
need_undeformed,
|
need_undeformed,
|
||||||
mesh->subdivision_type);
|
mesh->subdivision_type);
|
||||||
|
|
||||||
@@ -1277,7 +1277,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph& b_depsgraph,
|
|||||||
b_mesh = object_to_mesh(b_data,
|
b_mesh = object_to_mesh(b_data,
|
||||||
b_ob,
|
b_ob,
|
||||||
b_depsgraph,
|
b_depsgraph,
|
||||||
true,
|
false,
|
||||||
false,
|
false,
|
||||||
Mesh::SUBDIVISION_NONE);
|
Mesh::SUBDIVISION_NONE);
|
||||||
}
|
}
|
||||||
|
@@ -162,10 +162,24 @@ void BlenderSync::sync_light(BL::Object& b_parent,
|
|||||||
light->axisu = transform_get_column(&tfm, 0);
|
light->axisu = transform_get_column(&tfm, 0);
|
||||||
light->axisv = transform_get_column(&tfm, 1);
|
light->axisv = transform_get_column(&tfm, 1);
|
||||||
light->sizeu = b_area_lamp.size();
|
light->sizeu = b_area_lamp.size();
|
||||||
if(b_area_lamp.shape() == BL::AreaLamp::shape_RECTANGLE)
|
switch(b_area_lamp.shape()) {
|
||||||
light->sizev = b_area_lamp.size_y();
|
case BL::AreaLamp::shape_SQUARE:
|
||||||
else
|
light->sizev = light->sizeu;
|
||||||
light->sizev = light->sizeu;
|
light->round = false;
|
||||||
|
break;
|
||||||
|
case BL::AreaLamp::shape_RECTANGLE:
|
||||||
|
light->sizev = b_area_lamp.size_y();
|
||||||
|
light->round = false;
|
||||||
|
break;
|
||||||
|
case BL::AreaLamp::shape_DISK:
|
||||||
|
light->sizev = light->sizeu;
|
||||||
|
light->round = true;
|
||||||
|
break;
|
||||||
|
case BL::AreaLamp::shape_ELLIPSE:
|
||||||
|
light->sizev = b_area_lamp.size_y();
|
||||||
|
light->round = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
light->type = LIGHT_AREA;
|
light->type = LIGHT_AREA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -203,10 +203,10 @@ static PyObject *exit_func(PyObject * /*self*/, PyObject * /*args*/)
|
|||||||
|
|
||||||
static PyObject *create_func(PyObject * /*self*/, PyObject *args)
|
static PyObject *create_func(PyObject * /*self*/, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *pyengine, *pyuserpref, *pydata, *pyscene, *pyregion, *pyv3d, *pyrv3d;
|
PyObject *pyengine, *pyuserpref, *pydata, *pyregion, *pyv3d, *pyrv3d;
|
||||||
int preview_osl;
|
int preview_osl;
|
||||||
|
|
||||||
if(!PyArg_ParseTuple(args, "OOOOOOOi", &pyengine, &pyuserpref, &pydata, &pyscene,
|
if(!PyArg_ParseTuple(args, "OOOOOOi", &pyengine, &pyuserpref, &pydata,
|
||||||
&pyregion, &pyv3d, &pyrv3d, &preview_osl))
|
&pyregion, &pyv3d, &pyrv3d, &preview_osl))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -225,10 +225,6 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args)
|
|||||||
RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr);
|
RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr);
|
||||||
BL::BlendData data(dataptr);
|
BL::BlendData data(dataptr);
|
||||||
|
|
||||||
PointerRNA sceneptr;
|
|
||||||
RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyscene), &sceneptr);
|
|
||||||
BL::Scene scene(sceneptr);
|
|
||||||
|
|
||||||
PointerRNA regionptr;
|
PointerRNA regionptr;
|
||||||
RNA_pointer_create(NULL, &RNA_Region, pylong_as_voidptr_typesafe(pyregion), ®ionptr);
|
RNA_pointer_create(NULL, &RNA_Region, pylong_as_voidptr_typesafe(pyregion), ®ionptr);
|
||||||
BL::Region region(regionptr);
|
BL::Region region(regionptr);
|
||||||
@@ -249,27 +245,13 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args)
|
|||||||
int width = region.width();
|
int width = region.width();
|
||||||
int height = region.height();
|
int height = region.height();
|
||||||
|
|
||||||
session = new BlenderSession(engine, userpref, data, scene, v3d, rv3d, width, height);
|
session = new BlenderSession(engine, userpref, data, v3d, rv3d, width, height);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* override some settings for preview */
|
|
||||||
if(engine.is_preview()) {
|
|
||||||
PointerRNA cscene = RNA_pointer_get(&sceneptr, "cycles");
|
|
||||||
|
|
||||||
RNA_boolean_set(&cscene, "shading_system", preview_osl);
|
|
||||||
RNA_boolean_set(&cscene, "use_progressive_refine", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* offline session or preview render */
|
/* offline session or preview render */
|
||||||
session = new BlenderSession(engine, userpref, data, scene);
|
session = new BlenderSession(engine, userpref, data, preview_osl);
|
||||||
}
|
}
|
||||||
|
|
||||||
python_thread_state_save(&session->python_thread_state);
|
|
||||||
|
|
||||||
session->create();
|
|
||||||
|
|
||||||
python_thread_state_restore(&session->python_thread_state);
|
|
||||||
|
|
||||||
return PyLong_FromVoidPtr(session);
|
return PyLong_FromVoidPtr(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +298,7 @@ static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
|
|||||||
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
|
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
|
||||||
|
|
||||||
PointerRNA depsgraphptr;
|
PointerRNA depsgraphptr;
|
||||||
RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
|
RNA_pointer_create(NULL, &RNA_Depsgraph, PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
|
||||||
BL::Depsgraph b_depsgraph(depsgraphptr);
|
BL::Depsgraph b_depsgraph(depsgraphptr);
|
||||||
|
|
||||||
PointerRNA objectptr;
|
PointerRNA objectptr;
|
||||||
@@ -360,9 +342,9 @@ static PyObject *draw_func(PyObject * /*self*/, PyObject *args)
|
|||||||
|
|
||||||
static PyObject *reset_func(PyObject * /*self*/, PyObject *args)
|
static PyObject *reset_func(PyObject * /*self*/, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *pysession, *pydata, *pyscene;
|
PyObject *pysession, *pydata, *pydepsgraph;
|
||||||
|
|
||||||
if(!PyArg_ParseTuple(args, "OOO", &pysession, &pydata, &pyscene))
|
if(!PyArg_ParseTuple(args, "OOO", &pysession, &pydata, &pydepsgraph))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
|
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
|
||||||
@@ -371,13 +353,13 @@ static PyObject *reset_func(PyObject * /*self*/, PyObject *args)
|
|||||||
RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr);
|
RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr);
|
||||||
BL::BlendData b_data(dataptr);
|
BL::BlendData b_data(dataptr);
|
||||||
|
|
||||||
PointerRNA sceneptr;
|
PointerRNA depsgraphptr;
|
||||||
RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyscene), &sceneptr);
|
RNA_pointer_create(NULL, &RNA_Depsgraph, PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
|
||||||
BL::Scene b_scene(sceneptr);
|
BL::Depsgraph b_depsgraph(depsgraphptr);
|
||||||
|
|
||||||
python_thread_state_save(&session->python_thread_state);
|
python_thread_state_save(&session->python_thread_state);
|
||||||
|
|
||||||
session->reset_session(b_data, b_scene);
|
session->reset_session(b_data, b_depsgraph);
|
||||||
|
|
||||||
python_thread_state_restore(&session->python_thread_state);
|
python_thread_state_restore(&session->python_thread_state);
|
||||||
|
|
||||||
@@ -394,7 +376,7 @@ static PyObject *sync_func(PyObject * /*self*/, PyObject *args)
|
|||||||
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
|
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
|
||||||
|
|
||||||
PointerRNA depsgraphptr;
|
PointerRNA depsgraphptr;
|
||||||
RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
|
RNA_pointer_create(NULL, &RNA_Depsgraph, PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
|
||||||
BL::Depsgraph b_depsgraph(depsgraphptr);
|
BL::Depsgraph b_depsgraph(depsgraphptr);
|
||||||
|
|
||||||
python_thread_state_save(&session->python_thread_state);
|
python_thread_state_save(&session->python_thread_state);
|
||||||
@@ -428,13 +410,17 @@ static PyObject *available_devices_func(PyObject * /*self*/, PyObject * /*args*/
|
|||||||
|
|
||||||
static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *pynodegroup, *pynode;
|
PyObject *pydata, *pynodegroup, *pynode;
|
||||||
const char *filepath = NULL;
|
const char *filepath = NULL;
|
||||||
|
|
||||||
if(!PyArg_ParseTuple(args, "OOs", &pynodegroup, &pynode, &filepath))
|
if(!PyArg_ParseTuple(args, "OOOs", &pydata, &pynodegroup, &pynode, &filepath))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* RNA */
|
/* RNA */
|
||||||
|
PointerRNA dataptr;
|
||||||
|
RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr);
|
||||||
|
BL::BlendData b_data(dataptr);
|
||||||
|
|
||||||
PointerRNA nodeptr;
|
PointerRNA nodeptr;
|
||||||
RNA_pointer_create((ID*)PyLong_AsVoidPtr(pynodegroup), &RNA_ShaderNodeScript, (void*)PyLong_AsVoidPtr(pynode), &nodeptr);
|
RNA_pointer_create((ID*)PyLong_AsVoidPtr(pynodegroup), &RNA_ShaderNodeScript, (void*)PyLong_AsVoidPtr(pynode), &nodeptr);
|
||||||
BL::ShaderNodeScript b_node(nodeptr);
|
BL::ShaderNodeScript b_node(nodeptr);
|
||||||
@@ -532,7 +518,7 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||||||
b_sock = b_node.outputs[param->name.string()];
|
b_sock = b_node.outputs[param->name.string()];
|
||||||
/* remove if type no longer matches */
|
/* remove if type no longer matches */
|
||||||
if(b_sock && b_sock.bl_idname() != socket_type) {
|
if(b_sock && b_sock.bl_idname() != socket_type) {
|
||||||
b_node.outputs.remove(b_sock);
|
b_node.outputs.remove(b_data, b_sock);
|
||||||
b_sock = BL::NodeSocket(PointerRNA_NULL);
|
b_sock = BL::NodeSocket(PointerRNA_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,7 +526,7 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||||||
b_sock = b_node.inputs[param->name.string()];
|
b_sock = b_node.inputs[param->name.string()];
|
||||||
/* remove if type no longer matches */
|
/* remove if type no longer matches */
|
||||||
if(b_sock && b_sock.bl_idname() != socket_type) {
|
if(b_sock && b_sock.bl_idname() != socket_type) {
|
||||||
b_node.inputs.remove(b_sock);
|
b_node.inputs.remove(b_data, b_sock);
|
||||||
b_sock = BL::NodeSocket(PointerRNA_NULL);
|
b_sock = BL::NodeSocket(PointerRNA_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,9 +534,9 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||||||
if(!b_sock) {
|
if(!b_sock) {
|
||||||
/* create new socket */
|
/* create new socket */
|
||||||
if(param->isoutput)
|
if(param->isoutput)
|
||||||
b_sock = b_node.outputs.create(socket_type.c_str(), param->name.c_str(), param->name.c_str());
|
b_sock = b_node.outputs.create(b_data, socket_type.c_str(), param->name.c_str(), param->name.c_str());
|
||||||
else
|
else
|
||||||
b_sock = b_node.inputs.create(socket_type.c_str(), param->name.c_str(), param->name.c_str());
|
b_sock = b_node.inputs.create(b_data, socket_type.c_str(), param->name.c_str(), param->name.c_str());
|
||||||
|
|
||||||
/* set default value */
|
/* set default value */
|
||||||
if(data_type == BL::NodeSocket::type_VALUE) {
|
if(data_type == BL::NodeSocket::type_VALUE) {
|
||||||
@@ -584,7 +570,7 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||||||
|
|
||||||
for(b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
|
for(b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
|
||||||
if(used_sockets.find(b_input->ptr.data) == used_sockets.end()) {
|
if(used_sockets.find(b_input->ptr.data) == used_sockets.end()) {
|
||||||
b_node.inputs.remove(*b_input);
|
b_node.inputs.remove(b_data, *b_input);
|
||||||
removed = true;
|
removed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -592,7 +578,7 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||||||
|
|
||||||
for(b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
|
for(b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
|
||||||
if(used_sockets.find(b_output->ptr.data) == used_sockets.end()) {
|
if(used_sockets.find(b_output->ptr.data) == used_sockets.end()) {
|
||||||
b_node.outputs.remove(*b_output);
|
b_node.outputs.remove(b_data, *b_output);
|
||||||
removed = true;
|
removed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -52,22 +52,22 @@ int BlenderSession::end_resumable_chunk = 0;
|
|||||||
BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
|
BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
|
||||||
BL::UserPreferences& b_userpref,
|
BL::UserPreferences& b_userpref,
|
||||||
BL::BlendData& b_data,
|
BL::BlendData& b_data,
|
||||||
BL::Scene& b_scene)
|
bool preview_osl)
|
||||||
: b_engine(b_engine),
|
: session(NULL),
|
||||||
|
b_engine(b_engine),
|
||||||
b_userpref(b_userpref),
|
b_userpref(b_userpref),
|
||||||
b_data(b_data),
|
b_data(b_data),
|
||||||
b_render(b_engine.render()),
|
b_render(b_engine.render()),
|
||||||
b_depsgraph(PointerRNA_NULL),
|
b_depsgraph(PointerRNA_NULL),
|
||||||
b_scene(b_scene),
|
b_scene(PointerRNA_NULL),
|
||||||
b_v3d(PointerRNA_NULL),
|
b_v3d(PointerRNA_NULL),
|
||||||
b_rv3d(PointerRNA_NULL),
|
b_rv3d(PointerRNA_NULL),
|
||||||
|
width(0),
|
||||||
|
height(0),
|
||||||
|
preview_osl(preview_osl),
|
||||||
python_thread_state(NULL)
|
python_thread_state(NULL)
|
||||||
{
|
{
|
||||||
/* offline render */
|
/* offline render */
|
||||||
|
|
||||||
width = render_resolution_x(b_render);
|
|
||||||
height = render_resolution_y(b_render);
|
|
||||||
|
|
||||||
background = true;
|
background = true;
|
||||||
last_redraw_time = 0.0;
|
last_redraw_time = 0.0;
|
||||||
start_resize_time = 0.0;
|
start_resize_time = 0.0;
|
||||||
@@ -77,24 +77,24 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
|
|||||||
BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
|
BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
|
||||||
BL::UserPreferences& b_userpref,
|
BL::UserPreferences& b_userpref,
|
||||||
BL::BlendData& b_data,
|
BL::BlendData& b_data,
|
||||||
BL::Scene& b_scene,
|
|
||||||
BL::SpaceView3D& b_v3d,
|
BL::SpaceView3D& b_v3d,
|
||||||
BL::RegionView3D& b_rv3d,
|
BL::RegionView3D& b_rv3d,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
: b_engine(b_engine),
|
: session(NULL),
|
||||||
|
b_engine(b_engine),
|
||||||
b_userpref(b_userpref),
|
b_userpref(b_userpref),
|
||||||
b_data(b_data),
|
b_data(b_data),
|
||||||
b_render(b_scene.render()),
|
b_render(b_engine.render()),
|
||||||
b_depsgraph(PointerRNA_NULL),
|
b_depsgraph(PointerRNA_NULL),
|
||||||
b_scene(b_scene),
|
b_scene(PointerRNA_NULL),
|
||||||
b_v3d(b_v3d),
|
b_v3d(b_v3d),
|
||||||
b_rv3d(b_rv3d),
|
b_rv3d(b_rv3d),
|
||||||
width(width),
|
width(width),
|
||||||
height(height),
|
height(height),
|
||||||
|
preview_osl(false),
|
||||||
python_thread_state(NULL)
|
python_thread_state(NULL)
|
||||||
{
|
{
|
||||||
/* 3d view render */
|
/* 3d view render */
|
||||||
|
|
||||||
background = false;
|
background = false;
|
||||||
last_redraw_time = 0.0;
|
last_redraw_time = 0.0;
|
||||||
start_resize_time = 0.0;
|
start_resize_time = 0.0;
|
||||||
@@ -168,18 +168,40 @@ void BlenderSession::create_session()
|
|||||||
update_resumable_tile_manager(session_params.samples);
|
update_resumable_tile_manager(session_params.samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlenderSession::reset_session(BL::BlendData& b_data_, BL::Scene& b_scene_)
|
void BlenderSession::reset_session(BL::BlendData& b_data, BL::Depsgraph& b_depsgraph)
|
||||||
{
|
{
|
||||||
b_data = b_data_;
|
this->b_data = b_data;
|
||||||
b_render = b_engine.render();
|
this->b_depsgraph = b_depsgraph;
|
||||||
b_scene = b_scene_;
|
this->b_scene = b_depsgraph.scene_eval();
|
||||||
|
|
||||||
|
if (preview_osl) {
|
||||||
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
||||||
|
RNA_boolean_set(&cscene, "shading_system", preview_osl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b_v3d) {
|
||||||
|
this->b_render = b_scene.render();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->b_render = b_engine.render();
|
||||||
|
width = render_resolution_x(b_render);
|
||||||
|
height = render_resolution_y(b_render);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (session == NULL) {
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b_v3d) {
|
||||||
|
/* NOTE: We need to create session, but all the code from below
|
||||||
|
* will make viewport render to stuck on initialization.
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background);
|
SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background);
|
||||||
SceneParams scene_params = BlenderSync::get_scene_params(b_scene, background);
|
SceneParams scene_params = BlenderSync::get_scene_params(b_scene, background);
|
||||||
|
|
||||||
width = render_resolution_x(b_render);
|
|
||||||
height = render_resolution_y(b_render);
|
|
||||||
|
|
||||||
if(scene->params.modified(scene_params) ||
|
if(scene->params.modified(scene_params) ||
|
||||||
session->params.modified(session_params) ||
|
session->params.modified(session_params) ||
|
||||||
!scene_params.persistent_data)
|
!scene_params.persistent_data)
|
||||||
|
@@ -37,12 +37,11 @@ public:
|
|||||||
BlenderSession(BL::RenderEngine& b_engine,
|
BlenderSession(BL::RenderEngine& b_engine,
|
||||||
BL::UserPreferences& b_userpref,
|
BL::UserPreferences& b_userpref,
|
||||||
BL::BlendData& b_data,
|
BL::BlendData& b_data,
|
||||||
BL::Scene& b_scene);
|
bool preview_osl);
|
||||||
|
|
||||||
BlenderSession(BL::RenderEngine& b_engine,
|
BlenderSession(BL::RenderEngine& b_engine,
|
||||||
BL::UserPreferences& b_userpref,
|
BL::UserPreferences& b_userpref,
|
||||||
BL::BlendData& b_data,
|
BL::BlendData& b_data,
|
||||||
BL::Scene& b_scene,
|
|
||||||
BL::SpaceView3D& b_v3d,
|
BL::SpaceView3D& b_v3d,
|
||||||
BL::RegionView3D& b_rv3d,
|
BL::RegionView3D& b_rv3d,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
@@ -56,7 +55,7 @@ public:
|
|||||||
void free_session();
|
void free_session();
|
||||||
|
|
||||||
void reset_session(BL::BlendData& b_data,
|
void reset_session(BL::BlendData& b_data,
|
||||||
BL::Scene& b_scene);
|
BL::Depsgraph& b_depsgraph);
|
||||||
|
|
||||||
/* offline render */
|
/* offline render */
|
||||||
void render(BL::Depsgraph& b_depsgraph);
|
void render(BL::Depsgraph& b_depsgraph);
|
||||||
@@ -119,6 +118,7 @@ public:
|
|||||||
double last_status_time;
|
double last_status_time;
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
|
bool preview_osl;
|
||||||
double start_resize_time;
|
double start_resize_time;
|
||||||
|
|
||||||
void *python_thread_state;
|
void *python_thread_state;
|
||||||
|
@@ -811,6 +811,22 @@ static ShaderNode *add_node(Scene *scene,
|
|||||||
get_tex_mapping(&sky->tex_mapping, b_texture_mapping);
|
get_tex_mapping(&sky->tex_mapping, b_texture_mapping);
|
||||||
node = sky;
|
node = sky;
|
||||||
}
|
}
|
||||||
|
else if(b_node.is_a(&RNA_ShaderNodeTexIES)) {
|
||||||
|
BL::ShaderNodeTexIES b_ies_node(b_node);
|
||||||
|
IESLightNode *ies = new IESLightNode();
|
||||||
|
switch(b_ies_node.mode()) {
|
||||||
|
case BL::ShaderNodeTexIES::mode_EXTERNAL:
|
||||||
|
ies->filename = blender_absolute_path(b_data, b_ntree, b_ies_node.filepath());
|
||||||
|
break;
|
||||||
|
case BL::ShaderNodeTexIES::mode_INTERNAL:
|
||||||
|
ies->ies = get_text_datablock_content(b_ies_node.ies().ptr);
|
||||||
|
if(ies->ies.empty()) {
|
||||||
|
ies->ies = "\n";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
node = ies;
|
||||||
|
}
|
||||||
else if(b_node.is_a(&RNA_ShaderNodeNormalMap)) {
|
else if(b_node.is_a(&RNA_ShaderNodeNormalMap)) {
|
||||||
BL::ShaderNodeNormalMap b_normal_map_node(b_node);
|
BL::ShaderNodeNormalMap b_normal_map_node(b_node);
|
||||||
NormalMapNode *nmap = new NormalMapNode();
|
NormalMapNode *nmap = new NormalMapNode();
|
||||||
|
@@ -796,7 +796,8 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
|
|||||||
params.text_timeout = (double)get_float(cscene, "debug_text_timeout");
|
params.text_timeout = (double)get_float(cscene, "debug_text_timeout");
|
||||||
|
|
||||||
/* progressive refine */
|
/* progressive refine */
|
||||||
params.progressive_refine = get_boolean(cscene, "use_progressive_refine") &&
|
params.progressive_refine = (b_engine.is_preview() ||
|
||||||
|
get_boolean(cscene, "use_progressive_refine")) &&
|
||||||
!b_r.use_save_buffers();
|
!b_r.use_save_buffers();
|
||||||
|
|
||||||
if(params.progressive_refine) {
|
if(params.progressive_refine) {
|
||||||
|
@@ -53,6 +53,7 @@ static inline BL::Mesh object_to_mesh(BL::BlendData& data,
|
|||||||
bool subsurf_mod_show_render = false;
|
bool subsurf_mod_show_render = false;
|
||||||
bool subsurf_mod_show_viewport = false;
|
bool subsurf_mod_show_viewport = false;
|
||||||
|
|
||||||
|
/* TODO: make this work with copy-on-write, modifiers are already evaluated. */
|
||||||
if(subdivision_type != Mesh::SUBDIVISION_NONE) {
|
if(subdivision_type != Mesh::SUBDIVISION_NONE) {
|
||||||
BL::Modifier subsurf_mod = object.modifiers[object.modifiers.length()-1];
|
BL::Modifier subsurf_mod = object.modifiers[object.modifiers.length()-1];
|
||||||
|
|
||||||
@@ -467,6 +468,21 @@ static inline string blender_absolute_path(BL::BlendData& b_data,
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline string get_text_datablock_content(const PointerRNA& ptr)
|
||||||
|
{
|
||||||
|
if(ptr.data == NULL) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string content;
|
||||||
|
BL::Text::lines_iterator iter;
|
||||||
|
for(iter.begin(ptr); iter; ++iter) {
|
||||||
|
content += iter->body() + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
/* Texture Space */
|
/* Texture Space */
|
||||||
|
|
||||||
static inline void mesh_texture_space(BL::Mesh& b_mesh,
|
static inline void mesh_texture_space(BL::Mesh& b_mesh,
|
||||||
|
@@ -73,12 +73,13 @@ struct SocketType
|
|||||||
INTERNAL = (1 << 2) | (1 << 3),
|
INTERNAL = (1 << 2) | (1 << 3),
|
||||||
|
|
||||||
LINK_TEXTURE_GENERATED = (1 << 4),
|
LINK_TEXTURE_GENERATED = (1 << 4),
|
||||||
LINK_TEXTURE_UV = (1 << 5),
|
LINK_TEXTURE_NORMAL = (1 << 5),
|
||||||
LINK_INCOMING = (1 << 6),
|
LINK_TEXTURE_UV = (1 << 6),
|
||||||
LINK_NORMAL = (1 << 7),
|
LINK_INCOMING = (1 << 7),
|
||||||
LINK_POSITION = (1 << 8),
|
LINK_NORMAL = (1 << 8),
|
||||||
LINK_TANGENT = (1 << 9),
|
LINK_POSITION = (1 << 9),
|
||||||
DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9)
|
LINK_TANGENT = (1 << 10),
|
||||||
|
DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10)
|
||||||
};
|
};
|
||||||
|
|
||||||
ustring name;
|
ustring name;
|
||||||
|
@@ -178,6 +178,7 @@ set(SRC_SVM_HEADERS
|
|||||||
svm/svm_geometry.h
|
svm/svm_geometry.h
|
||||||
svm/svm_gradient.h
|
svm/svm_gradient.h
|
||||||
svm/svm_hsv.h
|
svm/svm_hsv.h
|
||||||
|
svm/svm_ies.h
|
||||||
svm/svm_image.h
|
svm/svm_image.h
|
||||||
svm/svm_invert.h
|
svm/svm_invert.h
|
||||||
svm/svm_light_path.h
|
svm/svm_light_path.h
|
||||||
|
@@ -61,8 +61,13 @@ ccl_device_inline void kernel_filter_construct_gramian(int x, int y,
|
|||||||
make_int2(x+dx, y+dy), buffer + q_offset,
|
make_int2(x+dx, y+dy), buffer + q_offset,
|
||||||
pass_stride, *rank, design_row, transform, stride);
|
pass_stride, *rank, design_row, transform, stride);
|
||||||
|
|
||||||
|
#ifdef __KERNEL_GPU__
|
||||||
math_trimatrix_add_gramian_strided(XtWX, (*rank)+1, design_row, weight, stride);
|
math_trimatrix_add_gramian_strided(XtWX, (*rank)+1, design_row, weight, stride);
|
||||||
math_vec3_add_strided(XtWY, (*rank)+1, design_row, weight * q_color, stride);
|
math_vec3_add_strided(XtWY, (*rank)+1, design_row, weight * q_color, stride);
|
||||||
|
#else
|
||||||
|
math_trimatrix_add_gramian(XtWX, (*rank)+1, design_row, weight);
|
||||||
|
math_vec3_add(XtWY, (*rank)+1, design_row, weight * q_color);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_inline void kernel_filter_finalize(int x, int y,
|
ccl_device_inline void kernel_filter_finalize(int x, int y,
|
||||||
|
@@ -44,7 +44,7 @@ typedef struct LightSample {
|
|||||||
*
|
*
|
||||||
* Note: light_p is modified when sample_coord is true.
|
* Note: light_p is modified when sample_coord is true.
|
||||||
*/
|
*/
|
||||||
ccl_device_inline float area_light_sample(float3 P,
|
ccl_device_inline float rect_light_sample(float3 P,
|
||||||
float3 *light_p,
|
float3 *light_p,
|
||||||
float3 axisu, float3 axisv,
|
float3 axisu, float3 axisv,
|
||||||
float randu, float randv,
|
float randu, float randv,
|
||||||
@@ -125,6 +125,60 @@ ccl_device_inline float area_light_sample(float3 P,
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ccl_device_inline float3 ellipse_sample(float3 ru, float3 rv, float randu, float randv)
|
||||||
|
{
|
||||||
|
to_unit_disk(&randu, &randv);
|
||||||
|
return ru*randu + rv*randv;
|
||||||
|
}
|
||||||
|
|
||||||
|
ccl_device float3 disk_light_sample(float3 v, float randu, float randv)
|
||||||
|
{
|
||||||
|
float3 ru, rv;
|
||||||
|
|
||||||
|
make_orthonormals(v, &ru, &rv);
|
||||||
|
|
||||||
|
return ellipse_sample(ru, rv, randu, randv);
|
||||||
|
}
|
||||||
|
|
||||||
|
ccl_device float3 distant_light_sample(float3 D, float radius, float randu, float randv)
|
||||||
|
{
|
||||||
|
return normalize(D + disk_light_sample(D, randu, randv)*radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
ccl_device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv)
|
||||||
|
{
|
||||||
|
return disk_light_sample(normalize(P - center), randu, randv)*radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
ccl_device float spot_light_attenuation(float3 dir, float spot_angle, float spot_smooth, LightSample *ls)
|
||||||
|
{
|
||||||
|
float3 I = ls->Ng;
|
||||||
|
|
||||||
|
float attenuation = dot(dir, I);
|
||||||
|
|
||||||
|
if(attenuation <= spot_angle) {
|
||||||
|
attenuation = 0.0f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
float t = attenuation - spot_angle;
|
||||||
|
|
||||||
|
if(t < spot_smooth && spot_smooth != 0.0f)
|
||||||
|
attenuation *= smoothstepf(t/spot_smooth);
|
||||||
|
}
|
||||||
|
|
||||||
|
return attenuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
ccl_device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t)
|
||||||
|
{
|
||||||
|
float cos_pi = dot(Ng, I);
|
||||||
|
|
||||||
|
if(cos_pi <= 0.0f)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
return t*t/cos_pi;
|
||||||
|
}
|
||||||
|
|
||||||
/* Background Light */
|
/* Background Light */
|
||||||
|
|
||||||
#ifdef __BACKGROUND_MIS__
|
#ifdef __BACKGROUND_MIS__
|
||||||
@@ -170,7 +224,7 @@ float3 background_map_sample(KernelGlobals *kg, float randu, float randv, float
|
|||||||
float2 cdf_last_v = kernel_tex_fetch(__light_background_marginal_cdf, res);
|
float2 cdf_last_v = kernel_tex_fetch(__light_background_marginal_cdf, res);
|
||||||
|
|
||||||
/* importance-sampled V direction */
|
/* importance-sampled V direction */
|
||||||
float dv = (randv - cdf_v.y) / (cdf_next_v.y - cdf_v.y);
|
float dv = inverse_lerp(cdf_v.y, cdf_next_v.y, randv);
|
||||||
float v = (index_v + dv) / res;
|
float v = (index_v + dv) / res;
|
||||||
|
|
||||||
/* this is basically std::lower_bound as used by pbrt */
|
/* this is basically std::lower_bound as used by pbrt */
|
||||||
@@ -196,7 +250,7 @@ float3 background_map_sample(KernelGlobals *kg, float randu, float randv, float
|
|||||||
float2 cdf_last_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + res);
|
float2 cdf_last_u = kernel_tex_fetch(__light_background_conditional_cdf, index_v * cdf_count + res);
|
||||||
|
|
||||||
/* importance-sampled U direction */
|
/* importance-sampled U direction */
|
||||||
float du = (randu - cdf_u.y) / (cdf_next_u.y - cdf_u.y);
|
float du = inverse_lerp(cdf_u.y, cdf_next_u.y, randu);
|
||||||
float u = (index_u + du) / res;
|
float u = (index_u + du) / res;
|
||||||
|
|
||||||
/* compute pdf */
|
/* compute pdf */
|
||||||
@@ -295,11 +349,19 @@ ccl_device_inline float background_portal_pdf(KernelGlobals *kg,
|
|||||||
const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, portal);
|
const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, portal);
|
||||||
float3 axisu = make_float3(klight->area.axisu[0], klight->area.axisu[1], klight->area.axisu[2]);
|
float3 axisu = make_float3(klight->area.axisu[0], klight->area.axisu[1], klight->area.axisu[2]);
|
||||||
float3 axisv = make_float3(klight->area.axisv[0], klight->area.axisv[1], klight->area.axisv[2]);
|
float3 axisv = make_float3(klight->area.axisv[0], klight->area.axisv[1], klight->area.axisv[2]);
|
||||||
|
bool is_round = (klight->area.invarea < 0.0f);
|
||||||
|
|
||||||
if(!ray_quad_intersect(P, direction, 1e-4f, FLT_MAX, lightpos, axisu, axisv, dir, NULL, NULL, NULL, NULL))
|
if(!ray_quad_intersect(P, direction, 1e-4f, FLT_MAX, lightpos, axisu, axisv, dir, NULL, NULL, NULL, NULL, is_round))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
portal_pdf += area_light_sample(P, &lightpos, axisu, axisv, 0.0f, 0.0f, false);
|
if(is_round) {
|
||||||
|
float t;
|
||||||
|
float3 D = normalize_len(lightpos - P, &t);
|
||||||
|
portal_pdf += fabsf(klight->area.invarea) * lamp_light_pdf(kg, dir, -D, t);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
portal_pdf += rect_light_sample(P, &lightpos, axisu, axisv, 0.0f, 0.0f, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ignore_portal >= 0) {
|
if(ignore_portal >= 0) {
|
||||||
@@ -349,15 +411,26 @@ ccl_device float3 background_portal_sample(KernelGlobals *kg,
|
|||||||
const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, portal);
|
const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, portal);
|
||||||
float3 axisu = make_float3(klight->area.axisu[0], klight->area.axisu[1], klight->area.axisu[2]);
|
float3 axisu = make_float3(klight->area.axisu[0], klight->area.axisu[1], klight->area.axisu[2]);
|
||||||
float3 axisv = make_float3(klight->area.axisv[0], klight->area.axisv[1], klight->area.axisv[2]);
|
float3 axisv = make_float3(klight->area.axisv[0], klight->area.axisv[1], klight->area.axisv[2]);
|
||||||
|
bool is_round = (klight->area.invarea < 0.0f);
|
||||||
|
|
||||||
*pdf = area_light_sample(P, &lightpos,
|
float3 D;
|
||||||
axisu, axisv,
|
if(is_round) {
|
||||||
randu, randv,
|
lightpos += ellipse_sample(axisu*0.5f, axisv*0.5f, randu, randv);
|
||||||
true);
|
float t;
|
||||||
|
D = normalize_len(lightpos - P, &t);
|
||||||
|
*pdf = fabsf(klight->area.invarea) * lamp_light_pdf(kg, dir, -D, t);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*pdf = rect_light_sample(P, &lightpos,
|
||||||
|
axisu, axisv,
|
||||||
|
randu, randv,
|
||||||
|
true);
|
||||||
|
D = normalize(lightpos - P);
|
||||||
|
}
|
||||||
|
|
||||||
*pdf /= num_possible;
|
*pdf /= num_possible;
|
||||||
*sampled_portal = p;
|
*sampled_portal = p;
|
||||||
return normalize(lightpos - P);
|
return D;
|
||||||
}
|
}
|
||||||
|
|
||||||
portal--;
|
portal--;
|
||||||
@@ -458,55 +531,6 @@ ccl_device float background_light_pdf(KernelGlobals *kg, float3 P, float3 direct
|
|||||||
|
|
||||||
/* Regular Light */
|
/* Regular Light */
|
||||||
|
|
||||||
ccl_device float3 disk_light_sample(float3 v, float randu, float randv)
|
|
||||||
{
|
|
||||||
float3 ru, rv;
|
|
||||||
|
|
||||||
make_orthonormals(v, &ru, &rv);
|
|
||||||
to_unit_disk(&randu, &randv);
|
|
||||||
|
|
||||||
return ru*randu + rv*randv;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccl_device float3 distant_light_sample(float3 D, float radius, float randu, float randv)
|
|
||||||
{
|
|
||||||
return normalize(D + disk_light_sample(D, randu, randv)*radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
ccl_device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv)
|
|
||||||
{
|
|
||||||
return disk_light_sample(normalize(P - center), randu, randv)*radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccl_device float spot_light_attenuation(float3 dir, float spot_angle, float spot_smooth, LightSample *ls)
|
|
||||||
{
|
|
||||||
float3 I = ls->Ng;
|
|
||||||
|
|
||||||
float attenuation = dot(dir, I);
|
|
||||||
|
|
||||||
if(attenuation <= spot_angle) {
|
|
||||||
attenuation = 0.0f;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
float t = attenuation - spot_angle;
|
|
||||||
|
|
||||||
if(t < spot_smooth && spot_smooth != 0.0f)
|
|
||||||
attenuation *= smoothstepf(t/spot_smooth);
|
|
||||||
}
|
|
||||||
|
|
||||||
return attenuation;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccl_device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t)
|
|
||||||
{
|
|
||||||
float cos_pi = dot(Ng, I);
|
|
||||||
|
|
||||||
if(cos_pi <= 0.0f)
|
|
||||||
return 0.0f;
|
|
||||||
|
|
||||||
return t*t/cos_pi;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccl_device_inline bool lamp_light_sample(KernelGlobals *kg,
|
ccl_device_inline bool lamp_light_sample(KernelGlobals *kg,
|
||||||
int lamp,
|
int lamp,
|
||||||
float randu, float randv,
|
float randu, float randv,
|
||||||
@@ -601,26 +625,39 @@ ccl_device_inline bool lamp_light_sample(KernelGlobals *kg,
|
|||||||
float3 D = make_float3(klight->area.dir[0],
|
float3 D = make_float3(klight->area.dir[0],
|
||||||
klight->area.dir[1],
|
klight->area.dir[1],
|
||||||
klight->area.dir[2]);
|
klight->area.dir[2]);
|
||||||
|
float invarea = fabsf(klight->area.invarea);
|
||||||
|
bool is_round = (klight->area.invarea < 0.0f);
|
||||||
|
|
||||||
if(dot(ls->P - P, D) > 0.0f) {
|
if(dot(ls->P - P, D) > 0.0f) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 inplane = ls->P;
|
float3 inplane;
|
||||||
ls->pdf = area_light_sample(P, &ls->P,
|
|
||||||
axisu, axisv,
|
if(is_round) {
|
||||||
randu, randv,
|
inplane = ellipse_sample(axisu*0.5f, axisv*0.5f, randu, randv);
|
||||||
true);
|
ls->P += inplane;
|
||||||
|
ls->pdf = invarea;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inplane = ls->P;
|
||||||
|
ls->pdf = rect_light_sample(P, &ls->P,
|
||||||
|
axisu, axisv,
|
||||||
|
randu, randv,
|
||||||
|
true);
|
||||||
|
inplane = ls->P - inplane;
|
||||||
|
}
|
||||||
|
|
||||||
inplane = ls->P - inplane;
|
|
||||||
ls->u = dot(inplane, axisu) * (1.0f / dot(axisu, axisu)) + 0.5f;
|
ls->u = dot(inplane, axisu) * (1.0f / dot(axisu, axisu)) + 0.5f;
|
||||||
ls->v = dot(inplane, axisv) * (1.0f / dot(axisv, axisv)) + 0.5f;
|
ls->v = dot(inplane, axisv) * (1.0f / dot(axisv, axisv)) + 0.5f;
|
||||||
|
|
||||||
ls->Ng = D;
|
ls->Ng = D;
|
||||||
ls->D = normalize_len(ls->P - P, &ls->t);
|
ls->D = normalize_len(ls->P - P, &ls->t);
|
||||||
|
|
||||||
float invarea = klight->area.invarea;
|
|
||||||
ls->eval_fac = 0.25f*invarea;
|
ls->eval_fac = 0.25f*invarea;
|
||||||
|
if(is_round) {
|
||||||
|
ls->pdf *= lamp_light_pdf(kg, D, -ls->D, ls->t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,7 +768,8 @@ ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D,
|
|||||||
}
|
}
|
||||||
else if(type == LIGHT_AREA) {
|
else if(type == LIGHT_AREA) {
|
||||||
/* area light */
|
/* area light */
|
||||||
float invarea = klight->area.invarea;
|
float invarea = fabsf(klight->area.invarea);
|
||||||
|
bool is_round = (klight->area.invarea < 0.0f);
|
||||||
if(invarea == 0.0f)
|
if(invarea == 0.0f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -754,14 +792,20 @@ ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D,
|
|||||||
if(!ray_quad_intersect(P, D, 0.0f, t, light_P,
|
if(!ray_quad_intersect(P, D, 0.0f, t, light_P,
|
||||||
axisu, axisv, Ng,
|
axisu, axisv, Ng,
|
||||||
&ls->P, &ls->t,
|
&ls->P, &ls->t,
|
||||||
&ls->u, &ls->v))
|
&ls->u, &ls->v,
|
||||||
|
is_round))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ls->D = D;
|
ls->D = D;
|
||||||
ls->Ng = Ng;
|
ls->Ng = Ng;
|
||||||
ls->pdf = area_light_sample(P, &light_P, axisu, axisv, 0, 0, false);
|
if(is_round) {
|
||||||
|
ls->pdf = invarea * lamp_light_pdf(kg, Ng, -D, ls->t);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ls->pdf = rect_light_sample(P, &light_P, axisu, axisv, 0, 0, false);
|
||||||
|
}
|
||||||
ls->eval_fac = 0.25f*invarea;
|
ls->eval_fac = 0.25f*invarea;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -81,5 +81,8 @@ KERNEL_TEX(uint, __sobol_directions)
|
|||||||
/* image textures */
|
/* image textures */
|
||||||
KERNEL_TEX(TextureInfo, __texture_info)
|
KERNEL_TEX(TextureInfo, __texture_info)
|
||||||
|
|
||||||
|
/* ies lights */
|
||||||
|
KERNEL_TEX(float, __ies)
|
||||||
|
|
||||||
#undef KERNEL_TEX
|
#undef KERNEL_TEX
|
||||||
|
|
||||||
|
@@ -349,7 +349,7 @@ template<typename T> struct TextureInterpolator {
|
|||||||
* Only happens for AVX2 kernel and global __KERNEL_SSE__ vectorization
|
* Only happens for AVX2 kernel and global __KERNEL_SSE__ vectorization
|
||||||
* enabled.
|
* enabled.
|
||||||
*/
|
*/
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
static ccl_always_inline
|
static ccl_always_inline
|
||||||
#else
|
#else
|
||||||
static ccl_never_inline
|
static ccl_never_inline
|
||||||
|
@@ -956,9 +956,15 @@ bool OSLRenderServices::texture(ustring filename,
|
|||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(filename[1] == 'l') {
|
||||||
|
/* IES light. */
|
||||||
|
int slot = atoi(filename.c_str() + 2);
|
||||||
|
result[0] = kernel_ies_interp(kg, slot, s, t);
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
/* Packed texture. */
|
/* Packed texture. */
|
||||||
int slot = atoi(filename.c_str() + 1);
|
int slot = atoi(filename.c_str() + 2);
|
||||||
float4 rgba = kernel_tex_image_interp(kg, slot, s, 1.0f - t);
|
float4 rgba = kernel_tex_image_interp(kg, slot, s, 1.0f - t);
|
||||||
|
|
||||||
result[0] = rgba[0];
|
result[0] = rgba[0];
|
||||||
|
@@ -39,6 +39,7 @@ set(SRC_OSL
|
|||||||
node_principled_volume.osl
|
node_principled_volume.osl
|
||||||
node_holdout.osl
|
node_holdout.osl
|
||||||
node_hsv.osl
|
node_hsv.osl
|
||||||
|
node_ies_light.osl
|
||||||
node_image_texture.osl
|
node_image_texture.osl
|
||||||
node_invert.osl
|
node_invert.osl
|
||||||
node_layer_weight.osl
|
node_layer_weight.osl
|
||||||
|
42
intern/cycles/kernel/shaders/node_ies_light.osl
Normal file
42
intern/cycles/kernel/shaders/node_ies_light.osl
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2015 Blender Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stdosl.h"
|
||||||
|
#include "node_texture.h"
|
||||||
|
|
||||||
|
/* IES Light */
|
||||||
|
|
||||||
|
shader node_ies_light(
|
||||||
|
int use_mapping = 0,
|
||||||
|
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
||||||
|
int slot = 0,
|
||||||
|
float Strength = 1.0,
|
||||||
|
point Vector = I,
|
||||||
|
output float Fac = 0.0)
|
||||||
|
{
|
||||||
|
point p = Vector;
|
||||||
|
|
||||||
|
if (use_mapping) {
|
||||||
|
p = transform(mapping, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = normalize(p);
|
||||||
|
|
||||||
|
float v_angle = acos(-p[2]);
|
||||||
|
float h_angle = atan2(p[0], p[1]) + M_PI;
|
||||||
|
|
||||||
|
Fac = Strength * texture(format("@l%d", slot), h_angle, v_angle);
|
||||||
|
}
|
@@ -95,6 +95,8 @@ shader node_math(
|
|||||||
Value = safe_modulo(Value1, Value2);
|
Value = safe_modulo(Value1, Value2);
|
||||||
else if (type == "absolute")
|
else if (type == "absolute")
|
||||||
Value = fabs(Value1);
|
Value = fabs(Value1);
|
||||||
|
else if (type == "arctan2")
|
||||||
|
Value = atan2(Value1, Value2);
|
||||||
|
|
||||||
if (use_clamp)
|
if (use_clamp)
|
||||||
Value = clamp(Value, 0.0, 1.0);
|
Value = clamp(Value, 0.0, 1.0);
|
||||||
|
@@ -157,6 +157,7 @@ CCL_NAMESPACE_END
|
|||||||
#include "kernel/svm/svm_camera.h"
|
#include "kernel/svm/svm_camera.h"
|
||||||
#include "kernel/svm/svm_geometry.h"
|
#include "kernel/svm/svm_geometry.h"
|
||||||
#include "kernel/svm/svm_hsv.h"
|
#include "kernel/svm/svm_hsv.h"
|
||||||
|
#include "kernel/svm/svm_ies.h"
|
||||||
#include "kernel/svm/svm_image.h"
|
#include "kernel/svm/svm_image.h"
|
||||||
#include "kernel/svm/svm_gamma.h"
|
#include "kernel/svm/svm_gamma.h"
|
||||||
#include "kernel/svm/svm_brightness.h"
|
#include "kernel/svm/svm_brightness.h"
|
||||||
@@ -421,6 +422,9 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a
|
|||||||
case NODE_LIGHT_FALLOFF:
|
case NODE_LIGHT_FALLOFF:
|
||||||
svm_node_light_falloff(sd, stack, node);
|
svm_node_light_falloff(sd, stack, node);
|
||||||
break;
|
break;
|
||||||
|
case NODE_IES:
|
||||||
|
svm_node_ies(kg, sd, stack, node, &offset);
|
||||||
|
break;
|
||||||
# endif /* __EXTRA_NODES__ */
|
# endif /* __EXTRA_NODES__ */
|
||||||
#endif /* NODES_GROUP(NODE_GROUP_LEVEL_2) */
|
#endif /* NODES_GROUP(NODE_GROUP_LEVEL_2) */
|
||||||
|
|
||||||
|
110
intern/cycles/kernel/svm/svm_ies.h
Normal file
110
intern/cycles/kernel/svm/svm_ies.h
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2013 Blender Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/* IES Light */
|
||||||
|
|
||||||
|
ccl_device_inline float interpolate_ies_vertical(KernelGlobals *kg, int ofs, int v, int v_num, float v_frac, int h)
|
||||||
|
{
|
||||||
|
/* Since lookups are performed in spherical coordinates, clamping the coordinates at the low end of v
|
||||||
|
* (corresponding to the north pole) would result in artifacts.
|
||||||
|
* The proper way of dealing with this would be to lookup the corresponding value on the other side of the pole,
|
||||||
|
* but since the horizontal coordinates might be nonuniform, this would require yet another interpolation.
|
||||||
|
* Therefore, the assumtion is made that the light is going to be symmetrical, which means that we can just take
|
||||||
|
* the corresponding value at the current horizontal coordinate. */
|
||||||
|
|
||||||
|
#define IES_LOOKUP(v) kernel_tex_fetch(__ies, ofs+h*v_num+(v))
|
||||||
|
/* If v is zero, assume symmetry and read at v=1 instead of v=-1. */
|
||||||
|
float a = IES_LOOKUP((v == 0)? 1 : v-1);
|
||||||
|
float b = IES_LOOKUP(v);
|
||||||
|
float c = IES_LOOKUP(v+1);
|
||||||
|
float d = IES_LOOKUP(min(v+2, v_num-1));
|
||||||
|
#undef IES_LOOKUP
|
||||||
|
|
||||||
|
return cubic_interp(a, b, c, d, v_frac);
|
||||||
|
}
|
||||||
|
|
||||||
|
ccl_device_inline float kernel_ies_interp(KernelGlobals *kg, int slot, float h_angle, float v_angle)
|
||||||
|
{
|
||||||
|
/* Find offset of the IES data in the table. */
|
||||||
|
int ofs = __float_as_int(kernel_tex_fetch(__ies, slot));
|
||||||
|
if(ofs == -1) {
|
||||||
|
return 100.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
int h_num = __float_as_int(kernel_tex_fetch(__ies, ofs++));
|
||||||
|
int v_num = __float_as_int(kernel_tex_fetch(__ies, ofs++));
|
||||||
|
|
||||||
|
#define IES_LOOKUP_ANGLE_H(h) kernel_tex_fetch(__ies, ofs+(h))
|
||||||
|
#define IES_LOOKUP_ANGLE_V(v) kernel_tex_fetch(__ies, ofs+h_num+(v))
|
||||||
|
|
||||||
|
/* Check whether the angle is within the bounds of the IES texture. */
|
||||||
|
if(v_angle >= IES_LOOKUP_ANGLE_V(v_num-1)) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
kernel_assert(v_angle >= IES_LOOKUP_ANGLE_V(0));
|
||||||
|
kernel_assert(h_angle >= IES_LOOKUP_ANGLE_H(0));
|
||||||
|
kernel_assert(h_angle <= IES_LOOKUP_ANGLE_H(h_num-1));
|
||||||
|
|
||||||
|
/* Lookup the angles to find the table position. */
|
||||||
|
int h_i, v_i;
|
||||||
|
/* TODO(lukas): Consider using bisection. Probably not worth it for the vast majority of IES files. */
|
||||||
|
for(h_i = 0; IES_LOOKUP_ANGLE_H(h_i+1) < h_angle; h_i++);
|
||||||
|
for(v_i = 0; IES_LOOKUP_ANGLE_V(v_i+1) < v_angle; v_i++);
|
||||||
|
|
||||||
|
float h_frac = inverse_lerp(IES_LOOKUP_ANGLE_H(h_i), IES_LOOKUP_ANGLE_H(h_i+1), h_angle);
|
||||||
|
float v_frac = inverse_lerp(IES_LOOKUP_ANGLE_V(v_i), IES_LOOKUP_ANGLE_V(v_i+1), v_angle);
|
||||||
|
|
||||||
|
#undef IES_LOOKUP_ANGLE_H
|
||||||
|
#undef IES_LOOKUP_ANGLE_V
|
||||||
|
|
||||||
|
/* Skip forward to the actual intensity data. */
|
||||||
|
ofs += h_num+v_num;
|
||||||
|
|
||||||
|
/* Perform cubic interpolation along the horizontal coordinate to get the intensity value.
|
||||||
|
* If h_i is zero, just wrap around since the horizontal angles always go over the full circle.
|
||||||
|
* However, the last entry (360°) equals the first one, so we need to wrap around to the one before that. */
|
||||||
|
float a = interpolate_ies_vertical(kg, ofs, v_i, v_num, v_frac, (h_i == 0)? h_num-2 : h_i-1);
|
||||||
|
float b = interpolate_ies_vertical(kg, ofs, v_i, v_num, v_frac, h_i);
|
||||||
|
float c = interpolate_ies_vertical(kg, ofs, v_i, v_num, v_frac, h_i+1);
|
||||||
|
/* Same logic here, wrap around to the second element if necessary. */
|
||||||
|
float d = interpolate_ies_vertical(kg, ofs, v_i, v_num, v_frac, (h_i+2 == h_num)? 1 : h_i+2);
|
||||||
|
|
||||||
|
/* Cubic interpolation can result in negative values, so get rid of them. */
|
||||||
|
return max(cubic_interp(a, b, c, d, h_frac), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
ccl_device void svm_node_ies(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
|
||||||
|
{
|
||||||
|
uint vector_offset, strength_offset, fac_offset, dummy, slot = node.z;
|
||||||
|
decode_node_uchar4(node.y, &strength_offset, &vector_offset, &fac_offset, &dummy);
|
||||||
|
|
||||||
|
float3 vector = stack_load_float3(stack, vector_offset);
|
||||||
|
float strength = stack_load_float_default(stack, strength_offset, node.w);
|
||||||
|
|
||||||
|
vector = normalize(vector);
|
||||||
|
float v_angle = safe_acosf(-vector.z);
|
||||||
|
float h_angle = atan2f(vector.x, vector.y) + M_PI_F;
|
||||||
|
|
||||||
|
float fac = strength * kernel_ies_interp(kg, slot, h_angle, v_angle);
|
||||||
|
|
||||||
|
if(stack_valid(fac_offset)) {
|
||||||
|
stack_store_float(stack, fac_offset, fac);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CCL_NAMESPACE_END
|
@@ -92,6 +92,8 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
|
|||||||
Fac = safe_modulo(Fac1, Fac2);
|
Fac = safe_modulo(Fac1, Fac2);
|
||||||
else if(type == NODE_MATH_ABSOLUTE)
|
else if(type == NODE_MATH_ABSOLUTE)
|
||||||
Fac = fabsf(Fac1);
|
Fac = fabsf(Fac1);
|
||||||
|
else if(type == NODE_MATH_ARCTAN2)
|
||||||
|
Fac = atan2f(Fac1, Fac2);
|
||||||
else if(type == NODE_MATH_CLAMP)
|
else if(type == NODE_MATH_CLAMP)
|
||||||
Fac = saturate(Fac1);
|
Fac = saturate(Fac1);
|
||||||
else
|
else
|
||||||
|
@@ -136,6 +136,7 @@ typedef enum ShaderNodeType {
|
|||||||
NODE_DISPLACEMENT,
|
NODE_DISPLACEMENT,
|
||||||
NODE_VECTOR_DISPLACEMENT,
|
NODE_VECTOR_DISPLACEMENT,
|
||||||
NODE_PRINCIPLED_VOLUME,
|
NODE_PRINCIPLED_VOLUME,
|
||||||
|
NODE_IES,
|
||||||
} ShaderNodeType;
|
} ShaderNodeType;
|
||||||
|
|
||||||
typedef enum NodeAttributeType {
|
typedef enum NodeAttributeType {
|
||||||
@@ -259,6 +260,7 @@ typedef enum NodeMath {
|
|||||||
NODE_MATH_GREATER_THAN,
|
NODE_MATH_GREATER_THAN,
|
||||||
NODE_MATH_MODULO,
|
NODE_MATH_MODULO,
|
||||||
NODE_MATH_ABSOLUTE,
|
NODE_MATH_ABSOLUTE,
|
||||||
|
NODE_MATH_ARCTAN2,
|
||||||
NODE_MATH_CLAMP /* used for the clamp UI option */
|
NODE_MATH_CLAMP /* used for the clamp UI option */
|
||||||
} NodeMath;
|
} NodeMath;
|
||||||
|
|
||||||
|
@@ -774,6 +774,12 @@ void ShaderGraph::default_inputs(bool do_osl)
|
|||||||
|
|
||||||
connect(texco->output("Generated"), input);
|
connect(texco->output("Generated"), input);
|
||||||
}
|
}
|
||||||
|
if(input->flags() & SocketType::LINK_TEXTURE_NORMAL) {
|
||||||
|
if(!texco)
|
||||||
|
texco = new TextureCoordinateNode();
|
||||||
|
|
||||||
|
connect(texco->output("Normal"), input);
|
||||||
|
}
|
||||||
else if(input->flags() & SocketType::LINK_TEXTURE_UV) {
|
else if(input->flags() & SocketType::LINK_TEXTURE_UV) {
|
||||||
if(!texco)
|
if(!texco)
|
||||||
texco = new TextureCoordinateNode();
|
texco = new TextureCoordinateNode();
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
#include "render/shader.h"
|
#include "render/shader.h"
|
||||||
|
|
||||||
#include "util/util_foreach.h"
|
#include "util/util_foreach.h"
|
||||||
|
#include "util/util_hash.h"
|
||||||
|
#include "util/util_path.h"
|
||||||
#include "util/util_progress.h"
|
#include "util/util_progress.h"
|
||||||
#include "util/util_logging.h"
|
#include "util/util_logging.h"
|
||||||
|
|
||||||
@@ -117,6 +119,7 @@ NODE_DEFINE(Light)
|
|||||||
SOCKET_FLOAT(sizeu, "Size U", 1.0f);
|
SOCKET_FLOAT(sizeu, "Size U", 1.0f);
|
||||||
SOCKET_VECTOR(axisv, "Axis V", make_float3(0.0f, 0.0f, 0.0f));
|
SOCKET_VECTOR(axisv, "Axis V", make_float3(0.0f, 0.0f, 0.0f));
|
||||||
SOCKET_FLOAT(sizev, "Size V", 1.0f);
|
SOCKET_FLOAT(sizev, "Size V", 1.0f);
|
||||||
|
SOCKET_BOOLEAN(round, "Round", false);
|
||||||
|
|
||||||
SOCKET_INT(map_resolution, "Map Resolution", 512);
|
SOCKET_INT(map_resolution, "Map Resolution", 512);
|
||||||
|
|
||||||
@@ -175,6 +178,9 @@ LightManager::LightManager()
|
|||||||
|
|
||||||
LightManager::~LightManager()
|
LightManager::~LightManager()
|
||||||
{
|
{
|
||||||
|
foreach(IESSlot *slot, ies_slots) {
|
||||||
|
delete slot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LightManager::has_background_light(Scene *scene)
|
bool LightManager::has_background_light(Scene *scene)
|
||||||
@@ -730,12 +736,15 @@ void LightManager::device_update_points(Device *,
|
|||||||
float3 axisu = light->axisu*(light->sizeu*light->size);
|
float3 axisu = light->axisu*(light->sizeu*light->size);
|
||||||
float3 axisv = light->axisv*(light->sizev*light->size);
|
float3 axisv = light->axisv*(light->sizev*light->size);
|
||||||
float area = len(axisu)*len(axisv);
|
float area = len(axisu)*len(axisv);
|
||||||
float invarea = (area > 0.0f)? 1.0f/area: 1.0f;
|
if(light->round) {
|
||||||
|
area *= -M_PI_4_F;
|
||||||
|
}
|
||||||
|
float invarea = (area != 0.0f)? 1.0f/area: 1.0f;
|
||||||
float3 dir = light->dir;
|
float3 dir = light->dir;
|
||||||
|
|
||||||
dir = safe_normalize(dir);
|
dir = safe_normalize(dir);
|
||||||
|
|
||||||
if(light->use_mis && area > 0.0f)
|
if(light->use_mis && area != 0.0f)
|
||||||
shader_id |= SHADER_USE_MIS;
|
shader_id |= SHADER_USE_MIS;
|
||||||
|
|
||||||
klights[light_index].co[0] = co.x;
|
klights[light_index].co[0] = co.x;
|
||||||
@@ -803,7 +812,10 @@ void LightManager::device_update_points(Device *,
|
|||||||
float3 axisu = light->axisu*(light->sizeu*light->size);
|
float3 axisu = light->axisu*(light->sizeu*light->size);
|
||||||
float3 axisv = light->axisv*(light->sizev*light->size);
|
float3 axisv = light->axisv*(light->sizev*light->size);
|
||||||
float area = len(axisu)*len(axisv);
|
float area = len(axisu)*len(axisv);
|
||||||
float invarea = (area > 0.0f)? 1.0f/area: 1.0f;
|
if(light->round) {
|
||||||
|
area *= -M_PI_4_F;
|
||||||
|
}
|
||||||
|
float invarea = (area != 0.0f)? 1.0f/area: 1.0f;
|
||||||
float3 dir = light->dir;
|
float3 dir = light->dir;
|
||||||
|
|
||||||
dir = safe_normalize(dir);
|
dir = safe_normalize(dir);
|
||||||
@@ -858,6 +870,9 @@ void LightManager::device_update(Device *device, DeviceScene *dscene, Scene *sce
|
|||||||
device_update_background(device, dscene, scene, progress);
|
device_update_background(device, dscene, scene, progress);
|
||||||
if(progress.get_cancel()) return;
|
if(progress.get_cancel()) return;
|
||||||
|
|
||||||
|
device_update_ies(dscene);
|
||||||
|
if(progress.get_cancel()) return;
|
||||||
|
|
||||||
if(use_light_visibility != scene->film->use_light_visibility) {
|
if(use_light_visibility != scene->film->use_light_visibility) {
|
||||||
scene->film->use_light_visibility = use_light_visibility;
|
scene->film->use_light_visibility = use_light_visibility;
|
||||||
scene->film->tag_update(scene);
|
scene->film->tag_update(scene);
|
||||||
@@ -872,6 +887,7 @@ void LightManager::device_free(Device *, DeviceScene *dscene)
|
|||||||
dscene->lights.free();
|
dscene->lights.free();
|
||||||
dscene->light_background_marginal_cdf.free();
|
dscene->light_background_marginal_cdf.free();
|
||||||
dscene->light_background_conditional_cdf.free();
|
dscene->light_background_conditional_cdf.free();
|
||||||
|
dscene->ies_lights.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightManager::tag_update(Scene * /*scene*/)
|
void LightManager::tag_update(Scene * /*scene*/)
|
||||||
@@ -879,5 +895,121 @@ void LightManager::tag_update(Scene * /*scene*/)
|
|||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LightManager::add_ies_from_file(ustring filename)
|
||||||
|
{
|
||||||
|
string content;
|
||||||
|
|
||||||
|
/* If the file can't be opened, call with an empty line */
|
||||||
|
if(filename.empty() || !path_read_text(filename.c_str(), content)) {
|
||||||
|
content = "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return add_ies(ustring(content));
|
||||||
|
}
|
||||||
|
|
||||||
|
int LightManager::add_ies(ustring content)
|
||||||
|
{
|
||||||
|
uint hash = hash_string(content.c_str());
|
||||||
|
|
||||||
|
thread_scoped_lock ies_lock(ies_mutex);
|
||||||
|
|
||||||
|
/* Check whether this IES already has a slot. */
|
||||||
|
size_t slot;
|
||||||
|
for(slot = 0; slot < ies_slots.size(); slot++) {
|
||||||
|
if(ies_slots[slot]->hash == hash) {
|
||||||
|
ies_slots[slot]->users++;
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to find an empty slot for the new IES. */
|
||||||
|
for(slot = 0; slot < ies_slots.size(); slot++) {
|
||||||
|
if(ies_slots[slot]->users == 0 && ies_slots[slot]->hash == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If there's no free slot, add one. */
|
||||||
|
if(slot == ies_slots.size()) {
|
||||||
|
ies_slots.push_back(new IESSlot());
|
||||||
|
}
|
||||||
|
|
||||||
|
ies_slots[slot]->ies.load(content);
|
||||||
|
ies_slots[slot]->users = 1;
|
||||||
|
ies_slots[slot]->hash = hash;
|
||||||
|
|
||||||
|
need_update = true;
|
||||||
|
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightManager::remove_ies(int slot)
|
||||||
|
{
|
||||||
|
thread_scoped_lock ies_lock(ies_mutex);
|
||||||
|
|
||||||
|
if(slot < 0 || slot >= ies_slots.size()) {
|
||||||
|
assert(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(ies_slots[slot]->users > 0);
|
||||||
|
ies_slots[slot]->users--;
|
||||||
|
|
||||||
|
/* If the slot has no more users, update the device to remove it. */
|
||||||
|
need_update |= (ies_slots[slot]->users == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightManager::device_update_ies(DeviceScene *dscene)
|
||||||
|
{
|
||||||
|
/* Clear empty slots. */
|
||||||
|
foreach(IESSlot *slot, ies_slots) {
|
||||||
|
if(slot->users == 0) {
|
||||||
|
slot->hash = 0;
|
||||||
|
slot->ies.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Shrink the slot table by removing empty slots at the end. */
|
||||||
|
int slot_end;
|
||||||
|
for(slot_end = ies_slots.size(); slot_end; slot_end--) {
|
||||||
|
if(ies_slots[slot_end-1]->users > 0) {
|
||||||
|
/* If the preceding slot has users, we found the new end of the table. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* The slot will be past the new end of the table, so free it. */
|
||||||
|
delete ies_slots[slot_end-1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ies_slots.resize(slot_end);
|
||||||
|
|
||||||
|
if(ies_slots.size() > 0) {
|
||||||
|
int packed_size = 0;
|
||||||
|
foreach(IESSlot *slot, ies_slots) {
|
||||||
|
packed_size += slot->ies.packed_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ies_lights starts with an offset table that contains the offset of every slot,
|
||||||
|
* or -1 if the slot is invalid.
|
||||||
|
* Following that table, the packed valid IES lights are stored. */
|
||||||
|
float *data = dscene->ies_lights.alloc(ies_slots.size() + packed_size);
|
||||||
|
|
||||||
|
int offset = ies_slots.size();
|
||||||
|
for(int i = 0; i < ies_slots.size(); i++) {
|
||||||
|
int size = ies_slots[i]->ies.packed_size();
|
||||||
|
if(size > 0) {
|
||||||
|
data[i] = __int_as_float(offset);
|
||||||
|
ies_slots[i]->ies.pack(data + offset);
|
||||||
|
offset += size;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data[i] = __int_as_float(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dscene->ies_lights.copy_to_device();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CCL_NAMESPACE_END
|
CCL_NAMESPACE_END
|
||||||
|
|
||||||
|
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "graph/node.h"
|
#include "graph/node.h"
|
||||||
|
|
||||||
|
#include "util/util_ies.h"
|
||||||
|
#include "util/util_thread.h"
|
||||||
#include "util/util_types.h"
|
#include "util/util_types.h"
|
||||||
#include "util/util_vector.h"
|
#include "util/util_vector.h"
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ public:
|
|||||||
float sizeu;
|
float sizeu;
|
||||||
float3 axisv;
|
float3 axisv;
|
||||||
float sizev;
|
float sizev;
|
||||||
|
bool round;
|
||||||
|
|
||||||
Transform tfm;
|
Transform tfm;
|
||||||
|
|
||||||
@@ -86,6 +89,11 @@ public:
|
|||||||
LightManager();
|
LightManager();
|
||||||
~LightManager();
|
~LightManager();
|
||||||
|
|
||||||
|
/* IES texture management */
|
||||||
|
int add_ies(ustring ies);
|
||||||
|
int add_ies_from_file(ustring filename);
|
||||||
|
void remove_ies(int slot);
|
||||||
|
|
||||||
void device_update(Device *device,
|
void device_update(Device *device,
|
||||||
DeviceScene *dscene,
|
DeviceScene *dscene,
|
||||||
Scene *scene,
|
Scene *scene,
|
||||||
@@ -115,9 +123,19 @@ protected:
|
|||||||
DeviceScene *dscene,
|
DeviceScene *dscene,
|
||||||
Scene *scene,
|
Scene *scene,
|
||||||
Progress& progress);
|
Progress& progress);
|
||||||
|
void device_update_ies(DeviceScene *dscene);
|
||||||
|
|
||||||
/* Check whether light manager can use the object as a light-emissive. */
|
/* Check whether light manager can use the object as a light-emissive. */
|
||||||
bool object_usable_as_light(Object *object);
|
bool object_usable_as_light(Object *object);
|
||||||
|
|
||||||
|
struct IESSlot {
|
||||||
|
IESFile ies;
|
||||||
|
uint hash;
|
||||||
|
int users;
|
||||||
|
};
|
||||||
|
|
||||||
|
vector<IESSlot*> ies_slots;
|
||||||
|
thread_mutex ies_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
CCL_NAMESPACE_END
|
CCL_NAMESPACE_END
|
||||||
|
@@ -1307,7 +1307,7 @@ void MeshManager::update_svm_attributes(Device *, DeviceScene *dscene, Scene *sc
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* create attribute map */
|
/* create attribute map */
|
||||||
uint4 *attr_map = dscene->attributes_map.alloc(attr_map_size*scene->meshes.size());
|
uint4 *attr_map = dscene->attributes_map.alloc(attr_map_size);
|
||||||
memset(attr_map, 0, dscene->attributes_map.size()*sizeof(uint));
|
memset(attr_map, 0, dscene->attributes_map.size()*sizeof(uint));
|
||||||
|
|
||||||
for(size_t i = 0; i < scene->meshes.size(); i++) {
|
for(size_t i = 0; i < scene->meshes.size(); i++) {
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "render/image.h"
|
#include "render/image.h"
|
||||||
#include "render/integrator.h"
|
#include "render/integrator.h"
|
||||||
|
#include "render/light.h"
|
||||||
#include "render/nodes.h"
|
#include "render/nodes.h"
|
||||||
#include "render/scene.h"
|
#include "render/scene.h"
|
||||||
#include "render/svm.h"
|
#include "render/svm.h"
|
||||||
@@ -384,10 +385,10 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
|
|||||||
/* TODO(sergey): It's not so simple to pass custom attribute
|
/* TODO(sergey): It's not so simple to pass custom attribute
|
||||||
* to the texture() function in order to make builtin images
|
* to the texture() function in order to make builtin images
|
||||||
* support more clear. So we use special file name which is
|
* support more clear. So we use special file name which is
|
||||||
* "@<slot_number>" and check whether file name matches this
|
* "@i<slot_number>" and check whether file name matches this
|
||||||
* mask in the OSLRenderServices::texture().
|
* mask in the OSLRenderServices::texture().
|
||||||
*/
|
*/
|
||||||
compiler.parameter("filename", string_printf("@%d", slot).c_str());
|
compiler.parameter("filename", string_printf("@i%d", slot).c_str());
|
||||||
}
|
}
|
||||||
if(is_linear || color_space != NODE_COLOR_SPACE_COLOR)
|
if(is_linear || color_space != NODE_COLOR_SPACE_COLOR)
|
||||||
compiler.parameter("color_space", "linear");
|
compiler.parameter("color_space", "linear");
|
||||||
@@ -567,7 +568,7 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler)
|
|||||||
compiler.parameter(this, "filename");
|
compiler.parameter(this, "filename");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
compiler.parameter("filename", string_printf("@%d", slot).c_str());
|
compiler.parameter("filename", string_printf("@i%d", slot).c_str());
|
||||||
}
|
}
|
||||||
compiler.parameter(this, "projection");
|
compiler.parameter(this, "projection");
|
||||||
if(is_linear || color_space != NODE_COLOR_SPACE_COLOR)
|
if(is_linear || color_space != NODE_COLOR_SPACE_COLOR)
|
||||||
@@ -954,6 +955,97 @@ void VoronoiTextureNode::compile(OSLCompiler& compiler)
|
|||||||
compiler.add(this, "node_voronoi_texture");
|
compiler.add(this, "node_voronoi_texture");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* IES Light */
|
||||||
|
|
||||||
|
NODE_DEFINE(IESLightNode)
|
||||||
|
{
|
||||||
|
NodeType* type = NodeType::add("ies_light", create, NodeType::SHADER);
|
||||||
|
|
||||||
|
TEXTURE_MAPPING_DEFINE(IESLightNode);
|
||||||
|
|
||||||
|
SOCKET_STRING(ies, "IES", ustring());
|
||||||
|
SOCKET_STRING(filename, "File Name", ustring());
|
||||||
|
|
||||||
|
SOCKET_IN_FLOAT(strength, "Strength", 1.0f);
|
||||||
|
SOCKET_IN_POINT(vector, "Vector", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_NORMAL);
|
||||||
|
|
||||||
|
SOCKET_OUT_FLOAT(fac, "Fac");
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
IESLightNode::IESLightNode()
|
||||||
|
: TextureNode(node_type)
|
||||||
|
{
|
||||||
|
light_manager = NULL;
|
||||||
|
slot = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderNode *IESLightNode::clone() const
|
||||||
|
{
|
||||||
|
IESLightNode *node = new IESLightNode(*this);
|
||||||
|
|
||||||
|
node->light_manager = NULL;
|
||||||
|
node->slot = -1;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
IESLightNode::~IESLightNode()
|
||||||
|
{
|
||||||
|
if(light_manager) {
|
||||||
|
light_manager->remove_ies(slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IESLightNode::get_slot()
|
||||||
|
{
|
||||||
|
assert(light_manager);
|
||||||
|
|
||||||
|
if(slot == -1) {
|
||||||
|
if(ies.empty()) {
|
||||||
|
slot = light_manager->add_ies_from_file(filename);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
slot = light_manager->add_ies(ies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IESLightNode::compile(SVMCompiler& compiler)
|
||||||
|
{
|
||||||
|
light_manager = compiler.light_manager;
|
||||||
|
get_slot();
|
||||||
|
|
||||||
|
ShaderInput *strength_in = input("Strength");
|
||||||
|
ShaderInput *vector_in = input("Vector");
|
||||||
|
ShaderOutput *fac_out = output("Fac");
|
||||||
|
|
||||||
|
int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
|
||||||
|
|
||||||
|
compiler.add_node(NODE_IES,
|
||||||
|
compiler.encode_uchar4(
|
||||||
|
compiler.stack_assign_if_linked(strength_in),
|
||||||
|
vector_offset,
|
||||||
|
compiler.stack_assign(fac_out),
|
||||||
|
0),
|
||||||
|
slot,
|
||||||
|
__float_as_int(strength));
|
||||||
|
|
||||||
|
tex_mapping.compile_end(compiler, vector_in, vector_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IESLightNode::compile(OSLCompiler& compiler)
|
||||||
|
{
|
||||||
|
light_manager = compiler.light_manager;
|
||||||
|
get_slot();
|
||||||
|
|
||||||
|
tex_mapping.compile(compiler);
|
||||||
|
|
||||||
|
compiler.parameter("slot", slot);
|
||||||
|
compiler.add(this, "node_ies_light");
|
||||||
|
}
|
||||||
|
|
||||||
/* Musgrave Texture */
|
/* Musgrave Texture */
|
||||||
|
|
||||||
NODE_DEFINE(MusgraveTextureNode)
|
NODE_DEFINE(MusgraveTextureNode)
|
||||||
@@ -1470,7 +1562,7 @@ void PointDensityTextureNode::compile(OSLCompiler& compiler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(slot != -1) {
|
if(slot != -1) {
|
||||||
compiler.parameter("filename", string_printf("@%d", slot).c_str());
|
compiler.parameter("filename", string_printf("@i%d", slot).c_str());
|
||||||
}
|
}
|
||||||
if(space == NODE_TEX_VOXEL_SPACE_WORLD) {
|
if(space == NODE_TEX_VOXEL_SPACE_WORLD) {
|
||||||
compiler.parameter("mapping", tfm);
|
compiler.parameter("mapping", tfm);
|
||||||
@@ -4953,6 +5045,7 @@ NODE_DEFINE(MathNode)
|
|||||||
type_enum.insert("greater_than", NODE_MATH_GREATER_THAN);
|
type_enum.insert("greater_than", NODE_MATH_GREATER_THAN);
|
||||||
type_enum.insert("modulo", NODE_MATH_MODULO);
|
type_enum.insert("modulo", NODE_MATH_MODULO);
|
||||||
type_enum.insert("absolute", NODE_MATH_ABSOLUTE);
|
type_enum.insert("absolute", NODE_MATH_ABSOLUTE);
|
||||||
|
type_enum.insert("arctan2", NODE_MATH_ARCTAN2);
|
||||||
SOCKET_ENUM(type, "Type", type_enum, NODE_MATH_ADD);
|
SOCKET_ENUM(type, "Type", type_enum, NODE_MATH_ADD);
|
||||||
|
|
||||||
SOCKET_BOOLEAN(use_clamp, "Use Clamp", false);
|
SOCKET_BOOLEAN(use_clamp, "Use Clamp", false);
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class ImageManager;
|
class ImageManager;
|
||||||
|
class LightManager;
|
||||||
class Scene;
|
class Scene;
|
||||||
class Shader;
|
class Shader;
|
||||||
|
|
||||||
@@ -281,6 +282,27 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class IESLightNode : public TextureNode {
|
||||||
|
public:
|
||||||
|
SHADER_NODE_NO_CLONE_CLASS(IESLightNode)
|
||||||
|
|
||||||
|
~IESLightNode();
|
||||||
|
ShaderNode *clone() const;
|
||||||
|
virtual int get_group() { return NODE_GROUP_LEVEL_2; }
|
||||||
|
|
||||||
|
ustring filename;
|
||||||
|
ustring ies;
|
||||||
|
|
||||||
|
float strength;
|
||||||
|
float3 vector;
|
||||||
|
|
||||||
|
private:
|
||||||
|
LightManager *light_manager;
|
||||||
|
int slot;
|
||||||
|
|
||||||
|
void get_slot();
|
||||||
|
};
|
||||||
|
|
||||||
class MappingNode : public ShaderNode {
|
class MappingNode : public ShaderNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(MappingNode)
|
SHADER_NODE_CLASS(MappingNode)
|
||||||
|
@@ -99,7 +99,9 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
|
|||||||
* compile shaders alternating */
|
* compile shaders alternating */
|
||||||
thread_scoped_lock lock(ss_mutex);
|
thread_scoped_lock lock(ss_mutex);
|
||||||
|
|
||||||
OSLCompiler compiler((void*)this, (void*)ss, scene->image_manager);
|
OSLCompiler compiler((void*)this, (void*)ss,
|
||||||
|
scene->image_manager,
|
||||||
|
scene->light_manager);
|
||||||
compiler.background = (shader == scene->default_background);
|
compiler.background = (shader == scene->default_background);
|
||||||
compiler.compile(scene, og, shader);
|
compiler.compile(scene, og, shader);
|
||||||
|
|
||||||
@@ -546,11 +548,14 @@ OSLNode *OSLShaderManager::osl_node(const std::string& filepath,
|
|||||||
|
|
||||||
/* Graph Compiler */
|
/* Graph Compiler */
|
||||||
|
|
||||||
OSLCompiler::OSLCompiler(void *manager_, void *shadingsys_, ImageManager *image_manager_)
|
OSLCompiler::OSLCompiler(void *manager_, void *shadingsys_,
|
||||||
|
ImageManager *image_manager_,
|
||||||
|
LightManager *light_manager_)
|
||||||
{
|
{
|
||||||
manager = manager_;
|
manager = manager_;
|
||||||
shadingsys = shadingsys_;
|
shadingsys = shadingsys_;
|
||||||
image_manager = image_manager_;
|
image_manager = image_manager_;
|
||||||
|
light_manager = light_manager_;
|
||||||
current_type = SHADER_TYPE_SURFACE;
|
current_type = SHADER_TYPE_SURFACE;
|
||||||
current_shader = NULL;
|
current_shader = NULL;
|
||||||
background = false;
|
background = false;
|
||||||
|
@@ -120,7 +120,9 @@ protected:
|
|||||||
|
|
||||||
class OSLCompiler {
|
class OSLCompiler {
|
||||||
public:
|
public:
|
||||||
OSLCompiler(void *manager, void *shadingsys, ImageManager *image_manager);
|
OSLCompiler(void *manager, void *shadingsys,
|
||||||
|
ImageManager *image_manager,
|
||||||
|
LightManager *light_manager);
|
||||||
void compile(Scene *scene, OSLGlobals *og, Shader *shader);
|
void compile(Scene *scene, OSLGlobals *og, Shader *shader);
|
||||||
|
|
||||||
void add(ShaderNode *node, const char *name, bool isfilepath = false);
|
void add(ShaderNode *node, const char *name, bool isfilepath = false);
|
||||||
@@ -146,6 +148,7 @@ public:
|
|||||||
|
|
||||||
bool background;
|
bool background;
|
||||||
ImageManager *image_manager;
|
ImageManager *image_manager;
|
||||||
|
LightManager *light_manager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef WITH_OSL
|
#ifdef WITH_OSL
|
||||||
|
@@ -76,7 +76,8 @@ DeviceScene::DeviceScene(Device *device)
|
|||||||
svm_nodes(device, "__svm_nodes", MEM_TEXTURE),
|
svm_nodes(device, "__svm_nodes", MEM_TEXTURE),
|
||||||
shaders(device, "__shaders", MEM_TEXTURE),
|
shaders(device, "__shaders", MEM_TEXTURE),
|
||||||
lookup_table(device, "__lookup_table", MEM_TEXTURE),
|
lookup_table(device, "__lookup_table", MEM_TEXTURE),
|
||||||
sobol_directions(device, "__sobol_directions", MEM_TEXTURE)
|
sobol_directions(device, "__sobol_directions", MEM_TEXTURE),
|
||||||
|
ies_lights(device, "__ies", MEM_TEXTURE)
|
||||||
{
|
{
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
}
|
}
|
||||||
|
@@ -119,6 +119,9 @@ public:
|
|||||||
/* integrator */
|
/* integrator */
|
||||||
device_vector<uint> sobol_directions;
|
device_vector<uint> sobol_directions;
|
||||||
|
|
||||||
|
/* ies lights */
|
||||||
|
device_vector<float> ies_lights;
|
||||||
|
|
||||||
KernelData data;
|
KernelData data;
|
||||||
|
|
||||||
DeviceScene(Device *device);
|
DeviceScene(Device *device);
|
||||||
|
@@ -58,7 +58,7 @@ void SVMShaderManager::device_update_shader(Scene *scene,
|
|||||||
svm_nodes.push_back_slow(make_int4(NODE_SHADER_JUMP, 0, 0, 0));
|
svm_nodes.push_back_slow(make_int4(NODE_SHADER_JUMP, 0, 0, 0));
|
||||||
|
|
||||||
SVMCompiler::Summary summary;
|
SVMCompiler::Summary summary;
|
||||||
SVMCompiler compiler(scene->shader_manager, scene->image_manager);
|
SVMCompiler compiler(scene->shader_manager, scene->image_manager, scene->light_manager);
|
||||||
compiler.background = (shader == scene->default_background);
|
compiler.background = (shader == scene->default_background);
|
||||||
compiler.compile(scene, shader, svm_nodes, 0, &summary);
|
compiler.compile(scene, shader, svm_nodes, 0, &summary);
|
||||||
|
|
||||||
@@ -154,10 +154,13 @@ void SVMShaderManager::device_free(Device *device, DeviceScene *dscene, Scene *s
|
|||||||
|
|
||||||
/* Graph Compiler */
|
/* Graph Compiler */
|
||||||
|
|
||||||
SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, ImageManager *image_manager_)
|
SVMCompiler::SVMCompiler(ShaderManager *shader_manager_,
|
||||||
|
ImageManager *image_manager_,
|
||||||
|
LightManager *light_manager_)
|
||||||
{
|
{
|
||||||
shader_manager = shader_manager_;
|
shader_manager = shader_manager_;
|
||||||
image_manager = image_manager_;
|
image_manager = image_manager_;
|
||||||
|
light_manager = light_manager_;
|
||||||
max_stack_use = 0;
|
max_stack_use = 0;
|
||||||
current_type = SHADER_TYPE_SURFACE;
|
current_type = SHADER_TYPE_SURFACE;
|
||||||
current_shader = NULL;
|
current_shader = NULL;
|
||||||
|
@@ -95,7 +95,9 @@ public:
|
|||||||
string full_report() const;
|
string full_report() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
SVMCompiler(ShaderManager *shader_manager, ImageManager *image_manager);
|
SVMCompiler(ShaderManager *shader_manager,
|
||||||
|
ImageManager *image_manager,
|
||||||
|
LightManager *light_manager);
|
||||||
void compile(Scene *scene,
|
void compile(Scene *scene,
|
||||||
Shader *shader,
|
Shader *shader,
|
||||||
array<int4>& svm_nodes,
|
array<int4>& svm_nodes,
|
||||||
@@ -125,6 +127,7 @@ public:
|
|||||||
|
|
||||||
ImageManager *image_manager;
|
ImageManager *image_manager;
|
||||||
ShaderManager *shader_manager;
|
ShaderManager *shader_manager;
|
||||||
|
LightManager *light_manager;
|
||||||
bool background;
|
bool background;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -11,6 +11,7 @@ set(INC_SYS
|
|||||||
set(SRC
|
set(SRC
|
||||||
util_aligned_malloc.cpp
|
util_aligned_malloc.cpp
|
||||||
util_debug.cpp
|
util_debug.cpp
|
||||||
|
util_ies.cpp
|
||||||
util_logging.cpp
|
util_logging.cpp
|
||||||
util_math_cdf.cpp
|
util_math_cdf.cpp
|
||||||
util_md5.cpp
|
util_md5.cpp
|
||||||
@@ -45,6 +46,7 @@ set(SRC_HEADERS
|
|||||||
util_guarded_allocator.h
|
util_guarded_allocator.h
|
||||||
util_half.h
|
util_half.h
|
||||||
util_hash.h
|
util_hash.h
|
||||||
|
util_ies.h
|
||||||
util_image.h
|
util_image.h
|
||||||
util_image_impl.h
|
util_image_impl.h
|
||||||
util_list.h
|
util_list.h
|
||||||
|
396
intern/cycles/util/util_ies.cpp
Normal file
396
intern/cycles/util/util_ies.cpp
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2018 Blender Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "util/util_foreach.h"
|
||||||
|
#include "util/util_ies.h"
|
||||||
|
#include "util/util_math.h"
|
||||||
|
#include "util/util_string.h"
|
||||||
|
|
||||||
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
bool IESFile::load(ustring ies)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
if(!parse(ies) || !process()) {
|
||||||
|
clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IESFile::clear()
|
||||||
|
{
|
||||||
|
intensity.clear();
|
||||||
|
v_angles.clear();
|
||||||
|
h_angles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int IESFile::packed_size()
|
||||||
|
{
|
||||||
|
if(v_angles.size() && h_angles.size() > 0) {
|
||||||
|
return 2 + h_angles.size() + v_angles.size() + h_angles.size()*v_angles.size();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IESFile::pack(float *data)
|
||||||
|
{
|
||||||
|
if(v_angles.size() && h_angles.size()) {
|
||||||
|
*(data++) = __int_as_float(h_angles.size());
|
||||||
|
*(data++) = __int_as_float(v_angles.size());
|
||||||
|
|
||||||
|
memcpy(data, &h_angles[0], h_angles.size()*sizeof(float));
|
||||||
|
data += h_angles.size();
|
||||||
|
memcpy(data, &v_angles[0], v_angles.size()*sizeof(float));
|
||||||
|
data += v_angles.size();
|
||||||
|
|
||||||
|
for(int h = 0; h < intensity.size(); h++) {
|
||||||
|
memcpy(data, &intensity[h][0], v_angles.size()*sizeof(float));
|
||||||
|
data += v_angles.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class IESTextParser {
|
||||||
|
public:
|
||||||
|
vector<char> text;
|
||||||
|
char *data;
|
||||||
|
|
||||||
|
IESTextParser(ustring str)
|
||||||
|
: text(str.begin(), str.end())
|
||||||
|
{
|
||||||
|
std::replace(text.begin(), text.end(), ',', ' ');
|
||||||
|
data = strstr(&text[0], "\nTILT=");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool eof() {
|
||||||
|
return (data == NULL) || (data[0] == '\0');
|
||||||
|
}
|
||||||
|
|
||||||
|
double get_double() {
|
||||||
|
if(eof()) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
char *old_data = data;
|
||||||
|
double val = strtod(data, &data);
|
||||||
|
if(data == old_data) {
|
||||||
|
data = NULL;
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
long get_long() {
|
||||||
|
if(eof()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
char *old_data = data;
|
||||||
|
long val = strtol(data, &data, 10);
|
||||||
|
if(data == old_data) {
|
||||||
|
data = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool IESFile::parse(ustring ies)
|
||||||
|
{
|
||||||
|
if(ies.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IESTextParser parser(ies);
|
||||||
|
if(parser.eof()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle the tilt data block. */
|
||||||
|
if(strncmp(parser.data, "\nTILT=INCLUDE", 13) == 0) {
|
||||||
|
parser.data += 13;
|
||||||
|
parser.get_double(); /* Lamp to Luminaire geometry */
|
||||||
|
int num_tilt = parser.get_long(); /* Amount of tilt angles and factors */
|
||||||
|
/* Skip over angles and factors. */
|
||||||
|
for(int i = 0; i < 2*num_tilt; i++) {
|
||||||
|
parser.get_double();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Skip to next line. */
|
||||||
|
parser.data = strstr(parser.data+1, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parser.eof()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
parser.data++;
|
||||||
|
|
||||||
|
parser.get_long(); /* Number of lamps */
|
||||||
|
parser.get_double(); /* Lumens per lamp */
|
||||||
|
double factor = parser.get_double(); /* Candela multiplier */
|
||||||
|
int v_angles_num = parser.get_long(); /* Number of vertical angles */
|
||||||
|
int h_angles_num = parser.get_long(); /* Number of horizontal angles */
|
||||||
|
type = (IESType) parser.get_long(); /* Photometric type */
|
||||||
|
|
||||||
|
/* TODO(lukas): Test whether the current type B processing can also deal with type A files.
|
||||||
|
* In theory the only difference should be orientation which we ignore anyways, but with IES you never know...
|
||||||
|
*/
|
||||||
|
if(type != TYPE_B && type != TYPE_C) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
parser.get_long(); /* Unit of the geometry data */
|
||||||
|
parser.get_double(); /* Width */
|
||||||
|
parser.get_double(); /* Length */
|
||||||
|
parser.get_double(); /* Height */
|
||||||
|
factor *= parser.get_double(); /* Ballast factor */
|
||||||
|
factor *= parser.get_double(); /* Ballast-Lamp Photometric factor */
|
||||||
|
parser.get_double(); /* Input Watts */
|
||||||
|
|
||||||
|
/* Intensity values in IES files are specified in candela (lumen/sr), a photometric quantity.
|
||||||
|
* Cycles expects radiometric quantities, though, which requires a conversion.
|
||||||
|
* However, the Luminous efficacy (ratio of lumens per Watt) depends on the spectral distribution
|
||||||
|
* of the light source since lumens take human perception into account.
|
||||||
|
* Since this spectral distribution is not known from the IES file, a typical one must be assumed.
|
||||||
|
* The D65 standard illuminant has a Luminous efficacy of 177.83, which is used here to convert to Watt/sr.
|
||||||
|
* A more advanced approach would be to add a Blackbody Temperature input to the node and numerically
|
||||||
|
* integrate the Luminous efficacy from the resulting spectral distribution.
|
||||||
|
* Also, the Watt/sr value must be multiplied by 4*pi to get the Watt value that Cycles expects
|
||||||
|
* for lamp strength. Therefore, the conversion here uses 4*pi/177.83 as a Candela to Watt factor.
|
||||||
|
*/
|
||||||
|
factor *= 0.0706650768394;
|
||||||
|
|
||||||
|
v_angles.reserve(v_angles_num);
|
||||||
|
for(int i = 0; i < v_angles_num; i++) {
|
||||||
|
v_angles.push_back((float) parser.get_double());
|
||||||
|
}
|
||||||
|
|
||||||
|
h_angles.reserve(h_angles_num);
|
||||||
|
for(int i = 0; i < h_angles_num; i++) {
|
||||||
|
h_angles.push_back((float) parser.get_double());
|
||||||
|
}
|
||||||
|
|
||||||
|
intensity.resize(h_angles_num);
|
||||||
|
for(int i = 0; i < h_angles_num; i++) {
|
||||||
|
intensity[i].reserve(v_angles_num);
|
||||||
|
for(int j = 0; j < v_angles_num; j++) {
|
||||||
|
intensity[i].push_back((float) (factor * parser.get_double()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return !parser.eof();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IESFile::process_type_b()
|
||||||
|
{
|
||||||
|
vector<vector<float> > newintensity;
|
||||||
|
newintensity.resize(v_angles.size());
|
||||||
|
for(int i = 0; i < v_angles.size(); i++) {
|
||||||
|
newintensity[i].reserve(h_angles.size());
|
||||||
|
for(int j = 0; j < h_angles.size(); j++) {
|
||||||
|
newintensity[i].push_back(intensity[j][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intensity.swap(newintensity);
|
||||||
|
h_angles.swap(v_angles);
|
||||||
|
|
||||||
|
float h_first = h_angles[0], h_last = h_angles[h_angles.size()-1];
|
||||||
|
if(h_last != 90.0f) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(h_first == 0.0f) {
|
||||||
|
/* The range in the file corresponds to 90°-180°, we need to mirror that to get the
|
||||||
|
* full 180° range. */
|
||||||
|
vector<float> new_h_angles;
|
||||||
|
vector<vector<float> > new_intensity;
|
||||||
|
int hnum = h_angles.size();
|
||||||
|
new_h_angles.reserve(2*hnum-1);
|
||||||
|
new_intensity.reserve(2*hnum-1);
|
||||||
|
for(int i = hnum-1; i > 0; i--) {
|
||||||
|
new_h_angles.push_back(90.0f - h_angles[i]);
|
||||||
|
new_intensity.push_back(intensity[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < hnum; i++) {
|
||||||
|
new_h_angles.push_back(90.0f + h_angles[i]);
|
||||||
|
new_intensity.push_back(intensity[i]);
|
||||||
|
}
|
||||||
|
h_angles.swap(new_h_angles);
|
||||||
|
intensity.swap(new_intensity);
|
||||||
|
}
|
||||||
|
else if(h_first == -90.0f) {
|
||||||
|
/* We have full 180° coverage, so just shift to match the angle range convention. */
|
||||||
|
for(int i = 0; i < h_angles.size(); i++) {
|
||||||
|
h_angles[i] += 90.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* To get correct results with the cubic interpolation in the kernel, the horizontal range
|
||||||
|
* has to cover all 360°. Therefore, we copy the 0° entry to 360° to ensure full coverage
|
||||||
|
* and seamless interpolation. */
|
||||||
|
h_angles.push_back(360.0f);
|
||||||
|
intensity.push_back(intensity[0]);
|
||||||
|
|
||||||
|
float v_first = v_angles[0], v_last = v_angles[v_angles.size()-1];
|
||||||
|
if(v_last != 90.0f) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(v_first == 0.0f) {
|
||||||
|
/* The range in the file corresponds to 90°-180°, we need to mirror that to get the
|
||||||
|
* full 180° range. */
|
||||||
|
vector<float> new_v_angles;
|
||||||
|
int hnum = h_angles.size();
|
||||||
|
int vnum = v_angles.size();
|
||||||
|
new_v_angles.reserve(2*vnum-1);
|
||||||
|
for(int i = vnum-1; i > 0; i--) {
|
||||||
|
new_v_angles.push_back(90.0f - v_angles[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < vnum; i++) {
|
||||||
|
new_v_angles.push_back(90.0f + v_angles[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < hnum; i++) {
|
||||||
|
vector<float> new_intensity;
|
||||||
|
new_intensity.reserve(2*vnum-1);
|
||||||
|
for(int j = vnum-2; j >= 0; j--) {
|
||||||
|
new_intensity.push_back(intensity[i][j]);
|
||||||
|
}
|
||||||
|
new_intensity.insert(new_intensity.end(), intensity[i].begin(), intensity[i].end());
|
||||||
|
intensity[i].swap(new_intensity);
|
||||||
|
}
|
||||||
|
v_angles.swap(new_v_angles);
|
||||||
|
}
|
||||||
|
else if(v_first == -90.0f) {
|
||||||
|
/* We have full 180° coverage, so just shift to match the angle range convention. */
|
||||||
|
for(int i = 0; i < v_angles.size(); i++) {
|
||||||
|
v_angles[i] += 90.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IESFile::process_type_c()
|
||||||
|
{
|
||||||
|
if(h_angles[0] == 90.0f) {
|
||||||
|
/* Some files are stored from 90° to 270°, so we just rotate them to the regular 0°-180° range here. */
|
||||||
|
for(int i = 0; i < v_angles.size(); i++) {
|
||||||
|
h_angles[i] -= 90.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(h_angles[0] != 0.0f) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(h_angles.size() == 1) {
|
||||||
|
h_angles.push_back(360.0f);
|
||||||
|
intensity.push_back(intensity[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(h_angles[h_angles.size()-1] == 90.0f) {
|
||||||
|
/* Only one quadrant is defined, so we need to mirror twice (from one to two, then to four).
|
||||||
|
* Since the two->four mirroring step might also be required if we get an input of two quadrants,
|
||||||
|
* we only do the first mirror here and later do the second mirror in either case. */
|
||||||
|
int hnum = h_angles.size();
|
||||||
|
for(int i = hnum-2; i >= 0; i--) {
|
||||||
|
h_angles.push_back(180.0f - h_angles[i]);
|
||||||
|
intensity.push_back(intensity[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(h_angles[h_angles.size()-1] == 180.0f) {
|
||||||
|
/* Mirror half to the full range. */
|
||||||
|
int hnum = h_angles.size();
|
||||||
|
for(int i = hnum-2; i >= 0; i--) {
|
||||||
|
h_angles.push_back(360.0f - h_angles[i]);
|
||||||
|
intensity.push_back(intensity[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Some files skip the 360° entry (contrary to standard) because it's supposed to be identical to the 0° entry.
|
||||||
|
* If the file has a discernible order in its spacing, just fix this. */
|
||||||
|
if(h_angles[h_angles.size()-1] != 360.0f) {
|
||||||
|
int hnum = h_angles.size();
|
||||||
|
float last_step = h_angles[hnum-1]-h_angles[hnum-2];
|
||||||
|
float first_step = h_angles[1]-h_angles[0];
|
||||||
|
float difference = 360.0f - h_angles[hnum-1];
|
||||||
|
if(last_step == difference || first_step == difference) {
|
||||||
|
h_angles.push_back(360.0f);
|
||||||
|
intensity.push_back(intensity[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float v_first = v_angles[0], v_last = v_angles[v_angles.size()-1];
|
||||||
|
if(v_first == 90.0f) {
|
||||||
|
if(v_last == 180.0f) {
|
||||||
|
/* Flip to ensure that vertical angles always start at 0°. */
|
||||||
|
for(int i = 0; i < v_angles.size(); i++) {
|
||||||
|
v_angles[i] = 180.0f - v_angles[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(v_first != 0.0f) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IESFile::process()
|
||||||
|
{
|
||||||
|
if(h_angles.size() == 0 || v_angles.size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == TYPE_B) {
|
||||||
|
if(!process_type_b()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(type == TYPE_C);
|
||||||
|
if(!process_type_c()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(v_angles[0] == 0.0f);
|
||||||
|
assert(h_angles[0] == 0.0f);
|
||||||
|
assert(h_angles[h_angles.size()-1] == 360.0f);
|
||||||
|
|
||||||
|
/* Convert from deg to rad. */
|
||||||
|
for(int i = 0; i < v_angles.size(); i++) {
|
||||||
|
v_angles[i] *= M_PI_F / 180.f;
|
||||||
|
}
|
||||||
|
for(int i = 0; i < h_angles.size(); i++) {
|
||||||
|
h_angles[i] *= M_PI_F / 180.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IESFile::~IESFile()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
CCL_NAMESPACE_END
|
61
intern/cycles/util/util_ies.h
Normal file
61
intern/cycles/util/util_ies.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2018 Blender Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __UTIL_IES_H__
|
||||||
|
#define __UTIL_IES_H__
|
||||||
|
|
||||||
|
#include "util/util_param.h"
|
||||||
|
#include "util/util_vector.h"
|
||||||
|
|
||||||
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
class IESFile {
|
||||||
|
public:
|
||||||
|
IESFile() {}
|
||||||
|
~IESFile();
|
||||||
|
|
||||||
|
int packed_size();
|
||||||
|
void pack(float *data);
|
||||||
|
|
||||||
|
bool load(ustring ies);
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool parse(ustring ies);
|
||||||
|
bool process();
|
||||||
|
bool process_type_b();
|
||||||
|
bool process_type_c();
|
||||||
|
|
||||||
|
/* The brightness distribution is stored in spherical coordinates.
|
||||||
|
* The horizontal angles correspond to to theta in the regular notation
|
||||||
|
* and always span the full range from 0° to 360°.
|
||||||
|
* The vertical angles correspond to phi and always start at 0°. */
|
||||||
|
vector<float> v_angles, h_angles;
|
||||||
|
/* The actual values are stored here, with every entry storing the values
|
||||||
|
* of one horizontal segment. */
|
||||||
|
vector<vector<float> > intensity;
|
||||||
|
|
||||||
|
/* Types of angle representation in IES files. Currently, only B and C are supported. */
|
||||||
|
enum IESType {
|
||||||
|
TYPE_A = 3,
|
||||||
|
TYPE_B = 2,
|
||||||
|
TYPE_C = 1
|
||||||
|
} type;
|
||||||
|
};
|
||||||
|
|
||||||
|
CCL_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif /* __UTIL_IES_H__ */
|
@@ -310,6 +310,17 @@ ccl_device_inline float4 float3_to_float4(const float3 a)
|
|||||||
return make_float4(a.x, a.y, a.z, 1.0f);
|
return make_float4(a.x, a.y, a.z, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ccl_device_inline float inverse_lerp(float a, float b, float x)
|
||||||
|
{
|
||||||
|
return (x - a) / (b - a);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cubic interpolation between b and c, a and d are the previous and next point. */
|
||||||
|
ccl_device_inline float cubic_interp(float a, float b, float c, float d, float x)
|
||||||
|
{
|
||||||
|
return 0.5f*(((d + 3.0f*(b-c) - a)*x + (2.0f*a - 5.0f*b + 4.0f*c - d))*x + (c - a))*x + b;
|
||||||
|
}
|
||||||
|
|
||||||
CCL_NAMESPACE_END
|
CCL_NAMESPACE_END
|
||||||
|
|
||||||
#include "util/util_math_int2.h"
|
#include "util/util_math_int2.h"
|
||||||
|
@@ -186,12 +186,17 @@ ccl_device_forceinline bool ray_triangle_intersect(
|
|||||||
#undef dot3
|
#undef dot3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tests for an intersection between a ray and a quad defined by
|
||||||
|
* its midpoint, normal and sides.
|
||||||
|
* If ellipse is true, hits outside the ellipse that's enclosed by the
|
||||||
|
* quad are rejected.
|
||||||
|
*/
|
||||||
ccl_device bool ray_quad_intersect(float3 ray_P, float3 ray_D,
|
ccl_device bool ray_quad_intersect(float3 ray_P, float3 ray_D,
|
||||||
float ray_mint, float ray_maxt,
|
float ray_mint, float ray_maxt,
|
||||||
float3 quad_P,
|
float3 quad_P,
|
||||||
float3 quad_u, float3 quad_v, float3 quad_n,
|
float3 quad_u, float3 quad_v, float3 quad_n,
|
||||||
float3 *isect_P, float *isect_t,
|
float3 *isect_P, float *isect_t,
|
||||||
float *isect_u, float *isect_v)
|
float *isect_u, float *isect_v, bool ellipse)
|
||||||
{
|
{
|
||||||
/* Perform intersection test. */
|
/* Perform intersection test. */
|
||||||
float t = -(dot(ray_P, quad_n) - dot(quad_P, quad_n)) / dot(ray_D, quad_n);
|
float t = -(dot(ray_P, quad_n) - dot(quad_P, quad_n)) / dot(ray_D, quad_n);
|
||||||
@@ -200,20 +205,23 @@ ccl_device bool ray_quad_intersect(float3 ray_P, float3 ray_D,
|
|||||||
}
|
}
|
||||||
const float3 hit = ray_P + t*ray_D;
|
const float3 hit = ray_P + t*ray_D;
|
||||||
const float3 inplane = hit - quad_P;
|
const float3 inplane = hit - quad_P;
|
||||||
const float u = dot(inplane, quad_u) / dot(quad_u, quad_u) + 0.5f;
|
const float u = dot(inplane, quad_u) / dot(quad_u, quad_u);
|
||||||
if(u < 0.0f || u > 1.0f) {
|
if(u < -0.5f || u > 0.5f) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const float v = dot(inplane, quad_v) / dot(quad_v, quad_v) + 0.5f;
|
const float v = dot(inplane, quad_v) / dot(quad_v, quad_v);
|
||||||
if(v < 0.0f || v > 1.0f) {
|
if(v < -0.5f || v > 0.5f) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(ellipse && (u*u + v*v > 0.25f)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Store the result. */
|
/* Store the result. */
|
||||||
/* TODO(sergey): Check whether we can avoid some checks here. */
|
/* TODO(sergey): Check whether we can avoid some checks here. */
|
||||||
if(isect_P != NULL) *isect_P = hit;
|
if(isect_P != NULL) *isect_P = hit;
|
||||||
if(isect_t != NULL) *isect_t = t;
|
if(isect_t != NULL) *isect_t = t;
|
||||||
if(isect_u != NULL) *isect_u = u;
|
if(isect_u != NULL) *isect_u = u + 0.5f;
|
||||||
if(isect_v != NULL) *isect_v = v;
|
if(isect_v != NULL) *isect_v = v + 0.5f;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,6 +144,18 @@ ccl_device_inline void math_trimatrix_add_gramian_strided(ccl_global float *A,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ccl_device_inline void math_trimatrix_add_gramian(ccl_global float *A,
|
||||||
|
int n,
|
||||||
|
const float *ccl_restrict v,
|
||||||
|
float weight)
|
||||||
|
{
|
||||||
|
for(int row = 0; row < n; row++) {
|
||||||
|
for(int col = 0; col <= row; col++) {
|
||||||
|
MATHS(A, row, col, 1) += v[row]*v[col]*weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Transpose matrix A inplace. */
|
/* Transpose matrix A inplace. */
|
||||||
ccl_device_inline void math_matrix_transpose(ccl_global float *A, int n, int stride)
|
ccl_device_inline void math_matrix_transpose(ccl_global float *A, int n, int stride)
|
||||||
{
|
{
|
||||||
|
@@ -61,6 +61,7 @@ void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*);
|
|||||||
void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, unsigned v);
|
void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, unsigned v);
|
||||||
void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2);
|
void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2);
|
||||||
void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2, unsigned v3);
|
void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2, unsigned v3);
|
||||||
|
void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2, unsigned v3, unsigned v4);
|
||||||
|
|
||||||
Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*);
|
Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*);
|
||||||
void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*);
|
void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*);
|
||||||
|
@@ -22,6 +22,7 @@ typedef enum {
|
|||||||
GWN_PRIM_TRI_STRIP,
|
GWN_PRIM_TRI_STRIP,
|
||||||
GWN_PRIM_TRI_FAN,
|
GWN_PRIM_TRI_FAN,
|
||||||
|
|
||||||
|
GWN_PRIM_LINES_ADJ,
|
||||||
GWN_PRIM_TRIS_ADJ,
|
GWN_PRIM_TRIS_ADJ,
|
||||||
GWN_PRIM_LINE_STRIP_ADJ,
|
GWN_PRIM_LINE_STRIP_ADJ,
|
||||||
|
|
||||||
|
@@ -63,6 +63,9 @@ void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uns
|
|||||||
case GWN_PRIM_TRIS:
|
case GWN_PRIM_TRIS:
|
||||||
verts_per_prim = 3;
|
verts_per_prim = 3;
|
||||||
break;
|
break;
|
||||||
|
case GWN_PRIM_LINES_ADJ:
|
||||||
|
verts_per_prim = 4;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
#if TRUST_NO_ONE
|
#if TRUST_NO_ONE
|
||||||
assert(false);
|
assert(false);
|
||||||
@@ -127,6 +130,19 @@ void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsig
|
|||||||
GWN_indexbuf_add_generic_vert(builder, v3);
|
GWN_indexbuf_add_generic_vert(builder, v3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2, unsigned v3, unsigned v4)
|
||||||
|
{
|
||||||
|
#if TRUST_NO_ONE
|
||||||
|
assert(builder->prim_type == GWN_PRIM_LINES_ADJ);
|
||||||
|
assert(v2 != v3); /* only the line need diff indices */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GWN_indexbuf_add_generic_vert(builder, v1);
|
||||||
|
GWN_indexbuf_add_generic_vert(builder, v2);
|
||||||
|
GWN_indexbuf_add_generic_vert(builder, v3);
|
||||||
|
GWN_indexbuf_add_generic_vert(builder, v4);
|
||||||
|
}
|
||||||
|
|
||||||
#if GWN_TRACK_INDEX_RANGE
|
#if GWN_TRACK_INDEX_RANGE
|
||||||
// Everything remains 32 bit while building to keep things simple.
|
// Everything remains 32 bit while building to keep things simple.
|
||||||
// Find min/max after, then convert to smallest index type possible.
|
// Find min/max after, then convert to smallest index type possible.
|
||||||
|
@@ -24,6 +24,7 @@ Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type)
|
|||||||
[GWN_PRIM_TRI_STRIP] = GWN_PRIM_CLASS_SURFACE,
|
[GWN_PRIM_TRI_STRIP] = GWN_PRIM_CLASS_SURFACE,
|
||||||
[GWN_PRIM_TRI_FAN] = GWN_PRIM_CLASS_SURFACE,
|
[GWN_PRIM_TRI_FAN] = GWN_PRIM_CLASS_SURFACE,
|
||||||
|
|
||||||
|
[GWN_PRIM_LINES_ADJ] = GWN_PRIM_CLASS_LINE,
|
||||||
[GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE,
|
[GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE,
|
||||||
[GWN_PRIM_TRIS_ADJ] = GWN_PRIM_CLASS_SURFACE,
|
[GWN_PRIM_TRIS_ADJ] = GWN_PRIM_CLASS_SURFACE,
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type)
|
|||||||
[GWN_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP,
|
[GWN_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP,
|
||||||
[GWN_PRIM_TRI_FAN] = GL_TRIANGLE_FAN,
|
[GWN_PRIM_TRI_FAN] = GL_TRIANGLE_FAN,
|
||||||
|
|
||||||
|
[GWN_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY,
|
||||||
[GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY,
|
[GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY,
|
||||||
[GWN_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY,
|
[GWN_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY,
|
||||||
};
|
};
|
||||||
|
@@ -171,7 +171,7 @@ void *MEM_lockfree_dupallocN(const void *vmemh)
|
|||||||
void *newp = NULL;
|
void *newp = NULL;
|
||||||
if (vmemh) {
|
if (vmemh) {
|
||||||
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
|
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
|
||||||
const size_t prev_size = MEM_allocN_len(vmemh);
|
const size_t prev_size = MEM_lockfree_allocN_len(vmemh);
|
||||||
if (UNLIKELY(MEMHEAD_IS_MMAP(memh))) {
|
if (UNLIKELY(MEMHEAD_IS_MMAP(memh))) {
|
||||||
newp = MEM_lockfree_mapallocN(prev_size, "dupli_mapalloc");
|
newp = MEM_lockfree_mapallocN(prev_size, "dupli_mapalloc");
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ void *MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str)
|
|||||||
|
|
||||||
if (vmemh) {
|
if (vmemh) {
|
||||||
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
|
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
|
||||||
size_t old_len = MEM_allocN_len(vmemh);
|
size_t old_len = MEM_lockfree_allocN_len(vmemh);
|
||||||
|
|
||||||
if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) {
|
if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) {
|
||||||
newp = MEM_lockfree_mallocN(len, "realloc");
|
newp = MEM_lockfree_mallocN(len, "realloc");
|
||||||
@@ -204,9 +204,9 @@ void *MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str)
|
|||||||
else {
|
else {
|
||||||
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
|
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
|
||||||
newp = MEM_lockfree_mallocN_aligned(
|
newp = MEM_lockfree_mallocN_aligned(
|
||||||
old_len,
|
len,
|
||||||
(size_t)memh_aligned->alignment,
|
(size_t)memh_aligned->alignment,
|
||||||
"realloc");
|
"realloc");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newp) {
|
if (newp) {
|
||||||
@@ -235,16 +235,17 @@ void *MEM_lockfree_recallocN_id(void *vmemh, size_t len, const char *str)
|
|||||||
|
|
||||||
if (vmemh) {
|
if (vmemh) {
|
||||||
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
|
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
|
||||||
size_t old_len = MEM_allocN_len(vmemh);
|
size_t old_len = MEM_lockfree_allocN_len(vmemh);
|
||||||
|
|
||||||
if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) {
|
if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) {
|
||||||
newp = MEM_lockfree_mallocN(len, "recalloc");
|
newp = MEM_lockfree_mallocN(len, "recalloc");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
|
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
|
||||||
newp = MEM_lockfree_mallocN_aligned(old_len,
|
newp = MEM_lockfree_mallocN_aligned(
|
||||||
(size_t)memh_aligned->alignment,
|
len,
|
||||||
"recalloc");
|
(size_t)memh_aligned->alignment,
|
||||||
|
"recalloc");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newp) {
|
if (newp) {
|
||||||
|
375
make.bat
375
make.bat
@@ -4,359 +4,66 @@ REM This is for users who like to configure & build Blender with a single comman
|
|||||||
setlocal EnableDelayedExpansion
|
setlocal EnableDelayedExpansion
|
||||||
setlocal ENABLEEXTENSIONS
|
setlocal ENABLEEXTENSIONS
|
||||||
set BLENDER_DIR=%~dp0
|
set BLENDER_DIR=%~dp0
|
||||||
set BLENDER_DIR_NOSPACES=%BLENDER_DIR: =%
|
|
||||||
for %%X in (svn.exe) do (set HAS_SVN=%%~$PATH:X)
|
|
||||||
if not "%BLENDER_DIR%"=="%BLENDER_DIR_NOSPACES%" (
|
|
||||||
echo There are spaces detected in the build path "%BLENDER_DIR%", this is currently not supported, exiting....
|
|
||||||
goto EOF
|
|
||||||
)
|
|
||||||
set BUILD_DIR=%BLENDER_DIR%..\build_windows
|
|
||||||
set BUILD_TYPE=Release
|
|
||||||
rem reset all variables so they do not get accidentally get carried over from previous builds
|
|
||||||
set BUILD_DIR_OVERRRIDE=
|
|
||||||
set BUILD_CMAKE_ARGS=
|
|
||||||
set BUILD_ARCH=
|
|
||||||
set BUILD_VS_VER=
|
|
||||||
set BUILD_VS_YEAR=
|
|
||||||
set BUILD_VS_LIBDIRPOST=
|
|
||||||
set BUILD_VS_LIBDIR=
|
|
||||||
set BUILD_VS_SVNDIR=
|
|
||||||
set BUILD_NGE=
|
|
||||||
set KEY_NAME=
|
|
||||||
set MSBUILD_PLATFORM=
|
|
||||||
set MUST_CLEAN=
|
|
||||||
set NOBUILD=
|
|
||||||
set TARGET=
|
|
||||||
set WINDOWS_ARCH=
|
|
||||||
set TESTS_CMAKE_ARGS=
|
|
||||||
:argv_loop
|
|
||||||
if NOT "%1" == "" (
|
|
||||||
|
|
||||||
REM Help Message
|
call "%BLENDER_DIR%\build_files\windows\reset_variables.cmd"
|
||||||
if "%1" == "help" (
|
|
||||||
goto HELP
|
|
||||||
)
|
|
||||||
|
|
||||||
REM Build Types
|
call "%BLENDER_DIR%\build_files\windows\check_spaces_in_path.cmd"
|
||||||
if "%1" == "debug" (
|
if errorlevel 1 goto EOF
|
||||||
set BUILD_TYPE=Debug
|
|
||||||
REM Build Configurations
|
|
||||||
) else if "%1" == "noge" (
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_GAMEENGINE=OFF -DWITH_PLAYER=OFF
|
|
||||||
set BUILD_NGE=_noge
|
|
||||||
) else if "%1" == "builddir" (
|
|
||||||
set BUILD_DIR_OVERRRIDE="%BLENDER_DIR%..\%2"
|
|
||||||
shift /1
|
|
||||||
) else if "%1" == "with_tests" (
|
|
||||||
set TESTS_CMAKE_ARGS=-DWITH_GTESTS=On
|
|
||||||
) else if "%1" == "full" (
|
|
||||||
set TARGET=Full
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
|
|
||||||
-C"%BLENDER_DIR%\build_files\cmake\config\blender_full.cmake"
|
|
||||||
) else if "%1" == "lite" (
|
|
||||||
set TARGET=Lite
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
|
|
||||||
-C"%BLENDER_DIR%\build_files\cmake\config\blender_lite.cmake"
|
|
||||||
) else if "%1" == "cycles" (
|
|
||||||
set TARGET=Cycles
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
|
|
||||||
-C"%BLENDER_DIR%\build_files\cmake\config\cycles_standalone.cmake"
|
|
||||||
) else if "%1" == "headless" (
|
|
||||||
set TARGET=Headless
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
|
|
||||||
-C"%BLENDER_DIR%\build_files\cmake\config\blender_headless.cmake"
|
|
||||||
) else if "%1" == "bpy" (
|
|
||||||
set TARGET=Bpy
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
|
|
||||||
-C"%BLENDER_DIR%\build_files\cmake\config\bpy_module.cmake"
|
|
||||||
) else if "%1" == "release" (
|
|
||||||
set TARGET=Release
|
|
||||||
) else if "%1" == "x86" (
|
|
||||||
set BUILD_ARCH=x86
|
|
||||||
) else if "%1" == "x64" (
|
|
||||||
set BUILD_ARCH=x64
|
|
||||||
) else if "%1" == "2017" (
|
|
||||||
set BUILD_VS_VER=15
|
|
||||||
set BUILD_VS_YEAR=2017
|
|
||||||
set BUILD_VS_LIBDIRPOST=vc14
|
|
||||||
) else if "%1" == "2015" (
|
|
||||||
set BUILD_VS_VER=14
|
|
||||||
set BUILD_VS_YEAR=2015
|
|
||||||
set BUILD_VS_LIBDIRPOST=vc14
|
|
||||||
) else if "%1" == "2013" (
|
|
||||||
set BUILD_VS_VER=12
|
|
||||||
set BUILD_VS_YEAR=2013
|
|
||||||
set BUILD_VS_LIBDIRPOST=vc12
|
|
||||||
) else if "%1" == "packagename" (
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2"
|
|
||||||
shift /1
|
|
||||||
) else if "%1" == "nobuild" (
|
|
||||||
set NOBUILD=1
|
|
||||||
) else if "%1" == "showhash" (
|
|
||||||
for /f "delims=" %%i in ('git rev-parse HEAD') do echo Branch_hash=%%i
|
|
||||||
cd release/datafiles/locale
|
|
||||||
for /f "delims=" %%i in ('git rev-parse HEAD') do echo Locale_hash=%%i
|
|
||||||
cd %~dp0
|
|
||||||
cd release/scripts/addons
|
|
||||||
for /f "delims=" %%i in ('git rev-parse HEAD') do echo Addons_Hash=%%i
|
|
||||||
cd %~dp0
|
|
||||||
goto EOF
|
|
||||||
REM Non-Build Commands
|
|
||||||
) else if "%1" == "update" (
|
|
||||||
svn up ../lib/*
|
|
||||||
git pull --rebase
|
|
||||||
git submodule update --remote
|
|
||||||
goto EOF
|
|
||||||
) else if "%1" == "clean" (
|
|
||||||
set MUST_CLEAN=1
|
|
||||||
) else (
|
|
||||||
echo Command "%1" unknown, aborting!
|
|
||||||
goto EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
shift /1
|
call "%BLENDER_DIR%\build_files\windows\parse_arguments.cmd" %*
|
||||||
goto argv_loop
|
if errorlevel 1 goto EOF
|
||||||
)
|
|
||||||
if "%BUILD_ARCH%"=="" (
|
|
||||||
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
|
|
||||||
set WINDOWS_ARCH= Win64
|
|
||||||
set BUILD_ARCH=x64
|
|
||||||
) else if "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
|
|
||||||
set WINDOWS_ARCH= Win64
|
|
||||||
set BUILD_ARCH=x64
|
|
||||||
) else (
|
|
||||||
set WINDOWS_ARCH=
|
|
||||||
set BUILD_ARCH=x86
|
|
||||||
)
|
|
||||||
) else if "%BUILD_ARCH%"=="x64" (
|
|
||||||
set WINDOWS_ARCH= Win64
|
|
||||||
) else if "%BUILD_ARCH%"=="x86" (
|
|
||||||
set WINDOWS_ARCH=
|
|
||||||
)
|
|
||||||
|
|
||||||
if "%BUILD_VS_VER%"=="" (
|
call "%BLENDER_DIR%\build_files\windows\find_dependencies.cmd"
|
||||||
set BUILD_VS_VER=12
|
if errorlevel 1 goto EOF
|
||||||
set BUILD_VS_YEAR=2013
|
|
||||||
set BUILD_VS_LIBDIRPOST=vc12
|
|
||||||
)
|
|
||||||
|
|
||||||
if "%BUILD_ARCH%"=="x64" (
|
if "%SHOW_HELP%" == "1" (
|
||||||
set MSBUILD_PLATFORM=x64
|
call "%BLENDER_DIR%\build_files\windows\show_help.cmd"
|
||||||
) else if "%BUILD_ARCH%"=="x86" (
|
|
||||||
set MSBUILD_PLATFORM=win32
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if "%target%"=="Release" (
|
|
||||||
rem for vc12 check for both cuda 7.5 and 8
|
|
||||||
if "%CUDA_PATH%"=="" (
|
|
||||||
echo Cuda Not found, aborting!
|
|
||||||
goto EOF
|
|
||||||
)
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
|
|
||||||
-C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake"
|
|
||||||
)
|
|
||||||
|
|
||||||
:DetectMSVC
|
|
||||||
REM Detect MSVC Installation for 2013-2015
|
|
||||||
if DEFINED VisualStudioVersion goto msvc_detect_finally
|
|
||||||
set VALUE_NAME=ProductDir
|
|
||||||
REM Check 64 bits
|
|
||||||
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
|
|
||||||
for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C
|
|
||||||
if DEFINED MSVC_VC_DIR goto msvc_detect_finally
|
|
||||||
REM Check 32 bits
|
|
||||||
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
|
|
||||||
for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C
|
|
||||||
if DEFINED MSVC_VC_DIR goto msvc_detect_finally
|
|
||||||
:msvc_detect_finally
|
|
||||||
if DEFINED MSVC_VC_DIR call "%MSVC_VC_DIR%\vcvarsall.bat"
|
|
||||||
if DEFINED MSVC_VC_DIR goto sanity_checks
|
|
||||||
|
|
||||||
rem MSVC Build environment 2017 and up.
|
|
||||||
for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SXS\VS7" /v %BUILD_VS_VER%.0 2^>nul`) DO set MSVC_VS_DIR=%%C
|
|
||||||
if DEFINED MSVC_VS_DIR goto msvc_detect_finally_2017
|
|
||||||
REM Check 32 bits
|
|
||||||
for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\sxs\vs7" /v %BUILD_VS_VER%.0 2^>nul`) DO set MSVC_VS_DIR=%%C
|
|
||||||
if DEFINED MSVC_VS_DIR goto msvc_detect_finally_2017
|
|
||||||
:msvc_detect_finally_2017
|
|
||||||
if DEFINED MSVC_VS_DIR call "%MSVC_VS_DIR%\Common7\Tools\VsDevCmd.bat"
|
|
||||||
|
|
||||||
:sanity_checks
|
|
||||||
REM Sanity Checks
|
|
||||||
where /Q msbuild
|
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
|
||||||
if "%BUILD_VS_VER%"=="12" (
|
|
||||||
rem vs12 not found, try vs14
|
|
||||||
echo Visual Studio 2013 not found, trying Visual Studio 2015.
|
|
||||||
set BUILD_VS_VER=14
|
|
||||||
set BUILD_VS_YEAR=2015
|
|
||||||
set BUILD_VS_LIBDIRPOST=vc14
|
|
||||||
goto DetectMSVC
|
|
||||||
) else (
|
|
||||||
echo Error: "MSBuild" command not in the PATH.
|
|
||||||
echo You must have MSVC installed and run this from the "Developer Command Prompt"
|
|
||||||
echo ^(available from Visual Studio's Start menu entry^), aborting!
|
|
||||||
goto EOF
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
set BUILD_DIR=%BUILD_DIR%_%TARGET%%BUILD_NGE%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
|
|
||||||
if NOT "%BUILD_DIR_OVERRRIDE%"=="" (
|
|
||||||
set BUILD_DIR=%BUILD_DIR_OVERRRIDE%
|
|
||||||
)
|
|
||||||
|
|
||||||
where /Q cmake
|
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
|
||||||
echo Error: "CMake" command not in the PATH.
|
|
||||||
echo You must have CMake installed and added to your PATH, aborting!
|
|
||||||
goto EOF
|
goto EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%BUILD_ARCH%"=="x64" (
|
if "%BUILD_UPDATE%" == "1" (
|
||||||
set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
|
call "%BLENDER_DIR%\build_files\windows\update_sources.cmd"
|
||||||
) else if "%BUILD_ARCH%"=="x86" (
|
|
||||||
set BUILD_VS_SVNDIR=windows_%BUILD_VS_LIBDIRPOST%
|
|
||||||
)
|
|
||||||
set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"
|
|
||||||
|
|
||||||
if NOT EXIST %BUILD_VS_LIBDIR% (
|
|
||||||
rem libs not found, but svn is on the system
|
|
||||||
if not "%HAS_SVN%"=="" (
|
|
||||||
echo.
|
|
||||||
echo The required external libraries in %BUILD_VS_LIBDIR% are missing
|
|
||||||
echo.
|
|
||||||
set /p GetLibs= "Would you like to download them? (y/n)"
|
|
||||||
if /I "!GetLibs!"=="Y" (
|
|
||||||
echo.
|
|
||||||
echo Downloading %BUILD_VS_SVNDIR% libraries, please wait.
|
|
||||||
echo.
|
|
||||||
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/%BUILD_VS_SVNDIR% %BUILD_VS_LIBDIR%
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if NOT EXIST %BUILD_VS_LIBDIR% (
|
|
||||||
echo Error: Path to libraries not found "%BUILD_VS_LIBDIR%"
|
|
||||||
echo This is needed for building, aborting!
|
|
||||||
goto EOF
|
goto EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%TARGET%"=="" (
|
call "%BLENDER_DIR%\build_files\windows\detect_architecture.cmd"
|
||||||
echo Error: Convenience target not set
|
|
||||||
echo This is required for building, aborting!
|
|
||||||
echo .
|
|
||||||
goto HELP
|
|
||||||
)
|
|
||||||
|
|
||||||
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%" %TESTS_CMAKE_ARGS%
|
if "%BUILD_VS_YEAR%" == "" (
|
||||||
if NOT EXIST %BUILD_DIR%\nul (
|
call "%BLENDER_DIR%\build_files\windows\autodetect_msvc.cmd"
|
||||||
mkdir %BUILD_DIR%
|
if errorlevel 1 (
|
||||||
)
|
echo Visual Studio not found ^(try with the 'verbose' switch for more information^)
|
||||||
if "%MUST_CLEAN%"=="1" (
|
goto EOF
|
||||||
echo Cleaning %BUILD_DIR%
|
|
||||||
msbuild ^
|
|
||||||
%BUILD_DIR%\Blender.sln ^
|
|
||||||
/target:clean ^
|
|
||||||
/property:Configuration=%BUILD_TYPE% ^
|
|
||||||
/verbosity:minimal ^
|
|
||||||
/p:platform=%MSBUILD_PLATFORM%
|
|
||||||
|
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
|
||||||
echo Cleaned "%BUILD_DIR%"
|
|
||||||
)
|
)
|
||||||
goto EOF
|
) else (
|
||||||
)
|
call "%BLENDER_DIR%\build_files\windows\detect_msvc%BUILD_VS_YEAR%.cmd"
|
||||||
REM Only configure on first run or when called with nobuild
|
if errorlevel 1 (
|
||||||
if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1
|
echo Visual Studio %BUILD_VS_YEAR% not found ^(try with the 'verbose' switch for more information^)
|
||||||
if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
|
|
||||||
|
|
||||||
if "%MUST_CONFIGURE%"=="1" (
|
|
||||||
cmake ^
|
|
||||||
%BUILD_CMAKE_ARGS% ^
|
|
||||||
-H%BLENDER_DIR% ^
|
|
||||||
-B%BUILD_DIR% ^
|
|
||||||
%BUILD_CMAKE_ARGS%
|
|
||||||
|
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
|
||||||
echo "Configuration Failed"
|
|
||||||
goto EOF
|
goto EOF
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if DEFINED MSVC_VC_DIR echo call "%MSVC_VC_DIR%\vcvarsall.bat" > %BUILD_DIR%\rebuild.cmd
|
|
||||||
if DEFINED MSVC_VS_DIR echo call "%MSVC_VS_DIR%\Common7\Tools\VsDevCmd.bat" > %BUILD_DIR%\rebuild.cmd
|
|
||||||
echo cmake . >> %BUILD_DIR%\rebuild.cmd
|
|
||||||
echo msbuild ^
|
|
||||||
%BUILD_DIR%\Blender.sln ^
|
|
||||||
/target:build ^
|
|
||||||
/property:Configuration=%BUILD_TYPE% ^
|
|
||||||
/maxcpucount:2 ^
|
|
||||||
/verbosity:minimal ^
|
|
||||||
/p:platform=%MSBUILD_PLATFORM% ^
|
|
||||||
/flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log >> %BUILD_DIR%\rebuild.cmd
|
|
||||||
echo msbuild ^
|
|
||||||
%BUILD_DIR%\INSTALL.vcxproj ^
|
|
||||||
/property:Configuration=%BUILD_TYPE% ^
|
|
||||||
/verbosity:minimal ^
|
|
||||||
/p:platform=%MSBUILD_PLATFORM% >> %BUILD_DIR%\rebuild.cmd
|
|
||||||
|
|
||||||
if "%NOBUILD%"=="1" goto EOF
|
call "%BLENDER_DIR%\build_files\windows\set_build_dir.cmd"
|
||||||
|
|
||||||
msbuild ^
|
echo Building blender with VS%BUILD_VS_YEAR% for %BUILD_ARCH% in %BUILD_DIR%
|
||||||
%BUILD_DIR%\Blender.sln ^
|
|
||||||
/target:build ^
|
|
||||||
/property:Configuration=%BUILD_TYPE% ^
|
|
||||||
/maxcpucount:2 ^
|
|
||||||
/verbosity:minimal ^
|
|
||||||
/p:platform=%MSBUILD_PLATFORM% ^
|
|
||||||
/flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log
|
|
||||||
|
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
call "%BLENDER_DIR%\build_files\windows\check_libraries.cmd"
|
||||||
echo "Build Failed"
|
if errorlevel 1 goto EOF
|
||||||
goto EOF
|
|
||||||
|
call "%BLENDER_DIR%\build_files\windows\check_submodules.cmd"
|
||||||
|
if errorlevel 1 goto EOF
|
||||||
|
|
||||||
|
if "%BUILD_WITH_NINJA%" == "" (
|
||||||
|
call "%BLENDER_DIR%\build_files\windows\configure_msbuild.cmd"
|
||||||
|
if errorlevel 1 goto EOF
|
||||||
|
|
||||||
|
call "%BLENDER_DIR%\build_files\windows\build_msbuild.cmd"
|
||||||
|
if errorlevel 1 goto EOF
|
||||||
|
) else (
|
||||||
|
call "%BLENDER_DIR%\build_files\windows\configure_ninja.cmd"
|
||||||
|
if errorlevel 1 goto EOF
|
||||||
|
|
||||||
|
call "%BLENDER_DIR%\build_files\windows\build_ninja.cmd"
|
||||||
|
if errorlevel 1 goto EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
msbuild ^
|
|
||||||
%BUILD_DIR%\INSTALL.vcxproj ^
|
|
||||||
/property:Configuration=%BUILD_TYPE% ^
|
|
||||||
/verbosity:minimal ^
|
|
||||||
/p:platform=%MSBUILD_PLATFORM%
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo At any point you can optionally modify your build configuration by editing:
|
|
||||||
echo "%BUILD_DIR%\CMakeCache.txt", then run "rebuild.cmd" in the build folder to build with the changes applied.
|
|
||||||
echo.
|
|
||||||
echo Blender successfully built, run from: "%BUILD_DIR%\bin\%BUILD_TYPE%\blender.exe"
|
|
||||||
echo.
|
|
||||||
goto EOF
|
|
||||||
:HELP
|
|
||||||
echo.
|
|
||||||
echo Convenience targets
|
|
||||||
echo - release ^(identical to the official blender.org builds^)
|
|
||||||
echo - full ^(same as release minus the cuda kernels^)
|
|
||||||
echo - lite
|
|
||||||
echo - headless
|
|
||||||
echo - cycles
|
|
||||||
echo - bpy
|
|
||||||
echo.
|
|
||||||
echo Utilities ^(not associated with building^)
|
|
||||||
echo - clean ^(Target must be set^)
|
|
||||||
echo - update
|
|
||||||
echo - nobuild ^(only generate project files^)
|
|
||||||
echo - showhash ^(Show git hashes of source tree^)
|
|
||||||
echo.
|
|
||||||
echo Configuration options
|
|
||||||
echo - with_tests ^(enable building unit tests^)
|
|
||||||
echo - noge ^(disable building game enginge and player^)
|
|
||||||
echo - debug ^(Build an unoptimized debuggable build^)
|
|
||||||
echo - packagename [newname] ^(override default cpack package name^)
|
|
||||||
echo - buildir [newdir] ^(override default build folder^)
|
|
||||||
echo - x86 ^(override host auto-detect and build 32 bit code^)
|
|
||||||
echo - x64 ^(override host auto-detect and build 64 bit code^)
|
|
||||||
echo - 2013 ^(build with visual studio 2013^)
|
|
||||||
echo - 2015 ^(build with visual studio 2015^) [EXPERIMENTAL]
|
|
||||||
echo - 2017 ^(build with visual studio 2017^) [EXPERIMENTAL]
|
|
||||||
echo.
|
|
||||||
|
|
||||||
:EOF
|
:EOF
|
||||||
|
@@ -74,6 +74,24 @@ class TriMesh:
|
|||||||
return me
|
return me
|
||||||
|
|
||||||
|
|
||||||
|
def object_material_colors(ob):
|
||||||
|
material_colors = []
|
||||||
|
color_default = (1.0, 1.0, 1.0, 1.0)
|
||||||
|
for slot in ob.material_slots:
|
||||||
|
material = slot.material
|
||||||
|
color = color_default
|
||||||
|
if material is not None and material.use_nodes:
|
||||||
|
node_tree = material.node_tree
|
||||||
|
if node_tree is not None:
|
||||||
|
color = next((
|
||||||
|
node.outputs[0].default_value[:]
|
||||||
|
for node in node_tree.nodes
|
||||||
|
if node.type == 'RGB'
|
||||||
|
), color_default)
|
||||||
|
material_colors.append(color)
|
||||||
|
return material_colors
|
||||||
|
|
||||||
|
|
||||||
def object_child_map(objects):
|
def object_child_map(objects):
|
||||||
objects_children = {}
|
objects_children = {}
|
||||||
for ob in objects:
|
for ob in objects:
|
||||||
@@ -89,24 +107,25 @@ def object_child_map(objects):
|
|||||||
return objects_children
|
return objects_children
|
||||||
|
|
||||||
|
|
||||||
def mesh_data_lists_from_mesh(me):
|
def mesh_data_lists_from_mesh(me, material_colors):
|
||||||
me_loops = me.loops[:]
|
me_loops = me.loops[:]
|
||||||
me_loops_color = me.vertex_colors.active.data[:]
|
me_loops_color = me.vertex_colors.active.data[:]
|
||||||
me_verts = me.vertices[:]
|
me_verts = me.vertices[:]
|
||||||
me_polys = me.polygons[:]
|
me_polys = me.polygons[:]
|
||||||
|
|
||||||
# 100 layers of depth
|
tris_data = []
|
||||||
me_polys.sort(key=lambda p: int(p.center.z * 100))
|
|
||||||
|
|
||||||
tris_coords = []
|
|
||||||
tris_colors = []
|
|
||||||
|
|
||||||
for p in me_polys:
|
for p in me_polys:
|
||||||
|
|
||||||
# Backface culling (allows using spheres without tedious manual deleting).
|
# Backface culling (allows using spheres without tedious manual deleting).
|
||||||
if p.normal.z <= 0.0:
|
if p.normal.z <= 0.0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
material_index = p.material_index
|
||||||
|
if material_index < len(material_colors):
|
||||||
|
base_color = material_colors[p.material_index]
|
||||||
|
else:
|
||||||
|
base_color = (1.0, 1.0, 1.0, 1.0)
|
||||||
|
|
||||||
l_sta = p.loop_start
|
l_sta = p.loop_start
|
||||||
l_len = p.loop_total
|
l_len = p.loop_total
|
||||||
loops_poly = me_loops[l_sta:l_sta + l_len]
|
loops_poly = me_loops[l_sta:l_sta + l_len]
|
||||||
@@ -130,22 +149,27 @@ def mesh_data_lists_from_mesh(me):
|
|||||||
v1 = me_verts[l1.vertex_index]
|
v1 = me_verts[l1.vertex_index]
|
||||||
v2 = me_verts[l2.vertex_index]
|
v2 = me_verts[l2.vertex_index]
|
||||||
|
|
||||||
tris_coords.append((
|
tris_data.append((
|
||||||
v0.co.xy[:],
|
# float depth
|
||||||
v1.co.xy[:],
|
p.center.z,
|
||||||
v2.co.xy[:],
|
# XY coords.
|
||||||
|
(
|
||||||
|
v0.co.xy[:],
|
||||||
|
v1.co.xy[:],
|
||||||
|
v2.co.xy[:],
|
||||||
|
),
|
||||||
|
# RGBA color.
|
||||||
|
tuple((
|
||||||
|
[int(c * b * 255) for c, b in zip(cn.color, base_color)]
|
||||||
|
for cn in (c0, c1, c2)
|
||||||
|
)),
|
||||||
))
|
))
|
||||||
# Color as RGBA for each tri
|
|
||||||
tris_colors.append(
|
|
||||||
[[int(c * 255) for c in cn.color] for cn in (c0, c1, c2)]
|
|
||||||
)
|
|
||||||
i1 = i2
|
i1 = i2
|
||||||
return (tris_coords, tris_colors)
|
return tris_data
|
||||||
|
|
||||||
|
|
||||||
def mesh_data_lists_from_objects(ob_parent, ob_children):
|
def mesh_data_lists_from_objects(ob_parent, ob_children):
|
||||||
tris_coords = []
|
tris_data = []
|
||||||
tris_colors = []
|
|
||||||
|
|
||||||
has_parent = False
|
has_parent = False
|
||||||
if ob_children:
|
if ob_children:
|
||||||
@@ -156,11 +180,15 @@ def mesh_data_lists_from_objects(ob_parent, ob_children):
|
|||||||
with TriMesh(ob) as me:
|
with TriMesh(ob) as me:
|
||||||
if has_parent:
|
if has_parent:
|
||||||
me.transform(parent_matrix_inverted * ob.matrix_world)
|
me.transform(parent_matrix_inverted * ob.matrix_world)
|
||||||
tris_coords_iter, tris_colors_iter = mesh_data_lists_from_mesh(me)
|
|
||||||
tris_coords.extend(tris_coords_iter)
|
tris_data.extend(
|
||||||
tris_colors.extend(tris_colors_iter)
|
mesh_data_lists_from_mesh(
|
||||||
|
me,
|
||||||
|
object_material_colors(ob),
|
||||||
|
)
|
||||||
|
)
|
||||||
has_parent = True
|
has_parent = True
|
||||||
return tris_coords, tris_colors
|
return tris_data
|
||||||
|
|
||||||
|
|
||||||
def write_mesh_to_py(fh, ob, ob_children):
|
def write_mesh_to_py(fh, ob, ob_children):
|
||||||
@@ -178,7 +206,11 @@ def write_mesh_to_py(fh, ob, ob_children):
|
|||||||
float_as_byte(v[1], coords_range_align[1]),
|
float_as_byte(v[1], coords_range_align[1]),
|
||||||
)
|
)
|
||||||
|
|
||||||
tris_coords, tris_colors = mesh_data_lists_from_objects(ob, ob_children)
|
tris_data = mesh_data_lists_from_objects(ob, ob_children)
|
||||||
|
|
||||||
|
# 100 levels of Z depth, round to avoid differences from precision error
|
||||||
|
# causing different computers to write triangles in more or less random order.
|
||||||
|
tris_data.sort(key=lambda data: int(data[0] * 100))
|
||||||
|
|
||||||
if 0:
|
if 0:
|
||||||
# make as large as we can, keeping alignment
|
# make as large as we can, keeping alignment
|
||||||
@@ -211,10 +243,10 @@ def write_mesh_to_py(fh, ob, ob_children):
|
|||||||
# X, Y
|
# X, Y
|
||||||
fw(bytes((0, 0)))
|
fw(bytes((0, 0)))
|
||||||
|
|
||||||
for tri_coords in tris_coords:
|
for (_, tri_coords, _) in tris_data:
|
||||||
for vert in tri_coords:
|
for vert in tri_coords:
|
||||||
fw(bytes(vert_as_byte_pair(vert)))
|
fw(bytes(vert_as_byte_pair(vert)))
|
||||||
for tri_color in tris_colors:
|
for (_, _, tri_color) in tris_data:
|
||||||
for color in tri_color:
|
for color in tri_color:
|
||||||
fw(bytes(color))
|
fw(bytes(color))
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user