1
1

Compare commits

...

2434 Commits

Author SHA1 Message Date
55ee66be4d Merge branch 'functions' into builtin-simulation-nodes 2020-04-09 12:02:02 +02:00
dabd59ba23 Merge branch 'master' into functions 2020-04-09 11:59:24 +02:00
726cf93f8a allow using shader texture nodes in simulation node tree 2020-04-06 14:11:28 +02:00
e2c567efe6 fix after merge 2020-04-06 11:22:43 +02:00
a96af79259 Merge branch 'functions' into builtin-simulation-nodes 2020-04-06 11:22:32 +02:00
43f895a592 Merge branch 'master' into functions 2020-04-06 11:10:19 +02:00
4783e80502 Merge branch 'functions' into builtin-simulation-nodes 2020-03-31 11:17:08 +02:00
52606afaa6 Merge branch 'master' into functions 2020-03-31 11:16:32 +02:00
54602b70f0 add switch node ui 2020-03-30 14:15:09 +02:00
b91b06b76e add a couple more node uis 2020-03-30 13:37:37 +02:00
ca5b24ce8e add Float Compare node 2020-03-30 13:19:18 +02:00
1189582e39 add boolean math node ui 2020-03-30 12:51:46 +02:00
5a0e84a6ce Merge branch 'functions' into builtin-simulation-nodes 2020-03-30 12:05:25 +02:00
cd5f9516db Merge branch 'master' into functions 2020-03-30 12:04:42 +02:00
62c33b67ef remove node on cancel 2020-03-23 13:28:15 +01:00
3881606540 put builtin node groups into menu 2020-03-23 13:17:01 +01:00
76082b0494 import node group loading 2020-03-23 12:50:51 +01:00
68bd8431cf some cleanup 2020-03-23 11:49:55 +01:00
6a6a7ebd50 move builtin node group code to separate file 2020-03-23 11:37:17 +01:00
ed30c8bf3a Merge branch 'functions' into builtin-simulation-nodes 2020-03-23 11:24:56 +01:00
8ce5c50411 Merge branch 'master' into functions 2020-03-23 11:22:59 +01:00
5a1970b625 install node groups directory 2020-03-21 13:48:20 +01:00
2218ade694 initial node group shipped with Blender 2020-03-21 13:48:06 +01:00
4ccd998657 restore node width 2020-03-21 13:47:04 +01:00
4e15afad9e improve node group comparison 2020-03-21 13:40:55 +01:00
3c92432593 fixes 2020-03-21 13:05:09 +01:00
cae00bde2a simple search to select node group to import 2020-03-21 12:58:10 +01:00
96a57d7c25 Merge branch 'functions' into builtin-simulation-nodes 2020-03-21 12:14:34 +01:00
37ee4d4e2a Merge branch 'master' into functions 2020-03-21 12:09:13 +01:00
cd4152c242 add ui for surface nodes 2020-03-19 16:34:10 +01:00
c836becf17 initial duplicate node tree avoidance 2020-03-19 15:51:56 +01:00
4713680eef initial import group template operator 2020-03-19 15:10:09 +01:00
f1de50b387 initial export node group operator 2020-03-19 14:58:52 +01:00
0b5f0a7e90 Merge branch 'functions' into builtin-simulation-nodes 2020-03-19 11:33:19 +01:00
d9356a5b8d Cleanup: make format after SortedIncludes 2020-03-19 11:22:15 +01:00
edd0928d09 Merge branch 'master' into functions 2020-03-19 11:19:05 +01:00
080b013ea4 add group nodes to menu 2020-03-16 16:11:21 +01:00
3ad939f82d add Float Math/Vector Math function nodes 2020-03-16 14:36:59 +01:00
064181a3d2 make Tab to edit node group work 2020-03-16 13:58:52 +01:00
dfa169be9c add data type property to Set Particle Attribute node 2020-03-16 13:36:01 +01:00
108fc6c8ac add data type property to Particle Attribute node 2020-03-16 13:28:20 +01:00
07766ddc6f add layout nodes to menu 2020-03-16 12:06:03 +01:00
f45c3832fe Merge branch 'functions' into builtin-simulation-nodes 2020-03-16 12:01:35 +01:00
0feed991e2 Merge branch 'master' into functions 2020-03-16 11:59:54 +01:00
04780894ed store pointer to image in image socket 2020-03-13 15:40:26 +01:00
7dd54b3858 add separate/combine xyz/rgb/hsv node uis 2020-03-13 15:14:35 +01:00
e8738f86dc Rename to Combine XYZ for consistency 2020-03-13 14:38:57 +01:00
494eac50b6 new Particle Attribute node ui 2020-03-13 14:10:03 +01:00
defdf63973 remove "Input" from name 2020-03-13 14:02:59 +01:00
41efb8f9ac Merge branch 'functions' into builtin-simulation-nodes 2020-03-13 13:57:42 +01:00
26e7498b0c Merge branch 'master' into functions 2020-03-13 13:55:58 +01:00
0f1f55e14b new simulation time input node ui 2020-03-12 15:18:13 +01:00
e1a1112c47 new Emit Particles node ui 2020-03-12 15:10:31 +01:00
cf4ba3b88c add Particle Mesh Collision Event node ui 2020-03-12 14:52:58 +01:00
e59f449f1a add particle mesh emitter node ui 2020-03-12 14:42:00 +01:00
38566d0e11 fix naming 2020-03-12 14:32:45 +01:00
50b8e605d4 Store pointer to object data block in object socket 2020-03-12 13:20:21 +01:00
51cea97d48 Merge branch 'functions' into builtin-simulation-nodes 2020-03-12 11:27:04 +01:00
4a8a7cc3ca Merge branch 'master' into functions 2020-03-12 11:16:44 +01:00
78d8e9f962 fix after merge 2020-03-09 15:30:52 +01:00
4f8b24e0c5 Merge branch 'master' into functions 2020-03-09 15:27:27 +01:00
268e5fd210 add first function node ui 2020-03-05 16:04:17 +01:00
47112042e0 add Object, Image and Surface Hook socket types 2020-03-05 14:38:51 +01:00
008d06d133 rename Custom Force node to just Force 2020-03-05 13:15:18 +01:00
35d28e47f0 new multi execute node 2020-03-05 13:10:48 +01:00
5fae03fec0 new execute condition node 2020-03-05 12:57:21 +01:00
3546519707 add mode property to particle time step event node 2020-03-05 12:42:33 +01:00
f01fa8c8a7 initial particle time step event node 2020-03-05 12:12:15 +01:00
454acfddfa remove socket that was used for testing only 2020-03-05 11:50:26 +01:00
fe178ae449 Merge branch 'functions' into builtin-simulation-nodes 2020-03-05 11:42:58 +01:00
8471b2f22e Merge branch 'master' into functions 2020-03-05 11:41:38 +01:00
3d2fafcfcc add Particle Birth Event node ui 2020-03-02 17:23:12 +01:00
67066b03ec add Set Particle Attribute node ui 2020-03-02 17:15:12 +01:00
84959e1e6a define input and output link limit on socket type 2020-03-02 17:05:47 +01:00
b8d4f81a14 allow multiple inputs in particle simulation node 2020-03-02 16:47:07 +01:00
d5b6dc8420 actually use socket link limit from template 2020-03-02 16:43:45 +01:00
a321c9a29a add custom force node ui 2020-03-02 16:33:03 +01:00
2fc1ac2eb0 cleanup 2020-03-02 16:32:44 +01:00
26d39077fb Merge branch 'functions' into builtin-simulation-nodes 2020-03-02 15:45:56 +01:00
743443ac14 fix after merge 2020-03-02 15:44:31 +01:00
7686f1a8fe Merge branch 'master' into functions 2020-03-02 15:36:29 +01:00
a687c1d70f make simulation node groups work 2020-03-02 13:05:32 +01:00
0791ab863a give sockets a default display shape 2020-03-02 12:44:45 +01:00
4132dc2452 add new builtin socket types 2020-03-02 12:34:38 +01:00
60fc5fc9f3 add first node using builtin node registration methods 2020-03-02 11:47:59 +01:00
b70040d7f9 Merge branch 'functions' into builtin-simulation-nodes 2020-03-02 11:01:59 +01:00
b350b85aba Merge branch 'master' into functions 2020-03-02 10:59:03 +01:00
174ceea93b initial simulation tree type 2020-02-28 14:05:46 +01:00
1fee5a3cb0 Merge branch 'functions' into builtin-simulation-nodes 2020-02-28 13:43:05 +01:00
87d20d7c92 remove leftovers from initial simulation node tree 2020-02-28 13:42:46 +01:00
1ea9e5437b Merge branch 'functions' into builtin-simulation-nodes 2020-02-28 13:34:12 +01:00
ee292426a7 Merge branch 'master' into functions 2020-02-28 13:31:11 +01:00
7cb2b2fa26 start laying out simulation node files 2020-02-28 13:27:03 +01:00
4ed7334ef6 Merge branch 'master' into functions 2020-02-28 09:01:15 +01:00
b92b1a4fe5 Use new LinearAllocatedVector in various places 2020-02-23 17:37:15 +01:00
096856a700 new LinearAllocatedVector<T>
This is a vector that does not own the memory its elements are stored in.
Instead, a linear allocator is passed to every call to `append`, that will
be used if the vector has to grow. Since a linear allocator does not support
deallocation, no memory is dealloced until the linear allocator is destructed.

This structure can be used when many small vectors of initially unknown
size are required.
2020-02-23 17:35:47 +01:00
beed795e5a Merge branch 'master' into functions 2020-02-23 15:25:05 +01:00
fcfe9784cb Merge branch 'master' into functions 2020-02-20 09:27:28 +01:00
3b1c34267b improve copying StringRef to new buffer 2020-02-19 11:49:03 +01:00
3fe710aeaf Merge branch 'master' into functions 2020-02-19 10:17:36 +01:00
6399bfcee3 add missing include 2020-02-17 15:32:19 +01:00
7f35aa99c7 Merge branch 'master' into functions 2020-02-17 15:07:46 +01:00
1945a23259 Merge branch 'master' into functions 2020-02-17 10:47:28 +01:00
fad8e475c7 remove UNUSED_FUNCTION_NDEBUG macro again 2020-02-16 12:45:25 +01:00
b80585ba30 remove unused code 2020-02-16 12:41:01 +01:00
ecc78d29d6 bring back more correct duplicate removal 2020-02-16 12:39:16 +01:00
4d74116218 initial MultiFunctionID 2020-02-15 17:55:18 +01:00
bd42f7c275 remove operation hash of functions, a more reliable system is necessary 2020-02-15 17:52:52 +01:00
e543c9ad32 add global sin and cos functions 2020-02-14 11:40:02 +01:00
bdd69570e2 make naming more consistent 2020-02-14 11:31:23 +01:00
3e533af702 make some functions more reusable 2020-02-14 11:29:49 +01:00
8363204347 use faster CPPType access 2020-02-14 11:03:32 +01:00
0e0f6a9216 provide faster access to builtin CPPTypes 2020-02-14 10:59:37 +01:00
2b83d33032 Merge branch 'master' into functions 2020-02-14 10:01:16 +01:00
4526aa70e5 remove unused timers 2020-02-13 19:01:28 +01:00
1df94f6257 remove obselete BLI_math_cxx.h file 2020-02-13 18:58:34 +01:00
9564cd045a remove lazy init code 2020-02-13 18:44:50 +01:00
de23a2c35b remove lazy init usage 2020-02-13 18:39:38 +01:00
fd46b5e9fe remove lazy init usage 2020-02-13 18:33:56 +01:00
10927b6747 fix allocator usage for StringMap 2020-02-13 18:33:42 +01:00
ba1fcdf41a give test node a poll function 2020-02-13 18:33:29 +01:00
9906e5313b remove usage of lazy init macro 2020-02-13 18:21:15 +01:00
2e1d18600f remove unused code 2020-02-13 18:16:31 +01:00
e4343f6aa2 add license headers 2020-02-13 18:08:38 +01:00
953b8d6066 cleanup 2020-02-13 17:59:32 +01:00
f943f4f99c move rgba_b and rgba_f to separate file 2020-02-13 17:59:05 +01:00
350bc04f56 move float3 -> float2 conversion to different file 2020-02-13 17:55:15 +01:00
9933b5bc27 move float4x4 into separate file 2020-02-13 17:53:03 +01:00
2e950e3b89 move float2 to separate file 2020-02-13 17:47:04 +01:00
bb4b0cc954 move float3 to separate file 2020-02-13 17:45:26 +01:00
1c81255cdb try socket decl in c++ 2020-02-13 15:07:02 +01:00
90b41c7c2f create socket in new node 2020-02-13 12:52:29 +01:00
2630b4c231 new node type for testing 2020-02-13 12:43:01 +01:00
630da3b5e3 Initial builtin simulation node tree type 2020-02-13 12:04:41 +01:00
a88db0aa7d fix warning 2020-02-13 11:53:15 +01:00
f72b3f33a0 define UNUSED_FUNCTION_NDEBUG macro 2020-02-13 11:53:05 +01:00
2c077e741d test commit with different email 2020-02-13 11:12:18 +01:00
94c410a5af Merge branch 'master' into functions 2020-02-13 11:07:28 +01:00
a2a8932981 cleanup 2020-02-12 20:32:48 +01:00
e4a3186aad fix after merge 2020-02-12 19:02:03 +01:00
dc89a3ec7c Merge branch 'master' into functions 2020-02-12 19:00:59 +01:00
b4bf6b9cc9 remove pad_up function 2020-02-10 16:23:14 +01:00
2d36836616 cleanup dot export 2020-02-10 14:46:44 +01:00
0b9888d038 fix after merge 2020-02-10 14:40:04 +01:00
43e2ca8fd1 Merge branch 'master' into functions 2020-02-10 14:23:37 +01:00
8cda8bef1e Merge branch 'master' into functions 2020-02-10 14:14:16 +01:00
ff21d33bfe Don't allow getting mutable reference to vector set 2020-02-10 13:32:02 +01:00
bae72c4b8e remove unused classes 2020-02-10 13:27:30 +01:00
23b52a1958 remove unused class 2020-02-10 13:24:46 +01:00
6218f315bb remove unused class 2020-02-10 12:58:20 +01:00
3f65050354 remove unused classes 2020-02-10 12:53:44 +01:00
f363ff348c remove temporary allocator 2020-02-10 12:42:24 +01:00
003dc7ffc9 fix after merge 2020-02-10 12:26:14 +01:00
605928c15b Merge branch 'master' into functions 2020-02-10 12:01:07 +01:00
9880bebd1a improve linear allocator 2020-02-10 11:47:17 +01:00
9677fbe029 rename MonotonicAllocator to LinearAllocator 2020-02-10 10:51:18 +01:00
6989f9be3d add StringRef.substr method 2020-02-10 09:53:33 +01:00
ce14c2c7bd store default value per CPPType 2020-02-06 16:44:32 +01:00
09149b4f0d Zero initialize before default construction to make it more deterministic 2020-02-06 15:42:08 +01:00
cb46cc6705 Merge branch 'master' into functions 2020-02-05 17:34:24 +01:00
8fa26bf7e1 disable duplicate removal 2020-02-05 10:26:33 +01:00
cf59daf62f fix killing particles 2020-02-04 16:48:46 +01:00
601ed4061a cleanup 2020-02-02 14:17:49 +01:00
6905633e57 fix generating operation hash
this needs some more work
2020-02-02 14:17:39 +01:00
79b3de9a63 assert data types when inserting links 2020-02-02 14:16:58 +01:00
975decb5e3 new Vector Length node 2020-02-02 14:16:21 +01:00
58ec7b44fe fix memory leak 2020-02-02 12:39:13 +01:00
57a063f599 new normalize vector node 2020-02-02 12:37:59 +01:00
d944146ebe fix stack use out of scope error 2020-02-02 12:26:37 +01:00
2e5ab9640e vectorize Map Range node 2020-02-02 12:26:11 +01:00
7c06e2e8d2 new ceil and floor float nodes 2020-02-02 11:43:33 +01:00
a20c781343 Merge branch 'master' into functions 2020-02-02 10:40:56 +01:00
599e8f7bb1 cleanup same size asserts 2020-02-01 11:58:50 +01:00
26f4fa9de7 utility to add input/output dummy nodes 2020-02-01 11:37:36 +01:00
e52941fe5b utility for printing arrays 2020-02-01 11:34:57 +01:00
337b918b92 missing value forwarding 2020-01-29 21:21:10 +01:00
323c20bbb7 remove unused data structure 2020-01-29 21:18:41 +01:00
a11b21f1eb Merge branch 'master' into functions 2020-01-29 21:14:40 +01:00
2430d76b1e Write to output buffer directly instead of doing a copy in the end 2020-01-29 21:05:07 +01:00
9e490d7cf5 make naming more specific 2020-01-29 19:07:23 +01:00
2929bc8d7e cleanup 2020-01-29 18:56:49 +01:00
a5470fe0ca cleanup 2020-01-29 18:47:51 +01:00
06ddde0daa new way to construct custom functions at compile time 2020-01-29 18:43:52 +01:00
477d15998c add utility function 2020-01-27 23:04:02 +01:00
e8ea904cee fix compile error 2020-01-27 23:03:54 +01:00
d17a352f23 Merge branch 'master' into functions 2020-01-27 22:13:42 +01:00
787f6c8a7e enable node tree optimizations 2020-01-27 22:05:55 +01:00
f6334efbd8 cleanup naming 2020-01-27 22:05:44 +01:00
3a27fb824e fix typo 2020-01-27 21:57:50 +01:00
a39dc76dec pass buffer cache to functions via context 2020-01-27 21:30:59 +01:00
3f29c1dd39 remove array allocator 2020-01-27 21:08:12 +01:00
b4a5df88fa try using BufferCache instead of ArrayAllocator 2020-01-27 21:07:03 +01:00
9c0cd8d7a3 cleanup 2020-01-27 16:36:26 +01:00
62bc3b2716 cleanup 2020-01-27 16:23:23 +01:00
fb953e0d8d restructure file 2020-01-27 16:04:48 +01:00
92b5b1fb69 cleanup naming 2020-01-27 15:59:41 +01:00
638a48885a cleanup 2020-01-27 15:41:10 +01:00
45619f2f2f cleanup 2020-01-27 15:40:24 +01:00
1824b8fb52 make single element execution work again 2020-01-26 21:56:41 +01:00
cbadf3e29a cleanup warning 2020-01-26 21:55:32 +01:00
e7a9d2ce96 cleanup 2020-01-26 21:00:34 +01:00
a5b08c1d95 minor improvement 2020-01-26 20:56:05 +01:00
0116cc1f4d fix 2020-01-26 20:54:09 +01:00
4141c905f3 cleanup 2020-01-26 20:50:02 +01:00
4202a208c2 compute dependency depths in network implementation 2020-01-26 20:39:41 +01:00
8c45804a1c initial deepest depth first heuristic 2020-01-26 17:26:45 +01:00
97b6d31f41 use new network evaluation storage 2020-01-26 13:16:43 +01:00
24724b70f0 new network evaluation storage (unused so far) 2020-01-26 12:32:11 +01:00
8667a87134 Revert "try storing values per input differently"
This reverts commit fee675ffe0.
2020-01-26 11:06:54 +01:00
fee675ffe0 try storing values per input differently 2020-01-23 16:02:24 +01:00
ce3ec2f172 remove print 2020-01-23 16:01:55 +01:00
3ad9ccaba7 initial array allocator 2020-01-23 15:15:29 +01:00
dae7527f4f Merge branch 'master' into functions 2020-01-23 14:31:59 +01:00
9f63f863f1 Merge branch 'master' into functions 2020-01-23 12:34:12 +01:00
83d5b3be12 disable optimizations 2020-01-19 12:44:21 +01:00
2e28fc0dd6 cleanup 2020-01-19 12:31:07 +01:00
c5868657aa support for deduplicating many more functions 2020-01-19 12:24:12 +01:00
04bfe684c9 rename 2020-01-19 12:06:24 +01:00
e1a5d15d95 set more operation hashes 2020-01-19 12:05:54 +01:00
00b1399593 deduplicate Particle Attribute node 2020-01-19 11:47:56 +01:00
85c43fbd2e store a random hash per type 2020-01-19 11:47:43 +01:00
65237b2346 support deduplicating vectorized nodes 2020-01-19 11:39:00 +01:00
35af9ecd3d support deduplicating all math nodes 2020-01-19 11:35:22 +01:00
32b02c13d8 operation hash for converters 2020-01-19 11:10:34 +01:00
bf74ef2e40 should not iterate over array that is being changed 2020-01-19 11:10:18 +01:00
b40bdad104 utility to generate constant random numbers per line 2020-01-19 10:57:14 +01:00
ea5fa56ca9 disable optimizations for now 2020-01-18 20:15:20 +01:00
0db9e85a7a replace Vector.index with Vector.index_try 2020-01-18 20:10:53 +01:00
5697fd53f2 implement initial Remove Duplicates optimization 2020-01-18 20:03:10 +01:00
4afdb40b4e set operation hash for some functions 2020-01-18 20:00:14 +01:00
296fd08875 support for storing operation hash per function 2020-01-18 19:59:40 +01:00
03f51bf4e1 add utilities to MFNetworkBuilder 2020-01-18 19:59:01 +01:00
a73b17564c fix Vector.remove_first_occurrence_and_reorder 2020-01-18 19:58:37 +01:00
2b0041e4dd new Optional.set_new methods 2020-01-18 19:58:28 +01:00
7dad14ae79 simplify constant folding 2020-01-18 18:20:16 +01:00
40bac586dc improve naming 2020-01-18 17:54:54 +01:00
f439518781 Merge branch 'functions' into network-builder-refactor 2020-01-18 17:24:13 +01:00
ed89a010cb Merge branch 'master' into functions 2020-01-18 17:23:52 +01:00
0982fdccd9 fix alignment in BLI::Optional 2020-01-16 21:59:00 +01:00
d8ca0ea86d cleanup dead node elimination 2020-01-11 17:15:52 +01:00
f6c377aa5b remove unused nodes optimization 2020-01-11 16:35:35 +01:00
4684b69405 give nodes and sockets an id again 2020-01-11 16:09:06 +01:00
d46ac7934a add utility to debug allocated amount in monotonic allocator 2020-01-11 15:56:37 +01:00
238059ac2a store network more compactly 2020-01-11 15:51:06 +01:00
41df03637e store data in network builder more compactly 2020-01-11 15:34:52 +01:00
090ae9aefe avoid unnecessary type casting 2020-01-11 14:09:09 +01:00
6aa7a269ae remove nodes after constant folding 2020-01-11 13:21:18 +01:00
8ddf71d880 initial network builder refactor to enable support for removing nodes 2020-01-11 12:59:37 +01:00
2d7fee45d6 add method to access all nodes 2020-01-11 10:40:26 +01:00
d54eebbfa7 support constant folding for vectors 2020-01-09 17:41:10 +01:00
f1fc372df1 move constant functions to separate file 2020-01-09 17:20:33 +01:00
c8afdc93f9 Merge branch 'master' into functions 2020-01-09 17:09:36 +01:00
c2c6d152ad Merge branch 'master' into functions 2020-01-05 16:37:20 +01:00
66fdcd5f33 minor fixes 2020-01-04 16:38:09 +01:00
e3ee421314 better to string conversion for generic types 2020-01-04 16:21:03 +01:00
83308760a2 initial constant folding of multi function network 2020-01-04 16:07:59 +01:00
f526c8d303 rename Stack.empty to Stack.is_empty 2020-01-04 14:42:39 +01:00
d95b52f1c9 cleanup link insertion 2020-01-04 14:25:53 +01:00
6b9e7dc585 simplify conversion insertion 2020-01-04 13:59:39 +01:00
bc48280fed refactor: extract methods 2020-01-04 13:42:39 +01:00
7a931deab2 simplify names 2020-01-04 13:37:27 +01:00
b7f6be1b8b simplify names 2020-01-04 13:27:56 +01:00
9c20241272 simplify names 2020-01-04 13:26:17 +01:00
b2fb025153 rename FunctionNodeTree to FunctionTree 2020-01-04 13:24:29 +01:00
5e49e3df6e move code into sub namespace 2020-01-04 13:23:35 +01:00
5bbc1b2e16 refactor: initial removal of FunctionTreeMFNetworkBuilder 2020-01-04 13:17:33 +01:00
ea9282cbd6 extract class for managing the socket mapping 2020-01-03 15:02:41 +01:00
2c68bb3e51 cleanup naming 2020-01-03 14:43:00 +01:00
c505fc4d23 cleanup naming 2020-01-03 14:41:18 +01:00
4063e6c058 extract actual build step from builder 2020-01-03 14:30:47 +01:00
be23e6e2f2 extract members from builder 2020-01-03 14:21:17 +01:00
b7a8ef4b9f replace IdMultiMap with more generic IndexToRefMultiMap 2020-01-03 14:16:58 +01:00
1934749029 cleanup 2020-01-03 13:44:54 +01:00
35aaf2fe51 use IndexToRefMap instead of IndexMap 2020-01-03 13:40:31 +01:00
9c2e7a4e1c only map dummy sockets when function network has been created 2020-01-03 13:17:37 +01:00
e083ab2d02 remove unused method 2020-01-03 12:51:12 +01:00
2b00e17124 extract IdMultiMap data structure 2020-01-03 12:44:41 +01:00
089ee94b88 add missing hash function 2020-01-03 12:06:22 +01:00
ab3498b057 Merge branch 'master' into functions 2020-01-03 11:39:41 +01:00
7d4fb6880e use BLI::parallel_for when creating tetrahedons 2020-01-02 17:14:30 +01:00
d238e6410f improve copying of generic data 2020-01-02 17:09:02 +01:00
187844f712 use StringMultiMap in more places 2020-01-02 16:37:17 +01:00
6732a03531 introduce StringMultiMap 2020-01-02 16:28:55 +01:00
8753f92cb2 utility to iterate over string map in parallel 2020-01-02 16:05:41 +01:00
0ebb98ab3d cleanup 2020-01-02 15:49:41 +01:00
30b50638a0 rename index_iterator to index_range 2020-01-02 15:22:20 +01:00
25fc970f44 move tbb wrappers to blenlib 2020-01-02 15:20:44 +01:00
1e2401a5ff more parallelization 2020-01-02 15:12:26 +01:00
2025065931 simulate particles in parallel 2020-01-02 14:58:39 +01:00
169bdd890f extract method 2020-01-02 14:43:46 +01:00
ecfed4d70f cleanup parallel for/invoke 2020-01-02 14:39:52 +01:00
8a8223c193 cleanup parallel for 2020-01-02 14:36:07 +01:00
1273af1bdd simulate particle systems in parallel 2020-01-02 14:31:38 +01:00
3e325b42bb run emitters in parallel 2020-01-02 14:23:12 +01:00
f12b544515 new multi map implementation that can deal with non trivial types 2020-01-02 14:06:21 +01:00
fb512bfa3d initial working version with ParticleSet 2020-01-02 13:18:12 +01:00
0099355bc6 continue with ParticleSet 2019-12-31 16:48:01 +01:00
799fb759a7 improve particle set 2019-12-31 15:35:08 +01:00
0cda96f1be initial particle set 2019-12-31 14:59:58 +01:00
c2d3708224 introduce MutableAttributesRef 2019-12-31 14:59:48 +01:00
36221652a4 rename various types and variables 2019-12-31 14:17:44 +01:00
7ed83e0bee Move inlined node tree to functions folder 2019-12-31 13:53:48 +01:00
06e7d91f55 Merge branch 'master' into functions 2019-12-31 13:40:45 +01:00
4e0c2a8abd Merge branch 'master' into functions 2019-12-30 13:35:53 +01:00
04c0c92f87 use less generic tbb include 2019-12-28 13:28:06 +01:00
ad58b620b2 make surface hooks work in function deform/points modifiers 2019-12-28 12:23:17 +01:00
d7f18db74a fix evaluation of single input math function with constant input 2019-12-28 12:13:09 +01:00
1eca32bb84 improve usage of TBB 2019-12-28 11:29:34 +01:00
4601ea8f82 Merge branch 'master' into functions 2019-12-28 11:13:44 +01:00
bf4f376060 simplify some names 2019-12-22 15:04:13 +01:00
ee8dfc0062 replace time span with float interval 2019-12-22 14:21:25 +01:00
335b5bc540 cleanup influences collector 2019-12-22 13:53:24 +01:00
7250dfeb2e cleanup 2019-12-22 13:44:27 +01:00
feb938dfb8 remove task c++ wrapper in favor of tbb 2019-12-22 13:42:46 +01:00
4b8cd2cebd use tbb for parallel code 2019-12-22 13:22:55 +01:00
64b707eb67 use IndexMask in more places 2019-12-22 12:48:55 +01:00
f85c4ca3ae cleanup 2019-12-22 12:40:44 +01:00
a80ffa4bc5 cleanup usage of IndexMask 2019-12-22 12:37:42 +01:00
866894454f use IndexMask in more places 2019-12-22 12:32:43 +01:00
717beed8d7 cleanup naming 2019-12-22 12:26:34 +01:00
03dbcd82a4 cleanup naming 2019-12-22 11:10:54 +01:00
9c68e2ecc9 speedup multi function evaluation 2019-12-22 10:58:28 +01:00
b4b25eac9a access event filter duration in node tree 2019-12-20 17:43:13 +01:00
bed1a7cdb7 change some pointers to references 2019-12-20 17:09:23 +01:00
6600c532c4 change particle function evaluation api 2019-12-20 17:01:14 +01:00
81573c53b6 replace compare node 2019-12-20 16:43:04 +01:00
d00557bd19 use IndexMask in more places 2019-12-20 16:37:50 +01:00
dca21ef42f start improving custom events 2019-12-20 16:19:38 +01:00
70ada64a98 use index mask in event interface 2019-12-20 15:44:47 +01:00
d40031df15 remove event storage concept 2019-12-20 15:39:17 +01:00
adfd43db6b new Node Instance Identifier node 2019-12-20 15:22:21 +01:00
aabe38f06c change names displayed in search 2019-12-20 15:03:10 +01:00
a183cc3c4e handle not-found linked groups better 2019-12-20 14:59:33 +01:00
3b65445f4e Merge branch 'master' into functions 2019-12-20 14:21:54 +01:00
a549241728 bring back functionality of old actions 2019-12-19 15:52:10 +01:00
b3c93cfe90 initial ParticleAction class 2019-12-19 14:59:43 +01:00
35ee68ab69 fix when there is no nodelib 2019-12-19 14:58:11 +01:00
6caf9be863 remove variation input of age reached node 2019-12-19 14:35:40 +01:00
1b6e9574a6 leave group when active node is not selected 2019-12-19 14:14:26 +01:00
e8990fd220 cache node group names in .blend file 2019-12-19 13:21:06 +01:00
a1f79adde9 improve debug dot output 2019-12-19 13:17:38 +01:00
6cc8f3cd71 remove builtin group nodes 2019-12-19 13:11:33 +01:00
3c519d4917 new Join Text List node 2019-12-19 12:58:07 +01:00
9d885235eb better float3 printing 2019-12-19 12:38:37 +01:00
e97a45ef8c replace Kill Particle node with group 2019-12-19 12:24:51 +01:00
74eeb7a759 improve debug dot output 2019-12-19 12:12:24 +01:00
ed64bcfb71 remove Particle Info node 2019-12-19 11:53:30 +01:00
c78896e675 cleanup 2019-12-19 11:47:43 +01:00
aae54f903c fix path filter 2019-12-19 11:46:33 +01:00
98376bc8ee automatically load node groups from nodelib 2019-12-19 11:41:21 +01:00
150d76aa7b handle unknown node better 2019-12-19 11:24:38 +01:00
3d4f0fe7fe remove mockup nodes 2019-12-19 11:17:23 +01:00
e733615650 remove actions that can be build as node groups 2019-12-19 10:52:12 +01:00
54fe936849 remove unused action 2019-12-19 10:37:21 +01:00
136ac83c82 change IndexMask constructor 2019-12-19 10:37:13 +01:00
7b0ddb2420 replace MFMask with IndexMask 2019-12-19 10:11:31 +01:00
717283c038 Merge branch 'master' into functions 2019-12-19 09:49:43 +01:00
15c15d95e9 fix missing include 2019-12-18 15:21:26 +01:00
f72a4ab0af Remove Explode Particle node 2019-12-18 15:03:15 +01:00
a7ce3fc324 use Tab to open/close groups 2019-12-18 14:59:27 +01:00
7329734ec2 fix file load error 2019-12-18 14:59:09 +01:00
545e1b60f1 implement start-stop mode in Float Range node 2019-12-18 13:53:16 +01:00
5c90bec61e simplify socket identifiers 2019-12-18 13:38:51 +01:00
ec6fc1aaec support for inserting group nodes from search 2019-12-18 13:34:26 +01:00
17d18351c6 extract method to find callable trees 2019-12-18 13:17:49 +01:00
1c7e0b1755 improve node layout of group nodes 2019-12-18 13:11:48 +01:00
9fa91b8719 support for sampling random vectors in a sphere 2019-12-18 13:04:45 +01:00
c6cf1082cb new Multiply Vector with Float node 2019-12-18 12:53:02 +01:00
68b8979137 new Vector from Value node 2019-12-18 12:39:02 +01:00
4c5332cae7 new Random Vectors node 2019-12-18 12:31:19 +01:00
ceb5471884 improve Random Vector node 2019-12-18 12:11:02 +01:00
375ac4f37a new Random Vector node 2019-12-18 11:42:42 +01:00
06adff95b4 cleanup Spawn Particles node 2019-12-18 11:18:55 +01:00
6bb09a50fb support for computing vectors per particle 2019-12-18 11:06:55 +01:00
298b0cd863 Remove Action Context concept for now 2019-12-18 10:04:53 +01:00
e810f4dd7b Merge branch 'master' into functions 2019-12-18 09:54:06 +01:00
2d1cd3076f fix missing update 2019-12-17 15:05:39 +01:00
ced689a43a new Random Floats node 2019-12-17 14:48:05 +01:00
d16d58e6f9 show position attribute by default 2019-12-17 13:52:45 +01:00
79c5b4d4af fix socket drawing 2019-12-17 13:36:53 +01:00
ccc8d664fc initial Spawn Action node 2019-12-17 13:28:38 +01:00
71124e192f minor changes 2019-12-17 13:27:49 +01:00
e1e1069b45 initial spawn node ui 2019-12-17 12:04:09 +01:00
57ab7cefdd introduce ScopedVector 2019-12-17 11:48:33 +01:00
bd5be7c70a Rename TemporaryVector/Array to LargeScopedVector/Array 2019-12-17 11:40:26 +01:00
0144b11673 Support inline storage in BLI::Array 2019-12-17 11:35:13 +01:00
ae44dad2e1 cleanup 2019-12-17 11:18:25 +01:00
c03bb9db0d store name of node and sockets in dummy node 2019-12-17 11:13:00 +01:00
1fd9485a51 set dot background color utility 2019-12-17 11:12:19 +01:00
54229b8e82 support for removing execute sockets 2019-12-17 10:39:32 +01:00
eba730f986 Simplify execute socket naming 2019-12-17 10:09:25 +01:00
fba5b503f5 fix after merge 2019-12-17 09:46:17 +01:00
9a3b370061 Merge branch 'master' into functions 2019-12-17 09:34:13 +01:00
2b84a7d5b0 fix wrong comparison 2019-12-14 18:33:39 +01:00
f31dc22ebb fix some warnings 2019-12-14 18:25:42 +01:00
34d06de0dc remove some old tests 2019-12-14 18:07:18 +01:00
b6945930e8 remove unused functionality 2019-12-14 17:57:19 +01:00
67724f884a use new indices functions 2019-12-14 17:50:33 +01:00
b52c4ddfb9 more low level generic CPPType functions 2019-12-14 17:44:56 +01:00
617ab7847f add more functions to CPPType 2019-12-14 17:16:05 +01:00
2225dab801 optimize fill operation 2019-12-14 17:06:07 +01:00
e1a662ee3a optimize float range 2019-12-14 16:53:51 +01:00
f0cb97c9a3 cleanup 2019-12-14 16:49:21 +01:00
5419ae4d83 optimize generic extend operation 2019-12-14 16:19:16 +01:00
fc30d4e272 support for removing sockets in Select node 2019-12-14 15:36:00 +01:00
21ebaf9bc6 initial Select node 2019-12-14 15:28:13 +01:00
a1b0d7e982 print warning when inputs incorrectly depend on particles 2019-12-14 14:46:40 +01:00
510da24778 keep track of contexts used by function network 2019-12-14 14:46:21 +01:00
2646b9016f more utility functions for vector and stack 2019-12-14 14:45:37 +01:00
cd2385f608 refactor signature builder 2019-12-14 14:02:33 +01:00
5381fbc1a3 turn attribute name into an input socket 2019-12-14 13:15:28 +01:00
d720463300 support nicer drawing of sockets 2019-12-14 12:18:17 +01:00
776562623c new Multi Execute node 2019-12-14 11:35:27 +01:00
8a41c15bf9 prevent trails and explosion in a the same particle system 2019-12-14 11:29:49 +01:00
46b29a75a0 remove unused code 2019-12-14 11:10:55 +01:00
984ba7e943 Merge branch 'master' into functions 2019-12-14 11:02:49 +01:00
764857eb37 fix: find IDs used by output sockets as well 2019-12-13 19:42:49 +01:00
dc0d0d3936 Merge branch 'master' into functions 2019-12-13 19:40:19 +01:00
5c83319029 new Find Non Close Points node 2019-12-12 18:28:14 +01:00
d7d365f6eb new Get List Elements node 2019-12-12 15:34:53 +01:00
b716661366 support for vertex weights in Sample Object Surface node 2019-12-12 14:59:39 +01:00
4de6eafba3 sample hooks on surface 2019-12-12 13:05:08 +01:00
ee52b2f7d8 Merge branch 'master' into functions 2019-12-12 11:17:04 +01:00
6d3cd34bd5 fix compile error 2019-12-11 17:13:16 +01:00
df783a4ee1 access emitter time info in node tree 2019-12-11 16:32:48 +01:00
4d72f25e9a make vertex group name an input socket 2019-12-11 16:05:47 +01:00
5d8036c675 access position and normal directly in Closest surface hook node 2019-12-11 15:50:06 +01:00
03bde25be9 fix context in vectorized functions 2019-12-11 15:27:53 +01:00
3a1aec54a7 cleanup 2019-12-11 15:20:21 +01:00
2a25a0bd60 cleanup 2019-12-11 15:08:54 +01:00
a080464e31 extract function vectorizer to separate file 2019-12-11 15:03:19 +01:00
95e0ea69a2 extract customizable functions into separate file 2019-12-11 14:59:14 +01:00
a678e0df39 remove unused code 2019-12-11 14:55:32 +01:00
5d686b19a5 extract particle input functions from others 2019-12-11 14:52:48 +01:00
a908d95d9f extract surface hook functions to separate file 2019-12-11 14:48:40 +01:00
423060ac2f optimize closest surface hook on object node 2019-12-11 14:37:36 +01:00
fa942b5e6f optimize get weight on surface 2019-12-11 14:24:32 +01:00
f4a9e125bf optimize get normal on surface node 2019-12-11 14:16:10 +01:00
642fa43b13 optimize get position on surface node 2019-12-11 14:10:55 +01:00
e60516bdee cleanup 2019-12-11 14:03:13 +01:00
980b128b37 cleanup 2019-12-11 14:00:39 +01:00
bd92ed7e11 optimize single value case 2019-12-11 13:58:08 +01:00
bf85e6a637 improve grouping of similar indices 2019-12-11 13:53:53 +01:00
35989c6715 convert image to socket 2019-12-11 13:01:55 +01:00
aa10876c62 vectorize surface hook nodes 2019-12-11 12:18:56 +01:00
6dd8723620 fix memory leak 2019-12-11 11:42:30 +01:00
e985b20a77 more generic way to add per element and global contexts 2019-12-11 11:36:40 +01:00
d6f8ebf1f0 Merge branch 'master' into functions 2019-12-11 10:52:23 +01:00
28c554ec27 initial static class id system 2019-12-11 10:50:08 +01:00
eaa0c567fc make element contexts non virtual 2019-12-11 10:21:44 +01:00
9e056e8fd4 Merge branch 'master' into functions 2019-12-11 09:10:17 +01:00
73ed33953a don't register keymap in background mode 2019-12-11 00:10:44 +01:00
032c685472 fix endless recursion 2019-12-10 23:42:03 +01:00
a7d26bdc33 add external data cache to emitter function 2019-12-10 23:32:18 +01:00
5685b0a72a support for accessing id data blocks from emitter function 2019-12-10 23:26:45 +01:00
5dada6b465 new birth time modes for custom emitter 2019-12-10 23:20:50 +01:00
b93d0f8975 support for removing sockets in custom emitter 2019-12-10 22:59:47 +01:00
60b3fc8239 better handling of attribute name collisions 2019-12-10 22:53:32 +01:00
f961ef3e6b improve ui of Custom Emitter node 2019-12-10 22:52:54 +01:00
d91b7625cf fix warning 2019-12-10 18:19:23 +01:00
4df45d1c4c initial Custom Emitter node 2019-12-10 18:12:51 +01:00
826a132791 support nested properties in inferencer 2019-12-10 16:46:31 +01:00
24a7851fbe new Value node 2019-12-10 16:06:32 +01:00
daf119f2a7 initial support for custom particle attributes 2019-12-10 15:30:42 +01:00
4dccb3767a optimize some math nodes 2019-12-10 14:30:07 +01:00
ea5f871d29 deduplicate code 2019-12-10 14:17:55 +01:00
4755ab5b50 optimize variadic math functions 2019-12-10 14:05:31 +01:00
6d05b0910a optimize math functions a bit 2019-12-10 13:15:01 +01:00
e5f9640223 remove some timers 2019-12-10 11:47:05 +01:00
32c25e8c89 Merge branch 'master' into functions 2019-12-10 11:29:00 +01:00
4e4d350967 remove timer 2019-12-08 23:01:28 +01:00
2ce315c588 avoid computing the computing the same things many times 2019-12-08 23:01:21 +01:00
34d68139ac extend single elements when necessary 2019-12-08 22:01:31 +01:00
b09c2c7d00 Merge branch 'master' into functions 2019-12-08 21:31:53 +01:00
a382054837 Merge branch 'master' into functions 2019-12-07 11:01:54 +01:00
56dce4ae43 initital check for whether a function can be called once only 2019-12-06 13:55:03 +01:00
2390af8430 move class from header to cc 2019-12-06 13:34:52 +01:00
7c03565594 add utility to check if an input is only a single value 2019-12-06 13:30:10 +01:00
e93fe105d1 cleanup 2019-12-06 13:01:11 +01:00
de56346eee extract methods 2019-12-06 12:58:01 +01:00
a5790756e0 extract methods 2019-12-06 12:50:54 +01:00
94a280cb99 cleanup 2019-12-06 12:42:58 +01:00
039a1134cd cleanup data copying in network evaluation 2019-12-06 12:39:03 +01:00
ce35f42c0a simplify forwarding in network evaluation 2019-12-06 12:27:41 +01:00
6ec5ece968 cleanup naming 2019-12-06 11:50:10 +01:00
29106bdaee simplify allocation in multi function network evaluation 2019-12-06 11:48:40 +01:00
98d9f2bdfa store whether function depends on per element context 2019-12-06 11:35:34 +01:00
1996429dc6 Merge branch 'master' into functions 2019-12-06 11:25:26 +01:00
e1e1dad668 Merge branch 'master' into functions 2019-12-05 20:00:52 +01:00
d3dbacea08 open group interface panel from V pie menu 2019-12-05 14:14:36 +01:00
293c476822 initial support for reordering group inputs 2019-12-05 13:58:38 +01:00
e57a0ec211 handle other socket types in operator 2019-12-05 13:14:23 +01:00
95b2871550 make it easier to create group outputs 2019-12-05 13:10:35 +01:00
d4d0360604 better default value initialization 2019-12-05 12:47:58 +01:00
eb9f980912 initial V shortcut to create group inputs 2019-12-05 12:43:41 +01:00
dd452a314a improve group node ui 2019-12-05 11:21:24 +01:00
ab678735ab Merge branch 'master' into functions 2019-12-05 09:55:13 +01:00
c44fdcfab2 fix node identifier when node is in a group 2019-12-04 17:10:31 +01:00
d5ec476e36 simplify influence generation from xnodes 2019-12-04 16:42:04 +01:00
985e3e8ddc simplify action building code 2019-12-04 16:03:15 +01:00
f101aa6c4b fix naming after recent refactor 2019-12-04 15:32:30 +01:00
ee58e62f23 rename Surface Location to Surface Hook 2019-12-04 15:04:10 +01:00
db26a32601 store emit location in particles 2019-12-04 14:27:11 +01:00
2012ea2e9d add id handle lookups to function modifiers 2019-12-04 13:49:24 +01:00
c6a00f46ad pass around Object handles instead of pointers 2019-12-04 13:33:49 +01:00
907f72d4bc initial IDHandle implementation 2019-12-04 13:21:05 +01:00
182a56e3b0 improve SurfaceLocations members 2019-12-04 12:17:22 +01:00
e5e295beed fix when having emitter in node group 2019-12-04 11:53:15 +01:00
672b085264 Merge branch 'master' into functions 2019-12-04 11:33:48 +01:00
d709399b64 new Get Normal on Surface node 2019-12-03 16:00:02 +01:00
7fb768e2c4 cleanup: remove unused class 2019-12-03 15:17:38 +01:00
f6e39cc95d add StringMap.add method 2019-12-03 15:11:46 +01:00
4127c7ff87 make execute and influence sockets work in groups 2019-12-03 15:07:40 +01:00
90529a8d4d Merge branch 'master' into functions 2019-12-03 11:55:39 +01:00
9c102058e1 new Get Image Color on Surface node 2019-12-03 11:51:47 +01:00
9e8f68f4fa remove concept of particle function inputs from code 2019-11-30 15:34:38 +01:00
f9f6ab0251 remove remaining particle input nodes 2019-11-30 15:17:59 +01:00
a4cc5f1cbb make Is In Group a normal multi-function 2019-11-30 15:14:10 +01:00
d7b991aeb7 remove Particle Randomness node 2019-11-30 14:40:07 +01:00
f71eec7604 remove Surface Weight node 2019-11-30 14:38:01 +01:00
710c3b8312 new Get Weight on Surface node 2019-11-30 14:36:19 +01:00
a561a457dc initial Get Position on Surface node 2019-11-30 13:30:34 +01:00
945a752902 update closest location on object node 2019-11-27 18:15:48 +01:00
28a70ff15c new surface location data type 2019-11-27 17:06:58 +01:00
98a4a08fce various automated variable renamings 2019-11-27 16:06:55 +01:00
ea0b7dc6d1 make multifunction generation work with inlined node trees 2019-11-27 15:47:40 +01:00
a57e050f43 cleanup creation of group input nodes 2019-11-27 15:46:10 +01:00
49c3eb8478 replace virtual with inlined tree 2019-11-27 14:42:15 +01:00
529987089d Merge branch 'master' into functions 2019-11-27 10:19:26 +01:00
ceca20b798 color exported dot clusters randomly 2019-11-26 17:52:29 +01:00
02aef365ba add some noinline attributes 2019-11-26 17:26:53 +01:00
0a667c6614 cleanup 2019-11-26 17:12:06 +01:00
cfac0f5914 refactor: extract method 2019-11-26 17:10:46 +01:00
d33d8f5b20 refactor: extract methods 2019-11-26 17:01:39 +01:00
70fe3d8dea extract functions 2019-11-26 16:52:58 +01:00
288b562e46 cleanup 2019-11-26 16:41:31 +01:00
021650c4c0 cleanup 2019-11-26 16:34:28 +01:00
352afcd0b3 use array instead of map 2019-11-26 16:14:34 +01:00
413af94fd2 deduplicate node creation 2019-11-26 16:03:25 +01:00
4ade6cdfc0 initialize ids of xnodes 2019-11-26 15:33:38 +01:00
d148d2a447 free memory of inlined node tree 2019-11-26 15:27:27 +01:00
5d42b6a204 add accessor functions for inlined node tree 2019-11-26 13:30:10 +01:00
97a5f427d0 add clusters to inlined node tree dot export 2019-11-26 13:13:46 +01:00
48f2f3cea6 change cluster usage in dot exporter 2019-11-26 12:57:47 +01:00
abe3c18cf6 Merge branch 'master' into functions 2019-11-26 10:40:54 +01:00
0e1a4f39ac use generic dot export to export function networks 2019-11-24 15:24:46 +01:00
a4cf1eb035 export inlined node tree as dot graph 2019-11-24 14:58:43 +01:00
c0d0aff4da import dot export 2019-11-24 13:56:34 +01:00
8ae3debad0 node shape utility 2019-11-24 13:30:28 +01:00
0fea5c5d59 dot file export 2019-11-24 12:55:58 +01:00
afe4577256 initial InlinedNodeTree structure 2019-11-23 18:04:56 +01:00
1f52afb3fd new Vector.remove_first_occurence_and_reorder method 2019-11-23 17:25:41 +01:00
f63d9357bf new Vector.append_and_get_index function 2019-11-23 14:57:27 +01:00
2780bb1000 Merge branch 'master' into functions 2019-11-23 13:55:40 +01:00
0a7e29739d Merge branch 'master' into functions 2019-11-21 15:55:44 +01:00
89335330fa simplify some code 2019-11-21 15:42:06 +01:00
5c316f0910 remove unused code 2019-11-21 15:12:27 +01:00
47e7a8966e cleanup nodes mapping 2019-11-21 15:10:26 +01:00
d81273eaed cleanup 2019-11-21 14:46:26 +01:00
e36da5e16e cleanup 2019-11-21 14:38:14 +01:00
2335aaf58b improve naming 2019-11-21 14:29:03 +01:00
7f9e7c23e0 improve naming 2019-11-21 14:20:14 +01:00
7de6eb1b49 define multi function to node mapping 2019-11-21 14:08:54 +01:00
3ca095f1eb simplify vsocket to multi function mapping 2019-11-21 13:44:56 +01:00
92130916d5 fix network evaluation 2019-11-21 12:48:13 +01:00
92d4376c8e make VirtualNodeTree specific to one bNodeTree 2019-11-20 18:20:16 +01:00
00b4b90361 new try_lookup method for StringMap 2019-11-20 18:11:12 +01:00
6d71136e4a new vnode to multifunction mapping 2019-11-20 17:37:28 +01:00
2c83e550c4 change the node mapping a bit 2019-11-20 17:08:47 +01:00
0cf8799ef7 more utility functions 2019-11-19 14:34:03 +01:00
046204e7b2 extract preprocessed vtree data from builder 2019-11-19 13:38:25 +01:00
3d16a8193f improved debug error checking 2019-11-19 10:49:34 +01:00
1aef4b1298 cleanup parameter checks 2019-11-19 10:17:33 +01:00
ca19757aec refactor MFParamType 2019-11-17 12:10:48 +01:00
e81dbbaa2e add missing static keywords 2019-11-15 16:09:50 +01:00
2d4f8209a7 optimize Get Nearest Point when the object is the same for every element 2019-11-15 16:03:54 +01:00
3ecb692b43 fix task scheduling 2019-11-15 16:03:19 +01:00
ca1de7fe4c use more global external data cache 2019-11-15 15:30:12 +01:00
be57a27d6d fix Map Range clamping 2019-11-15 15:28:49 +01:00
459b54b45c remove unused code 2019-11-15 15:06:36 +01:00
9843ca071c prevent recursive node groups 2019-11-14 16:31:24 +01:00
5e72329889 make group defaults work 2019-11-14 15:39:00 +01:00
2423f1c531 add Random Float node 2019-11-14 15:20:07 +01:00
44320e9e08 remove unnecessarily complex code 2019-11-14 14:43:16 +01:00
057ec4bc97 remove unused nodes 2019-11-14 13:40:10 +01:00
4e61bfbb15 initial working function groups 2019-11-14 13:38:39 +01:00
758a751fb2 new group nodes 2019-11-13 15:29:00 +01:00
7398acb56d initial group input node 2019-11-13 14:55:42 +01:00
16f7804d5f bring back Clamp and Map Range nodes 2019-11-13 14:23:21 +01:00
ccfe2a2db1 initial Closest Point on Object node 2019-11-13 13:48:03 +01:00
03d7ba7055 Make Particle Info node a normal function 2019-11-13 12:40:12 +01:00
3235d6cd41 pass MFContext directly 2019-11-13 12:02:16 +01:00
4dfc1e9026 pass MFParams directly 2019-11-13 11:53:28 +01:00
ce59ef0ea9 pass MFMask directly 2019-11-13 11:29:31 +01:00
d5e9fa61d9 testing another way to use multi function contexts 2019-11-12 15:53:00 +01:00
112ffb49d1 fix default node tree 2019-11-12 14:26:21 +01:00
1ac1081953 remove other forces, they should be build using Particle functions 2019-11-12 14:16:36 +01:00
54b40587e4 output vector from Perlin Noise node 2019-11-12 14:15:59 +01:00
ad96830a4b support mapping input vsockets to multiple new sockets 2019-11-12 14:15:08 +01:00
1d69abe558 new Custom Force and Perlin Noise node 2019-11-12 11:00:19 +01:00
a924c1a401 Merge branch 'master' into functions 2019-11-12 10:08:57 +01:00
bb15b89375 Merge branch 'functions' into functions-experimental-refactor 2019-11-08 20:46:56 +01:00
ef2b03e317 Merge branch 'master' into functions 2019-11-08 20:46:43 +01:00
b6027a2f15 fix Is In Group input 2019-11-08 20:34:01 +01:00
a74a2882ed bring back compare node 2019-11-08 20:33:44 +01:00
3a3970c2e0 change uint8_t to bool 2019-11-08 19:50:23 +01:00
a708562177 move attribute defaults back into AttributesInfo 2019-11-08 19:48:04 +01:00
b9d42020be make function name more precise 2019-11-08 19:19:54 +01:00
fea9c7c1a3 cleanup 2019-11-08 19:15:21 +01:00
9cc27bd6ff remove a node 2019-11-08 18:49:49 +01:00
5f8bd0fa71 make switch node work again 2019-11-08 18:21:26 +01:00
de3d75110c bring back object mesh info node 2019-11-08 17:50:19 +01:00
2bae4dd503 remove some nodes for now 2019-11-08 17:33:29 +01:00
8e1ced7596 bring back color nodes 2019-11-08 17:32:20 +01:00
d47962f7a9 boolean math nodes 2019-11-08 17:11:29 +01:00
366a427f04 more vector math 2019-11-08 16:56:06 +01:00
fa7c300edc more vector math 2019-11-08 16:27:58 +01:00
e390a51cc7 bring back some vector math nodes 2019-11-08 16:12:43 +01:00
470a2ce330 fix compile error 2019-11-07 15:17:44 +01:00
4e0b5fd215 cleanup 2019-11-07 14:03:46 +01:00
eada832040 make AttributesInfo non copy and non movable 2019-11-07 13:59:47 +01:00
9116016f93 rename GET_TYPE to CPP_TYPE 2019-11-07 13:48:30 +01:00
bef3e0022c use monotonic allocator for network builder 2019-11-07 13:38:51 +01:00
a4a46d8a97 use monotonic allocator for vtree generation 2019-11-07 13:21:39 +01:00
1fb8e34c9c rename functions2 to functions 2019-11-07 11:57:35 +01:00
ae862db1f4 remove old function system 2019-11-07 11:54:00 +01:00
7884ae9bc3 port particle system to new functions system 2019-11-07 11:44:08 +01:00
856049d771 merge bparticles node tree into functions node tree 2019-11-06 16:08:20 +01:00
cccaca258b simplify naming 2019-11-06 13:05:26 +01:00
6e135618be use monotonic allocator to allocate functions 2019-11-05 15:54:44 +01:00
06e398f427 rename OwnedResources to ResourceCollector 2019-11-05 15:40:03 +01:00
2ae8040373 improve aligned allocation in monotonic allocator 2019-11-05 15:32:53 +01:00
7317074eb3 bring back some more math operations 2019-11-05 14:36:45 +01:00
ab2625529c bring back more math nodes 2019-11-05 14:17:35 +01:00
a35f5ff3c8 improve add/mul/min/max math nodes 2019-11-05 13:47:57 +01:00
3a4d9fa228 remove unused code 2019-11-05 11:56:37 +01:00
720edd0c30 cleanup 2019-11-05 11:53:24 +01:00
e0554f7f31 access time from node tree 2019-11-05 11:48:29 +01:00
55ecd940ac initial more generic context handling 2019-11-05 11:19:57 +01:00
07ac997f1c make Float Range node work again 2019-11-04 23:17:01 +01:00
09862e2b2f assert earlier when nodes were not inserted correctly 2019-11-04 23:16:46 +01:00
62cd4cca56 Merge branch 'functions' into functions-experimental-refactor 2019-11-04 22:09:23 +01:00
a63b896055 Merge branch 'master' into functions 2019-11-04 22:09:06 +01:00
f52e43554f simplify interface for generating functions from node trees 2019-11-03 16:32:23 +01:00
b1bee3ffc5 update Function Points modifier to use new system 2019-11-03 16:06:25 +01:00
d5bcdeef9f rename pack list socket declaration to something more generic 2019-11-03 15:31:30 +01:00
9fdef6ae5b attributes block container compression and utilities 2019-11-03 15:09:21 +01:00
5e20def930 cleanup function allocation 2019-11-03 14:30:45 +01:00
1a90ef6e58 cleanup builder 2019-11-03 14:19:05 +01:00
f1dfadb3cb initial MFContext usage 2019-11-03 14:12:34 +01:00
fa18a28277 move multi function context to separate file 2019-11-03 13:55:49 +01:00
30a1a0bf58 separate some files 2019-11-03 13:44:31 +01:00
146f6a827b add utility to destruct and reorder attribute arrays 2019-11-03 13:08:35 +01:00
da0169bca4 simplify CPPType construction 2019-11-03 12:08:34 +01:00
dafbb5daf7 properly align inline storage in vector and map 2019-11-03 11:37:10 +01:00
5a6da2c1b1 update attribute blocks 2019-11-02 21:31:56 +01:00
45fd15f824 initial attributes block container in functions2 2019-11-02 20:48:35 +01:00
61609e90d5 initial AttributesRef in functions2 2019-11-02 20:19:49 +01:00
8523b03473 cleanup 2019-11-02 19:22:05 +01:00
4a0b22d449 cleanup 2019-11-02 19:12:46 +01:00
2c8ad4ef0b cleanup 2019-11-02 19:07:37 +01:00
4b1532b064 move file 2019-11-02 18:53:29 +01:00
74e7816a22 move node inserters to separate file 2019-11-02 13:45:22 +01:00
8ed320be86 fix memory leak 2019-11-02 13:29:06 +01:00
ed727f3c0f refactor mapping from vtree to multi functions 2019-11-02 13:26:02 +01:00
100ff71944 New VirtualNodeTree implementation 2019-11-02 12:34:39 +01:00
ef636af49e move network generation to separate file 2019-11-01 20:31:13 +01:00
fcfa225e5d move multi function network evaluation to functions2 2019-11-01 20:14:01 +01:00
e778aba584 move VTreeMFNetworkBuilder to functions2 2019-11-01 20:02:51 +01:00
ed47df29e3 move VTreeMFNetwork to functions2 2019-11-01 19:56:11 +01:00
f91bd73986 remove code from blenkernel (now lives in functions2) 2019-11-01 19:51:34 +01:00
11808ee3c2 update functiondeform modifier to using functions2 2019-11-01 19:46:54 +01:00
e9fd7c335f move tuple to functions2 2019-11-01 19:37:25 +01:00
617d8ab8dc move multi function network to functions2 2019-11-01 19:32:52 +01:00
2b805f0ae8 move multi functions to functions2 2019-11-01 19:30:31 +01:00
72eb10b467 copy generic data structures to functions2 2019-11-01 19:11:53 +01:00
324537287f initial functions2 folder 2019-11-01 19:05:09 +01:00
6379f1d035 improve performance when iterating over mask indices 2019-11-01 14:37:58 +01:00
f354aebc6f cleanup name access 2019-11-01 14:35:44 +01:00
ae8332f7c6 introduce MFMask 2019-11-01 14:17:09 +01:00
3ba1c11f3b fix memory leak 2019-10-31 15:01:53 +01:00
5b60e21f1b make text socket work again 2019-10-31 14:57:40 +01:00
badad91ac3 make Object socket work again 2019-10-31 14:39:16 +01:00
92e04dcd15 rename placeholder to dummy 2019-10-31 14:15:27 +01:00
d218811e85 access function and parameter names 2019-10-31 14:11:11 +01:00
db0ee0fe36 further improve MultiFunction API 2019-10-31 13:51:05 +01:00
e09e429f57 cleanup MultiFunction API 2019-10-31 13:43:44 +01:00
cdd69f8e6d dot export 2019-10-31 13:32:53 +01:00
53d345a897 add missing implicit conversions 2019-10-31 13:15:33 +01:00
b7c516a121 add more primitive conversions 2019-10-31 12:55:23 +01:00
16150b75ac cleanup network generation code 2019-10-31 12:27:35 +01:00
5816f75544 initial automatic node vectorization 2019-10-31 11:44:01 +01:00
0ceef31d99 support for full pointer array in virtual list 2019-10-31 10:59:46 +01:00
568315b0b8 make Get List Element node work again 2019-10-30 16:39:33 +01:00
3baf1f7ffa remove unused code 2019-10-30 16:31:23 +01:00
be738fa181 make Pack List node work again 2019-10-30 16:27:53 +01:00
cdeb4ecf8e make some list nodes work again 2019-10-30 15:32:33 +01:00
98577ce2b2 initial non recursive multi-function evaluator 2019-10-30 14:01:00 +01:00
aec147ec74 new ArrayRef.first_index method 2019-10-29 16:52:38 +01:00
cdb7f3c192 change GenericVectorArray 2019-10-29 16:31:36 +01:00
269488d1c3 use virtual list list ref in multi functions 2019-10-29 15:46:25 +01:00
c6ebe25337 initial VirtualListListRef 2019-10-29 15:00:47 +01:00
353af1c51a Support for implicit conversions, float math node and int type 2019-10-29 13:32:22 +01:00
e1ca6c4129 Merge branch 'functions' into functions-experimental-refactor 2019-10-29 11:21:58 +01:00
cacbe466b2 Merge branch 'master' into functions 2019-10-29 11:15:49 +01:00
7bef9b83fb initial MultiFunction generation from node tree 2019-10-22 13:54:55 +02:00
dfa3ed8761 insert links function 2019-10-22 13:04:54 +02:00
73a709844b make VirtualNodeTree const in many places 2019-10-22 12:51:46 +02:00
bc8d442717 initial new node inserters 2019-10-22 11:47:29 +02:00
4adbf49d83 improve ArrayRef 2019-10-22 11:47:00 +02:00
59df914983 replace ArrayOrSingleRef with VirtualListRef 2019-10-20 15:55:33 +02:00
b04aed8db6 experimental VirtualListRef 2019-10-20 15:11:52 +02:00
fc1ca9a2e2 fixes 2019-10-20 14:53:17 +02:00
f6f4f2914c utility functions 2019-10-20 14:27:54 +02:00
4d61b8b1f9 initial VTreeMFNetwork and VTreeMFNetworkBuilder 2019-10-20 13:29:38 +02:00
31ecaf4a8a make MultiFunction const in more places 2019-10-18 17:49:12 +02:00
ff29177a4c make CPPType const everywhere 2019-10-18 17:47:02 +02:00
84baab05b2 remove unused code 2019-10-18 17:46:51 +02:00
838ac481f2 cleanup 2019-10-18 17:40:18 +02:00
5151d05625 cleanup 2019-10-18 17:37:33 +02:00
53d3d32992 use MF prefix in more places 2019-10-18 17:31:22 +02:00
9dbe43f044 start using MF prefix for some classes 2019-10-18 17:23:35 +02:00
36310012ff allow passing destruct_ptr to OwnedResources 2019-10-18 17:08:55 +02:00
2f6ea75758 move destruct_ptr to BLI 2019-10-18 16:46:15 +02:00
d0dd083cbb multi function with constant output 2019-10-18 15:08:20 +02:00
416d6a17dc first created and executed multi function graph 2019-10-17 17:53:04 +02:00
59dc9f1f1a implement initial conversion from builder to network 2019-10-17 16:35:09 +02:00
c2aea94511 give nodes and sockets ids 2019-10-17 15:21:10 +02:00
94d06d7094 initial network structure 2019-10-17 15:08:00 +02:00
2f02949798 initial multi function network builder 2019-10-17 14:19:21 +02:00
0d4a90000d Merge branch 'functions' into functions-experimental-refactor 2019-10-17 10:49:29 +02:00
b660768ae0 Merge branch 'master' into functions 2019-10-17 10:49:00 +02:00
586a9c14ad pass context into multi functions 2019-10-16 13:05:57 +02:00
376f4813dd experiment with an interface to specify external data dependencies 2019-10-16 12:57:21 +02:00
b08bcb1ef4 remove unused code 2019-10-16 12:37:30 +02:00
c1d570ebb1 separate concept of data types from parameter types 2019-10-16 12:19:38 +02:00
76655021c2 remove unused code 2019-10-16 12:19:22 +02:00
2b781131ed experimental AnyAllocator 2019-10-16 11:39:27 +02:00
4d08c352c3 cleanup 2019-10-16 11:39:16 +02:00
f4455b442c separate vector function 2019-10-15 15:52:53 +02:00
34a66dea4e Combine Vector multi function 2019-10-15 15:32:06 +02:00
9952cbc715 initial multi function node tree evaluation 2019-10-15 15:12:48 +02:00
0cc550108a new add vectors multi function 2019-10-15 12:32:05 +02:00
2c06ccec82 initial params builder 2019-10-15 12:05:43 +02:00
56ab056637 test function call 2019-10-13 22:04:01 +02:00
78aa2d5f02 further implement signature builder 2019-10-13 18:32:47 +02:00
a9a8741270 further develop Signature 2019-10-13 18:32:47 +02:00
f0b62c43ef start implementing Params 2019-10-13 18:32:47 +02:00
a1308c1f98 init stuff 2019-10-13 18:32:47 +02:00
42894aa3df don't use old function system for function deform modifier 2019-10-13 18:32:47 +02:00
8a3ce65044 fix 2019-10-13 18:32:47 +02:00
630d32b159 new socket type mapping 2019-10-13 18:32:47 +02:00
7588b4e493 separate declaration and implementation 2019-10-13 18:32:47 +02:00
745c6dec4d move functions to other file 2019-10-13 18:32:47 +02:00
59b077c020 fix test 2019-10-13 18:32:47 +02:00
cad83fee9f move multi function to separate header 2019-10-13 18:32:47 +02:00
9cd357768d fix 2019-10-13 18:32:47 +02:00
029e63093d fix 2019-10-13 18:32:47 +02:00
f84f8b2a02 combine lists 2019-10-13 18:32:47 +02:00
c696a29058 list lengths 2019-10-13 18:32:47 +02:00
2ef5959f8a GenericVectorArrayOrSingleRef 2019-10-13 18:32:47 +02:00
b38ee6daab generic array or single ref 2019-10-13 18:32:47 +02:00
b4130c3d2a more generic vector array functionality 2019-10-13 18:32:47 +02:00
1ee3c53ed2 prototyping vector array usage 2019-10-13 18:32:47 +02:00
c365ec7c61 initial GenericVectorArray 2019-10-13 18:32:47 +02:00
2efdb20b0b use allocator in MonotonicAllocator and use minimum allocation size 2019-10-13 18:32:47 +02:00
0627a6b2d5 cleanup 2019-10-13 18:32:47 +02:00
375a600b8b initial ArrayOrSingleRef implementation 2019-10-13 18:32:47 +02:00
909dc85f2f node functions 2019-10-13 18:32:47 +02:00
2892434cdf improve naming 2019-10-13 18:32:47 +02:00
5ab8cc2eaf add generic mutable array ref 2019-10-13 18:32:47 +02:00
2cfb80f68c cleanup 2019-10-13 18:32:47 +02:00
ffad150868 rename 2019-10-13 18:32:47 +02:00
cfaa0e566a rename TypeCPP to CPPType 2019-10-13 18:32:47 +02:00
326878d82c initial new function type 2019-10-13 18:32:47 +02:00
bdfc3e9a6b GenericArrayRef type 2019-10-13 18:32:47 +02:00
b75cdf36a8 new tuple implementation 2019-10-13 18:32:47 +02:00
55d0c80611 add more type attributes 2019-10-13 18:32:47 +02:00
302e1e9a86 initial cpp type 2019-10-13 18:32:47 +02:00
faf2184f52 Merge branch 'master' into functions 2019-10-13 18:12:07 +02:00
65e6598e7e avoid ambiguous call to make_unique 2019-09-27 16:59:04 +02:00
503fadaeb9 cleanup Tuple class 2019-09-27 15:40:40 +02:00
37bc9ffc53 remove using namespace BLI 2019-09-27 15:27:33 +02:00
123d945027 function is noncopyable and nonmovable 2019-09-27 15:17:53 +02:00
254b69417b remove refcounter from Function class 2019-09-27 15:15:10 +02:00
0102c06cb2 remove Falloff implementation
The plan is to achieve the same functionality in a different way
that allows more customization.
2019-09-27 14:14:39 +02:00
4086bf9823 make particle colors work again
This broke in rBa168c3d282083bb4.
2019-09-27 12:35:02 +02:00
d724444dba remove some debug prints 2019-09-27 12:33:26 +02:00
033924c630 Merge branch 'master' into functions 2019-09-27 10:58:21 +02:00
ab9a01313f add resources to data graph instead of function 2019-09-26 18:15:55 +02:00
ea6db832a0 utility to print resource names 2019-09-26 18:07:59 +02:00
2263656526 add resource via VTreeDataGraphBuilder 2019-09-26 17:57:02 +02:00
d31da8e870 data graph can own arbitrary resources now 2019-09-26 17:42:52 +02:00
727a8da77f make Function class a bit smaller 2019-09-26 17:35:59 +02:00
3bca19b38a separate owned resources container from function 2019-09-26 17:23:16 +02:00
387a97ae42 experimental lazy init for unique pointers 2019-09-26 16:46:52 +02:00
b65a28b9d7 use make_unique in some places 2019-09-26 16:18:53 +02:00
f2b2279c1a Remove owns_mem attribute from Tuple 2019-09-26 15:41:19 +02:00
cdcae9d22e remove run_destructors member from Tuple 2019-09-26 15:21:17 +02:00
5b0d883e50 remove refcount from TupleMeta 2019-09-26 15:02:07 +02:00
be2358fe61 remove refcounter from data graph 2019-09-26 14:35:42 +02:00
802c820334 improved static and dynamic type checking for function bodies 2019-09-26 14:05:16 +02:00
abed72f22c store tuple as resource in function 2019-09-26 13:49:11 +02:00
74fba99cc6 initial resource storage for functions 2019-09-26 13:35:06 +02:00
5460fa6efc store StringRef directly in function
That increases the size slightly, but is easier to debug
2019-09-26 12:46:51 +02:00
353d6112d2 use header guards 2019-09-26 12:06:20 +02:00
d942d6daa7 rename file 2019-09-26 12:03:29 +02:00
7ba7667d8e reduce error handling complexity 2019-09-26 11:04:27 +02:00
b34c174dfb Merge branch 'master' into functions 2019-09-26 10:43:33 +02:00
c3d30f2992 cleanup 2019-09-26 10:43:14 +02:00
6cdc6ce355 Merge branch 'master' into functions 2019-09-25 16:02:22 +02:00
d4e58e630c Replace Falloff with weight input 2019-09-23 12:08:36 +02:00
31a3dc769d start using monotonic allocator when parsing bparticles tree 2019-09-23 11:42:04 +02:00
89db5e8946 Merge branch 'master' into functions 2019-09-23 11:01:22 +02:00
e64fa963de initial particle group implementation 2019-09-22 15:05:45 +02:00
e0b82c6616 access influences collector from action parsers 2019-09-22 14:37:20 +02:00
5c733ab445 move responsibility of registering attributes to node frontend 2019-09-22 14:14:03 +02:00
fcd6a9ddcb allow only one collision per time step 2019-09-22 13:54:48 +02:00
93c0fdcd45 pass simulation state to interfaces 2019-09-22 13:54:30 +02:00
5eecfaf824 better distinction between particle simulation and system 2019-09-22 12:59:13 +02:00
63116f2c8c improved handling of moving colliders 2019-09-22 12:44:07 +02:00
ad8733038e Merge branch 'master' into functions 2019-09-22 12:01:54 +02:00
e397b67946 cleanup 2019-09-20 16:37:41 +02:00
97da5f31d4 move responsibility to ensure that attributes exist out of simulator 2019-09-20 16:32:59 +02:00
9c46c784d5 move attributes declaration out of simulate code 2019-09-20 16:21:02 +02:00
cdfb3d3a28 move responsibility of keeping track of particle ids 2019-09-20 16:09:01 +02:00
8d860d4a9b use shared particle allocator instead of one per thread 2019-09-20 16:00:26 +02:00
f1a7d102dc don't access particles state through allocator 2019-09-20 15:09:45 +02:00
cab2f0f6bd declare more attributes in same place 2019-09-20 15:04:00 +02:00
cb974c4c66 Merge branch 'master' into functions 2019-09-20 14:38:43 +02:00
691f2d449a Merge branch 'master' into functions 2019-09-19 10:34:45 +02:00
d2bd35eab4 fix usage of frame nodes 2019-09-19 10:34:13 +02:00
21889a5475 fix crash with negative emitter rate 2019-09-19 10:30:24 +02:00
c3e289440d Merge branch 'master' into functions 2019-09-18 17:42:59 +02:00
16d5919206 copy color to new particles in trails node 2019-09-17 15:27:24 +02:00
5b1d7afb9c new particle randomness input 2019-09-17 15:04:23 +02:00
df47dd16ce reorder menu entries 2019-09-17 14:02:27 +02:00
561450715b add missing nodes to menu 2019-09-17 13:49:38 +02:00
4d4eeedfa0 rename file 2019-09-17 13:49:24 +02:00
9fecdb3a45 use reference to indicate that action cannot be null 2019-09-17 12:43:59 +02:00
872ee8bbe0 add some node mockups 2019-09-17 12:32:44 +02:00
8d285ee398 Merge branch 'master' into functions 2019-09-17 09:56:59 +02:00
e6ef82180f add execute input to point emitter 2019-09-16 17:00:37 +02:00
d51f6b010d add execute input to initial grid emitter 2019-09-16 16:56:00 +02:00
afada870e7 rename to Influences 2019-09-16 16:43:21 +02:00
8a3348d49b make it easier to add a new particle system 2019-09-16 16:40:57 +02:00
b5d2265b60 remove unused functions 2019-09-16 11:57:59 +02:00
7e3e301bb1 more centralized ownership of actions 2019-09-16 11:39:43 +02:00
a3080c2bc3 don't crash when connecting certain sockets 2019-09-16 11:15:23 +02:00
609147a4d9 improve error handling of various nodes 2019-09-16 11:04:25 +02:00
6384a61a99 Add arrow and star operator to BLI::Optional 2019-09-16 11:04:05 +02:00
4a9bfa95ed centralize function evaluation a bit more 2019-09-16 10:51:08 +02:00
881b5377cf change ownership of name vectors 2019-09-16 10:41:37 +02:00
a5e1f95467 move system discovery to vtreedata 2019-09-16 10:33:13 +02:00
f54bf13cc1 missing file in cmakelists 2019-09-16 10:26:49 +02:00
f45badafd5 Merge branch 'master' into functions 2019-09-16 10:10:22 +02:00
5f5a7fcd62 fixes after merge 2019-09-15 12:46:14 +02:00
35de65ec81 Merge branch 'master' into functions 2019-09-15 12:42:24 +02:00
0d81bf5cb0 fixes after merge 2019-09-14 12:48:25 +02:00
345b86ca4e Merge branch 'master' into functions 2019-09-14 12:44:31 +02:00
4de668c30c Merge branch 'master' into functions 2019-09-14 12:41:02 +02:00
214964b2a0 Merge branch 'master' into functions 2019-09-13 17:08:02 +02:00
f21586cfa1 fix after rename 2019-09-13 16:32:28 +02:00
5b9ee5a55e use NamedTupleRef in more places 2019-09-13 15:47:35 +02:00
c5c05aa40b improve NameTupleRef abstraction 2019-09-13 14:55:48 +02:00
71184d2bc8 fix overflow in color conversion 2019-09-13 14:24:47 +02:00
e26301b30a Rename Particle Type to Particle System and Behaviors to Influences 2019-09-13 14:09:32 +02:00
2232300639 Merge branch 'master' into functions 2019-09-13 12:28:43 +02:00
a86dda2a80 fix cmake after merge 2019-09-13 12:27:35 +02:00
ef7f059216 Merge branch 'master' into functions 2019-09-13 12:16:59 +02:00
3c4d8b1f59 rename BLI_hash.hpp to BLI_hash_cxx.h 2019-09-12 17:13:10 +02:00
d24380dd43 remove unused function 2019-09-12 16:31:02 +02:00
3cdc35dfc4 test OutputTupleRef abstraction 2019-09-12 16:29:40 +02:00
9e9e150b74 size parameter in turbulence force node 2019-09-12 15:55:47 +02:00
592470b07b simplify code by changing ownership of particle functions 2019-09-12 15:45:55 +02:00
971ad95f2b solve merge conflicts 2019-09-12 14:59:16 +02:00
cabc40db81 Merge branch 'master' into functions 2019-09-12 14:49:38 +02:00
e23abea88d add license header to memory utils 2019-09-12 12:49:18 +02:00
7b4a2d578f rename BLI_memory.h to BLI_memory_utils_cxx.h 2019-09-12 12:48:36 +02:00
e7aa06520a change .cpp to .cc in blenlib 2019-09-12 12:45:55 +02:00
2e21ec0d88 change .hpp to .h in blenlib 2019-09-12 12:41:14 +02:00
54350b7db2 change .hpp to .h 2019-09-12 12:23:42 +02:00
590b231124 reflow comment 2019-09-12 12:21:40 +02:00
7825047f47 Merge branch 'master' into functions 2019-09-12 10:09:01 +02:00
1f957995f6 Fix birth moments of emitted particles 2019-09-11 17:59:45 +02:00
1b9cc8bfb1 Merge branch 'master' into functions 2019-09-11 17:46:43 +02:00
09ffcc5de1 initial Always Execute node 2019-09-11 17:24:47 +02:00
23de6e6960 new Falloff input for Turbulence Force 2019-09-11 16:05:51 +02:00
f082115395 Merge branch 'master' into functions 2019-09-11 15:17:11 +02:00
0f47a7d0d7 use Array instead of Vector 2019-09-11 13:29:17 +02:00
8d31f929db fix Array and add tests 2019-09-11 13:28:40 +02:00
a988a16e3d new Change Particle Position node 2019-09-11 11:36:52 +02:00
5743c0eab6 new Custom Event node 2019-09-11 11:24:45 +02:00
3f28239efe move events ui to same file 2019-09-11 10:55:37 +02:00
ef8775b676 allocate VTreeDataGraph on heap 2019-09-11 10:41:47 +02:00
880c5a4360 store size of vector in debug builds to ease debugging 2019-09-11 10:18:34 +02:00
cd48588cf6 Merge branch 'master' into functions 2019-09-11 09:50:12 +02:00
972760397f fix keymap registration 2019-09-10 17:41:32 +02:00
8024da670c testing initial bit array ref implementation 2019-09-10 17:02:23 +02:00
72a05f9f4f remove unnecessary inline keywords 2019-09-10 16:14:48 +02:00
29c7232f4f comments 2019-09-10 16:11:18 +02:00
bfdf90e68c quiet warning 2019-09-10 16:05:38 +02:00
ff3f7c5291 invert Mesh Distance Falloff 2019-09-10 15:59:20 +02:00
a9112c4932 do not register keymap in background mode 2019-09-10 15:46:53 +02:00
b928050af3 initial Mesh Distance Falloff node 2019-09-10 15:44:58 +02:00
01e97d117f initial experimental Mesh Force node 2019-09-10 14:23:52 +02:00
2c0397edfb Merge branch 'master' into functions 2019-09-10 13:26:17 +02:00
a911775cbe store attributes info directly instead of unique pointer 2019-09-10 13:02:12 +02:00
c339917d7f don't store attributes info ref directly in block 2019-09-10 12:56:54 +02:00
1b3ee092db move attributes block container stuff to same file again 2019-09-10 12:39:18 +02:00
b22dc19ce7 new Dot Production operation in vector math node 2019-09-10 12:18:58 +02:00
844c2c8a79 new Project operation in vector math node 2019-09-10 12:10:40 +02:00
147863ac7c Improve copy and move constructor of Vector 2019-09-10 11:54:03 +02:00
dcd84a1051 remove limit for index range arrays 2019-09-09 17:58:43 +02:00
cfb50f6581 implement multiple density modes in Mesh Emitter node 2019-09-09 17:22:54 +02:00
cdc432429f Falloff input in Drag Force node 2019-09-09 16:23:38 +02:00
5d319ba8ff new Drag Force node 2019-09-09 16:17:32 +02:00
706bd95ae8 Merge branch 'master' into functions 2019-09-09 15:45:19 +02:00
40e9cf9df8 initial new attributes block storage 2019-09-09 15:43:23 +02:00
c541e31931 cleanup some nonmovable and noncopyable functions 2019-09-09 12:17:28 +02:00
b2a449e783 test if it builds on buildbot without alembic tests 2019-09-09 11:51:35 +02:00
11d61f3d00 test moving functions to bf_functions 2019-09-09 11:41:07 +02:00
dc02a49fb7 test adding a virtual destructor to solve a linker issue 2019-09-09 11:33:54 +02:00
63133ee688 Merge branch 'master' into functions 2019-09-09 10:55:21 +02:00
da598e31eb support for outputting None/Points/Tetrahedons 2019-09-06 17:44:25 +02:00
e876360aaa Merge branch 'master' into functions 2019-09-06 17:07:59 +02:00
aa5ea9f0fe New UInt32 attribute type 2019-09-06 16:51:32 +02:00
5045219ca9 separate BParticles Output modifier 2019-09-06 16:34:21 +02:00
d30979dddb new Constant Falloff node 2019-09-06 15:51:03 +02:00
57ceacf8b4 move falloff implementations out of header 2019-09-06 15:42:54 +02:00
12663d2e21 cleanup boolean math 2019-09-06 15:34:03 +02:00
0b8514a99c fix memory leak 2019-09-06 15:32:04 +02:00
264719c0b4 simplify string type 2019-09-06 14:50:13 +02:00
213d807a08 deduplicate some code 2019-09-06 14:14:33 +02:00
524df333bc use correct wrapper for Object pointers 2019-09-06 12:49:42 +02:00
3d85989efa rename 2019-09-06 12:26:36 +02:00
199d201cce rename 2019-09-06 12:21:32 +02:00
f45791f436 remove unused class 2019-09-06 12:18:53 +02:00
a22b7177d2 improve llvm type info for shared immutable types 2019-09-06 12:17:16 +02:00
9ba1fce608 use specialized llvm type info for pointer references 2019-09-06 11:37:25 +02:00
4e2ee7e962 remove unused code 2019-09-06 11:27:58 +02:00
d0eafffed4 Initial Falloff implementation 2019-09-06 11:21:53 +02:00
6163ce3dee Merge branch 'master' into functions 2019-09-06 09:21:28 +02:00
02cdf856f6 fix attribute initialization 2019-09-05 19:07:08 +02:00
d226d46144 Merge branch 'master' into functions 2019-09-05 18:30:52 +02:00
58997f47af initial passive modifier mode
This allows creating separate meshes for the different particle types.
2019-09-05 18:30:36 +02:00
66c07705f9 Initial Size Over Time node 2019-09-05 16:58:35 +02:00
bc654dd3dd support for choosing uv layer by name 2019-09-05 16:21:32 +02:00
882e7e4903 cleanup usage of temporary allocator 2019-09-05 15:17:43 +02:00
f541e79196 add comments 2019-09-05 14:27:02 +02:00
942cf217c5 add some comments 2019-09-05 14:18:48 +02:00
02f4bf505a more comments 2019-09-05 12:53:58 +02:00
b39ddcd628 add some comments 2019-09-05 12:43:53 +02:00
5420375d4a return StringRef from virtual node/socket 2019-09-05 12:36:45 +02:00
f59ea9a10f support not-equal operator for StringRef 2019-09-05 12:35:27 +02:00
242e027dea cleanup Vector Adaptor 2019-09-05 12:27:13 +02:00
ded8e6f0af rename test files 2019-09-05 12:17:47 +02:00
d6ac3fd2f2 rename file 2019-09-05 12:14:57 +02:00
a61852a5e2 store size in IndexRange 2019-09-05 12:12:08 +02:00
1ed83f1004 use another constructor for IndexRange 2019-09-05 11:51:54 +02:00
d22cf2fd77 replace generic Range with IndexRange 2019-09-05 11:46:55 +02:00
3a17600bed move ChunkedRange to separate file 2019-09-05 11:30:48 +02:00
3939274a46 cleanup names 2019-09-05 11:20:22 +02:00
964ee85777 access surface color from chained action context 2019-09-05 11:15:40 +02:00
f58f26a35d cleanup vertex weight input provider 2019-09-05 11:00:50 +02:00
fd8244fb26 new Combine Behaviors node 2019-09-05 10:38:03 +02:00
a6d08dfccb Merge branch 'master' into functions 2019-09-05 10:05:08 +02:00
b14e8f35f7 vertices should have a unit length normal 2019-09-04 18:05:06 +02:00
1c8f6d8807 cleanup 2019-09-04 16:27:13 +02:00
5f91002b51 better time sampling in mesh emitter 2019-09-04 16:27:13 +02:00
0e528d5361 improve spacing of trail particles 2019-09-04 16:27:13 +02:00
30185113fd take triangle areas into account 2019-09-04 16:27:13 +02:00
f0c354c97a refactor triangle weight computation 2019-09-04 16:27:13 +02:00
6e828316b3 compute barycentric weights more centrally 2019-09-04 16:27:13 +02:00
d979cd2690 use Surface Info node instead of Collision Info 2019-09-04 16:27:13 +02:00
c665ef49ad store surface velocities in surface context 2019-09-04 16:27:13 +02:00
c718c9e6c5 refactor usage of MeshSurfaceContext 2019-09-04 16:27:13 +02:00
1b1292b7b1 assert that the number of temporary buffers does not grow unbounded 2019-09-04 16:27:13 +02:00
560b55c4c8 cleanup 2019-09-04 16:27:13 +02:00
22624ad774 cleanup handling of emitter action contexts 2019-09-04 16:27:13 +02:00
cb35556472 support slicing ArrayRef with range 2019-09-04 16:27:13 +02:00
185ef25243 temporarily remove unnecessary emitter sockets 2019-09-04 16:27:13 +02:00
848603d032 Merge branch 'master' into functions 2019-09-04 16:27:02 +02:00
db230d4833 skip matrix interpolation when not necessary 2019-09-04 11:33:56 +02:00
716cc34a87 move AttributesRef to BKE namespace 2019-09-04 11:09:36 +02:00
fbe0a3950f more accurate runtime type checking in debug builds 2019-09-04 10:51:06 +02:00
90aaf67e5a Merge branch 'master' into functions 2019-09-04 09:45:37 +02:00
0edb87c629 Merge branch 'master' into functions 2019-09-03 18:12:57 +02:00
4dd3773283 Merge branch 'master' into functions 2019-09-03 16:30:22 +02:00
8443f319e3 quiet warning 2019-09-03 16:22:55 +02:00
d3210c2547 deduplicate vertex weights input code 2019-09-03 16:17:22 +02:00
24a02ee51b initial action context chaining 2019-09-03 16:07:31 +02:00
fc0a7648b5 fix finding execute sockets 2019-09-03 16:07:03 +02:00
a72bcf11e0 new Surface Weights input node 2019-09-03 15:13:27 +02:00
3398112573 refactor how input providers are parsed 2019-09-03 14:06:57 +02:00
f7206f9910 cleanup iterating over AttributeRefs 2019-09-03 13:50:22 +02:00
b245562d0e better error handling when expected action context is not given 2019-09-03 12:34:45 +02:00
2491dc812f rename stride to size 2019-09-03 11:58:45 +02:00
ee8f58eb66 move particle function input providers to separate file 2019-09-03 11:56:49 +02:00
e3454c0708 new Change Particle Size node 2019-09-03 11:39:11 +02:00
61ec4a3d89 move change color/velocity node to same file 2019-09-03 11:20:04 +02:00
370a506ad0 refactor age reached event 2019-09-03 11:16:17 +02:00
c78acc85f3 initial variation input for age reached event 2019-09-03 11:07:17 +02:00
b9a2dc60e1 rename attribute reference classes
AttributeArrays -> AttributesRef
NewParticles -> AttributesRefGroup
2019-09-03 10:53:07 +02:00
b513079ee2 Merge branch 'master' into functions 2019-09-03 10:30:32 +02:00
410599dca2 reorganize where interfaces are declared 2019-09-02 19:01:33 +02:00
551ca28108 remove unused parameter 2019-09-02 18:13:24 +02:00
147d2dfac5 don't pass particle allocator using BlockStepData 2019-09-02 18:08:44 +02:00
1d15c51bf9 use annotation for properties 2019-09-02 17:58:19 +02:00
0d700d201a remove ParticleSet and ParticleSets abstraction 2019-09-02 17:56:14 +02:00
d2fe280a6e improved Change Particle Velocity node 2019-09-02 16:09:52 +02:00
fce176dbd0 fix mesh emitter action context 2019-09-02 15:40:13 +02:00
49b6e1dccf abstract mesh surface action context 2019-09-02 15:13:49 +02:00
27081694f9 rename 2019-09-02 15:07:24 +02:00
4d46c481ac Merge branch 'master' into functions 2019-09-02 14:42:45 +02:00
06565e21ea use action context in mesh emitter 2019-09-02 12:31:49 +02:00
e45fb9e735 use more generic mesh surface action context 2019-09-02 12:11:58 +02:00
e485f030e8 fix temporary deallocation 2019-09-02 12:05:16 +02:00
2412efdf89 simplify mesh emitter more 2019-09-02 11:33:20 +02:00
9ff4828501 cleanup mesh emitter 2019-09-02 11:20:22 +02:00
bde76782eb sample varying float4x4 2019-09-02 11:13:19 +02:00
36016e2960 extract triangle sampling 2019-09-02 11:02:24 +02:00
381ece9410 extract birth moment computation 2019-09-02 10:48:21 +02:00
5f31282c46 Merge branch 'master' into functions 2019-09-02 09:59:03 +02:00
acd7915371 fix computing cumulative distribution 2019-08-28 18:05:39 +02:00
a55745ba7f sample weighted triangles differently 2019-08-28 18:01:10 +02:00
42c58fe840 support allocating larger buffers with temporary allocator 2019-08-28 16:29:30 +02:00
ea068aeb22 start implementing vertex group support in emitter 2019-08-28 14:23:38 +02:00
bc218feff1 append n times function for vector adaptor 2019-08-28 14:23:10 +02:00
fac51ca754 store attribute indices in string map 2019-08-28 12:16:51 +02:00
6e5e1e7ee7 store Range in AttributeArrays 2019-08-28 10:50:55 +02:00
c238c179d7 Merge branch 'master' into functions 2019-08-28 10:25:02 +02:00
25e5488594 don't store particle name in particle sets structure 2019-08-27 17:40:20 +02:00
b52c3b3fc7 Initial string socket type
The internal implementation is working, but not very efficient yet (every string
is allocated separately without any cache). I'm still thinking about a better
solution, but for now having any working text socket is more important.
2019-08-27 17:22:47 +02:00
7ca34c3838 Merge branch 'master' into functions 2019-08-27 14:23:35 +02:00
0ee75f415a bring back transform interpolation for mesh emitter 2019-08-27 13:54:03 +02:00
d95073c9c7 roll back some changes regarding world transition handling 2019-08-27 13:48:51 +02:00
5a7dfe59da fix some more warnings 2019-08-27 12:24:25 +02:00
c5449eb30f avoid some warnings 2019-08-27 12:20:54 +02:00
e12b1cf8ce fix some warnings 2019-08-27 12:17:56 +02:00
a32472bd31 remove unnecessary semicolon 2019-08-27 11:55:47 +02:00
955c931b45 Merge branch 'master' into functions 2019-08-27 11:19:58 +02:00
5ef500c27b cleanup arrayref and stringref 2019-08-26 15:48:26 +02:00
645a54107c add missing include 2019-08-26 15:37:16 +02:00
cd0f866aef move time from ParticlesState to SimulationState 2019-08-26 15:21:10 +02:00
2cf9e5070a start updating how the world state is used 2019-08-26 14:54:20 +02:00
357be047aa build virtual node tree in constructor 2019-08-26 12:17:51 +02:00
bccd47ab4f remove particle block from interfaces 2019-08-26 11:58:01 +02:00
5a3a155438 remove StepDescription and ParticleType entirely 2019-08-26 11:33:50 +02:00
3f01ddd5d2 don't use ParticleType abstraction in simulation code 2019-08-26 11:09:31 +02:00
0c98f500e2 don't use StepDescription abstraction in simulation code 2019-08-26 10:49:47 +02:00
3c541ff26c initial step simulator abstraction 2019-08-26 10:27:20 +02:00
7b08fe78e5 move simulation state to separate file 2019-08-26 10:05:08 +02:00
9efc8d1d9f combine particle and world state in c api 2019-08-26 09:57:40 +02:00
a5260c143c implicitely convert StringRef to std::string 2019-08-26 09:37:04 +02:00
43b449fc18 add missing const 2019-08-26 09:27:49 +02:00
08f0727864 add missing const 2019-08-26 09:25:42 +02:00
f4e3d5f30e Merge branch 'master' into functions 2019-08-26 09:18:17 +02:00
23c31ec27d add float hash 2019-08-25 14:34:10 +02:00
2e712d4eec add test 2019-08-25 14:30:36 +02:00
7e4715a534 remove unused macro 2019-08-25 14:23:32 +02:00
58754850ca remove unused mempool 2019-08-25 14:19:31 +02:00
dbdd6b88ef unify hash tables a bit 2019-08-25 14:07:56 +02:00
c52a4316d0 update the hashing template 2019-08-25 13:58:01 +02:00
bb81caeb1e Fix build error 2019-08-24 21:28:36 +02:00
6d0dad6290 Update Vector implementation 2019-08-23 17:35:19 +02:00
1e74b276c4 don't inline grow for other data structures 2019-08-23 16:57:24 +02:00
d49f1f8772 don't inline grow functions 2019-08-23 16:52:24 +02:00
f35171a9a8 add some comments 2019-08-23 16:32:49 +02:00
a3d9fc20cf store usable slots in open addressing array 2019-08-23 16:25:43 +02:00
c52e381c8b Add license header 2019-08-23 16:06:07 +02:00
af89849067 replace magic number 2019-08-23 16:04:21 +02:00
4d2dcb6a5f Initial implementation of updated ui proposal 2019-08-23 15:41:33 +02:00
9c05112910 fix after merge 2019-08-23 10:12:22 +02:00
dc383b2bfd Merge branch 'master' into functions 2019-08-23 10:01:55 +02:00
c20301adf1 fix build error 2019-08-22 14:19:30 +02:00
ac4c2b3a48 Merge branch 'master' into functions 2019-08-22 12:14:56 +02:00
Eitan
9644f7c8c7 New boolean math node with And, Or and Not operation 2019-08-22 11:47:30 +02:00
1a0a642063 fix boolean c++/llvm conversion 2019-08-22 11:44:56 +02:00
b0034fd7a2 more comments 2019-08-21 18:24:05 +02:00
33949188a7 add some comments 2019-08-21 17:57:42 +02:00
fda6430d6a improve const correctness in many places 2019-08-21 17:38:54 +02:00
700ff7b073 Merge branch 'master' into functions 2019-08-21 17:29:22 +02:00
6f511f6722 Fix raw allocator
This allocator is necessary because sometimes we don't want to use
Blenders guarded allocator. Especially when an object lives longer
than the guarded allocator.
2019-08-21 14:44:09 +02:00
7f79bc3054 Merge branch 'master' into functions 2019-08-21 09:27:24 +02:00
8c95d02504 more tests 2019-08-20 18:45:26 +02:00
6c78f41a2f add StringMap tests 2019-08-20 18:31:19 +02:00
0b2164c5ed remove unused MappedArrayRef class 2019-08-20 18:12:20 +02:00
b45cd6b8bd implement an actual string map that does not rely on std::string 2019-08-20 18:08:17 +02:00
dc01c108d4 improve ArrayRef and StringRef 2019-08-20 18:07:31 +02:00
075a36ae95 Merge branch 'master' into functions 2019-08-20 18:05:44 +02:00
c26a23f245 fix set vector remove 2019-08-20 12:34:39 +02:00
f591503f32 Merge branch 'master' into functions 2019-08-20 09:57:12 +02:00
206495642f Merge branch 'master' into functions 2019-08-19 18:42:56 +02:00
a6b66db204 cleanup Map 2019-08-19 18:34:26 +02:00
ecb8d0bdae cleanup Set 2019-08-19 18:30:16 +02:00
a00101ae5d move hash table slot iterators out of class 2019-08-19 18:24:16 +02:00
6f79e52665 Initial support for custom allocators for containers 2019-08-19 18:18:20 +02:00
607942330c Merge branch 'master' into functions 2019-08-19 10:39:12 +02:00
38b973a679 New Map, Set and SetVector implementation
All tests are runnings still, but I need to do more testing in the upcoming days.
This implementation uses a different approach for sharing code between
the different structures. I tried different abstractions in the last weeks
and this is the best one I found so far.
2019-08-18 16:31:48 +02:00
de8a52dcee low level memory utilities in blenlib 2019-08-18 12:12:39 +02:00
b0ca3469ed Merge branch 'master' into functions 2019-08-18 12:05:11 +02:00
25ab857e4d Fix particle tetrahedon mesh generation 2019-08-18 12:05:00 +02:00
a8eb9448e7 Merge branch 'master' into functions 2019-08-16 15:03:06 +02:00
f52b66c7ec cleanup type usage 2019-08-14 15:32:26 +02:00
a0d9f387bb free types when Blender exits 2019-08-14 15:20:33 +02:00
e16afbe4f5 use guarded allocator for some core types 2019-08-14 14:59:24 +02:00
7921c6cb7e store types in global variables 2019-08-14 14:39:39 +02:00
def527c9b0 Do not use a reference counter for Types
Types can be expected to stay alive until Blender exists.
This also works well with the fact that they are identified
by their pointer.

Furthermore, the number of types is fairly low, but they
are passed around a lot. Maintaining a thread-safe reference
count seems to be unnecessary overhead.
2019-08-14 13:59:05 +02:00
f073f232cf improve map method names 2019-08-14 11:53:08 +02:00
b7bc639d00 add more license headers 2019-08-14 11:46:29 +02:00
d39f5109cc add license header to blenlib files 2019-08-14 11:44:11 +02:00
1ca951cb6f Merge branch 'master' into functions 2019-08-14 09:57:15 +02:00
8b0706a6c1 fix compile error 2019-08-13 13:27:43 +02:00
180d46c76e remove copy to clipboard 2019-08-13 11:43:20 +02:00
a1fef73075 Merge branch 'master' into functions 2019-08-13 11:28:49 +02:00
1ebfffa310 fix compile error on windows 2019-08-12 17:55:52 +02:00
artem ivanov
0b15817ad2 More Float Math operations
Differential Revision: https://developer.blender.org/D5433
2019-08-12 16:36:31 +02:00
Eitan
e0ebaf8f3c Add multiply and divide to vector math node
Differential Revision: https://developer.blender.org/D5430
2019-08-12 16:24:58 +02:00
8aa6ff8ec9 Reimplement the way many arrays are allocated
This new implementation is more generic and easier to use.
2019-08-12 15:50:08 +02:00
52578524bd remove AttributeArrayCore class
It worked well, but having it does not provide enough value
to justify the additional complexity.
2019-08-12 10:30:51 +02:00
00d456761f Merge branch 'master' into functions 2019-08-12 09:23:25 +02:00
8ef0c6b0df Merge branch 'master' into functions 2019-08-07 12:02:06 +02:00
b277709d53 comment some library functions 2019-08-07 12:00:23 +02:00
f8909cfab7 only wrap intrusive listbases for now 2019-08-07 11:40:16 +02:00
4457268059 add some comments 2019-08-07 11:14:14 +02:00
b429156131 experimental reloadable function inputs 2019-08-07 11:04:30 +02:00
2428486775 allocate aligned from monotonic allocator 2019-08-07 10:54:01 +02:00
468be50313 remove unnecessary small object optimization for monotonic allocator 2019-08-07 09:33:37 +02:00
e231654e24 cleanup llvm function type creation 2019-08-06 17:40:25 +02:00
b0585aa4d4 rename element_amount to size 2019-08-06 17:23:00 +02:00
b04ec4faa5 move function to correct file 2019-08-06 17:17:34 +02:00
b46e26cd34 Fix exception when using the node search 2019-08-06 16:17:35 +02:00
71ec8895b7 rename tuple folder to cpp 2019-08-06 11:59:36 +02:00
4022d8784c New list implementation
Instead of using a templated list, it is easier to use a "generic" list, that can
handle every type with a CPPTypeInfo extension. This simplifies the code quite
a bit, because templates can be avoided in many places.
This also makes it easier to add new types.

The list will still be refcounted and still have the shared immutability semantic.
So when a list has more than one user, it is immutable.
2019-08-06 11:54:49 +02:00
a0364a6227 rename files for consistency 2019-08-05 18:18:59 +02:00
2a7b684a8a Merge branch 'master' into functions 2019-08-05 17:17:16 +02:00
b3d5ef9971 remove unused function 2019-08-05 16:35:27 +02:00
bd56ee7a78 cleanup cpp type extension 2019-08-05 15:51:05 +02:00
18820b10fd rename file 2019-08-05 14:59:34 +02:00
39989cb106 rename multimap to multi_map 2019-08-05 13:43:00 +02:00
4f282b4216 Allow passing unlinked input handlers to graph generation 2019-08-05 13:13:09 +02:00
3ea03318bb fix compile error and warning on macos 2019-08-05 13:07:40 +02:00
d5546057f2 rename classes 2019-08-05 12:58:31 +02:00
31c6db7d2a separate unlinked input grouper from inserter 2019-08-05 12:51:32 +02:00
5b8feb038d simple multivector data structure 2019-08-05 12:49:21 +02:00
80ce0cd20f join map.lookup and map.lookup_ref 2019-08-05 12:10:00 +02:00
artem ivanov
d0cdadc81e More vector math operations: Subtract, Cross Product, Reflect 2019-08-05 11:50:00 +02:00
db88d6e1a5 fix auto vectorization when function does not have certain bodies 2019-08-05 11:49:15 +02:00
6b1e4f51c0 Merge branch 'master' into functions 2019-08-05 10:39:52 +02:00
05d85c52a2 rename 2019-08-02 19:18:13 +02:00
8e9323cafa experiment with different ways to group unlinked inputs 2019-08-02 19:12:13 +02:00
afe19d51e3 remember placeholder nodes after they are created 2019-08-02 18:57:19 +02:00
f149445d38 vector.fill_indices 2019-08-02 18:51:02 +02:00
c21f39578f easily create dot graph from vtree data graph builder 2019-08-02 17:42:45 +02:00
d51db9a526 don't create array ref from single value 2019-08-02 17:42:15 +02:00
fb034c8e14 fix dot export after recent changes 2019-08-02 17:41:45 +02:00
5176484fbc rename UnlinkedInputsHandler to InputInserter 2019-08-02 16:22:06 +02:00
71d8ebd201 refactor how information about the node tree is stored 2019-08-02 16:11:25 +02:00
375577cfb9 improve file names 2019-08-02 14:10:39 +02:00
92319905a0 unify mapping names 2019-08-02 14:07:14 +02:00
2f3ccb7e90 move all tree mappings into folder 2019-08-02 14:00:46 +02:00
d537af9303 execute action for new particles after explosion 2019-08-02 13:43:56 +02:00
2be7226e86 new rgba_b attribute type 2019-08-02 13:21:12 +02:00
d022328974 new float2 particle attribute type 2019-08-02 13:18:57 +02:00
7f802fb750 initial texture color access after collision 2019-08-02 12:56:10 +02:00
3411511499 new float2 and rgba_b types 2019-08-02 12:52:40 +02:00
645293e2d9 remove redundant values 2019-08-02 10:08:51 +02:00
c5caaafd7f move collision info and particle info node in same file 2019-08-02 09:37:37 +02:00
363ba2ee7a Merge branch 'master' into functions 2019-08-02 09:27:17 +02:00
219573de22 Fix: Build error with MSVC
Zero sized arrays not being at the end of struct/class makes MSVC sad
2019-08-01 15:25:07 -06:00
480e284250 Merge branch 'master' into functions 2019-08-01 18:24:20 +02:00
f0b7499750 support for default values for vectorized inputs 2019-08-01 18:19:58 +02:00
d63f673e05 move input handlers to separate file 2019-08-01 17:55:47 +02:00
b07626e48b fix use after free in python 2019-08-01 17:25:54 +02:00
79b85c1426 add ability to store socket values as constants in IR 2019-08-01 17:18:34 +02:00
787e97057a return function body instead of bool 2019-08-01 17:18:07 +02:00
eb403083c6 support that tuples own their meta data 2019-08-01 17:17:36 +02:00
d3763513ff remove timer 2019-08-01 16:35:23 +02:00
f9a555a60a don't load socket values dynamically 2019-08-01 16:35:06 +02:00
d91a5b69d9 cleanup socket loaders 2019-08-01 16:06:25 +02:00
46bd09b789 cleanup 2019-08-01 15:56:00 +02:00
faeb98b48e compute type of every socket only once 2019-08-01 15:36:37 +02:00
0b970bc160 fix fill constructor of vector 2019-08-01 15:36:16 +02:00
795bae3410 cleanup type mappings 2019-08-01 15:07:04 +02:00
e606316ed6 rename refresh to sync_tree 2019-08-01 14:55:55 +02:00
13dce85083 fix float math node inputs 2019-08-01 14:55:20 +02:00
0ef25d8001 cleanup 2019-08-01 14:36:52 +02:00
104df5f5f2 support color in Custom Emitter node 2019-08-01 14:16:12 +02:00
69a8699b54 fix use-after-free crash from python 2019-08-01 14:15:56 +02:00
3d1de1e44e cache enum items in python 2019-08-01 14:15:28 +02:00
ffbe506a55 rename DFGraphSocket to DataSocket 2019-08-01 13:33:40 +02:00
3d2e279b3d rename DataFlowGraph to just DataGraph 2019-08-01 13:30:13 +02:00
6dc48fd18d replace DataFlowGraphBuilder implementation 2019-08-01 13:26:34 +02:00
218fcf4473 replace another map with a vector 2019-08-01 10:28:30 +02:00
1fd26737b5 use virtual socket index to replace a map with a vector 2019-08-01 10:16:56 +02:00
2f948952b5 store an index per virtual socket 2019-08-01 10:16:36 +02:00
f6ef23ebe7 remove IndexedNodeTree data structure in favor of VirtualNodeTree 2019-08-01 09:59:55 +02:00
fe5356bf25 Merge branch 'master' into functions 2019-08-01 09:52:03 +02:00
4c8746a965 Merge branch 'master' into functions 2019-07-31 18:41:50 +02:00
28ba204e17 easy access to identifier of socket 2019-07-31 18:41:06 +02:00
56e541dba6 identify types with idname 2019-07-31 18:35:24 +02:00
27b365058e remove last remainings of GraphInserters 2019-07-31 18:28:14 +02:00
22bd4ad4fb move more code out of GraphInserters 2019-07-31 17:53:37 +02:00
7ffa849297 start removing graph inserters 2019-07-31 17:43:46 +02:00
385e61a122 cleanup VTreeDataGraph creation 2019-07-31 17:28:48 +02:00
a5bc1b002f rename file 2019-07-31 17:21:43 +02:00
8e8049fa28 move VTreeDataGraph to separate file 2019-07-31 17:18:29 +02:00
b1fb402e1b cleanup VTreeDataGraph 2019-07-31 17:11:26 +02:00
69b0da1987 rename BTreeGraphBuilder to VTreeDataGraphBuilder 2019-07-31 17:01:33 +02:00
ed4db612f8 new Combine Color node 2019-07-31 16:57:04 +02:00
3e406633f7 only compile when there are outputs 2019-07-31 16:49:12 +02:00
529b78160c move ui code of multiple nodes in the same file 2019-07-31 16:29:14 +02:00
38463de2d9 extract some methods from llvm array execution 2019-07-31 16:09:20 +02:00
b6e533a0d9 don't expose different array execution functions 2019-07-31 15:48:50 +02:00
0f80acd54b don't prepare execution stack when not necessary 2019-07-31 15:40:11 +02:00
0f3b50329c cleanup llvm ir when stack info is maintained 2019-07-31 15:18:36 +02:00
14bb065f13 support for compiling particle functions down to machine code 2019-07-31 14:54:28 +02:00
eaaa8610fa some llvm usage improvements 2019-07-31 14:27:30 +02:00
36f0132394 llvm does not permit void*, so replace all uses with i8* 2019-07-31 14:24:44 +02:00
670537ed8a initial tuple call array execution 2019-07-31 11:23:13 +02:00
bff87f3a9a fix merge conflict 2019-07-31 10:35:33 +02:00
5878add697 Merge branch 'master' into functions 2019-07-31 10:30:30 +02:00
3e0fd90605 use another strategy to create functions for unlinked inputs 2019-07-30 16:13:44 +02:00
042cc17bab clang-format 2019-07-30 15:06:22 +02:00
760e084791 show node search in menu 2019-07-30 14:59:28 +02:00
9d3a92d3e3 use background color for particle type node 2019-07-30 14:59:28 +02:00
e54acfa2ff rename 2019-07-30 14:59:28 +02:00
5841005187 add buttons to create particle type nodes 2019-07-30 14:59:28 +02:00
4f5093f403 renamed particle_modifier_output to particle_effector_output 2019-07-30 14:55:15 +02:00
26d0bbffa8 added point force node for particle nodes 2019-07-30 14:41:28 +02:00
773b6bbd42 rename modifier to effector in some places
That was missing in a previous commit.
2019-07-30 13:58:17 +02:00
c2e63d660b add color attribute type 2019-07-30 13:44:39 +02:00
33c29f35b8 simplify the way attribute information is stored 2019-07-30 13:27:37 +02:00
4bbee4acf2 new Change Particle Color node 2019-07-30 12:14:42 +02:00
99e5f16d4a new Separate Color node 2019-07-30 12:01:33 +02:00
093583620c new color socket type 2019-07-30 12:01:00 +02:00
d29052a514 make object an input in mesh collision event 2019-07-30 10:59:51 +02:00
937dde6060 fix wrong element size due to alignment 2019-07-30 10:59:34 +02:00
e41084f94a cleanup style 2019-07-30 10:20:40 +02:00
40b3c50837 Merge branch 'master' into functions 2019-07-30 10:08:15 +02:00
9fb73c42fd windows compile fixes - missing includes 2019-07-29 20:28:30 +02:00
c62b1850e3 rename "size_of_type" to just "size" 2019-07-29 17:55:52 +02:00
910431e382 start taking alignment of types into account when constructing tuples 2019-07-29 17:53:12 +02:00
bd514d20e0 remove more redundant code 2019-07-29 17:21:21 +02:00
e38e761ba6 remove more redundant code 2019-07-29 17:17:38 +02:00
b645fa8d12 remove more redundant code 2019-07-29 17:13:42 +02:00
0bf70bde16 rename try_get_T to try_get<T> 2019-07-29 17:07:03 +02:00
f78e2837ff change get_T to get<T> when accessing attributes 2019-07-29 17:03:32 +02:00
deecc8c6f8 fix error when using Call node 2019-07-29 16:43:11 +02:00
555d29a0fe initialize particles with IDs 2019-07-29 16:39:35 +02:00
c28a441a9d fix coyp paste error 2019-07-29 16:05:08 +02:00
74bdbb94e5 add integer attribute type 2019-07-29 15:48:59 +02:00
d2c1f7b9ca initial particles block id 2019-07-29 15:16:21 +02:00
aa1c4663a1 remove lots of redundant code 2019-07-29 15:08:05 +02:00
ac5bf8e4f9 initial age output in particle info node 2019-07-29 14:50:19 +02:00
e87cd0c807 introduce input provider interface 2019-07-29 14:02:04 +02:00
e2a6763be3 support for freeing particle function input arrays 2019-07-29 13:51:41 +02:00
c2461a8b87 extract method to create particle function input provider 2019-07-29 13:39:17 +02:00
f2d3539cb5 new particle function input providers abstraction 2019-07-29 13:30:55 +02:00
dbc453f414 extract methods from particle function evaluation 2019-07-29 12:30:59 +02:00
58c67cdde4 remove unnecessary typedef 2019-07-29 12:19:01 +02:00
4ed19b6b1e cleanup particle function builder 2019-07-29 12:16:55 +02:00
888aec8234 move particle function building to separate file 2019-07-29 12:07:08 +02:00
5a1a8fa917 handle inputs with no dependencies separately 2019-07-29 11:55:25 +02:00
ed2180832e use debug name checking again 2019-07-29 11:20:42 +02:00
904966b3ef particle function contains two functions: with/without dependencies 2019-07-29 11:14:38 +02:00
6e83213a5f utility to iterate over trivial particle indices 2019-07-29 10:06:48 +02:00
41f83ef571 scoped timer per element 2019-07-29 10:03:27 +02:00
a8c46c4bf0 fix after merge 2019-07-29 09:13:38 +02:00
1b274efd7c Merge branch 'master' into functions 2019-07-29 09:09:33 +02:00
248ee40712 Cleanup: Fix build error with msvc. 2019-07-25 15:18:33 -06:00
7db0b9c265 add utility to combine strings on the stack 2019-07-25 15:09:57 +02:00
7a3e5c1dad simplify creating particle function 2019-07-25 14:31:25 +02:00
9b3e1859ef simplify action builders 2019-07-25 14:20:36 +02:00
63a9949c27 compute particle functions more centrally for events 2019-07-25 10:18:22 +02:00
6c3afa7801 create particle function for force inputs more centrally 2019-07-25 10:06:03 +02:00
7e4c489778 use particle function for gravity force 2019-07-25 10:01:10 +02:00
c92dd7bed6 create particle function more centrally for offset handlers 2019-07-25 09:54:46 +02:00
7de561f930 Merge branch 'master' into functions 2019-07-25 09:42:45 +02:00
03f4489e4d Merge branch 'master' into functions 2019-07-24 19:19:46 +02:00
93b01da75e use threading again 2019-07-24 19:10:55 +02:00
3976570539 use particle function in Age Reached event 2019-07-24 19:07:55 +02:00
2d925db8b0 fix double free and optimize when particle function inputs have no dependencies 2019-07-24 19:07:38 +02:00
fd0226f614 handle type extensions as references instead of pointers by default 2019-07-24 17:52:22 +02:00
85536c5e75 use function bodies as references instead of pointers by default 2019-07-24 17:43:00 +02:00
f54507724f rename 2019-07-24 17:13:33 +02:00
54724cc5b3 simplify usage of particle functions 2019-07-24 17:12:13 +02:00
b60b193384 do more checks when debugging 2019-07-24 16:27:07 +02:00
299ba77cc9 fix false positive memory leak 2019-07-24 16:15:06 +02:00
c0fd3b6962 remove tests because their are more trouble than they are worth currently 2019-07-24 16:14:50 +02:00
dec218643e use particle function in turbulence node 2019-07-24 15:54:16 +02:00
1cc5f83442 introduce force interface 2019-07-24 15:46:30 +02:00
e468ca977e use particle function in trails node 2019-07-24 15:25:43 +02:00
d9f02f209b further simplify usage of particle function 2019-07-24 15:09:55 +02:00
f169a5eeb7 improve particle function 2019-07-24 15:06:07 +02:00
bdcca74b23 rename 2019-07-24 14:47:05 +02:00
1f79a069d3 move particle function to separate file 2019-07-24 14:44:36 +02:00
d4f57524be rename 2019-07-24 13:58:04 +02:00
89001688d6 rename EventInfo to ActionContext 2019-07-24 13:56:07 +02:00
2859cf6902 cleanup executing actions 2019-07-24 13:50:36 +02:00
bc9d51d048 expose collision normal in new Collision Info node 2019-07-24 13:33:12 +02:00
712701a4ef remember socket that triggered an action 2019-07-24 12:52:35 +02:00
f777ac8a52 use new function creation method for action and offset handlers 2019-07-24 12:36:13 +02:00
efa9b1cc41 use error handling for event nodes 2019-07-24 11:47:37 +02:00
5de6dca2f5 create function to compute force inputs 2019-07-24 11:43:28 +02:00
cb091c196f use better error handling for other emitters 2019-07-24 11:37:30 +02:00
d9348adb33 better error handling when creating function for emitter inputs 2019-07-24 11:33:15 +02:00
f1c69c71c6 move FunctionBuilder to separate file and add more methods 2019-07-24 11:32:40 +02:00
b1425fc68b namespace fix 2019-07-24 11:31:53 +02:00
556691b19a Improve error handling with ValueOrError class
We might want to use exceptions instead of this.
I'm not sure yet.
2019-07-24 10:58:11 +02:00
a0f9564d1b cleanup finding placeholder dependencies 2019-07-24 10:14:51 +02:00
c21d8bd0d9 cleanup finding node inputs 2019-07-23 19:03:49 +02:00
a18d338d3f minor improvements 2019-07-23 19:02:39 +02:00
a781b6fc3a rename BTreeDataGraph to VTreeDataGraph 2019-07-23 18:06:41 +02:00
17dd4e03b8 move function generation file to correct file 2019-07-23 18:04:27 +02:00
fa26630d87 fix uninitialized memory 2019-07-23 18:00:24 +02:00
937a448de2 Remove Composition data structure
This simplifies the code and speeds up accessing function
bodies and type extensions. Now, a lock is only necessary
when create new bodies or extensions.

This is achieved at the cost of having a slighly less generic
system, because we have to give e.g. different function body
types different IDs. Since the number of different types
is expected to be fairly low, this trade off is worth it.
2019-07-23 16:54:40 +02:00
d6a7832f6d simplify virtual node tree usage 2019-07-23 14:59:18 +02:00
9869bc3bc4 Merge branch 'master' into functions 2019-07-23 09:46:00 +02:00
d6b7aecbbc reorder lines 2019-07-22 17:58:31 +02:00
5bcc78ada9 remove builders that are not necessary for now 2019-07-22 17:57:20 +02:00
c900098170 remove unnecessary usings 2019-07-22 17:34:03 +02:00
51fb6b5098 remove unnecessary type definitions 2019-07-22 17:31:20 +02:00
5a269bfb57 remove "small" from test names 2019-07-22 17:19:35 +02:00
f0c164b861 rename SmallVector to Vector 2019-07-22 17:17:47 +02:00
a1ba33090b rename SmallMap to Map 2019-07-22 17:10:42 +02:00
6a63774f43 rename SmallMultiMap to MultiMap 2019-07-22 17:07:58 +02:00
d0d6f38754 rename SmallStack to Stack 2019-07-22 17:05:37 +02:00
f179b2dd30 rename SmallSetVector to SetVector 2019-07-22 16:59:52 +02:00
f9caf48eab Rename SmallSet to just Set
The fact that the data structure has small object optimization
is not important enough to justify a more complex name.
Following commits will rename other data structures.
2019-07-22 16:57:59 +02:00
f039c43f95 cleanup 2019-07-22 16:47:32 +02:00
4b42c112fd cleanup accessing rna of virtual node 2019-07-22 16:46:11 +02:00
3dfbbf606e cleanup accessing node names 2019-07-22 16:40:29 +02:00
9a4d125533 use virtual node tree for parsing particle system node trees 2019-07-22 16:35:49 +02:00
7d5ee7c689 start using virtual node tree to generate functions 2019-07-22 15:49:13 +02:00
c71997dd67 initial virtual node tree 2019-07-22 14:19:12 +02:00
fb26304aa2 ArrayRef.contains_ptr 2019-07-22 14:18:43 +02:00
8a69395d6a rename SocketBuilder to NodeBuilder 2019-07-22 12:41:02 +02:00
86fb4243d1 cleanup 2019-07-22 12:37:31 +02:00
ddf0b72870 make socket.data_type a class property 2019-07-22 12:32:51 +02:00
b7efaadb8e get socket data type from idname 2019-07-22 12:04:42 +02:00
227a28e9e5 remove dead code 2019-07-22 10:49:46 +02:00
b1d21db61b remove colored socket builder 2019-07-22 10:48:34 +02:00
6356f27a87 Merge branch 'master' into functions 2019-07-22 10:24:28 +02:00
fa9f34c056 show particle type names in nodes 2019-07-20 14:21:22 +02:00
1180996832 add ability to select output mesh type in modifier settings 2019-07-20 14:06:51 +02:00
dd47cbf3b7 use constant velocity integrator when there are no forces 2019-07-20 13:40:00 +02:00
0767dad328 rename function 2019-07-20 13:39:17 +02:00
9fa5d75d80 Fix moving sets and maps 2019-07-20 12:57:12 +02:00
ff398d29a6 Merge branch 'master' into functions 2019-07-20 11:53:07 +02:00
9a965af529 move offset handlers to separate file 2019-07-18 17:34:40 +02:00
49d2d8b47e add timer 2019-07-18 17:18:52 +02:00
10c81747fe splitup remainings of core.hpp 2019-07-18 17:16:40 +02:00
c23ccfc0ac separate files for particle state and allocator 2019-07-18 16:59:31 +02:00
0645752ab7 cleanup 2019-07-18 16:59:08 +02:00
bd49708841 rename target to new_particles 2019-07-18 16:49:20 +02:00
c67953c53e move particle set to separate file 2019-07-18 16:47:10 +02:00
182cc12015 fix trail creation for partial time steps 2019-07-18 16:39:28 +02:00
83e75345a2 simple rate input for Trail node 2019-07-18 16:19:31 +02:00
e29914292a missing destructor 2019-07-18 15:57:34 +02:00
6793bab243 use proper constructors for step description and particle type 2019-07-18 15:39:05 +02:00
2c0c758d72 make StepDescription class non-virtual 2019-07-18 15:30:48 +02:00
234f5d9407 make ParticleType class non-virtual 2019-07-18 15:28:08 +02:00
d0eed2a7ac change how particle types declare which attributes they need 2019-07-18 15:23:45 +02:00
023f477bdd rename AttributesInfoBuilder to AttributesDeclaration 2019-07-18 15:04:23 +02:00
8dd5be76c0 initial step desription builder 2019-07-18 14:59:07 +02:00
24c5a21977 remove redundant particle type name storage 2019-07-18 14:30:53 +02:00
f2737b927d rename ForwardListener to OffsetHandler 2019-07-18 14:04:38 +02:00
1272208b2b remove redundant information 2019-07-18 13:52:58 +02:00
d908edbc8a cleanup 2019-07-18 13:47:13 +02:00
9fd56bed3f cleanup 2019-07-18 13:44:29 +02:00
e47c49c872 remove redundant information 2019-07-18 13:40:36 +02:00
168f5964b6 remove redundant information 2019-07-18 13:37:04 +02:00
fe8cace993 use block step data in more places 2019-07-18 12:56:22 +02:00
ea6bbc1aec use step block data in more functions 2019-07-18 12:39:02 +02:00
d1f05d2415 use step block data in more functions 2019-07-18 12:22:47 +02:00
a6914c973f introduce BlockStepData as container for data that would have to be passed into many functions 2019-07-18 12:16:10 +02:00
7aa22a24a7 initial forwarding listeners + particle trail node
Still looking for a better name instead of Forwarding Listeners
2019-07-18 12:08:36 +02:00
4672d7aa83 Merge branch 'master' into functions 2019-07-18 10:37:40 +02:00
d6230d1563 don't always use cache for now since it makes testing more annoying 2019-07-17 18:01:25 +02:00
e800a2d5fa experimental initial grid emitter 2019-07-17 17:45:44 +02:00
0df9c55578 pass time step in from the modifier 2019-07-17 17:11:05 +02:00
a2b128a451 experimental Close By Points event 2019-07-17 16:46:13 +02:00
54f7163310 minor changes 2019-07-17 15:57:17 +02:00
09bc3a0aac Revert "use evaluated node tree"
This reverts commit eddb4d0af4.

Sometimes the evaluated node trees are not updated when the real
node tree changes. Use original trees until this is fixed.
2019-07-17 11:20:47 +02:00
da04c045fe velocity and size input for point emitter 2019-07-16 18:18:53 +02:00
ce2081e5b3 support for interpolated float values 2019-07-16 18:18:09 +02:00
06d8ed1a8a store color per particle 2019-07-16 17:59:20 +02:00
ec7054772b utility operators to create emitter and particle system trees 2019-07-16 17:33:13 +02:00
bd573cf2d7 use vector adaptor instead of pointer+length in fgraph tuple call 2019-07-16 16:29:13 +02:00
667b56f87b use "ifdef DEBUG" instead of "if DEBUG" 2019-07-16 16:28:49 +02:00
eddb4d0af4 use evaluated node tree 2019-07-16 16:12:56 +02:00
c41a9d0e88 fix fgraph tuple call 2019-07-16 16:12:06 +02:00
55a74c35dd fix vector math node 2019-07-16 15:59:42 +02:00
c35feef507 new node to get the vertices of a mesh 2019-07-16 15:36:22 +02:00
9a02226aa2 support for geometry dependencies of functions 2019-07-16 15:35:50 +02:00
f4dac36c05 extract another function for linking 2019-07-16 14:52:06 +02:00
a5b90dc661 extract method that links functions 2019-07-16 14:43:47 +02:00
70f8f3231b Custom Emitter functions can have inputs now 2019-07-16 14:33:08 +02:00
6a8985dfa5 utility to map multiple sockets 2019-07-16 13:22:58 +02:00
f0cc032f83 construct SmallVector from arbitrary containers 2019-07-16 13:04:26 +02:00
39ebd2fd1f more general function tree dependency discovery 2019-07-16 12:57:30 +02:00
8fec347121 more powerful custom emitter 2019-07-16 11:37:43 +02:00
f058e7b11a remove unnecessary check 2019-07-16 11:32:12 +02:00
8ba1856a13 fix bug in fgraph tuple call 2019-07-16 11:32:01 +02:00
38e223e392 initialize attributes by repeating a given array 2019-07-16 10:00:57 +02:00
f388fdc4f1 Merge branch 'master' into functions 2019-07-16 09:37:19 +02:00
36bd4e1225 get rid of static block size 2019-07-15 18:09:07 +02:00
e95c0078a2 initial custom function emitter 2019-07-15 17:56:02 +02:00
94d2a11636 more debug time checks 2019-07-15 17:25:19 +02:00
ad6fa16304 use more debug time checks 2019-07-15 17:19:02 +02:00
c5d18a0a8a check that indices correspond to correct outputs in debug build 2019-07-15 17:09:32 +02:00
6d208e3183 remove indirection 2019-07-15 16:54:47 +02:00
89a8b1f4f5 cleanup events 2019-07-15 16:51:23 +02:00
aefdc1807a cleanup emitters 2019-07-15 16:43:27 +02:00
b5a74ae166 remove a level of indirection 2019-07-15 16:23:42 +02:00
034956978e more boilerplate code removal 2019-07-15 16:18:59 +02:00
fa9bf0c5b1 cleanup 2019-07-15 16:15:06 +02:00
719357ffda revisit autorefcount 2019-07-15 16:07:24 +02:00
f2421c042e abstract interpolated vectors and matrices 2019-07-15 15:35:45 +02:00
0b3ff01ba4 bring back some emitter settings 2019-07-15 15:23:20 +02:00
39476c5ce3 remove boilerplate code for emitters 2019-07-15 15:18:35 +02:00
419f0de8d3 initialize emitter differently 2019-07-15 15:11:36 +02:00
25b3b122e6 experiment with remembering last point emitter position 2019-07-15 14:39:59 +02:00
2e1ba1c02a interpolate vectors 2019-07-15 14:37:37 +02:00
65f2000075 cleanup variable shadowing 2019-07-15 13:49:29 +02:00
3c979ed37e delete particles in same taskpool as simulation 2019-07-15 12:08:23 +02:00
89b625a0ce Merge branch 'master' into functions 2019-07-15 11:47:47 +02:00
b6b26efb9f Merge branch 'master' into functions 2019-07-12 15:06:01 +02:00
a84fcf8cde actually use threading... 2019-07-12 14:49:30 +02:00
60a2d39782 remove temporary code 2019-07-12 14:08:34 +02:00
45b4704df6 use function to compute point input of point emitter 2019-07-12 14:05:33 +02:00
3915ca912a remove unused code 2019-07-12 13:58:11 +02:00
82844c5f11 cleanup dependency builder 2019-07-12 13:51:20 +02:00
b6c1d3e1bd make updating depsgraph work again 2019-07-12 12:39:57 +02:00
fe4c294656 improve fgraph dependencies 2019-07-12 12:24:43 +02:00
b6820e4a87 fixes 2019-07-12 12:17:43 +02:00
da34e3476e cleanup 2019-07-12 12:02:26 +02:00
b0015fc7cd multimap fix 2019-07-12 12:00:39 +02:00
c77abe1e8d initial revised function dependency handling 2019-07-12 10:33:22 +02:00
5366c5c827 utility functions to access data flow graph 2019-07-12 10:27:52 +02:00
53d00eb08b simplify array printing 2019-07-12 10:14:27 +02:00
b124984220 fix when there are no triangles in mesh 2019-07-12 10:14:12 +02:00
3708e233b5 add multiple in multimap 2019-07-12 09:16:44 +02:00
5b7f49edc4 comment in stringmap 2019-07-11 16:34:53 +02:00
800a578ed7 use StringMap everywhere 2019-07-11 16:30:46 +02:00
12149d8e1b initial string map 2019-07-11 15:50:46 +02:00
05d742427f cleanup action builders 2019-07-11 15:39:06 +02:00
d8719603f8 pass build context instead of separate parameters 2019-07-11 15:30:13 +02:00
db6a45ce1f reorder functions 2019-07-11 15:21:11 +02:00
e0a7c11dd0 cleanup simple emitter builders 2019-07-11 15:14:12 +02:00
32e435bbc3 simplify event inserters 2019-07-11 14:44:01 +02:00
9f1c625056 cleanup force node handling 2019-07-11 14:29:17 +02:00
abb76708d1 simplify create function for node inputs 2019-07-11 13:47:53 +02:00
79ec9180e6 rename GeneratedGraph to BTreeDataGraph 2019-07-11 13:37:43 +02:00
57f7d83def cleanup executing actions for a subset 2019-07-11 12:47:05 +02:00
8eb57698c4 cleanup running action from event 2019-07-11 12:36:09 +02:00
401ff628bd settings size in point emitter is not necessary anymore 2019-07-11 12:28:31 +02:00
75cc874922 introduce attributes info builder 2019-07-11 12:24:06 +02:00
7a62e775bb simplify calling action from emitter 2019-07-11 11:46:10 +02:00
615269b749 rename modifiers to effectors 2019-07-11 11:20:15 +02:00
202708eeae run action on particle birth 2019-07-11 11:17:53 +02:00
5114a48fd7 correct usage of attribute offsets that are not available 2019-07-11 10:15:56 +02:00
35dcbf506d fill an array partially 2019-07-11 09:53:39 +02:00
ed9bc5f5c0 Merge branch 'master' into functions 2019-07-11 09:37:08 +02:00
5f02cc2d3a simple clear cache operator 2019-07-10 17:17:26 +02:00
5216bf6014 get rid of particles.range() 2019-07-10 16:53:39 +02:00
dee695f2da cleanup usage of particle indices 2019-07-10 16:45:05 +02:00
4d6b6ab7e3 fix wrong index access 2019-07-10 16:34:07 +02:00
d7fd4ed39c rename particle_indices to pindices 2019-07-10 16:30:45 +02:00
b5af31fb57 use particle indices to trigger particles 2019-07-10 16:28:43 +02:00
157f0aedcb remove unused code 2019-07-10 16:23:16 +02:00
37a3a41de8 cleanup 2019-07-10 16:21:28 +02:00
8e2ae56b25 access time factors to next event with particle indices 2019-07-10 16:19:31 +02:00
25e7319488 access next event indices with particle indices 2019-07-10 16:11:31 +02:00
18e8a12ef1 use particle indices to access remaining durations 2019-07-10 15:58:53 +02:00
9386bcb29a rename durations to remaining_durations 2019-07-10 15:45:28 +02:00
0135d47a06 compute remaining durations in every thread again 2019-07-10 15:43:10 +02:00
1f9186c270 store remaining durations instead of end times 2019-07-10 15:17:56 +02:00
85b8376829 pass array allocator to emitter and execute event interface 2019-07-10 14:56:44 +02:00
3d93967292 take event execute interface out of action interface 2019-07-10 14:35:57 +02:00
8b13cd86ec more centralized solution to getting an array ref for a range 2019-07-10 14:21:53 +02:00
ab0f8b46a6 use ParticleSets abstraction instead of emitter targets 2019-07-10 13:54:33 +02:00
8ea9f57601 simplify event execute interface 2019-07-10 12:59:20 +02:00
d00457ba64 cleanup ParticleAllocators class 2019-07-10 12:39:15 +02:00
ee70791626 rename BlockAllocator to ParticleAllocator 2019-07-10 12:35:20 +02:00
1104d30f9e remove intermediate class 2019-07-10 12:32:18 +02:00
d191a1cee7 start simplifying the emitter interface 2019-07-10 12:27:18 +02:00
d58a5ac3aa Merge branch 'master' into functions 2019-07-10 11:58:14 +02:00
f09794f280 size input for mesh emitter 2019-07-10 11:36:04 +02:00
b197bf5903 sync node trees when file is loaded 2019-07-10 11:33:33 +02:00
317a2ff1e9 unify float and float3 caching 2019-07-10 11:22:27 +02:00
d34c240ebf Cache particle blocks in container for reuse 2019-07-10 11:05:46 +02:00
804ea8fe82 store and cache size per particle 2019-07-10 10:26:48 +02:00
5e22b41ce1 normal and emitter velocity inputs 2019-07-09 17:07:56 +02:00
ab6106149f move world state to mesh emitter 2019-07-09 17:01:58 +02:00
7b674cc684 pass emitter object and rate into mesh emitter node 2019-07-09 16:56:19 +02:00
fa483d50d1 pass object into object transforms node 2019-07-09 16:23:57 +02:00
7c10fa0ac3 object list type 2019-07-09 16:20:40 +02:00
761090b9d4 object type in function system 2019-07-09 16:09:22 +02:00
0a07de8839 object data type in ui 2019-07-09 16:02:30 +02:00
1b1fcd79da basic caching system so that particles can be rendered 2019-07-09 15:56:38 +02:00
52040433a1 rename modifier 2019-07-09 13:48:00 +02:00
a9c1831b07 remove unused code 2019-07-09 13:33:06 +02:00
d2e4f94205 move action builders to separate functions 2019-07-09 13:32:20 +02:00
4b9b9c7813 simplify inserters 2019-07-09 13:24:16 +02:00
72913dbafc initial process node interface 2019-07-09 12:55:15 +02:00
6ab1d300d6 fix variable names 2019-07-09 12:29:30 +02:00
1bfe567129 new node_frontend interface 2019-07-09 12:27:26 +02:00
fb1fdbd217 remove unnecessary includes 2019-07-09 12:16:54 +02:00
43d037b086 move inserters to separate file 2019-07-09 12:13:34 +02:00
d845e15750 move integrator to seprate file 2019-07-09 12:02:11 +02:00
8364c3aafc move step description to separate file 2019-07-09 11:53:36 +02:00
81795f30b4 move world state to separate file 2019-07-09 11:44:37 +02:00
f3b06e8b15 taking emitter velocity into account 2019-07-09 11:23:06 +02:00
3d919e445a add ability to cache the world state to avoid stepping effects 2019-07-09 10:53:56 +02:00
9863f2bfec new map.add_override method 2019-07-09 10:53:14 +02:00
438aae9d0f remove Function from displace modifier (was only for testing) 2019-07-09 09:58:12 +02:00
30dee2dbd2 specify default inputs for some nodes 2019-07-09 09:50:07 +02:00
d94c249194 add ability to specify default values for data sockets 2019-07-09 09:49:55 +02:00
0d28e20bc3 move possibly empty arrays to end of struct for msvc compatibility 2019-07-09 09:32:35 +02:00
b01071a4f3 Merge branch 'master' into functions 2019-07-08 17:55:29 +02:00
435698e219 rename insert to add 2019-07-08 17:55:07 +02:00
ad7c91b346 new compare function 2019-07-08 17:34:48 +02:00
fed773cec6 random number node should have float instead of int input 2019-07-08 17:14:02 +02:00
9d79363098 move functions to correct file 2019-07-08 17:09:29 +02:00
317158e106 reintroduce unique_ptr for actions and events 2019-07-08 17:08:31 +02:00
6e86e314ef move action interface to separate file 2019-07-08 16:56:27 +02:00
65292981a4 improve ActionInterface 2019-07-08 16:50:28 +02:00
6dd1e480b5 initial Action interface 2019-07-08 16:21:44 +02:00
2a0abf0adf initial condition action 2019-07-08 16:09:32 +02:00
f7e7335123 improved event info usage 2019-07-08 15:39:54 +02:00
49e5434e94 initial collision event info 2019-07-08 15:13:57 +02:00
b293739f1f initial event info 2019-07-08 14:23:08 +02:00
c8816dbd31 StringRef.drop_prefix 2019-07-08 14:14:45 +02:00
6bfa473b60 simplify StringRef operator overloads 2019-07-08 14:02:19 +02:00
cba2b0367c stringref: iterate, startswith and endswith 2019-07-08 13:57:25 +02:00
1251ef30aa gather required attributes from particle type and events 2019-07-08 13:30:58 +02:00
fe697e5c1f SmallSet.add_multiple_new 2019-07-08 13:30:08 +02:00
db89c65746 remove separate EventFilter class 2019-07-08 12:57:39 +02:00
03e95e569b distribute tetrahedons in parallel 2019-07-08 12:43:39 +02:00
d71543bf60 new utility to process a range with multiple threads 2019-07-08 12:42:35 +02:00
fce3694f0d new ChunkedRange 2019-07-08 12:42:13 +02:00
d824cb4a7f allow using array allocator in integrator 2019-07-08 11:53:38 +02:00
16a23f4195 rename FixedArrayAllocator to just ArrayAllocator 2019-07-08 11:44:21 +02:00
7387e36267 simplify allocating arrays and vectors from fixed array allocator 2019-07-08 11:41:38 +02:00
fc412c78b4 comment on fixed array allocator 2019-07-08 11:08:23 +02:00
ef8cbccd54 simplify method names 2019-07-08 11:03:26 +02:00
5503207730 use scoped array allocations to simplify memory management 2019-07-08 11:00:41 +02:00
fff24d71f7 cleanup multimap 2019-07-08 10:37:28 +02:00
3c67bda1d2 Merge branch 'master' into functions 2019-07-08 09:56:40 +02:00
2e701cbaaf rename file to BLI_small_multimap 2019-07-06 18:01:23 +02:00
20bd3b5ed1 add vertex colors to tetrahedons for visualization 2019-07-06 17:30:00 +02:00
e852f7d356 create SmallVector from MappedArrayRef 2019-07-06 17:12:11 +02:00
6715600796 flatten float3 attribute of container 2019-07-06 16:49:12 +02:00
b832be6206 improved particle to tetrahedon conversion 2019-07-06 16:38:26 +02:00
b2188f052b initial particle info node 2019-07-06 15:36:02 +02:00
f204ea5624 Fix append_n_time reallocating every time 2019-07-06 15:14:51 +02:00
1d2adb08f8 Fix ArrayLookup for the case when all slots are used or dummies 2019-07-06 14:43:31 +02:00
f7e0f429e2 remove unused modifier properties 2019-07-05 18:07:12 +02:00
2746f423bd initial turbulence node 2019-07-05 17:38:29 +02:00
f67431d729 use gravity node in simulation 2019-07-05 16:56:40 +02:00
30c6880fe0 initial gravity force node ui 2019-07-05 16:39:29 +02:00
fa79121db2 initial mesh collision event node 2019-07-05 15:40:58 +02:00
d5f21d2aac cleanup age reached event inserter 2019-07-05 15:19:33 +02:00
7beef61562 get node of socket from indexed tree 2019-07-05 15:13:28 +02:00
57cb7849fa construct SmallStack from array 2019-07-05 15:03:48 +02:00
cc8ff01d8e deduplicate function create code 2019-07-05 14:49:18 +02:00
2c8e8d547f add speed input to explode node 2019-07-05 14:42:54 +02:00
681ae8d03c initial explode particle node 2019-07-05 14:38:35 +02:00
0380b22606 better handling of zero duration 2019-07-05 13:42:52 +02:00
452369f1b7 simulate more events per step, again 2019-07-05 12:57:03 +02:00
278dc870c0 allow event filters to add attributes to a particle type 2019-07-05 12:53:37 +02:00
f9edcf46b3 improved change direction action 2019-07-05 12:23:45 +02:00
873f483836 new change direction action 2019-07-05 11:15:57 +02:00
7de0213588 access element at index in listbase 2019-07-05 11:15:31 +02:00
821b7e5360 initial build action from nodes 2019-07-05 10:48:44 +02:00
fc490e4236 new action that does nothing 2019-07-05 10:38:58 +02:00
b71291c96d cleanup 2019-07-05 10:38:44 +02:00
e02befdd2c remove unnecessary IndexedBParticlesTree 2019-07-05 10:28:43 +02:00
5e7dc72f11 better function signature for inserters 2019-07-05 10:24:38 +02:00
057455726c new kill particle node ui 2019-07-05 10:14:01 +02:00
c5330b6d94 new control flow socket 2019-07-05 10:11:40 +02:00
9328e6f0bf Merge branch 'master' into functions 2019-07-05 09:53:41 +02:00
d3c5e882b0 Use monotonic allocator instead of more complex ones 2019-07-04 18:04:58 +02:00
16c92706d8 some comments for allocators 2019-07-04 17:33:46 +02:00
7f410f0655 initial replaceable unlinked inputs handler
Depending the use case, unlinked node inputs should be handled differently.
Sometimes, it is okay to load them from RNA on every call, but
sometimes they should also be hardcoded into the generated assembly.
2019-07-04 16:30:31 +02:00
cdd5d41e6e fix memory leak 2019-07-04 16:08:07 +02:00
3a0cfed4aa first time using the function nodes within bparticle nodes 2019-07-04 15:57:38 +02:00
82ae82488e cleanup data flow graph generation 2019-07-04 15:31:09 +02:00
e7ff5b1470 don't use output parameter when building data flow graph 2019-07-04 15:02:10 +02:00
7a6ab07e9e make it possible to build data flow graphs for any node tree 2019-07-04 14:49:53 +02:00
bee737bbad store list with non-reroute and non-frame nodes explicitely 2019-07-04 14:03:06 +02:00
d66644dd87 cleanup finding input and output nodes of function 2019-07-04 13:57:05 +02:00
be0ed93f99 use indexed node tree in more places 2019-07-04 13:44:33 +02:00
b06ed62500 initial age reached event node 2019-07-04 13:29:49 +02:00
8628f329e8 cleanup rna access 2019-07-04 11:34:49 +02:00
4ae4d125cd simple point emitter node for testing 2019-07-04 11:30:49 +02:00
c44a8e5ede initial emitter inserter 2019-07-04 11:17:21 +02:00
4cb0cb6a06 improve indexed node tree 2019-07-04 10:54:17 +02:00
96f4921704 refactor IndexedBParticlesTree 2019-07-04 10:32:57 +02:00
a6b5767d27 rename NodeTreeQuery to IndexedNodeTree 2019-07-04 10:29:35 +02:00
28c4b3e6f8 identify particle types with name instead of integer
While this might be less efficient, it is much more comfortable to work with.
Also it might be possible to make it a bit more efficient again in the future.
2019-07-04 10:20:32 +02:00
fefeaec48d Merge branch 'master' into functions 2019-07-03 19:11:23 +02:00
5aa6c03fbc use BLI_STATIC_ASSERT 2019-07-03 19:10:07 +02:00
f16c8eec40 optimize adding multiple new values to multimap 2019-07-03 19:02:49 +02:00
10437bba07 only use new multimap implementation 2019-07-03 19:01:14 +02:00
2df06e3172 fix issue with multiple links at same socket 2019-07-03 18:49:57 +02:00
d14073a5fc better multimap implementation for a specific use case 2019-07-03 18:42:29 +02:00
918cdba723 missing from last commit 2019-07-03 18:42:01 +02:00
33dda8463d improved lookup or insert functions for map 2019-07-03 18:41:16 +02:00
b9fee1a5d7 return index when value was inserted before 2019-07-03 17:09:33 +02:00
9af1aa48ab remove unnecessary template parameter 2019-07-03 16:56:01 +02:00
d9277bf1c4 support storing multiple connected sockets per socket 2019-07-03 16:35:36 +02:00
5db4d8269e add multiple new elements to multimap 2019-07-03 16:33:53 +02:00
d037390cd2 iterate keys of multimap 2019-07-03 16:13:35 +02:00
011e88d03c convert linked list to array for further processing 2019-07-03 15:57:56 +02:00
29413c894b class to simplify querying bparticle node tree 2019-07-03 15:51:39 +02:00
b80000f073 rename BNodeTreeLookup to NodeTreeQuery 2019-07-03 15:36:32 +02:00
9c7ef45214 Use float3 instead of custom vector type in function system 2019-07-03 15:34:47 +02:00
bf55ab38d8 comment on llvm builder and types 2019-07-03 15:16:22 +02:00
2448312278 comment on tuple-call 2019-07-03 15:01:54 +02:00
8840be2fb9 Merge branch 'master' into functions 2019-07-03 11:19:24 +02:00
aaef6e6e3a comment on tuple 2019-07-02 18:38:06 +02:00
7a7592e615 comment on CPPTypeInfo 2019-07-02 18:01:06 +02:00
c347373fc6 Comment on SourceInfo, FunctionGraph and DataFlowGraphBuilder 2019-07-02 17:51:10 +02:00
32fdee4444 comment on data flow graph 2019-07-02 17:41:56 +02:00
f5358bc122 comment on Function class 2019-07-02 17:27:00 +02:00
9a9b1e1595 separate declaration from implementation for Function type 2019-07-02 17:11:20 +02:00
6e786c85ea comment on type system 2019-07-02 17:01:14 +02:00
49804947e9 separate declaration and implementation of methods of type 2019-07-02 16:42:20 +02:00
b22a82869c get rid of using TypeVector 2019-07-02 16:33:12 +02:00
4fcd92f624 Tuple now has a weak reference to its metadata to prevent synchronization overhead 2019-07-02 16:31:34 +02:00
d94d68afde parse very simple bparticles node tree 2019-07-02 16:09:56 +02:00
5481e5119b use multimap to more generally store socket origins 2019-07-02 15:31:01 +02:00
1a7507709f get number of values stored per key in multimap 2019-07-02 15:30:32 +02:00
a0cff9838a utility to get nodes with idname 2019-07-02 15:05:38 +02:00
deb642d2ec disable bmesh unit test due to linker errors that I cannot fix now 2019-07-02 15:01:22 +02:00
e0af39a0dc construct SmallVector from ListBase 2019-07-02 15:00:38 +02:00
7db1888bf2 move node tree lookup utilities to BKE 2019-07-02 14:15:20 +02:00
a4fd3f7cc4 store pointer to node tree in modifier data 2019-07-02 12:51:32 +02:00
33e09fe233 initial particle type and mesh emitter node 2019-07-02 12:40:01 +02:00
d41e65e44c rename function_nodes folder to nodes and add bparticles tree type 2019-07-02 12:13:16 +02:00
d5b0df396a various small improvements 2019-07-02 12:02:54 +02:00
940776370c Merge branch 'master' into functions 2019-07-02 09:13:37 +02:00
59d9310b28 initial point randomization accross surface 2019-07-01 17:45:21 +02:00
77d8f118ef avoid stepping when the emitter is moving quickly 2019-07-01 17:29:14 +02:00
2e2fab2f3b cleanup 2019-07-01 17:12:10 +02:00
145e061bce minor cleanup 2019-07-01 17:02:26 +02:00
05027c4d41 cleanup bounce code a little 2019-07-01 16:57:43 +02:00
d7e2e5f99d remove comments that are more confusing than helpful 2019-07-01 15:53:46 +02:00
ad516eda2f cleanup event handling code 2019-07-01 15:47:56 +02:00
6ae9324ada comment on time span 2019-07-01 15:40:22 +02:00
8a6a59d99e comment on particle block 2019-07-01 15:36:15 +02:00
7e2418a877 rename block.size() to block.capacity() 2019-07-01 15:26:28 +02:00
7afeb9775a rename inactive to unused to avoid confusion 2019-07-01 15:25:09 +02:00
f52ff92cc3 rename block.slice() to block.attributes_slice() 2019-07-01 15:21:01 +02:00
ab0c7b8485 rename block.slice_all() to block.attributes_all() 2019-07-01 15:19:24 +02:00
f67bb0ad35 rename block.slice_active() to block.attributes() 2019-07-01 15:16:12 +02:00
c74de0c2e9 comment on particles container 2019-07-01 15:14:39 +02:00
b9baffc59d Comment on AttributeArraysCore and AttributeArrays 2019-07-01 15:02:39 +02:00
eb3fc2c23a comments for AttributeInfo 2019-07-01 14:48:27 +02:00
468e2b8e66 cleanup extracting all particle positions 2019-07-01 14:14:02 +02:00
0de90d6f88 make sure event data is not overwritten by later events 2019-07-01 14:01:06 +02:00
50802c0e6c comment remaining api functions 2019-07-01 13:43:27 +02:00
00bde8527d more comments on api 2019-07-01 12:59:59 +02:00
ac57332ddf access current simulation time through accessor 2019-07-01 12:42:08 +02:00
eb2da8bc5a improve attribute interface 2019-07-01 12:39:02 +02:00
6f069a03d1 new integrator interface 2019-07-01 12:20:55 +02:00
4bdc04e8fb comment particle system api 2019-07-01 12:12:05 +02:00
37c0e0e6e9 cleanup: separate declarations from implementations 2019-07-01 11:42:15 +02:00
a8eb1d28db start cleaning up core.hpp 2019-07-01 11:24:22 +02:00
585d6a51c0 initial api for threading with thread local data
This does look quite ugly so far, but it is still better than doing it manually every time.
2019-07-01 11:08:00 +02:00
6335c3dee8 change threading api 2019-07-01 10:16:29 +02:00
6289393f7b initial c++ api for parallel processing on top of BLI_task 2019-07-01 09:57:34 +02:00
d65427ca94 Merge branch 'master' into functions 2019-07-01 09:37:12 +02:00
2c3d53cf7f minor changes 2019-06-30 15:59:47 +02:00
3c5f321639 fix indices errors 2019-06-30 15:51:18 +02:00
af46f07ef5 initial bounce test 2019-06-30 15:21:43 +02:00
b7b2849c82 initial event storage 2019-06-30 14:34:31 +02:00
ae346fb579 bring back old test setup 2019-06-30 14:07:58 +02:00
4fb660d036 rename run_actions to execute_events 2019-06-30 13:55:20 +02:00
27149c94ee rename EventAction to Event + interface name changes 2019-06-30 13:54:22 +02:00
2618c497c5 rename old Event to EventFilter 2019-06-30 13:49:18 +02:00
3c80e4bc92 code for testing 2019-06-30 13:47:20 +02:00
59e58328ec multithread deletion of tagged particles 2019-06-30 13:42:31 +02:00
c839b2b7b5 use Vector Adapator to simulate to next event 2019-06-30 13:29:01 +02:00
ea5a9c8ec0 use array allocator in simulate_with_max_n_events function 2019-06-30 13:11:26 +02:00
88f5ba087a remove last event times for now 2019-06-30 12:17:23 +02:00
749af6d36c enable threading again 2019-06-30 12:10:40 +02:00
b60dcf9765 store fixed array allocator per thread 2019-06-30 11:51:03 +02:00
8e6bdabb00 always display nanoseconds for now 2019-06-30 11:27:18 +02:00
eb78369271 initial usage of fixed array allocator in simulation 2019-06-30 11:16:14 +02:00
686fa5ca84 utility to allocate attributes from array allocator 2019-06-30 11:12:02 +02:00
0fd83de6c3 new fixed array allocator 2019-06-30 11:11:34 +02:00
80a84f7c11 remove some timers 2019-06-30 11:00:48 +02:00
aaf4b00ba1 test impact of manual vectorization (2x speedup) 2019-06-30 10:40:31 +02:00
2ec577c75e separate methods of integrator 2019-06-30 10:40:08 +02:00
2f91feeb03 allocate attributes at 64 byte aligned addresses 2019-06-30 10:37:49 +02:00
78362edb49 optimization when indices are trivial 2019-06-30 09:55:54 +02:00
1e45e1b6b2 don't check for events when there are none 2019-06-30 09:53:24 +02:00
0bbf940965 better timing statistics 2019-06-30 09:49:10 +02:00
d183496162 cleanup: pass events instead of particle type 2019-06-30 09:26:04 +02:00
b6e0a11e41 prepare simulation for optimizations 2019-06-30 09:22:28 +02:00
a8473ead9e new emitter for testing 2019-06-30 09:21:56 +02:00
ffb79ef037 support printing timings in nanoseconds 2019-06-30 09:04:54 +02:00
e9b83d74d2 cleanup 2019-06-29 16:19:12 +02:00
d53b5af637 refactor high level simulation code 2019-06-29 16:17:01 +02:00
5f7e8e6670 refactor simulation main entry point 2019-06-29 16:04:42 +02:00
ee16f26610 remove unnecessary use of smart pointers 2019-06-29 15:56:25 +02:00
c2e13a2f94 combine event and action 2019-06-29 15:51:38 +02:00
19dda33497 optimization for the case when particle indices are trivial 2019-06-29 15:36:51 +02:00
8dd4082b27 easy access of first and last element in array ref 2019-06-29 15:36:13 +02:00
d206062e10 implicitely convert SmallSetVector to ArrayRef 2019-06-29 15:11:22 +02:00
1d031a92a5 define attributes as part of particle type 2019-06-29 15:05:15 +02:00
425d620d57 more generic way to apply attribute offsets 2019-06-29 14:14:48 +02:00
f77dfe6e94 cleanup: rename to attribute_offsets 2019-06-29 13:48:59 +02:00
b65783941c separate integrator from simulation 2019-06-29 13:44:00 +02:00
0f26e99517 bring back loop to simulate n events 2019-06-29 13:08:48 +02:00
506b6d7df9 temporarily unrolled event loop 2019-06-29 12:53:19 +02:00
efd91c4701 integrate particles of entire block instead of a particle set 2019-06-29 12:29:06 +02:00
21dfdbc58b Merge branch 'master' into functions 2019-06-28 17:42:08 +02:00
7e767d0858 initial experimental vector adaptor data structure 2019-06-28 17:41:15 +02:00
3be92ce31b function to simulate a block 2019-06-28 16:41:18 +02:00
bb537df8d0 cleanup remove unused return parameter 2019-06-28 15:46:15 +02:00
3dbd8b81ba compute ideal offsets only once per particle per time step
I have to bring back simulating multiple events per particle now.
2019-06-28 15:43:50 +02:00
6c5a2fecf6 refactor: move computation of ideal offsets up 2019-06-28 15:33:56 +02:00
4c85e861ea refactor applying remaining particle offsets 2019-06-28 15:31:36 +02:00
b0f2b24160 cleanup 2019-06-28 15:12:42 +02:00
40f65055e3 loop only over particles with events instead of all 2019-06-28 14:58:18 +02:00
624794e006 float3 * scalar operator 2019-06-28 14:46:15 +02:00
a0fcdb0f98 extract method to compute current time per particle 2019-06-28 14:29:16 +02:00
035d92dd1a faster temporary random number function 2019-06-28 14:20:04 +02:00
a4a69e605c improve interface for killing particles 2019-06-28 14:11:06 +02:00
105353359c improve birth time handling in action interface 2019-06-28 13:49:47 +02:00
c500e94670 cleanup handling of birth times in emitters 2019-06-28 13:30:36 +02:00
d2e050e5e1 experimental explode action 2019-06-28 12:50:16 +02:00
485b07dc55 give action access to current time per particle 2019-06-28 12:30:50 +02:00
58452b095d initial test for spawning new particles in an action 2019-06-28 11:32:08 +02:00
788297480f split EmitTarget into EmitTargetBase and TimeSpanEmitTarget 2019-06-28 10:53:15 +02:00
fad7613963 simulate newly created particles until there are no new ones 2019-06-28 10:45:15 +02:00
b928475df0 separate partial simulation of new particles from emitters 2019-06-28 10:34:38 +02:00
2835c8df6f allow SmallVector to use ArrayRef 2019-06-28 09:59:32 +02:00
83a8f830c0 simulate particles of all types at the same time 2019-06-28 09:16:09 +02:00
7326d0a3f8 Merge branch 'master' into functions 2019-06-28 08:56:38 +02:00
17441b327b use one block allocator per thread instead of per block 2019-06-27 17:03:44 +02:00
700c2c823a keep track of newly allocated blocks 2019-06-27 16:21:29 +02:00
58253b535f make Block Allocator part of action interface 2019-06-27 15:41:25 +02:00
dd55ac9128 cleanup: remove unnecessary state parameter 2019-06-27 15:30:56 +02:00
878028d385 make it easier for emitters to specify birth moments 2019-06-27 15:07:39 +02:00
42d70c8152 emitter decides at which time individual particles are spawned 2019-06-27 14:29:26 +02:00
ab136cb188 size-value constructor for SmallVector 2019-06-27 13:59:18 +02:00
f2ed497129 initialize attributes with default values 2019-06-27 13:46:03 +02:00
e858f2e9ff thread safe block creation and deletion 2019-06-27 13:27:52 +02:00
551ae21bff use block allocator to allow muliple emitters to emit into the same block 2019-06-27 13:25:01 +02:00
2fa66f6f96 move function from header to cpp 2019-06-27 12:40:33 +02:00
8349161f14 refactor emitter interface internals
The problem previously was that all the information about which
blocks contain the attributes was not accessible by the emitter.
2019-06-27 12:36:47 +02:00
db8c116f5c remove request_raw function from public emitter interface 2019-06-27 11:21:59 +02:00
938bd0edc4 ParticleSet should know the block it is in 2019-06-27 11:13:48 +02:00
40a2f975dc Merge branch 'master' into functions 2019-06-27 10:02:07 +02:00
06fab69664 visualize different particle types with vertex colors 2019-06-26 18:18:38 +02:00
ddb44cefbd figure out how to add vertex colors to a new mesh 2019-06-26 15:58:32 +02:00
6ea4623ea1 ability to store attribute defaults in AttributeInfo 2019-06-26 15:34:57 +02:00
1d807a8399 Allow emitters to emit multiple types of particles 2019-06-26 14:46:44 +02:00
6704c82293 new ActionInterface class 2019-06-26 14:12:12 +02:00
333d82ebc0 remove unused variable 2019-06-26 12:52:08 +02:00
165580c661 Update attribute arrays based on which attributes are required 2019-06-26 12:51:58 +02:00
9728f45e89 particles container has responsibility to allocate attribute arrays again 2019-06-26 12:06:22 +02:00
2d7673578e comment out unused variables 2019-06-26 11:41:12 +02:00
6736ce6a03 Merge branch 'master' into functions 2019-06-26 11:34:08 +02:00
059639e301 new EventInterface abstraction 2019-06-24 12:37:27 +02:00
c2e4c7490f take reference to emitter interface 2019-06-24 09:47:30 +02:00
4b5a23b096 rename EmitterHelper to EmitterInterface 2019-06-24 09:44:14 +02:00
c5744593ec rename pindex_of to get_particle_index 2019-06-24 09:40:51 +02:00
b12daf64ca separate tuple from tuple-call 2019-06-24 09:38:54 +02:00
450d3be01f Merge branch 'master' into functions 2019-06-24 09:13:21 +02:00
7c4208f8a9 Merge branch 'master' into functions 2019-06-21 18:52:00 +02:00
5f0286302e Comment methods of ArrayRef and StringRef 2019-06-21 18:51:37 +02:00
da5f1dd8e5 comment methods of some more data structures 2019-06-21 18:41:04 +02:00
b247fc7d46 comments for methods of SmallVector 2019-06-21 18:12:07 +02:00
a19a5f8675 initial code layout for updating the required attributes 2019-06-21 16:56:19 +02:00
3a87096f24 allocate attributes arrays in AttributeArraysCore 2019-06-21 16:48:19 +02:00
8ee05156e6 simulate all particle types with description 2019-06-21 16:21:25 +02:00
098cb4ceaa cleanup copying ArrayRef to pointer 2019-06-21 16:12:16 +02:00
cf81da2547 refactor towards supporting multiple particle types 2019-06-21 16:03:30 +02:00
ab51c0e7dc initial particle type intermediate class 2019-06-21 15:10:23 +02:00
3e5fb5d83e fix using wrong length 2019-06-21 14:56:13 +02:00
d5bc8a6840 support point and tetrahedon mesh creation 2019-06-21 14:45:41 +02:00
db06b3a0b4 comment to note invariants of particle indices arrays 2019-06-21 14:14:34 +02:00
da1524fca8 new ParticleSet abstraction: attribute arrays + particle indices 2019-06-21 14:09:59 +02:00
5a31c30b5c transform emitter mesh to world space 2019-06-21 13:28:17 +02:00
cae29a0d9d transform collision rays to object space 2019-06-21 13:23:55 +02:00
c9958be749 initial mesh collision event 2019-06-21 12:53:51 +02:00
1294a9b5b4 generate tetraeders for particles 2019-06-21 12:02:27 +02:00
9f53e98472 minor cleanup 2019-06-21 11:32:55 +02:00
a7a6fe3ebc initial double event avoidance 2019-06-21 11:19:16 +02:00
5d590fc1bb extract method to simulate multiple events per step 2019-06-21 11:00:48 +02:00
e5fa7e58ba Merge branch 'master' into functions 2019-06-21 10:24:06 +02:00
f1369dd6ac bring back multithreading support 2019-06-20 15:49:49 +02:00
ad051d46aa don't inline simulation functions to make profiles more useful 2019-06-20 15:20:55 +02:00
a29da3be76 remove outdated simulation code 2019-06-20 15:17:23 +02:00
82c4bdc6d0 move events and actions to separate files 2019-06-20 15:16:57 +02:00
f0cca10248 use mesh surface emitter again 2019-06-20 15:05:08 +02:00
0bf6fa4729 test multiple events 2019-06-20 14:56:42 +02:00
9c7c2d0de3 support for multiple events per particle per time step 2019-06-20 14:34:09 +02:00
0886cdb1fe support killing particles again 2019-06-20 14:23:39 +02:00
c7b1129e77 bring back event handling 2019-06-20 13:57:32 +02:00
bcc877e180 compress blocks after each simulation step 2019-06-20 12:51:07 +02:00
2a9316d33c actually free emitters etc. 2019-06-20 12:44:07 +02:00
831d5665b0 apply forces to particles again 2019-06-20 12:36:23 +02:00
cfb18bb6c3 Pass particle influences into the right functions 2019-06-20 12:21:30 +02:00
dd8d2517d6 separate emitters from particle influencers 2019-06-20 12:16:43 +02:00
5561684337 support emitting particles again 2019-06-20 12:10:07 +02:00
f7cca29528 bring back creating the combined positon array 2019-06-20 11:18:54 +02:00
c8bf758a9a restructure solver api
Now I have to bring back all the functionality that was there already.
2019-06-20 11:04:45 +02:00
c74934cbf9 remove abstractions that are wrong for now 2019-06-20 10:17:09 +02:00
10fe6f6037 Merge branch 'master' into functions 2019-06-20 09:43:01 +02:00
05969e5418 initial curve emitter 2019-06-19 12:24:20 +02:00
0a7715e308 move forces into separate file 2019-06-19 11:06:23 +02:00
3138c7c5d7 rename files 2019-06-19 10:39:02 +02:00
3134c78661 remove turbulence force to have less distorted profiles 2019-06-19 10:34:30 +02:00
20c7fa6bcc extract temporary method for old particle deletion 2019-06-19 10:34:08 +02:00
d43d28a348 avoid creating the same arrays many times 2019-06-19 10:29:58 +02:00
5554851f15 refactor moving particles to next event time 2019-06-18 18:23:10 +02:00
ae80a416bd extract methods to simulate to next event vs. to next frame 2019-06-18 16:45:18 +02:00
7b15ec8713 Integrate particles again after an event 2019-06-18 16:22:05 +02:00
647503ec47 remove specialized step function for new particles 2019-06-18 15:18:31 +02:00
7629b86581 use indices mask to update only certain particles 2019-06-18 15:02:59 +02:00
913e130897 naming cleanup 2019-06-18 14:26:57 +02:00
de5971b1df initial positional event abstraction 2019-06-18 14:21:35 +02:00
d600fb3a45 more explicit particle integration step 2019-06-18 14:02:32 +02:00
17bff65c6b Use multithreading when moving particles forward
Timings in my current test file (nanoseconds per particle per time step):
* Debug Build: 150ns
* Optimized Build: 47ns
* With threading: 9ns
2019-06-18 12:35:22 +02:00
962a64aaaa restructure simulation steps in solver 2019-06-18 12:03:46 +02:00
5d08ae535a Utility to convert SmallSet to SmallVector 2019-06-18 12:03:15 +02:00
dd856ee973 Cleanup: reorder some functions 2019-06-18 11:49:15 +02:00
e8e94a6800 Allow emitters to emit into separate buffers 2019-06-18 11:46:14 +02:00
14125d2652 minor emitter API improvement 2019-06-18 10:05:16 +02:00
155c1de9ad improved particle attribute handling 2019-06-17 15:52:04 +02:00
8482ee2be9 utilities to create a range before/after another 2019-06-17 15:51:06 +02:00
270f4cb1f0 SmallVector: Append N Times 2019-06-17 15:13:19 +02:00
125ff9f320 initial mesh surface emitter 2019-06-17 12:16:41 +02:00
e8ecbf3a42 Emit from other objects origin 2019-06-17 11:19:26 +02:00
b010464151 simple point emitter 2019-06-17 10:59:04 +02:00
e77d269088 Merge branch 'master' into functions 2019-06-17 10:14:23 +02:00
dd201e3fc3 Merge branch 'master' into functions 2019-06-13 11:31:10 +02:00
4faf2de83a initial particle action abstraction 2019-06-10 12:23:15 +02:00
aa05731607 compute new positions and velocities in separate buffer 2019-06-10 12:05:28 +02:00
81eecb252a cleanup naming 2019-06-10 12:04:16 +02:00
97ecf23069 ArrayRef.copy_from 2019-06-10 12:03:29 +02:00
8e3178e1f2 use NamedBuffers in more places 2019-06-10 11:11:32 +02:00
2d73ff2380 rename buffer accessors 2019-06-10 11:07:40 +02:00
c49ca5c99f rename Vec3 to float3 2019-06-10 10:53:36 +02:00
b5fda893ce add byte attribute type 2019-06-09 13:51:37 +02:00
bcc8a07fd3 experimental turbulence force 2019-06-09 13:18:55 +02:00
5da27a41c1 improve naming 2019-06-09 12:59:41 +02:00
da1eb092eb flag killed particles in step function 2019-06-09 12:55:26 +02:00
93e38f5f6b cleanup stepping a slice of particles 2019-06-09 12:45:24 +02:00
4ffc3c46a1 partial step newly emitted particles 2019-06-09 12:37:21 +02:00
a38b89ecb5 initial emitter info class 2019-06-09 11:58:00 +02:00
270cee3d4a fix old particle removal 2019-06-08 14:02:51 +02:00
dc26770356 keep track of time since simulation start 2019-06-08 14:00:24 +02:00
a4de314d20 ArrayRef take_front and take_back methods 2019-06-08 13:55:21 +02:00
c77945366c pass elapsed seconds into step function 2019-06-08 13:39:49 +02:00
f693a5b66d automatically initialize attributes the emitter does not care about 2019-06-08 13:30:33 +02:00
c76ed1781b method to fill an ArrayRef 2019-06-08 13:28:35 +02:00
941159fba5 emitter can decide which attributes it initializes 2019-06-08 12:59:04 +02:00
e3d3d2eec7 introduce concept of particle block slices 2019-06-08 12:38:30 +02:00
3fd4418cfd fix lazy init unit test 2019-06-08 12:37:49 +02:00
c0b36372d0 easy access last element in vector 2019-06-08 12:37:39 +02:00
3c04bdbddb cleanup naming and implement some destructors 2019-06-08 11:54:45 +02:00
17804e4ecb experiment with an emitter abstraction 2019-06-07 23:12:35 +02:00
dbc50aa156 initial deletion or particles and compression of blocks 2019-06-07 22:43:29 +02:00
c2fa4a33fa test NamedBuffersRef abstraction to separate components
More specifically this separates implementation details of
Forces and ParticleBlocks.
2019-06-07 18:07:54 +02:00
9351db7146 work-in-progress functions to compress a set of particle blocks 2019-06-07 17:50:33 +02:00
4c0e7a285a initial particles container 2019-06-07 17:18:18 +02:00
d0cbd39310 initial force implementation 2019-06-07 15:53:48 +02:00
2c519ceb63 simple Vec3 type 2019-06-07 15:53:12 +02:00
2bcf091ba9 control simulation with some properties 2019-06-07 15:13:11 +02:00
80ec80cb83 don't reset simulation when pausing playback 2019-06-07 12:34:15 +02:00
ed02e1d252 cleanup interface to solver 2019-06-07 12:30:39 +02:00
d3013152ce little bit more interesting particle movement 2019-06-07 12:24:28 +02:00
3d797d0070 splitup bparticles code into multiple files 2019-06-07 12:17:22 +02:00
41cbcf96e9 try a different approach to connect state to solvers 2019-06-07 12:00:02 +02:00
01196be661 initial particle system api test
Still not happy with the way solver-dependent state is handled.
2019-06-07 11:04:01 +02:00
741ed59745 very simple particles state reset logic 2019-06-06 17:43:23 +02:00
b61fce82f9 more consistent naming in C wrappers 2019-06-06 11:33:46 +02:00
c5850f6ef1 use runtime data in modifier 2019-06-06 11:21:31 +02:00
56a0a71649 new simulations folder with some test code 2019-06-06 10:42:01 +02:00
6f728beec9 Merge branch 'master' into functions 2019-06-06 10:10:35 +02:00
6262b2bf7c initial empty particle nodes modifier 2019-06-05 10:28:26 +02:00
0387abd20f better explanation for lazy-init macros 2019-06-05 10:05:27 +02:00
473b79b4c2 remove unused include 2019-06-05 09:58:01 +02:00
6ffab86a4d simplify naming for lazy init macros 2019-06-05 09:56:25 +02:00
63c4712450 lazy init: thread safe registration and utility to list all 2019-06-05 09:47:27 +02:00
4df64a4393 improve move semantic usage in BLI::Optional 2019-06-04 18:14:37 +02:00
6ac4a72b28 free cached vectorized functions 2019-06-04 18:05:15 +02:00
77df7c61e6 Destruct lazy initialized objects when Blender quits 2019-06-04 17:38:05 +02:00
b8cb48b630 Merge branch 'master' into functions 2019-06-04 16:31:37 +02:00
a5413ba0f8 sort includes 2019-05-28 15:18:19 +02:00
5ea27e3d14 cleanup SmallVector 2019-05-28 15:14:20 +02:00
a34761afc0 Reduce wasted space in Function class
This is achieved by storing strings in a single buffer instead
of using `std::string`, which does small object optimization
for every string individually. This optimization can be done
because all strings are known when the function is build and
don't change later on.
2019-05-28 12:11:11 +02:00
5c72fb6a34 implement == operator for StringRef 2019-05-28 11:42:53 +02:00
3913b81f9e construct StringRefNull from pointer and length 2019-05-28 11:15:50 +02:00
a02cf6a05b Merge branch 'master' into functions 2019-05-28 10:53:36 +02:00
68174cf0b2 Merge branch 'master' into functions 2019-05-23 17:27:26 +02:00
cbb8bd467b better cross platform exponent computation 2019-05-22 17:31:43 +02:00
8c37c378a4 more assertions in ArrayLookup 2019-05-22 17:21:12 +02:00
e59d0263ba create ArrayRef from std::vector and std::array 2019-05-22 17:11:09 +02:00
dac0f4864d cleanup SmallMap 2019-05-22 17:00:10 +02:00
28887080a5 ArrayRef constructor for SmallSet 2019-05-22 16:41:53 +02:00
3ab2a2af29 correct small object optimization for sets and maps 2019-05-22 16:37:07 +02:00
d5b707b6fb improve SmallStack class 2019-05-22 16:22:47 +02:00
9ec8e308e7 more efficient small vector extend 2019-05-22 16:16:34 +02:00
b3283176a0 fix memory leaks in unit tests 2019-05-22 16:05:01 +02:00
24c3b57ec3 remove unused StringCollection 2019-05-22 15:53:15 +02:00
7863cf89de cleanup ScopedTimer 2019-05-22 15:41:20 +02:00
900e7f6352 Merge branch 'master' into functions 2019-05-22 15:31:28 +02:00
bddc6999b0 support for caching auto vectorized functions 2019-05-20 11:19:06 +02:00
357fa4a5ba equality operator for functions 2019-05-20 11:07:41 +02:00
0338da1063 smallmap: lookup or insert using key function 2019-05-20 11:07:23 +02:00
341b078d91 allow creating small vector with different size from array ref 2019-05-20 11:06:53 +02:00
d8d6f2a521 smallmap: lookup or insert using callback 2019-05-20 10:55:15 +02:00
92a3a4e029 speedup when all types in tuple meta are trivially destructible 2019-05-20 09:51:33 +02:00
0b63963c5a llvm vectors are not stored as struct anymore 2019-05-20 09:42:29 +02:00
a10f336346 Merge branch 'master' into functions 2019-05-20 09:36:28 +02:00
1bde9ab004 remove signature and paramter classes 2019-05-17 12:02:22 +02:00
ffeea91347 don't use signature in function anymore 2019-05-17 11:59:40 +02:00
e0032e8446 remove more dependencies on signature and parameter types 2019-05-17 11:46:31 +02:00
d6eb9668a0 move more signature logic into function 2019-05-17 11:18:30 +02:00
3bc03102d8 Merge branch 'master' into functions 2019-05-17 11:11:49 +02:00
3cddf75818 use StringRef and ArrayRef in more places 2019-05-16 12:02:57 +02:00
9d92456c88 use ArrayRef in more places 2019-05-16 11:52:56 +02:00
9107197320 use ArrayRef in more places 2019-05-16 11:46:39 +02:00
0a66b12776 less usage of InputParameter and OutputParameter type 2019-05-16 11:40:12 +02:00
9de7d3fa45 use new FunctionBuilder instead of creating Signature manually 2019-05-16 10:46:57 +02:00
3f82445d43 windows build fix 2019-05-16 10:15:21 +02:00
eb74be102e Rename StridedArrayRef to MappedArrayRef 2019-05-15 18:03:08 +02:00
836a780649 Merge branch 'master' into functions 2019-05-15 17:55:11 +02:00
8ab87c1998 initial StringCollection class 2019-05-15 17:16:47 +02:00
39d4e0182c use string ref in llvm ir builder 2019-05-15 11:39:25 +02:00
23c1b1edc8 deduplicate string ref code 2019-05-15 11:38:06 +02:00
13e06e7670 use string ref in more places 2019-05-15 11:22:50 +02:00
6dedb028d8 use string ref in more places 2019-05-15 11:17:20 +02:00
3b6bed43cd use string ref for type names 2019-05-15 11:10:02 +02:00
92c1d9044c new StringRefNull class 2019-05-15 11:00:07 +02:00
6e4866465d initial StringRef class 2019-05-15 10:49:38 +02:00
dbced1d563 Merge branch 'master' into functions 2019-05-15 10:16:35 +02:00
4b6799394f Some documentation for the C++ data structures in BLI 2019-05-13 18:38:37 +02:00
f7fd87d9d2 Merge branch 'master' into functions 2019-05-13 10:05:30 +02:00
3cb181ffe0 utilities to access function parameters 2019-05-12 20:25:49 +02:00
f959f4d2b2 use ArrayRef in more places 2019-05-12 20:07:16 +02:00
f2e5ed0e34 missing from last commit 2019-05-12 20:04:36 +02:00
38531114f7 initial support for defaults when using auto vectorization 2019-05-12 20:04:16 +02:00
4a2193927d improve ArrayRef 2019-05-12 19:47:46 +02:00
a2ef8e34d5 support different list lengths in llvm vectorization 2019-05-12 17:53:41 +02:00
ec2c1e54ed print with stacktrace from IR 2019-05-09 13:20:29 +02:00
d9c7df2492 put current loop iteration on stack 2019-05-09 13:02:41 +02:00
9f6e0a74cb float comparison IR 2019-05-09 12:43:58 +02:00
192b5e9cfb simplify usage of construct builders 2019-05-09 12:29:00 +02:00
e0c2784327 support for calling printf from llvm ir 2019-05-09 12:23:12 +02:00
9880a1b366 printing from Ir cleanup 2019-05-09 10:57:30 +02:00
6151808f1b initial if then else construct helper 2019-05-09 10:45:07 +02:00
989c2691ac improve ir loop constructs 2019-05-09 10:31:22 +02:00
5fe4ad93bc more specialized iterations loop builder 2019-05-09 10:20:24 +02:00
dbb52fec27 initial for loop builder helper 2019-05-09 09:51:45 +02:00
6df353d805 Merge branch 'master' into functions 2019-05-08 18:06:43 +02:00
bbb3770be2 speedup size constructor of small vector 2019-05-03 12:42:50 +02:00
49131279ee generate more readable IR 2019-05-03 12:39:21 +02:00
c1267d9e01 allow passing function pointer name 2019-05-03 12:18:35 +02:00
4cd8792882 cleanup code builder interface 2019-05-03 12:16:00 +02:00
6ad32d6675 create llvm wrapper function for calls to pointers 2019-05-03 12:09:40 +02:00
4390091f8b utility to create a float constant 2019-05-03 11:38:33 +02:00
2a957e405d cleanup small vector 2019-05-03 11:37:58 +02:00
c38b9e12b2 Merge branch 'master' into functions 2019-05-03 10:43:49 +02:00
2a87cfd809 allocate function bodies within function 2019-05-02 11:39:42 +02:00
0ca57c14af rename extend to add_extension 2019-05-02 11:21:52 +02:00
5d4bf32c40 allocate type extensions in type directly
This makes sense, since every extension is owned
by a Type object. Also this improves thread safety.
2019-05-02 11:19:05 +02:00
9deeb8eb22 use centralized pool to reuse llvm contexts 2019-05-02 10:48:30 +02:00
676918e7a1 Merge branch 'master' into functions 2019-05-02 10:16:52 +02:00
6e652a42fc splitup llvm vectorization into multiple methods 2019-05-01 19:26:51 +02:00
640a744d54 start simplifying automatic vectorization 2019-05-01 19:12:04 +02:00
1ab8b7f658 move c functions to access lists to lists.cpp 2019-05-01 18:26:42 +02:00
28051e2754 rerun clang format on functions folder 2019-05-01 18:01:03 +02:00
bde00c4aed Merge branch 'master' into functions 2019-05-01 17:59:27 +02:00
576243ba39 Initial automatic function vectorization with llvm 2019-05-01 15:27:00 +02:00
f09f8ad61f move slicing functionality to ArrayRef 2019-05-01 11:39:05 +02:00
034639a877 initial vector slicing API 2019-05-01 10:57:26 +02:00
fd5d972efb Merge branch 'master' into functions 2019-05-01 10:20:10 +02:00
ffe0796c41 use first-class llvm vector for Vector type 2019-04-30 13:58:13 +02:00
e8e0e7bc69 rename SimpleLLVMTypeInfo to PackedLLVMTypeInfo 2019-04-30 12:48:44 +02:00
dc2979a942 cleanup LLVMBool type info 2019-04-30 12:42:26 +02:00
2524a5e509 new TrivialLLVMTypeInfo to simplify creating other types 2019-04-30 12:35:19 +02:00
45271f785a clear cached node states on file load 2019-04-30 12:07:20 +02:00
f5d0dbed20 move btree lookup class to separate file 2019-04-30 11:57:38 +02:00
3b00f6625c Merge branch 'master' into functions
This also removes dependency creation for function drivers
(due to merge conflicts that I could not resolve yet).
2019-04-30 10:55:36 +02:00
d1aa60da80 Merge branch 'master' into functions 2019-04-29 11:42:58 +02:00
0e0495cf32 Merge branch 'master' into functions 2019-04-29 10:52:11 +02:00
8f70d4986e splitup forwarding function 2019-04-28 21:15:43 +02:00
6c1e5d7f34 extract method that ensure all inputs 2019-04-28 19:30:39 +02:00
1aa827d496 extract method that ensures required inputs 2019-04-28 19:23:59 +02:00
b287de4e68 deduplicate stack setup code 2019-04-28 19:20:24 +02:00
f16e64435f deduplicate some code 2019-04-28 19:15:57 +02:00
26ce24b928 better type names 2019-04-28 19:12:26 +02:00
e80d9a5391 destruct unused values as early as possible 2019-04-28 18:56:16 +02:00
f48b9823a4 deduplicate code to setup tuples 2019-04-28 18:45:09 +02:00
1242de1b6d deduplicate some code 2019-04-28 18:38:47 +02:00
64210d6682 simplify stack info setup 2019-04-28 18:33:36 +02:00
049d66aa80 initial support for lazy inputs in new fgraph evaluation 2019-04-28 18:25:29 +02:00
da3d297b3f subscript operator for range 2019-04-28 17:50:44 +02:00
7b75b665d3 group node info into a struct 2019-04-28 15:06:23 +02:00
c9eb9f4ad1 fix error in last merge 2019-04-28 14:49:59 +02:00
df0b4a4d0e Merge branch 'master' into functions 2019-04-28 14:42:08 +02:00
c27bbb3eca use more correct type name 2019-04-27 23:59:33 +02:00
3f6357b970 initialize llvm for tests 2019-04-27 23:40:53 +02:00
93dea8967d unit test for Float Range function 2019-04-27 23:29:33 +02:00
5b6dde93e9 initial unit test for functions system 2019-04-27 23:18:14 +02:00
1db1ac121a reduce likelyhood for heap allocation in fgraph evaluation 2019-04-27 22:32:11 +02:00
b76f54e540 splitup graph evaluation in three parts 2019-04-27 22:23:23 +02:00
d01cc80b08 move more into the value storage abstraction 2019-04-27 22:16:28 +02:00
76c3bd772e move value storage into separate struct 2019-04-27 22:03:04 +02:00
e0531b4338 use macro for pointer offset 2019-04-27 20:21:41 +02:00
05985d98ff put values in a struct that are accessed together 2019-04-27 20:15:58 +02:00
833cdfdd0c remove unused socket flag 2019-04-27 19:58:30 +02:00
21f1e501a7 do less unnecessary data copies 2019-04-27 19:49:33 +02:00
bbede5b3bd copy computed value to fn_out immediatly 2019-04-27 19:34:49 +02:00
bae0d22e06 make it optional to run value destructors when tuple is destructed 2019-04-27 17:04:55 +02:00
eece95823c multipool tried to deallocate the wrong pointer 2019-04-27 12:55:07 +02:00
9ca8b7a444 initial non recursive evaluation of new data flow graph 2019-04-27 12:48:04 +02:00
a9efbd6bcd utility set functions 2019-04-27 12:21:13 +02:00
04a4f1aa4d extract ensure tuple calls function 2019-04-27 10:24:43 +02:00
ad168871b1 dot export for new data flow graph 2019-04-27 10:01:36 +02:00
4346e88286 Split up the data flow graph data structure
The main goal is to be able to traverse the graph very efficiently
once it is build. This is hard when the structure has to be dynamic
(i.e. it can be changed). The solution is to use a builder that
can dynamically construct the graph. Once everything is set up,
the graph is converted into the compact form for further use.
2019-04-26 19:21:28 +02:00
ccc4285dee Merge branch 'master' into functions 2019-04-26 17:09:11 +02:00
a8bc2fc2b7 Merge branch 'master' into functions 2019-04-25 09:57:14 +02:00
81b9187dda Merge branch 'master' into functions 2019-04-24 09:22:11 +02:00
844745da77 Simple range iterator with tests 2019-04-19 13:56:49 +02:00
34fda46a3e produce lookup statistics for map and set 2019-04-19 11:19:23 +02:00
866e9c31e9 socket builder utility function 2019-04-19 10:34:22 +02:00
6a7efc26bd support conversions in all directions between bool, int and float 2019-04-18 11:25:20 +02:00
12904214d1 update inferencing to new type rules 2019-04-18 11:01:17 +02:00
9b3e36f6c4 concept of conversion groups in type system 2019-04-18 10:42:39 +02:00
7178267f20 start using a better defined type system 2019-04-18 10:19:30 +02:00
2141478180 implicit conversions between float and integer lists 2019-04-18 09:42:29 +02:00
5333710282 Merge branch 'master' into functions 2019-04-18 09:13:01 +02:00
8c6457820b bring back llvm include dirs 2019-04-17 11:10:51 +02:00
bd54f55f3a add bf_functions to LIB 2019-04-17 11:00:22 +02:00
2213234715 Merge 'master' into 'functions' 2019-04-17 10:28:33 +02:00
9e1d43367c Merge 'master' into 'functions' 2019-04-17 10:26:56 +02:00
06a966ebe7 Merge 'master' into 'functions' 2019-04-17 10:25:47 +02:00
d348a27380 improved reuse of dummy slots in array lookup 2019-04-15 15:33:56 +02:00
b07b7d0a63 deduplicate some array lookup code 2019-04-15 15:03:23 +02:00
5d83b59751 splitup tests for set and set_vector 2019-04-15 14:48:07 +02:00
9bd835e1fb don't use linear search in SmallSetVector 2019-04-15 14:31:18 +02:00
4687f961f0 remove refcount class that is not used anymore 2019-04-15 14:26:16 +02:00
6615900384 pack list declaration handles implicitely convertable types 2019-04-15 10:39:05 +02:00
955dc9f977 add LIB to CMakeLists.txt 2019-04-15 10:33:39 +02:00
a628f1842b Merge branch 'master' into functions 2019-04-15 10:24:47 +02:00
158425fc61 use a multimap data structure to store links of output sockets 2019-04-11 13:47:01 +02:00
f92bc17cb3 utility to count the number of times an output socket is used 2019-04-08 18:57:01 +02:00
7e2f02b019 more generic function to find relevant sockets in a function graph 2019-04-08 18:35:58 +02:00
45917d435d utility functions for set and map 2019-04-08 18:34:35 +02:00
e352d7d3ca new Float Range node 2019-04-08 17:29:04 +02:00
750d47e4d9 fix inferencing of vectorized nodes 2019-04-08 17:06:11 +02:00
db03f3399c fix probing function 2019-04-08 17:03:24 +02:00
54d4464a29 remove "small" from some type names 2019-04-08 16:13:44 +02:00
5a1279fdce faster adding to array lookup 2019-04-08 16:01:16 +02:00
6742728ff1 don't use llvm fgraph execution for now 2019-04-08 12:39:03 +02:00
338d84676f cleanup array lookup structure 2019-04-08 12:35:30 +02:00
b26a74c470 method to pop item from map 2019-04-07 20:22:06 +02:00
d866113089 End all files with a newline 2019-04-07 19:44:27 +02:00
76a1e9bdb8 Merge branch 'master' into functions 2019-04-07 17:21:30 +02:00
f6f8323082 Fix Sin operation in Float Math node
The patch only fixed the python part. I added the c++ part.

Differential Revision: https://developer.blender.org/D4658
2019-04-07 17:17:29 +02:00
0f1b4d7c38 Use actual hash tables instead of linear search
The hash functions themselves are not optimized yet.
2019-04-07 17:01:31 +02:00
6f96045c2f rename ptr to rna to avoid confusing with actual pointers 2019-04-07 00:01:41 +02:00
9e8babf885 vectorize Float Math node 2019-04-06 23:54:06 +02:00
ece895e7d5 remove some redundency 2019-04-06 23:43:35 +02:00
be53a35ad3 allow lazy tuple call in fgraph ir generation 2019-04-06 23:42:57 +02:00
e38e04e9af cleanup vectorized node inserters 2019-04-06 23:24:12 +02:00
44d8980780 cleanup and vectorize Vector Math node 2019-04-06 23:07:12 +02:00
5ea3eca380 use function name prefix for inserters 2019-04-06 22:50:20 +02:00
954b2de3d5 improve method names 2019-04-06 22:42:52 +02:00
28f239a384 remove BuilderContext 2019-04-06 22:27:58 +02:00
decd4d8ecf rename Builder to GraphBuilder 2019-04-06 22:13:24 +02:00
d3b807ff02 move BuilderContext into Builder 2019-04-06 22:08:13 +02:00
87b472e1f6 use common prefix for type getters 2019-04-06 21:48:43 +02:00
586210c437 use common prefix for function getters 2019-04-06 21:44:10 +02:00
b4a3d036a9 cleanup auto vectorization function 2019-04-06 21:18:08 +02:00
49553de662 vectorized Separate Vector node 2019-04-06 21:06:06 +02:00
59116b27ea Merge branch 'master' into functions 2019-04-06 18:52:37 +02:00
c251ddeafc simplify execution stack management 2019-04-06 18:46:42 +02:00
362f8ec767 remove debug print 2019-04-06 18:14:26 +02:00
66e4eb795d higher level macro for tuple allocation 2019-04-06 18:12:48 +02:00
05e3ee5ae6 automatically destruct stack allocated tuples in c++ 2019-04-06 18:05:34 +02:00
5296f03f9f initial generic automatic vectorization, used in Combine Vector node 2019-04-06 17:21:07 +02:00
acbfda0c6b Implicit conversion from individual elements to lists 2019-04-06 15:23:17 +02:00
7c5cf3fd79 vectorized output sockets don't need a property 2019-04-06 14:58:29 +02:00
84670db6ea List Length node and fail early when socket types don't match 2019-04-06 12:00:35 +02:00
2e2f289d25 Vectorization support for Node UI 2019-04-06 11:05:40 +02:00
1456a030f4 initial IR for vector addition 2019-04-05 19:31:11 +02:00
0f42dd82ac new Vector Math node 2019-04-05 18:57:31 +02:00
cb158219e0 Generate LLVM IR for Mul and Sin 2019-04-05 18:44:01 +02:00
6fa863f6d9 Sin operation in Float Math node 2019-04-05 12:45:11 +02:00
3273d6be58 remove notes and unused variable 2019-04-05 12:31:34 +02:00
4a3720740d use the socket name directly, instead of a getter function 2019-04-05 12:29:07 +02:00
52ff44d02c Validate more aspects of the node tree while syncing 2019-04-05 12:10:30 +02:00
23a8864669 Splitup C API for separate components in different files 2019-04-05 11:32:34 +02:00
072fbb030a fix for reroute nodes 2019-04-04 17:53:37 +02:00
2865ca6fb6 Merge branch 'master' into functions 2019-04-04 17:49:29 +02:00
c789c5288d Fix: print python error message if there is one 2019-04-04 14:29:52 +02:00
dd5c352af5 More robust node tree update after changes
This implements a tree wide synching procedure, that corrects
all invalid things it can find. Also, trees are updated in
the correct order, when they depend on each other.
2019-04-04 14:26:20 +02:00
8675779372 Merge branch 'master' into functions 2019-04-03 19:01:49 +02:00
6ce1e30539 Merge branch 'master' into functions 2019-04-03 18:26:41 +02:00
4e84ea3da0 Merge branch 'master' into functions 2019-04-03 15:19:27 +02:00
2a8c7b8230 use cache to avoid building the same function ir twice 2019-04-03 11:55:11 +02:00
bcb6fa6e51 use better socket names in conversion to functions 2019-04-03 11:13:52 +02:00
ac7107df7c better socket name accessor function 2019-04-03 10:25:11 +02:00
d9097f7484 initial automatic update of call node 2019-04-03 10:05:26 +02:00
c1ba8dcd85 Fix 2019-04-02 12:35:49 +02:00
118ce79baf initial reroute support in graph conversion 2019-04-02 12:30:45 +02:00
6e78ef3ce5 initial support for reroutes in the ui 2019-04-02 11:29:31 +02:00
40d37cc8a0 Fix Get List Element node 2019-04-01 13:52:15 +02:00
9b2f1c0b38 fix modifier definition 2019-04-01 13:51:55 +02:00
212014e0d2 Merge branch 'master' into functions 2019-04-01 12:23:44 +02:00
7ace279696 cleanup pack list node converter 2019-04-01 10:42:13 +02:00
62059b465f improve Pack List node UI 2019-04-01 10:32:54 +02:00
c7447b51bd Pack List nodes have two inputs by default 2019-04-01 10:27:50 +02:00
02765a86cc create pack list node if certain type from search 2019-04-01 10:20:19 +02:00
62f4467a49 simple operators to create new function trees from modifier 2019-04-01 10:11:56 +02:00
25e1a10de6 type extension base class 2019-03-29 15:57:24 +01:00
7b210749bb simple operator to setup new function trees 2019-03-29 14:11:37 +01:00
b9a4ff5d38 Refactor node socket declaration 2019-03-29 13:56:14 +01:00
166e05b6ed store node in declaration 2019-03-29 09:53:36 +01:00
b958410308 cleanup 2019-03-29 09:39:12 +01:00
9f3ffe53bd name some virtual registers 2019-03-28 19:55:58 +01:00
b0f77c11d1 utility functions to optimize and print generated code 2019-03-28 19:55:44 +01:00
6af5d940db cleanup 2019-03-28 18:17:34 +01:00
bd480232ee remove LLVMCompiledBody 2019-03-28 18:09:46 +01:00
8259f92110 don't cache llvm type per context 2019-03-28 17:48:41 +01:00
6304ecbb06 ability to turn stack maintance on and off 2019-03-28 17:39:14 +01:00
40c12c675f move execution context pointer through llvm 2019-03-28 17:25:29 +01:00
b60be30ed5 cleanup pointer calls 2019-03-28 16:30:48 +01:00
cdf4591edb Improve interface of IR generators and wrap IRBuilder<> 2019-03-28 12:47:29 +01:00
c7bf98a186 push initial function caller information on execution stack 2019-03-28 09:50:12 +01:00
031bc7ca2d Use Vector List in Function Points modifier 2019-03-27 12:18:25 +01:00
721581c366 fix 2019-03-27 12:16:45 +01:00
925b0b732c show problems in separate problems panel 2019-03-27 11:36:26 +01:00
65ee9b6233 cleanup 2019-03-27 10:34:32 +01:00
439fdfcda7 initial ability to show warning messages in nodes 2019-03-27 10:30:55 +01:00
80a994776b use multi mempool for source information 2019-03-26 17:34:41 +01:00
aebddd0ed6 initial multi mempool 2019-03-26 17:34:12 +01:00
1a8bc27052 Use Blender's guarded allocators 2019-03-26 16:56:23 +01:00
0b2baaab1a missing include guards 2019-03-26 16:55:05 +01:00
895f68c8b2 fix panel idname 2019-03-26 11:28:59 +01:00
f0524205d6 Merge branch 'master' into functions 2019-03-26 11:23:05 +01:00
a90dca0ff5 also keep track of link sources 2019-03-26 11:20:33 +01:00
c23e2becdc print with traceback utility 2019-03-26 11:00:08 +01:00
72593ecaed cleanup 2019-03-26 10:51:49 +01:00
6b72c23e0a data flow graph manages source info allocation 2019-03-26 10:45:50 +01:00
024247797f keep track of original nodes 2019-03-26 10:33:10 +01:00
de7094a930 new SourceInfo class to keep track of where functions come from 2019-03-26 10:02:57 +01:00
9539b402b8 initial Execution Stack 2019-03-26 09:52:14 +01:00
8b777f5acf function should not be copied 2019-03-26 09:51:38 +01:00
9295e3bdde pass (currently empty) execution context into tuple call 2019-03-26 09:31:23 +01:00
bf8a98ffc5 experimental lazy fgraph evaluation 2019-03-25 09:57:44 +01:00
20e12025ea Merge branch 'master' into functions 2019-03-24 18:41:02 +01:00
9421bf6655 initial body type for lazy input evaluation 2019-03-24 18:40:23 +01:00
d79805e1db cleanup classes that are used in a composition 2019-03-24 17:29:06 +01:00
13ef2b1065 remove special type info for lists 2019-03-24 17:03:07 +01:00
f463cfb4c9 fix 2019-03-24 16:38:50 +01:00
c3a3b2e9b1 new Switch node 2019-03-24 16:16:59 +01:00
28a1b801b1 new Boolean type 2019-03-24 16:14:25 +01:00
b033626948 experimental byte code interpreter for function graph 2019-03-24 13:52:44 +01:00
0c15bc41b0 better naming 2019-03-24 13:52:14 +01:00
d819361cc5 simplify allocating tuple in prepared buffer 2019-03-24 11:31:33 +01:00
dc171b2a3e non recursive method to find required sockets 2019-03-24 10:41:01 +01:00
e77a8b97e1 initial support for calling subprograms 2019-03-22 11:57:03 +01:00
cf72da183d fail early when node inserter does not work 2019-03-22 11:52:49 +01:00
0efee91b63 rename tree type 2019-03-22 10:51:53 +01:00
95ccb24857 implement custom search terms for nodes 2019-03-22 10:21:01 +01:00
24d89e1cce better file naming 2019-03-21 18:44:47 +01:00
ad79af4843 typo 2019-03-21 18:40:36 +01:00
c6e4c29988 implement concept of implicit conversions 2019-03-21 12:17:35 +01:00
b31b4d5df8 cleanup 2019-03-21 12:16:14 +01:00
b52af3a031 refactor frontend data type definition system 2019-03-21 11:12:35 +01:00
8450e44cb6 move data type information into a separate file 2019-03-21 11:01:04 +01:00
fb038ebe53 refactor list decision inferencing 2019-03-21 10:56:11 +01:00
1a73618b36 cleanup file structure 2019-03-21 10:46:05 +01:00
8968155985 improve file name 2019-03-21 10:41:53 +01:00
5cc1bbd6de update tree automatically after changes 2019-03-21 10:39:57 +01:00
1ae0a8d760 Fix ListCPPTypeInfo 2019-03-20 20:03:45 +01:00
6db961e8b2 Merge branch 'master' into functions 2019-03-20 19:36:45 +01:00
1d64c35c3b allow removal of sockets from pack list node 2019-03-20 19:33:34 +01:00
e25a0c4bb3 remove dead code 2019-03-20 19:11:23 +01:00
81d5383ce2 save socket states 2019-03-20 19:07:35 +01:00
8788431086 allow changing type of Pack List node 2019-03-20 18:51:02 +01:00
1b90194608 allow declarations to draw in node 2019-03-20 18:16:55 +01:00
8d5f02a191 New Pack List Input operator 2019-03-20 18:11:56 +01:00
28fc08bff9 replace Append to List and Combine Lists nodes with Pack List 2019-03-20 18:06:27 +01:00
c59b457ee5 Merge branch 'master' into functions 2019-03-20 12:53:45 +01:00
46f5cf2b41 remove code that is not used currently 2019-03-20 12:53:04 +01:00
a2ca81bf6e initial version of less automatic inferencer 2019-03-20 12:46:30 +01:00
7533b4416e decision id cleanup 2019-03-19 17:11:49 +01:00
4c499e6d09 Merge branch 'master' into functions 2019-03-19 12:05:06 +01:00
fae338bf7c initial variadic list declaration 2019-03-19 12:03:47 +01:00
37bb26a217 cleanup list function generation 2019-03-19 11:06:38 +01:00
882ce6812f cleanup graph generation for combine lists and get list element 2019-03-19 10:51:46 +01:00
f7a9d8f447 cleanup Graph generation for Append to List node 2019-03-19 10:40:10 +01:00
c7e2b27199 Merge branch 'master' into functions 2019-03-18 16:08:50 +01:00
af2f924b11 Unified socket declaration system
Function input/output use the same structure to declare
sockets as other nodes now.

The type inferencer can be invoked in the panel on the
right in the node editor.

The list nodes work with floats, vectors and ints.
2019-03-18 16:05:21 +01:00
d0ae91b7c0 Merge branch 'master' into functions 2019-03-14 10:41:28 +01:00
dee5ee40e0 actually run the inferencer on a node tree 2019-03-13 16:21:30 +01:00
614c8be1d8 Use data type names instead of idname in c++ 2019-03-12 18:47:57 +01:00
51885aea9d simple inferencer in python with tests 2019-03-12 18:29:16 +01:00
185c80e9ba data type socket builder 2019-03-12 17:20:10 +01:00
255e1fe149 data type info 2019-03-12 16:48:00 +01:00
bd3334feaa allow more advanced socket declarations 2019-03-12 16:30:41 +01:00
c15103f454 steps towards a second list type 2019-03-11 17:58:36 +01:00
121189e560 disable some debug prints 2019-03-10 19:15:51 +01:00
163af9c8cb Merge branch 'master' into functions 2019-03-10 19:07:23 +01:00
a0627749b6 cleanup c wrapper 2019-03-10 18:59:44 +01:00
5a637fafd2 typo 2019-03-10 18:32:30 +01:00
391ee16746 new Combine Lists node 2019-03-10 18:29:00 +01:00
cfafdde927 use function to generate a list of floats 2019-03-10 18:10:53 +01:00
eaf5914496 allow float list input and output in frontend 2019-03-10 17:36:31 +01:00
a8cb18c644 new Function Points modifier for testing 2019-03-10 17:26:08 +01:00
b5f64cdb6e float list type in C interface 2019-03-10 16:28:14 +01:00
5ab0eca7c6 fgraph ir builder prefers precompiled ir if available 2019-03-10 16:21:24 +01:00
6281aa7f5d fix double value forwarding 2019-03-10 16:04:14 +01:00
5c916fa8f8 utility to copy dot format to clipboard 2019-03-10 15:49:15 +01:00
7fa6389d62 Get List Element and Append to List node 2019-03-10 15:38:11 +01:00
dcd90fae85 start implementing float list in frontend 2019-03-10 15:03:53 +01:00
9f850e5e4e get float list element function 2019-03-10 14:56:05 +01:00
5b3f7c09d2 cleanup 2019-03-10 14:55:34 +01:00
fe5c13386c use control2 as seed 2019-03-10 14:27:32 +01:00
4688ed1e28 use ctrl+A to open the node search 2019-03-10 14:27:22 +01:00
20f9248222 simple node search 2019-03-10 14:16:59 +01:00
657204dfce use auto load for registration 2019-03-10 13:57:37 +01:00
6c49690847 also allow heap allocation for tuples in C 2019-03-10 13:11:02 +01:00
57450b4fbe improve thread safety 2019-03-10 12:51:44 +01:00
1c844a694a cleanup 2019-03-10 12:17:37 +01:00
a53b2b4564 allow tuple stack allocation in C 2019-03-10 12:06:51 +01:00
ac02c2daf2 cleanup C wrapper 2019-03-10 10:44:20 +01:00
e57c3996bd store possible tuple meta in tuple call body 2019-03-10 10:26:19 +01:00
f6d994faac stack allocate tuple 2019-03-10 10:00:51 +01:00
0c8c082f9d improve shared lists 2019-03-09 16:11:10 +01:00
2e5df2cfa6 allow tuple call to modify fn_in 2019-03-09 14:22:14 +01:00
01d09210ff use shared list in tuple 2019-03-08 14:54:36 +01:00
75ecfd03ab more generic CPP and LLVM type info for lists 2019-03-08 14:31:50 +01:00
468f4f7985 Rename "Shared" to "AutoRefCount" 2019-03-08 14:09:29 +01:00
dcd4e2f767 more specific tuple access functions 2019-03-08 14:06:16 +01:00
151c9cd9ff make SharedImmutable work with the automatic refcounting 2019-03-08 13:56:50 +01:00
9697e81dab use intrusive refcounter because it simplifies things quite a bit 2019-03-08 13:42:55 +01:00
70534e5106 Merge branch 'master' into functions 2019-03-08 13:12:57 +01:00
d11b9c7239 cleanup 2019-03-07 11:38:48 +01:00
e60d04b129 rename RefCounted to RefCountedPtr 2019-03-07 11:22:50 +01:00
2c5ca6c7be refcounter cleanup 2019-03-07 11:17:49 +01:00
b0552bbe57 Merge branch 'master' into functions 2019-03-06 13:59:30 +01:00
51aa004a39 initial list types implementation 2019-03-06 13:59:00 +01:00
ebab49d135 define separate and combine vector nodes in terms of llvm ir 2019-03-06 11:37:54 +01:00
8b0c9e4331 don't hardcode llvm include dirs 2019-03-06 11:23:04 +01:00
4b39cbdeef fix "make full" on windows 2019-03-06 09:45:28 +01:00
8ba4f227ea remove printing 2019-03-05 15:22:56 +01:00
771074d848 improve ir wrapper for tuple call 2019-03-05 15:13:48 +01:00
b23cf5f41a put multiple unlinked inputs into a single function 2019-03-05 14:55:39 +01:00
8f5e6cf087 destruct tuple in wrapper 2019-03-05 13:48:00 +01:00
c4f1560ef3 Merge branch 'master' into functions 2019-03-05 13:36:52 +01:00
c1bad0da7a improve LLVMCompiledBody 2019-03-04 16:29:56 +01:00
3dcfe05354 build llvm ir for function graph 2019-03-04 16:14:45 +01:00
a6374a2896 missing renamings 2019-03-04 14:19:34 +01:00
5a81ea8dcd cleanup file naming 2019-03-04 14:16:15 +01:00
d8815d5b41 cleanup naming of function bodies and derive functions 2019-03-04 14:12:01 +01:00
f0d53df716 rename "LLVMGenBody" -> "LLVMGenerateIRBody" 2019-03-04 13:37:00 +01:00
7310c95ab7 Merge branch 'master' into functions 2019-03-04 13:29:50 +01:00
8a8b7d40ac deduplicate compilation code 2019-03-03 20:41:54 +01:00
21fc76b50d precompiled llvm function body 2019-03-03 20:13:24 +01:00
662b5ade05 generate separate wrapper functions 2019-03-03 15:03:56 +01:00
0e177a3b50 initial llvm wrapper for tuple call 2019-03-03 13:53:30 +01:00
149e6aa58c don't use SmallVector in tuple 2019-03-03 11:36:00 +01:00
c090a2f821 cleanup 2019-03-03 11:07:39 +01:00
e99f72ae6d common base class for function bodies 2019-03-03 10:56:57 +01:00
aa179bdfa3 separate tuple from its meta data 2019-03-02 22:00:47 +01:00
0ed75e7dbe only types know how they should be stored/loaded 2019-03-02 12:48:47 +01:00
910d7d4be0 compile llvm to tuple call 2019-03-02 12:14:06 +01:00
5ad9010ebf initial llvm integration (include path is still hardcoded...) 2019-03-01 19:30:20 +01:00
a42fe3e7df cleanup 2019-03-01 18:07:13 +01:00
a74e970b1d minor improvement 2019-03-01 17:30:22 +01:00
80efd2fed8 split core into multiple files 2019-03-01 17:19:36 +01:00
2cdb3d825a Merge branch 'master' into functions 2019-03-01 16:33:35 +01:00
8085925bc6 naming cleanup 2019-03-01 16:31:41 +01:00
1f504e3bd9 separate dependencies from tuple call body 2019-03-01 16:27:45 +01:00
73ceb30a98 cleanup 2019-03-01 16:08:57 +01:00
b25aa2c753 only equal types are allowed to be linked 2019-03-01 15:51:40 +01:00
7260d0333e fix 2019-03-01 15:44:13 +01:00
bdf1522fae move CPU specific stuff to backend folder 2019-03-01 15:34:11 +01:00
7333478220 refactor function generation from data flow nodes 2019-03-01 13:41:54 +01:00
4a502bef3c fix 2019-03-01 13:40:51 +01:00
d26f3663b1 Merge branch 'master' into functions 2019-03-01 10:32:36 +01:00
dd372c4d3d first test using optional value 2019-02-28 14:42:54 +01:00
c4d221b149 simple BLI::optional<T> type (C++11 compatible) 2019-02-28 14:18:06 +01:00
dbc584ea9c move some files 2019-02-28 14:01:47 +01:00
97997dd056 header cleanup 2019-02-28 12:40:20 +01:00
060a6c0e06 rename function headers 2019-02-28 12:31:34 +01:00
451884d2ea better separation between functions and nodes 2019-02-28 12:25:57 +01:00
367b065369 Merge branch 'master' into functions 2019-02-28 11:45:46 +01:00
5c72773a6d typo and minor improvement 2019-02-25 17:35:06 +01:00
b7ec20cc27 Merge branch 'master' into functions 2019-02-25 15:56:19 +01:00
3901ae2cb7 init defaults in tuple 2019-02-22 15:42:32 +01:00
e8187d58e5 Map Range node 2019-02-22 15:09:47 +01:00
9458baa8fe pass seed to driver function 2019-02-22 14:44:11 +01:00
c9a9e8670b pass index to function in displace modifier 2019-02-22 14:28:33 +01:00
5846212aab fix and cleanup 2019-02-22 14:27:53 +01:00
4108d2f4f9 integer socket 2019-02-22 14:27:34 +01:00
eaeda7dc6b remove unnecessary file 2019-02-22 13:53:47 +01:00
adba334093 utility function 2019-02-22 13:53:25 +01:00
36efb78551 improved naming 2019-02-22 13:42:41 +01:00
038a32ce1c Merge branch 'master' into functions 2019-02-21 16:56:36 +01:00
95f02d7806 new Driver Variable type that evaluates a function 2019-02-21 16:56:00 +01:00
be308462b4 vector socket actually works now 2019-02-21 16:54:41 +01:00
660ca276ca add function relations 2019-02-21 16:51:42 +01:00
daaa02f8b1 Use weight function in displace modifier 2019-02-21 14:32:59 +01:00
6593ba7e6b improved C function API 2019-02-21 14:27:10 +01:00
4f686995c8 read from original tree 2019-02-21 13:40:49 +01:00
2fbdd08636 Merge branch 'master' into functions 2019-02-20 17:20:01 +01:00
1472b4a77f simple to use function timer 2019-02-20 17:19:09 +01:00
de6a5ea3a0 clamp node as combination of min and max functions 2019-02-20 16:59:21 +01:00
d82a6a89b4 min and max of floats 2019-02-20 16:44:21 +01:00
72b67178dc vector distance node 2019-02-20 16:32:31 +01:00
dbd5c54510 debug print for functions 2019-02-20 16:21:40 +01:00
2218d7bf9e check function signature in modifier 2019-02-20 16:06:09 +01:00
e865bc730d check function signature with c wrapper 2019-02-20 15:48:22 +01:00
c4f39dd4aa remove some testing code 2019-02-20 15:34:52 +01:00
263bf06f66 annotation... 2019-02-20 15:25:48 +01:00
fa306a3c4a more generic float math node 2019-02-20 15:25:04 +01:00
08da311c74 dynamically add and remove sockets 2019-02-20 15:05:47 +01:00
513b7b3c78 add outputs dynamically 2019-02-20 14:21:54 +01:00
2ac967c63e typo 2019-02-20 13:48:06 +01:00
7699ea4d27 refactor graph generation 2019-02-20 13:44:03 +01:00
e3c61a30e1 refactor data flow graph generation 2019-02-20 12:50:58 +01:00
c1c17ba542 lookup_default 2019-02-20 12:49:44 +01:00
0267002a47 Merge branch 'master' into functions 2019-02-19 19:27:51 +01:00
dfdc955b1c cleanup 2019-02-19 17:54:57 +01:00
144a90688c better lazy init macro 2019-02-19 17:54:00 +01:00
a2ecba884a missing pragma once 2019-02-19 17:53:24 +01:00
e417f07ee2 use mempool to allocate nodes 2019-02-19 17:17:38 +01:00
66389f8933 inference list relations properly 2019-02-18 18:18:47 +01:00
cca48e2d00 different way to store Type Relations 2019-02-18 17:22:52 +01:00
d533afa17b all_equal tests 2019-02-18 17:21:23 +01:00
1a282bdca1 Signature.has_interface 2019-02-18 17:21:09 +01:00
6922161179 SmallVector::all_equal 2019-02-18 17:20:34 +01:00
a5cf0149dc Merge branch 'master' into functions 2019-02-18 16:24:46 +01:00
30d7e0814f fix SmallVector 2019-02-18 15:00:33 +01:00
c3b7bfbded use allowed namespace definition syntax only 2019-02-18 14:59:46 +01:00
7df89986a5 Merge branch 'functions-in-train' into functions 2019-02-17 21:17:11 +01:00
34e1684fa2 Merge branch 'master' into functions 2019-02-17 21:09:08 +01:00
47ea90771d initial type relations and improved inferencer 2019-02-17 17:44:21 +01:00
d93ecc84bb initial type inferencer 2019-02-17 15:54:00 +01:00
b166e18d56 small vector - remove and reorder 2019-02-17 15:49:43 +01:00
d7fca3e468 initial lazy init macro 2019-02-17 14:46:54 +01:00
e3cdeb80b1 MemPool 2019-02-17 14:17:48 +01:00
f2c8e39d29 small stack 2019-02-17 13:32:29 +01:00
27dd613a84 Merge branch 'master' into functions 2019-02-13 17:00:47 +01:00
aafe1034bb store node tree pointer in modifier
Unfortunately, there are still issues with the COW system resulting in a crash.
2019-02-12 19:20:45 +01:00
393f220f48 setup object dependencies correctly 2019-02-12 14:32:14 +01:00
79d2ea4f41 cleanup 2019-02-11 18:20:27 +01:00
139cdff657 object transforms node 2019-02-11 18:01:48 +01:00
10395fd00d separate vector node 2019-02-11 17:33:34 +01:00
e49edb2ef1 actually read socket value 2019-02-11 17:13:31 +01:00
fb3e05ff62 better usage of wrapper 2019-02-11 16:57:36 +01:00
548eb3a822 listbase wrapper 2019-02-11 16:51:33 +01:00
62cfea48a3 initial node tree to function conversion 2019-02-11 16:10:17 +01:00
caa03d7a5d cleanup 2019-02-10 20:14:26 +01:00
edad572189 FunctionGraph - a graph with specified inputs and outputs 2019-02-10 20:14:25 +01:00
8133fb0fad cleanup 2019-02-10 20:14:25 +01:00
4c1a59fa96 cleanup 2019-02-10 20:14:25 +01:00
49385f89b9 function input and output node 2019-02-10 20:14:25 +01:00
c4364f3499 initial node tree 2019-02-10 20:14:25 +01:00
791902b2d2 better dot exprot 2019-02-10 20:14:25 +01:00
785289594b SmallMap.add should not replace existing entries 2019-02-10 20:14:25 +01:00
ffdf77dd59 better naming 2019-02-10 20:14:25 +01:00
6ad32098af do not use this-> for prefixed member variables 2019-02-10 20:14:25 +01:00
34026205f0 store more type info in Type 2019-02-10 20:14:25 +01:00
5743ffc46f cmake fix 2019-02-10 20:14:25 +01:00
c3b0b85d47 move Composition to BLI 2019-02-10 20:14:25 +01:00
ac8555af9e Function and Type are final classes - can still be extended with Composition 2019-02-10 20:14:25 +01:00
999a802600 generate function from data flow graph 2019-02-10 20:14:25 +01:00
59d589e736 move concrete type definitions into separate translation unit 2019-02-10 20:14:24 +01:00
4c3941745a types don't have to be const everywhere 2019-02-10 20:14:24 +01:00
04350ca976 initial value iterator 2019-02-10 20:14:24 +01:00
ff59b09f02 cleanup 2019-02-10 20:14:24 +01:00
d5e675bddb append rvalue reference to smallvector 2019-02-10 20:14:24 +01:00
ecd2e2b454 move shared without incref and decref 2019-02-10 20:14:24 +01:00
a9c1796470 use shared ownership for functions and types 2019-02-10 20:14:24 +01:00
05f9492580 actually free elements in small vector 2019-02-10 20:14:24 +01:00
328a6e9c91 use shared ownership for functions and types 2019-02-10 20:14:24 +01:00
7773e1c2af better separation of concerns for shared objects 2019-02-10 20:14:24 +01:00
542caff21b custom reference counter that supports manual incref and decref 2019-02-10 20:14:24 +01:00
4d572be4e6 small set vector 2019-02-10 20:14:23 +01:00
74e40a8863 Tuple::copy_element 2019-02-10 20:14:23 +01:00
8d55ff177d extend set and vector data structure 2019-02-10 20:14:23 +01:00
fff8781973 dot export for data flow graph 2019-02-10 20:14:23 +01:00
252e46a346 input and output parameter class 2019-02-10 20:14:23 +01:00
010a4a76b5 data flow graph 2019-02-10 20:14:23 +01:00
434e2afe3c more generic dynamic composition of types and functions 2019-02-10 20:14:23 +01:00
5784e17ff7 renaming 2019-02-10 20:14:23 +01:00
617d35315c test dynamic composition instead of inheritance for functions 2019-02-10 20:14:23 +01:00
f63f7c1c86 minor fix, should be solved differently.. 2019-02-10 20:14:23 +01:00
d5e25680df separate actual core from cpu functions 2019-02-10 20:14:23 +01:00
6185d5fa7d typo 2019-02-10 20:14:23 +01:00
25ff42d7d5 use const ref parameter 2019-02-10 20:14:23 +01:00
317a2880f6 fill test 2019-02-10 20:14:23 +01:00
f4e7621ee7 don't construct unneeded objects in SmallVector 2019-02-10 20:14:22 +01:00
cbefe2ad55 initial SmallMap 2019-02-10 20:14:22 +01:00
0774265195 modifier fix 2019-02-10 20:14:22 +01:00
3012e7a3c2 Tuple structure (no copy/move functionality yet) 2019-02-10 20:14:22 +01:00
a22763349a use static size information to increase performance 2019-02-10 20:14:22 +01:00
4328946e12 work better with uninitialized memory + tests for SmallVector 2019-02-10 20:14:21 +01:00
be5c59f09a cleanup api a bit 2019-02-10 20:14:20 +01:00
a52d9b4bac actually deform something 2019-02-10 20:14:20 +01:00
59970cc12f move test code to new modifier 2019-02-10 20:14:20 +01:00
46a4cf3697 new deform modifier 2019-02-10 20:14:20 +01:00
ebc898756a deform function test 2019-02-10 20:14:20 +01:00
a9322b7e58 small buffer inherits small vector 2019-02-10 20:14:20 +01:00
54b8d6ba0b more const 2019-02-10 20:14:20 +01:00
a3aaf9d4f9 implement move semantics properly, hopefully 2019-02-10 20:14:20 +01:00
b36a4d7c72 first successful execution 2019-02-10 20:14:20 +01:00
178d41c250 fix 2019-02-10 20:14:20 +01:00
520d7cd663 better naming 2019-02-10 20:14:20 +01:00
bd44822f89 implement other small vector constructors 2019-02-10 20:14:20 +01:00
37e0362215 cleanup 2019-02-10 20:14:19 +01:00
9b3a4c1697 real SmallVector implementation + make types const 2019-02-10 20:14:19 +01:00
09a561aa25 more initial setup 2019-02-10 20:14:19 +01:00
7fbebda942 basic code structure 2019-02-10 20:14:19 +01:00
ade4c61063 function api design 2019-02-10 20:14:19 +01:00
319 changed files with 31005 additions and 98 deletions

View File

@@ -49,6 +49,7 @@ if(NOT LLVM_ROOT_DIR)
OUTPUT_VARIABLE LLVM_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_ROOT_DIR ${LLVM_ROOT_DIR} CACHE PATH "Path to the LLVM installation")
set(LLVM_INCLUDE_DIRS ${LLVM_ROOT_DIR}/include CACHE PATH "Path to the LLVM include directory")
endif()
if(NOT LLVM_LIBPATH)
execute_process(COMMAND ${LLVM_CONFIG} --libdir

View File

@@ -0,0 +1,207 @@
{
"blender_version": [
2,
83,
10
],
"name": "Particle Age",
"inputs": [],
"outputs": [
{
"name": "Value",
"identifier": "Output_1",
"default_value": 0.0,
"type": "VALUE",
"bl_socket_idname": "NodeSocketFloat"
}
],
"nodes": [
{
"name": "Particle Attribute",
"bl_idname": "SimulationNodeParticleAttribute",
"location": [
-398,
-1
],
"width": 184.53359985351562,
"properties": {
"data_type": "FLOAT"
},
"inputs": [
{
"name": "Name",
"identifier": "Name",
"default_value": "Birth Time",
"type": "STRING"
}
],
"outputs": [
{
"name": "Float",
"identifier": "Float",
"default_value": 0.0,
"type": "VALUE"
},
{
"name": "Int",
"identifier": "Int",
"default_value": 0,
"type": "INT"
},
{
"name": "Boolean",
"identifier": "Boolean",
"default_value": false,
"type": "BOOLEAN"
},
{
"name": "Vector",
"identifier": "Vector",
"default_value": [
0.0,
0.0,
0.0
],
"type": "VECTOR"
},
{
"name": "Color",
"identifier": "Color",
"default_value": [
0.0,
0.0,
0.0,
0.0
],
"type": "RGBA"
},
{
"name": "Object",
"identifier": "Object",
"default_value": null,
"type": "OBJECT"
},
{
"name": "Image",
"identifier": "Image",
"default_value": null,
"type": "IMAGE"
},
{
"name": "Surface Hook",
"identifier": "Surface Hook",
"default_value": null,
"type": "SURFACE_HOOK"
}
]
},
{
"name": "Simulation Time",
"bl_idname": "SimulationNodeSimulationTime",
"location": [
-352,
73
],
"width": 140.0,
"properties": {},
"inputs": [],
"outputs": [
{
"name": "Simulation Time",
"identifier": "Simulation Time",
"default_value": 0.0,
"type": "VALUE"
}
]
},
{
"name": "Float Math",
"bl_idname": "FunctionNodeFloatMath",
"location": [
-160,
120
],
"width": 140.0,
"properties": {
"operation": "SUBTRACT",
"use_clamp": false
},
"inputs": [
{
"name": "Value",
"identifier": "Value",
"default_value": 0.5,
"type": "VALUE"
},
{
"name": "Value",
"identifier": "Value_001",
"default_value": 0.5,
"type": "VALUE"
},
{
"name": "Value",
"identifier": "Value_002",
"default_value": 0.0,
"type": "VALUE"
}
],
"outputs": [
{
"name": "Value",
"identifier": "Value",
"default_value": 0.0,
"type": "VALUE"
}
]
},
{
"name": "Group Output",
"bl_idname": "NodeGroupOutput",
"location": [
19,
113
],
"width": 140.0
}
],
"links": [
{
"from": [
"Simulation Time",
"Simulation Time",
0
],
"to": [
"Float Math",
"Value",
0
]
},
{
"from": [
"Particle Attribute",
"Float",
0
],
"to": [
"Float Math",
"Value_001",
1
]
},
{
"from": [
"Float Math",
"Value",
0
],
"to": [
"Group Output",
"Output_1",
0
]
}
],
"dependencies": []
}

View File

@@ -0,0 +1,170 @@
{
"blender_version": [
2,
83,
10
],
"name": "Particle Age Reached Event",
"inputs": [
{
"name": "Age",
"identifier": "Input_3",
"default_value": 0.5,
"type": "VALUE",
"bl_socket_idname": "NodeSocketFloat"
},
{
"name": "Execute",
"identifier": "Input_1",
"default_value": null,
"type": "CONTROL_FLOW",
"bl_socket_idname": "NodeSocketControlFlow"
}
],
"outputs": [
{
"name": "Event",
"identifier": "Output_5",
"default_value": null,
"type": "EVENTS",
"bl_socket_idname": "NodeSocketEvents"
}
],
"nodes": [
{
"name": "Execute Condition",
"bl_idname": "SimulationNodeExecuteCondition",
"location": [
-13,
-65
],
"width": 140,
"properties": {},
"inputs": [
{
"name": "Condition",
"identifier": "Condition",
"default_value": false,
"type": "BOOLEAN"
},
{
"name": "If True",
"identifier": "If True",
"default_value": null,
"type": "CONTROL_FLOW"
},
{
"name": "If False",
"identifier": "If False",
"default_value": null,
"type": "CONTROL_FLOW"
}
],
"outputs": [
{
"name": "Execute",
"identifier": "Execute",
"default_value": null,
"type": "CONTROL_FLOW"
}
]
},
{
"name": "Group Input",
"bl_idname": "NodeGroupInput",
"location": [
-390,
-94
],
"width": 140
},
{
"name": "Group",
"bl_idname": "SimulationNodeGroup",
"location": [
-384,
16
],
"width": 140,
"group_name": "Particle Age"
},
{
"name": "Particle Time Step Event",
"bl_idname": "SimulationNodeParticleTimeStepEvent",
"location": [
168,
-60
],
"width": 140,
"properties": {
"mode": "BEGIN"
},
"inputs": [
{
"name": "Execute",
"identifier": "Execute",
"default_value": null,
"type": "CONTROL_FLOW"
}
],
"outputs": [
{
"name": "Event",
"identifier": "Event",
"default_value": null,
"type": "EVENTS"
}
]
},
{
"name": "Group Output",
"bl_idname": "NodeGroupOutput",
"location": [
354,
-64
],
"width": 140
}
],
"links": [
{
"from": [
"Particle Time Step Event",
"Event",
0
],
"to": [
"Group Output",
"Output_5",
0
]
},
{
"from": [
"Group Input",
"Input_1",
1
],
"to": [
"Execute Condition",
"If True",
1
]
},
{
"from": [
"Execute Condition",
"Execute",
0
],
"to": [
"Particle Time Step Event",
"Execute",
0
]
}
],
"dependencies": [
"Particle Age"
]
}

View File

@@ -0,0 +1,305 @@
import os
import bpy
import json
from functools import lru_cache
def get_socket_value(sock):
if sock.type in {"VALUE", "INT", "BOOLEAN", "STRING"}:
return sock.default_value
elif sock.type in {"VECTOR", "RGBA"}:
return tuple(sock.default_value)
else:
return None
def insert_socket_data(sock_data, sock):
sock_data["name"] = sock.name
sock_data["identifier"] = sock.identifier
sock_data["default_value"] = get_socket_value(sock)
sock_data["type"] = sock.type
def insert_group_interface(json_data, group):
for sock in group.inputs:
sock_data = {}
insert_socket_data(sock_data, sock)
sock_data["bl_socket_idname"] = sock.bl_socket_idname
json_data["inputs"].append(sock_data)
for sock in group.outputs:
sock_data = {}
insert_socket_data(sock_data, sock)
sock_data["bl_socket_idname"] = sock.bl_socket_idname
json_data["outputs"].append(sock_data)
def insert_node_data(node_data, node):
node_data["name"] = node.name
node_data["bl_idname"] = node.bl_idname
node_data["location"] = tuple(map(int, node.location))
node_data["width"] = int(node.width)
# Don't compute this only once in the beginning, because addons might register more properties.
base_node_property_names = {prop.identifier for prop in bpy.types.Node.bl_rna.properties}
if node.bl_idname in {"NodeGroupInput", "NodeGroupOutput"}:
pass
elif node.bl_idname == "SimulationNodeGroup":
node_data["group_name"] = getattr(node.node_tree, "name", None)
else:
node_data["properties"] = {}
for prop in node.bl_rna.properties:
if prop.identifier not in base_node_property_names:
node_data["properties"][prop.identifier] = getattr(node, prop.identifier)
node_data["inputs"] = []
node_data["outputs"] = []
for sock in node.inputs:
sock_data = {}
insert_socket_data(sock_data, sock)
node_data["inputs"].append(sock_data)
for sock in node.outputs:
sock_data = {}
insert_socket_data(sock_data, sock)
node_data["outputs"].append(sock_data)
def insert_nodes_data(json_data, group):
for node in group.nodes:
node_data = {}
insert_node_data(node_data, node)
json_data["nodes"].append(node_data)
def insert_links_data(json_data, group):
for link in group.links:
link_data = {}
link_data["from"] = [link.from_node.name, link.from_socket.identifier, list(link.from_node.outputs).index(link.from_socket)]
link_data["to"] = [link.to_node.name, link.to_socket.identifier, list(link.to_node.inputs).index(link.to_socket)]
json_data["links"].append(link_data)
def find_direct_dependency_groups(group):
dependencies = set()
for node in group.nodes:
if node.bl_idname == "SimulationNodeGroup":
if node.node_tree is not None:
dependencies.add(node.node_tree)
return dependencies
def insert_dependencies(json_data, group):
dependency_names = [dependency.name for dependency in find_direct_dependency_groups(group)]
json_data["dependencies"] = dependency_names
def node_group_to_json_data(group):
json_data = {}
json_data["blender_version"] = bpy.app.version
json_data["name"] = group.name
json_data["inputs"] = []
json_data["outputs"] = []
json_data["nodes"] = []
json_data["links"] = []
insert_group_interface(json_data, group)
insert_nodes_data(json_data, group)
insert_links_data(json_data, group)
insert_dependencies(json_data, group)
return json_data
def save_group_as_json(group, file_path):
json_data = node_group_to_json_data(group)
json_str = json.dumps(json_data, indent=1)
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, "w") as f:
f.write(json_str)
builtin_node_group_directory = os.path.join(bpy.utils.resource_path("LOCAL"), "datafiles", "node_groups")
def group_name_to_file_name(group_name):
return group_name.replace(" ", "_") + ".json"
def file_name_to_group_name(file_name):
return file_name.replace("_", " ")[:-len(".json")]
def group_name_to_file_path(group_name):
file_name = group_name_to_file_name(group_name)
return os.path.join(builtin_node_group_directory, file_name)
def property_has_given_value(owner, prop_name, value):
prop = owner.bl_rna.properties[prop_name]
if prop.type in {'BOOLEAN', 'INT', 'STRING', 'ENUM'}:
return getattr(owner, prop_name) == value
elif prop.type == 'FLOAT':
if prop.array_length <= 1:
return getattr(owner, prop_name) == value
else:
return tuple(getattr(owner, prop_name)) == tuple(value)
else:
assert False
def group_matches_json_data(group, json_data, loaded_group_by_name):
groups_json_data = get_builtin_groups_data()
if len(group.nodes) != len(json_data["nodes"]):
return False
if len(group.links) != len(json_data["links"]):
return False
if len(group.inputs) != len(json_data["inputs"]):
return False
if len(group.outputs) != len(json_data["outputs"]):
return False
for node_data in json_data["nodes"]:
node = group.nodes.get(node_data["name"])
if node is None:
return False
if node.bl_idname != node_data["bl_idname"]:
return False
if node.bl_idname in {"NodeGroupInput", "NodeGroupOutput"}:
pass
elif node.bl_idname == "SimulationNodeGroup":
if node.node_tree is None:
return False
elif node.node_tree == loaded_group_by_name[node_data["group_name"]]:
pass
elif not group_matches_json_data(node.node_tree,
groups_json_data[node_data["group_name"]],
loaded_group_by_name):
return False
else:
for key, value in node_data["properties"].items():
if getattr(node, key) != value:
return False
if len(node.inputs) != len(node_data["inputs"]):
return False
if len(node.outputs) != len(node_data["outputs"]):
return False
for sock_data, sock in zip(node_data["inputs"], node.inputs):
if hasattr(sock, "default_value"):
if not property_has_given_value(sock, "default_value", sock_data["default_value"]):
return False
for sock_data, sock in zip(json_data["inputs"], group.inputs):
if sock_data["bl_socket_idname"] != sock.bl_socket_idname:
return False
if sock_data["name"] != sock.name:
return False
for sock_data, sock in zip(json_data["outputs"], group.outputs):
if sock_data["bl_socket_idname"] != sock.bl_socket_idname:
return False
if sock_data["name"] != sock.name:
return False
link_cache = set()
for link in group.links:
link_cache.add((
link.from_node.name, list(link.from_node.outputs).index(link.from_socket),
link.to_node.name, list(link.to_node.inputs).index(link.to_socket)))
for link_data in json_data["links"]:
if (link_data["from"][0], link_data["from"][2], link_data["to"][0], link_data["to"][2]) not in link_cache:
return False
return True
def get_or_create_node_group(json_data, loaded_group_by_name):
for potential_group in bpy.data.node_groups:
if group_matches_json_data(potential_group, json_data, loaded_group_by_name):
return potential_group
group = bpy.data.node_groups.new(json_data["name"], "SimulationNodeTree")
for node_data in json_data["nodes"]:
node = group.nodes.new(node_data["bl_idname"])
node.name = node_data["name"]
node.location = node_data["location"]
node.select = False
node.width = node_data["width"]
if node.bl_idname in {"NodeGroupInput", "NodeGroupOutput"}:
pass
elif node.bl_idname == "SimulationNodeGroup":
node.node_tree = loaded_group_by_name[node_data["group_name"]]
else:
for key, value in node_data["properties"].items():
setattr(node, key, value)
for sock_data, sock in zip(node_data["inputs"], node.inputs):
if hasattr(sock, "default_value"):
sock.default_value = sock_data["default_value"]
for sock_data in json_data["inputs"]:
group.inputs.new(sock_data["bl_socket_idname"], sock_data["name"])
for sock_data in json_data["outputs"]:
group.outputs.new(sock_data["bl_socket_idname"], sock_data["name"])
for link_data in json_data["links"]:
from_socket = group.nodes[link_data["from"][0]].outputs[link_data["from"][2]]
to_socket = group.nodes[link_data["to"][0]].inputs[link_data["to"][2]]
group.links.new(from_socket, to_socket)
return group
def export_builtin_node_group(group):
file_path = group_name_to_file_path(group.name)
save_group_as_json(group, file_path)
@lru_cache()
def get_builtin_groups_data():
json_data_by_group_name = dict()
if not os.path.exists(builtin_node_group_directory):
return json_data_by_group_name
for file_name in os.listdir(builtin_node_group_directory):
if not file_name.endswith(".json"):
continue
file_path = os.path.join(builtin_node_group_directory, file_name)
with open(file_path, "r") as f:
json_str = f.read()
json_data = json.loads(json_str)
group_name = json_data["name"]
json_data_by_group_name[group_name] = json_data
return json_data_by_group_name
def get_sorted_group_names_to_load(main_group_name):
groups_json_data = get_builtin_groups_data()
sorted_group_names = []
def add_group(group_name):
if group_name in sorted_group_names:
return
json_data = groups_json_data[group_name]
for dependency_name in json_data["dependencies"]:
add_group(dependency_name)
sorted_group_names.append(group_name)
add_group(main_group_name)
return sorted_group_names
def get_builtin_group_items_cb(node_tree_idname):
def items_generator(self, context):
items = []
for i, name in enumerate(get_builtin_groups_data().keys()):
items.append((str(i), name, ""))
return items
return items_generator
def import_builtin_node_group_with_dependencies(group_name):
sorted_group_names = get_sorted_group_names_to_load(group_name)
groups_json_data = get_builtin_groups_data()
loaded_group_by_name = dict()
for group_name in sorted_group_names:
json_data = groups_json_data[group_name]
group = get_or_create_node_group(json_data, loaded_group_by_name)
loaded_group_by_name[group_name] = group
return loaded_group_by_name[group_name]
def import_builtin_node_group_by_item_identifier(item_identifier):
index = int(item_identifier)
group_name = list(get_builtin_groups_data().keys())[index]
return import_builtin_node_group_with_dependencies(group_name)

View File

@@ -33,6 +33,7 @@ _modules = [
"file",
"image",
"mesh",
"modifiers",
"node",
"object",
"object_align",

View File

@@ -0,0 +1,91 @@
import bpy
from bpy.props import (
StringProperty,
)
class ModifierOperator:
object_name: StringProperty()
modifier_name: StringProperty()
def get_modifier(self):
ob = bpy.data.objects.get(self.object_name)
if ob is None:
return None
return ob.modifiers.get(self.modifier_name)
class NewDeformationFunction(bpy.types.Operator, ModifierOperator):
bl_idname = "fn.new_deformation_function"
bl_label = "New Deformation Function"
def execute(self, context):
mod = self.get_modifier()
if mod is None:
return {'CANCELLED'}
from nodes.node_operators import new_function_tree
tree = new_function_tree("Deformation Function", [
("Vector", "Old Position"),
("Float", "Control 1"),
("Integer", "Control 2")
], [
("Vector", "New Position"),
])
tree.new_link(
tree.get_input_nodes()[0].outputs[0],
tree.get_output_nodes()[0].inputs[0])
mod.function_tree = tree
return {'FINISHED'}
class NewPointGeneratorFunction(bpy.types.Operator, ModifierOperator):
bl_idname = "fn.new_point_generator_function"
bl_label = "New Point Generator Function"
def execute(self, context):
mod = self.get_modifier()
if mod is None:
return {'CANCELLED'}
from nodes.node_operators import new_function_tree
tree = new_function_tree("Point Generator", [
("Float", "Control 1"),
("Integer", "Control 2"),
], [
("Vector List", "Points"),
])
mod.function_tree = tree
return {'FINISHED'}
class NewParticleSimulationTree(bpy.types.Operator, ModifierOperator):
bl_idname = "fn.new_particle_simulation_tree"
bl_label = "New Particle Simulation Tree"
def execute(self, context):
mod = self.get_modifier()
if mod is None:
return {'CANCELLED'}
tree = bpy.data.node_groups.new("Particle Simulation", "FunctionTree")
type_node = tree.nodes.new("fn_ParticleSystemNode")
emitter_node = tree.nodes.new("fn_InitialGridEmitterNode")
emitter_node.location = (-250, 200)
gravity_node = tree.nodes.new("fn_ForceNode")
gravity_node.inputs[0].value = (0, 0, -1)
gravity_node.location = (-250, -100)
tree.links.new(emitter_node.outputs[0], type_node.inputs[0])
tree.links.new(gravity_node.outputs[0], type_node.inputs[0])
mod.node_tree = tree
return {'FINISHED'}
classes = (
NewDeformationFunction,
NewPointGeneratorFunction,
NewParticleSimulationTree,
)

View File

@@ -18,7 +18,9 @@
# <pep8-80 compliant>
import os
import bpy
import json
import nodeitems_utils
from bpy.types import (
Operator,
@@ -31,7 +33,12 @@ from bpy.props import (
IntProperty,
StringProperty,
)
from builtin_node_groups import (
export_builtin_node_group,
get_builtin_group_items_cb,
import_builtin_node_group_by_item_identifier,
import_builtin_node_group_with_dependencies,
)
class NodeSetting(PropertyGroup):
value: StringProperty(
@@ -295,6 +302,60 @@ class NODE_OT_tree_path_parent(Operator):
return {'FINISHED'}
class NODE_OT_export_group_template(Operator):
bl_idname = "node.export_group_template"
bl_label = "Export Node Group Template"
@classmethod
def poll(cls, context):
space = context.space_data
return space.type == 'NODE_EDITOR' and getattr(space.edit_tree, "bl_idname", "") == "SimulationNodeTree"
def execute(self, context):
group = context.space_data.edit_tree
export_builtin_node_group(group)
return {'FINISHED'}
class NODE_OT_import_group_template_search(bpy.types.Operator):
bl_idname = "node.import_group_template_search"
bl_label = "Import Node Group Template Search"
bl_property = "item"
item: EnumProperty(items=get_builtin_group_items_cb("SimulationNodeTree"))
def invoke(self, context, event):
context.window_manager.invoke_search_popup(self)
return {'CANCELLED'}
def execute(self, context):
if self.item == "NONE":
return {'CANCELLED'}
else:
import_builtin_node_group_by_item_identifier(self.item)
return {'FINISHED'}
class NODE_OT_add_builtin_node_group(bpy.types.Operator):
bl_idname = "node.add_builtin_node_group"
bl_label = "Add Builtin Node Group"
group_name: StringProperty()
def invoke(self, context, event):
node_tree = context.space_data.edit_tree
for node in node_tree.nodes:
node.select = False
group = import_builtin_node_group_with_dependencies(self.group_name)
group_node = node_tree.nodes.new("SimulationNodeGroup")
group_node.node_tree = group
group_node.select = True
node_tree.nodes.active = group_node
bpy.ops.node.translate_attach_remove_on_cancel('INVOKE_DEFAULT')
return {'FINISHED'}
classes = (
NodeSetting,
@@ -303,4 +364,7 @@ classes = (
NODE_OT_add_search,
NODE_OT_collapse_hide_unused_toggle,
NODE_OT_tree_path_parent,
NODE_OT_export_group_template,
NODE_OT_import_group_template_search,
NODE_OT_add_builtin_node_group,
)

View File

@@ -406,7 +406,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
row.prop(md, "mid_level")
row.prop(md, "strength")
def DYNAMIC_PAINT(self, layout, _ob, _md):
def DYNAMIC_PAINT(self, layout, _ob, md):
layout.label(text="Settings are inside the Physics tab")
def EDGE_SPLIT(self, layout, _ob, md):
@@ -1788,6 +1788,42 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "thresh", text="Threshold")
col.prop(md, "face_influence")
def FUNCTION_DEFORM(self, layout, ob, md):
layout.prop(md, "control1")
layout.prop(md, "control2")
row = layout.row(align=True)
row.prop(md, "function_tree")
props = row.operator("fn.new_deformation_function", text="", icon="ADD")
props.object_name = ob.name
props.modifier_name = md.name
def FUNCTION_POINTS(self, layout, ob, md):
layout.prop(md, "control1")
layout.prop(md, "control2")
row = layout.row(align=True)
row.prop(md, "function_tree")
props = row.operator("fn.new_point_generator_function", text="", icon="ADD")
props.object_name = ob.name
props.modifier_name = md.name
def BPARTICLES(self, layout, ob, md):
row = layout.row(align=True)
row.prop(md, "node_tree")
props = row.operator("fn.new_particle_simulation_tree", text="", icon="ADD")
props.object_name = ob.name
props.modifier_name = md.name
layout.operator("object.bparticles_clear_cache", text="Clear Cache")
layout.prop(md, "output_type")
def BPARTICLES_OUTPUT(self, layout, ob, md):
layout.prop(md, "source_object")
layout.prop(md, "source_particle_system", icon="PHYSICS")
layout.prop(md, "output_type")
class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
bl_label = "Modifiers"

View File

@@ -207,6 +207,11 @@ class NODE_MT_add(bpy.types.Menu):
def draw(self, context):
layout = self.layout
from nodes.base import BaseTree
tree = context.space_data.node_tree
if isinstance(tree, BaseTree):
return
layout.operator_context = 'INVOKE_DEFAULT'
props = layout.operator("node.add_search", text="Search...", icon='VIEWZOOM')
props.use_transform = True

View File

@@ -1229,6 +1229,7 @@ class USERPREF_PT_file_paths_data(FilePathsPanel, Panel):
col.prop(paths, "script_directory", text="Scripts")
col.prop(paths, "sound_directory", text="Sounds")
col.prop(paths, "temporary_directory", text="Temporary Files")
col.prop(paths, "nodelib_directory", text="Nodelib Files")
class USERPREF_PT_file_paths_render(FilePathsPanel, Panel):

View File

@@ -2194,6 +2194,10 @@ class VIEW3D_MT_add(Menu):
layout.separator()
layout.operator("fn.new_particle_system", text="Particle Simulation", icon='MOD_PARTICLES')
layout.separator()
if VIEW3D_MT_camera_add.is_extended():
layout.menu("VIEW3D_MT_camera_add", icon='OUTLINER_OB_CAMERA')
else:

View File

@@ -24,6 +24,9 @@ from nodeitems_utils import (
NodeItem,
NodeItemCustom,
)
from builtin_node_groups import (
get_builtin_groups_data,
)
# Subclasses for standard node types
@@ -57,6 +60,18 @@ class TextureNodeCategory(SortedNodeCategory):
return (context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'TextureNodeTree')
class SimulationNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'SimulationNodeTree')
class FunctionNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'SimulationNodeTree')
# menu entry for node group tools
def group_tools_draw(self, layout, context):
@@ -70,6 +85,7 @@ node_tree_group_type = {
'CompositorNodeTree': 'CompositorNodeGroup',
'ShaderNodeTree': 'ShaderNodeGroup',
'TextureNodeTree': 'TextureNodeGroup',
'SimulationNodeTree' : 'SimulationNodeGroup',
}
@@ -109,6 +125,14 @@ def node_group_items(context):
group.name,
{"node_tree": "bpy.data.node_groups[%r]" % group.name})
def draw_builtin_node_groups(self, layout, context):
layout.separator()
groups_json_data = get_builtin_groups_data()
for group_name in groups_json_data.keys():
props = layout.operator("node.add_builtin_node_group", text=group_name)
props.group_name = group_name
yield NodeItemCustom(draw=draw_builtin_node_groups)
# only show input/output nodes inside node groups
def group_input_output_item_poll(context):
@@ -467,17 +491,87 @@ texture_node_categories = [
]),
]
simulation_node_categories = [
SimulationNodeCategory("SIM_OUTPUT", "Output", items=[
NodeItem("SimulationNodeParticleSimulation"),
]),
SimulationNodeCategory("EMITTERS", "Emitters", items=[
NodeItem("SimulationNodeParticleMeshEmitter"),
NodeItem("SimulationNodeEmitParticles"),
]),
SimulationNodeCategory("EVENTS", "Events", items=[
NodeItem("SimulationNodeParticleBirthEvent"),
NodeItem("SimulationNodeParticleTimeStepEvent"),
NodeItem("SimulationNodeParticleMeshCollisionEvent"),
]),
SimulationNodeCategory("FORCES", "Forces", items=[
NodeItem("SimulationNodeForce"),
]),
SimulationNodeCategory("EXECUTE", "Execute", items=[
NodeItem("SimulationNodeSetParticleAttribute"),
NodeItem("SimulationNodeExecuteCondition"),
NodeItem("SimulationNodeMultiExecute"),
]),
SimulationNodeCategory("FUNCTION_INPUTS", "Function Inputs", items=[
NodeItem("SimulationNodeSimulationTime"),
NodeItem("SimulationNodeParticleAttribute"),
]),
FunctionNodeCategory("CONVERTER", "Converter", items=[
NodeItem("FunctionNodeCombineXYZ"),
NodeItem("FunctionNodeSeparateXYZ"),
NodeItem("FunctionNodeCombineRGB"),
NodeItem("FunctionNodeSeparateRGB"),
NodeItem("FunctionNodeCombineHSV"),
NodeItem("FunctionNodeSeparateHSV"),
NodeItem("FunctionNodeFloatMath"),
NodeItem("FunctionNodeVectorMath"),
NodeItem("FunctionNodeBooleanMath"),
NodeItem("FunctionNodeFloatCompare"),
NodeItem("FunctionNodeInstanceIdentifier"),
NodeItem("FunctionNodeStringConcatenation"),
NodeItem("FunctionNodeObjectTransforms"),
NodeItem("FunctionNodeSwitch"),
]),
FunctionNodeCategory("SURFACE", "Surface", items=[
NodeItem("FunctionNodeClosestSurface"),
NodeItem("FunctionNodeSurfaceColor"),
NodeItem("FunctionNodeSurfaceNormal"),
NodeItem("FunctionNodeSurfacePosition"),
NodeItem("FunctionNodeSurfaceWeight"),
]),
FunctionNodeCategory("NOISE", "Noise", items=[
NodeItem("ShaderNodeTexWhiteNoise"),
NodeItem("ShaderNodeTexGradient"),
NodeItem("ShaderNodeTexNoise"),
NodeItem("ShaderNodeTexMagic"),
NodeItem("ShaderNodeTexWave"),
NodeItem("ShaderNodeTexMusgrave"),
NodeItem("ShaderNodeTexVoronoi"),
NodeItem("ShaderNodeTexChecker"),
NodeItem("ShaderNodeTexBrick"),
]),
SimulationNodeCategory("GROUPS", "Groups", items=node_group_items),
SimulationNodeCategory("LAYOUT", "Layout", items=[
NodeItem("NodeFrame"),
NodeItem("NodeReroute"),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
]),
]
def register():
nodeitems_utils.register_node_categories('SHADER', shader_node_categories)
nodeitems_utils.register_node_categories('COMPOSITING', compositor_node_categories)
nodeitems_utils.register_node_categories('TEXTURE', texture_node_categories)
nodeitems_utils.register_node_categories('SIMULATION', simulation_node_categories)
def unregister():
nodeitems_utils.unregister_node_categories('SHADER')
nodeitems_utils.unregister_node_categories('COMPOSITING')
nodeitems_utils.unregister_node_categories('TEXTURE')
nodeitems_utils.unregister_node_categories('SIMULATION')
if __name__ == "__main__":

View File

@@ -0,0 +1,3 @@
from . auto_load import init, register, unregister
init()

View File

@@ -0,0 +1,138 @@
import os
import bpy
import sys
import typing
import inspect
import pkgutil
import importlib
from pathlib import Path
__all__ = (
"init",
"register",
"unregister",
)
modules = None
ordered_classes = None
def init():
global modules
global ordered_classes
modules = get_all_submodules(Path(__file__).parent)
ordered_classes = get_ordered_classes_to_register(modules)
def register():
for cls in ordered_classes:
bpy.utils.register_class(cls)
for module in modules:
if module.__name__ == __name__:
continue
if hasattr(module, "register"):
module.register()
def unregister():
for cls in reversed(ordered_classes):
bpy.utils.unregister_class(cls)
for module in modules:
if module.__name__ == __name__:
continue
if hasattr(module, "unregister"):
module.unregister()
# Import modules
#################################################
def get_all_submodules(directory):
return list(iter_submodules(directory, directory.name))
def iter_submodules(path, package_name):
for name in sorted(iter_submodule_names(path)):
yield importlib.import_module("." + name, package_name)
def iter_submodule_names(path, root=""):
for _, module_name, is_package in pkgutil.iter_modules([str(path)]):
if is_package:
sub_path = path / module_name
sub_root = root + module_name + "."
yield from iter_submodule_names(sub_path, sub_root)
else:
yield root + module_name
# Find classes to register
#################################################
def get_ordered_classes_to_register(modules):
return toposort(get_register_deps_dict(modules))
def get_register_deps_dict(modules):
deps_dict = {}
classes_to_register = set(iter_classes_to_register(modules))
for cls in classes_to_register:
deps_dict[cls] = set(iter_own_register_deps(cls, classes_to_register))
return deps_dict
def iter_own_register_deps(cls, own_classes):
yield from (dep for dep in iter_register_deps(cls) if dep in own_classes)
def iter_register_deps(cls):
for value in typing.get_type_hints(cls, {}, {}).values():
dependency = get_dependency_from_annotation(value)
if dependency is not None:
yield dependency
def get_dependency_from_annotation(value):
if isinstance(value, tuple) and len(value) == 2:
if value[0] in (bpy.props.PointerProperty, bpy.props.CollectionProperty):
return value[1]["type"]
return None
def iter_classes_to_register(modules):
base_types = get_register_base_types()
for cls in get_classes_in_modules(modules):
if any(base in base_types for base in cls.__bases__):
if not getattr(cls, "is_registered", False):
yield cls
def get_classes_in_modules(modules):
classes = set()
for module in modules:
for cls in iter_classes_in_module(module):
classes.add(cls)
return classes
def iter_classes_in_module(module):
for value in module.__dict__.values():
if inspect.isclass(value):
yield value
def get_register_base_types():
return set(getattr(bpy.types, name) for name in [
"Panel", "Operator", "PropertyGroup",
"AddonPreferences", "Header", "Menu",
"Node", "NodeSocket", "NodeTree",
"UIList", "RenderEngine"
])
# Find order to register to solve dependencies
#################################################
def toposort(deps_dict):
sorted_list = []
sorted_values = set()
while len(deps_dict) > 0:
unsorted = []
for value, deps in deps_dict.items():
if len(deps) == 0:
sorted_list.append(value)
sorted_values.add(value)
else:
unsorted.append(value)
deps_dict = {value : deps_dict[value] - sorted_values for value in unsorted}
return sorted_list

View File

@@ -0,0 +1,303 @@
import bpy
from bpy.props import *
from . utils.generic import iter_subclasses_recursive
import itertools
from collections import defaultdict
class BaseTree:
def new_link(self, a, b):
if a.is_output:
self.links.new(a, b)
else:
self.links.new(b, a)
def update(self):
self.sync()
def sync(self):
from . sync import sync_trees_and_dependent_trees
sync_trees_and_dependent_trees({self})
class SocketValueStates:
def __init__(self, node):
self.node = node
self.input_value_storage = dict()
def store_current(self):
for socket in self.node.inputs:
if not isinstance(socket, DataSocket):
continue
storage_id = (socket.data_type, socket.identifier)
self.input_value_storage[storage_id] = socket.get_state()
def try_load(self):
for socket in self.node.inputs:
if not isinstance(socket, DataSocket):
continue
storage_id = (socket.data_type, socket.identifier)
if storage_id in self.input_value_storage:
socket.restore_state(self.input_value_storage[storage_id])
def get_new_node_identifier():
import uuid
return str(uuid.uuid4())
class BaseNode:
search_terms = tuple()
search_terms_only = False
identifier: StringProperty()
def init(self, context):
self.identifier = get_new_node_identifier()
from . sync import skip_syncing
with skip_syncing():
self.init_props()
builder = self.get_node_builder()
builder.initialize_decls()
builder.build()
def init_props(self):
pass
@classmethod
def get_search_terms(cls):
if not cls.search_terms_only:
yield (cls.bl_label, dict())
yield from cls.search_terms
def sync_tree(self, context=None):
self.tree.sync()
def rebuild(self):
from . sync import skip_syncing
with skip_syncing():
self.socket_value_states.store_current()
linkage_state = LinkageState(self)
self.rebuild_fast()
self.socket_value_states.try_load()
linkage_state.try_restore()
def rebuild_fast(self):
from . sync import skip_syncing
with skip_syncing():
builder = self.get_node_builder()
builder.build()
_decl_map_per_node[self] = builder.get_sockets_decl_map()
@property
def tree(self):
return self.id_data
def get_node_builder(self):
from . node_builder import NodeBuilder
builder = NodeBuilder(self)
self.declaration(builder)
return builder
def declaration(self, builder):
raise NotImplementedError()
def draw_buttons(self, context, layout):
self.draw(layout)
for decl in self.decl_map.iter_decls():
decl.draw_node(layout)
def draw_buttons_ext(self, context, layout):
self.draw_advanced(layout)
def draw(self, layout):
pass
def draw_advanced(self, layout):
pass
def draw_socket(self, layout, socket, text, decl, index_in_decl):
decl.draw_socket(layout, socket, index_in_decl)
def draw_label(self):
if self.hide:
return self.draw_closed_label()
else:
return self.bl_label
def draw_closed_label(self):
return self.bl_label
def iter_directly_used_trees(self):
return
yield
def invoke_function(self,
layout, function_name, text,
*, icon="NONE", settings=tuple()):
assert isinstance(settings, tuple)
props = layout.operator("fn.node_operator", text=text, icon=icon)
self._set_common_invoke_props(props, function_name, settings)
def invoke_type_selection(self,
layout, function_name, text,
*, mode="ALL", icon="NONE", settings=tuple()):
assert isinstance(settings, tuple)
props = layout.operator("fn.node_data_type_selector", text=text, icon=icon)
self._set_common_invoke_props(props, function_name, settings)
props.mode = mode
def invoke_group_selector(self,
layout, function_name, text,
*, icon="NONE", settings=tuple()):
assert isinstance(settings, tuple)
props = layout.operator("fn.node_group_selector", text=text, icon=icon)
self._set_common_invoke_props(props, function_name, settings)
def _set_common_invoke_props(self, props, function_name, settings):
props.tree_name = self.id_data.name
props.node_name = self.name
props.function_name = function_name
props.settings_repr = repr(settings)
@classmethod
def iter_final_subclasses(cls):
yield from filter(lambda x: issubclass(x, bpy.types.Node), iter_subclasses_recursive(cls))
def find_input(self, identifier):
for socket in self.inputs:
if socket.identifier == identifier:
return socket
else:
return None
def find_output(self, identifier):
for socket in self.outputs:
if socket.identifier == identifier:
return socket
else:
return None
def find_socket(self, identifier, is_output):
if is_output:
return self.find_output(identifier)
else:
return self.find_input(identifier)
def iter_sockets(self):
yield from self.inputs
yield from self.outputs
# Storage
#########################
@property
def decl_map(self):
if self not in _decl_map_per_node:
builder = self.get_node_builder()
_decl_map_per_node[self] = builder.get_sockets_decl_map()
return _decl_map_per_node[self]
@property
def socket_value_states(self):
if self not in _socket_value_states_per_node:
_socket_value_states_per_node[self] = SocketValueStates(self)
return _socket_value_states_per_node[self]
def free(self):
if self in _decl_map_per_node:
del _decl_map_per_node[self]
def copy(self, src_node):
self.identifier = get_new_node_identifier()
self.duplicate(src_node)
def duplicate(self, src_node):
pass
class BaseSocket:
color = (0, 0, 0, 0)
def draw_color(self, context, node):
return self.color
def draw(self, context, layout, node, text):
decl, index = self.get_decl_with_index(node)
node.draw_socket(layout, self, text, decl, index)
def draw_self(self, layout, node, text):
layout.label(text=text)
def get_index(self, node):
if self.is_output:
return tuple(node.outputs).index(self)
else:
return tuple(node.inputs).index(self)
def to_id(self, node):
return (node, self.is_output, self.identifier)
def get_decl(self, node):
return node.decl_map.get_decl_by_socket(self)
def get_decl_with_index(self, node):
decl_map = node.decl_map
decl = decl_map.get_decl_by_socket(self)
index = decl_map.get_socket_index_in_decl(self)
return decl, index
class FunctionNode(BaseNode):
pass
class SimulationNode(BaseNode):
pass
class DataSocket(BaseSocket):
def draw_self(self, layout, node, text):
if not (self.is_linked or self.is_output) and hasattr(self, "draw_property"):
self.draw_property(layout, node, text)
else:
layout.label(text=text)
def get_state(self):
return None
def restore_state(self, state):
pass
class LinkageState:
def __init__(self, node):
self.node = node
self.tree = node.tree
self.links_per_input = defaultdict(set)
self.links_per_output = defaultdict(set)
for link in self.tree.links:
if link.from_node == node:
self.links_per_output[link.from_socket.identifier].add(link.to_socket)
if link.to_node == node:
self.links_per_input[link.to_socket.identifier].add(link.from_socket)
def try_restore(self):
tree = self.tree
for socket in self.node.inputs:
for from_socket in self.links_per_input[socket.identifier]:
tree.links.new(socket, from_socket)
for socket in self.node.outputs:
for to_socket in self.links_per_output[socket.identifier]:
tree.links.new(to_socket, socket)
_decl_map_per_node = {}
_socket_value_states_per_node = {}
@bpy.app.handlers.persistent
def clear_cached_node_states(_):
_decl_map_per_node.clear()
_socket_value_states_per_node.clear()
def register():
bpy.app.handlers.load_pre.append(clear_cached_node_states)

View File

@@ -0,0 +1,26 @@
import bpy
from bpy.props import *
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class AlwaysExecuteNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_AlwaysExecuteNode"
bl_label = "Always Execute"
execute__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.execute_input("execute", "Execute", "execute__prop")
builder.influences_output("influence", "Influence")
class MultiExecuteNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_MultiExecuteNode"
bl_label = "Multi Execute"
execute__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.execute_input("execute", "Execute", "execute__prop")
builder.execute_output("execute", "Execute")

View File

@@ -0,0 +1,11 @@
import bpy
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class CombineInfluencesNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_CombineInfluencesNode"
bl_label = "Combine Influences"
def declaration(self, builder: NodeBuilder):
builder.influences_input("influences", "Influences")
builder.influences_output("influences", "Influences")

View File

@@ -0,0 +1,18 @@
import bpy
from bpy.props import *
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class ParticleConditionNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_ParticleConditionNode"
bl_label = "Particle Condition"
execute_if_true__prop: NodeBuilder.ExecuteInputProperty()
execute_if_false__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("condition", "Condition", "Boolean")
builder.execute_input("execute_if_true", "Execute If True", "execute_if_true__prop")
builder.execute_input("execute_if_false", "Execute If False", "execute_if_false__prop")
builder.execute_output("execute", "Execute")

View File

@@ -0,0 +1,46 @@
import bpy
from bpy.props import *
from .. base import SimulationNode, FunctionNode
from .. node_builder import NodeBuilder
class SetParticleAttributeNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_SetParticleAttributeNode"
bl_label = "Set Attribute"
attribute_type: StringProperty(
name="Attribute Type",
default="Float",
update=SimulationNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
builder.fixed_input("name", "Name", "Text", default="My Attribute", display_name=False)
builder.fixed_input("value", "Value", self.attribute_type)
builder.execute_output("execute", "Execute")
def draw(self, layout):
self.invoke_type_selection(layout, "set_type", "Select Type", mode="BASE", icon="SETTINGS")
def set_type(self, data_type):
self.attribute_type = data_type
class GetParticleAttributeNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetParticleAttributeNode"
bl_label = "Get Attribute"
attribute_type: StringProperty(
name="Attribute Type",
default="Float",
update=SimulationNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
builder.fixed_input("name", "Name", "Text", default="My Attribute", display_name=False)
builder.fixed_output("value", "Value", self.attribute_type)
def draw(self, layout):
self.invoke_type_selection(layout, "set_type", "Select Type", mode="BASE", icon="SETTINGS")
def set_type(self, data_type):
self.attribute_type = data_type

View File

@@ -0,0 +1,169 @@
import bpy
import uuid
from bpy.props import *
from .. base import SimulationNode, DataSocket, FunctionNode
from .. node_builder import NodeBuilder
from .. types import type_infos
from .. sync import skip_syncing
class CustomEmitterAttribute(bpy.types.PropertyGroup):
def sync_tree(self, context):
self.id_data.sync()
attribute_name: StringProperty(update=sync_tree)
attribute_type: StringProperty(update=sync_tree)
identifier: StringProperty()
is_list: NodeBuilder.VectorizedProperty()
class CustomEmitter(bpy.types.Node, SimulationNode):
bl_idname = "fn_CustomEmitterNode"
bl_label = "Custom Emitter"
execute_on_birth__prop: NodeBuilder.ExecuteInputProperty()
attributes: CollectionProperty(
type=CustomEmitterAttribute,
)
birth_time_mode: EnumProperty(
name="Birth Time Mode",
items=[
("NONE", "None", "Manually specify birth times of every particle", "NONE", 0),
("BEGIN", "Begin", "Spawn particles at the beginning of each time step", "NONE", 1),
("END", "End", "Spawn particles at the end of each time step", "NONE", 2),
("RANDOM", "Random", "Spawn particles at random moments in the time step", "NONE", 3),
("LINEAR", "Linear", "Distribute particles linearly in each time step", "NONE", 4),
],
default="END",
)
def init_props(self):
self.add_attribute("Vector", "Position")
def declaration(self, builder: NodeBuilder):
for i, item in enumerate(self.attributes):
builder.vectorized_input(
item.identifier,
f"attributes[{i}].is_list",
item.attribute_name,
item.attribute_name,
item.attribute_type)
builder.execute_input("execute_on_birth", "Execute on Birth", "execute_on_birth__prop")
builder.influences_output("emitter", "Emitter")
def draw(self, layout):
layout.prop(self, "birth_time_mode", text="Birth")
self.invoke_type_selection(layout, "add_attribute", "Add Attribute", mode="BASE")
def draw_socket(self, layout, socket, text, decl, index_in_decl):
if isinstance(socket, DataSocket):
index = list(self.inputs).index(socket)
item = self.attributes[index]
col = layout.column(align=True)
row = col.row(align=True)
row.prop(item, "attribute_name", text="")
self.invoke_type_selection(row, "set_attribute_type", "",
icon="SETTINGS", mode="BASE", settings=(index, ))
self.invoke_function(row, "remove_attribute", "", icon="X", settings=(index, ))
if not socket.is_linked and hasattr(socket, "draw_property"):
socket.draw_property(col, self, "")
else:
decl.draw_socket(layout, socket, index_in_decl)
def add_attribute(self, data_type, name="My Attribute"):
with skip_syncing():
item = self.attributes.add()
item.identifier = str(uuid.uuid4())
item.attribute_type = data_type
item.attribute_name = name
self.sync_tree()
def remove_attribute(self, index):
self.attributes.remove(index)
self.sync_tree()
def set_attribute_type(self, data_type, index):
self.attributes[index].attribute_type = data_type
class EmitterTimeInfoNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_EmitterTimeInfoNode"
bl_label = "Emitter Time Info"
def declaration(self, builder: NodeBuilder):
builder.fixed_output("duration", "Duration", "Float")
builder.fixed_output("begin", "Begin", "Float")
builder.fixed_output("end", "End", "Float")
builder.fixed_output("step", "Step", "Integer")
class SpawnParticlesAttribute(bpy.types.PropertyGroup):
def sync_tree(self, context):
self.id_data.sync()
attribute_name: StringProperty(update=sync_tree)
attribute_type: StringProperty(update=sync_tree)
identifier: StringProperty()
is_list: NodeBuilder.VectorizedProperty()
class SpawnParticlesNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_SpawnParticlesNode"
bl_label = "Spawn Particles"
execute_on_birth__prop: NodeBuilder.ExecuteInputProperty()
attributes: CollectionProperty(
type=SpawnParticlesAttribute,
)
def init_props(self):
self.add_attribute("Vector", "Position")
def declaration(self, builder: NodeBuilder):
for i, item in enumerate(self.attributes):
builder.vectorized_input(
item.identifier,
f"attributes[{i}].is_list",
item.attribute_name,
item.attribute_name,
item.attribute_type)
builder.execute_input("execute_on_birth", "Execute on Birth", "execute_on_birth__prop")
builder.execute_output("execute", "Execute")
builder.influences_output("spawn_system", "Spawn System")
def draw(self, layout):
self.invoke_type_selection(layout, "add_attribute", "Add Attribute", mode="BASE")
def draw_socket(self, layout, socket, text, decl, index_in_decl):
if isinstance(socket, DataSocket):
index = list(self.inputs).index(socket)
item = self.attributes[index]
col = layout.column(align=True)
row = col.row(align=True)
row.prop(item, "attribute_name", text="")
self.invoke_type_selection(row, "set_attribute_type", "",
icon="SETTINGS", mode="BASE", settings=(index, ))
self.invoke_function(row, "remove_attribute", "", icon="X", settings=(index, ))
if not socket.is_linked and hasattr(socket, "draw_property"):
socket.draw_property(col, self, "")
else:
decl.draw_socket(layout, socket, index_in_decl)
def add_attribute(self, data_type, name="My Attribute"):
with skip_syncing():
item = self.attributes.add()
item.identifier = str(uuid.uuid4())
item.attribute_type = data_type
item.attribute_name = name
self.sync_tree()
def remove_attribute(self, index):
self.attributes.remove(index)
self.sync_tree()
def set_attribute_type(self, data_type, index):
self.attributes[index].attribute_type = data_type

View File

@@ -0,0 +1,60 @@
import bpy
from bpy.props import *
from .. base import SimulationNode, FunctionNode
from .. node_builder import NodeBuilder
class AgeReachedEventNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_AgeReachedEventNode"
bl_label = "Age Reached Event"
execute_on_event__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("age", "Age", "Float", default=3)
builder.execute_input("execute_on_event", "Execute on Event", "execute_on_event__prop")
builder.influences_output("event", "Event")
class MeshCollisionEventNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_MeshCollisionEventNode"
bl_label = "Mesh Collision Event"
execute_on_event__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("object", "Object", "Object")
builder.execute_input("execute_on_event", "Execute on Event", "execute_on_event__prop")
builder.influences_output("event", "Event")
class CustomEventNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_CustomEventNode"
bl_label = "Custom Event"
execute_on_event__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("condition", "Condition", "Boolean")
builder.fixed_input("time_factor", "Time Factor", "Float", default=1.0)
builder.execute_input("execute_on_event", "Execute on Event", "execute_on_event__prop")
builder.influences_output("event", "Event")
class EventFilterEndTimeNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_EventFilterEndTimeNode"
bl_label = "Event Filter End Time"
def declaration(self, builder: NodeBuilder):
builder.fixed_output("end_time", "End Time", "Float")
class EventFilterDurationNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_EventFilterDurationNode"
bl_label = "Event Filter Duration"
def declaration(self, builder: NodeBuilder):
builder.fixed_output("duration", "Duration", "Float")

View File

@@ -0,0 +1,13 @@
import bpy
from bpy.props import *
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class ForceNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_ForceNode"
bl_label = "Force"
def declaration(self, builder: NodeBuilder):
builder.fixed_input("force", "Force", "Vector")
builder.influences_output("force", "Force")

View File

@@ -0,0 +1,19 @@
import bpy
from bpy.props import *
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class InitialGridEmitterNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_InitialGridEmitterNode"
bl_label = "Initial Grid Emitter"
execute_on_birth__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("amount_x", "Amount X", "Integer", default=50)
builder.fixed_input("amount_y", "Amount Y", "Integer", default=50)
builder.fixed_input("step_x", "Step X", "Float", default=0.2)
builder.fixed_input("step_y", "Step Y", "Float", default=0.2)
builder.fixed_input("size", "Size", "Float", default=0.01)
builder.execute_input("execute_on_birth", "Execute on Birth", "execute_on_birth__prop")
builder.influences_output("emitter", "Emitter")

View File

@@ -0,0 +1,32 @@
import bpy
from bpy.props import *
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class MeshEmitterNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_MeshEmitterNode"
bl_label = "Mesh Emitter"
execute_on_birth__prop: NodeBuilder.ExecuteInputProperty()
density_mode: EnumProperty(
name="Density Mode",
items=[
('UNIFORM', "Uniform", "", 'NONE', 0),
('VERTEX_WEIGHTS', "Vertex Weights", "", 'NONE', 1),
],
update=SimulationNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
builder.fixed_input("object", "Object", "Object")
builder.fixed_input("rate", "Rate", "Float", default=10)
if self.density_mode == 'VERTEX_WEIGHTS':
builder.fixed_input("density_vertex_group", "Density Group", "Text")
builder.execute_input("execute_on_birth", "Execute on Birth", "execute_on_birth__prop")
builder.influences_output("emitter", "Emitter")
def draw(self, layout):
layout.prop(self, "density_mode")

View File

@@ -0,0 +1,15 @@
import bpy
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class ParticleSystemNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_ParticleSystemNode"
bl_label = "Particle System"
def declaration(self, builder: NodeBuilder):
builder.background_color((0.8, 0.5, 0.4))
builder.influences_input("influences", "Influences")
def draw(self, layout):
layout.prop(self, "name", text="", icon="PHYSICS")

View File

@@ -0,0 +1,17 @@
import bpy
from bpy.props import *
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class PointEmitterNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_PointEmitterNode"
bl_label = "Point Emitter"
execute_on_birth__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("position", "Position", "Vector")
builder.fixed_input("velocity", "Velocity", "Vector", default=(1, 0, 0))
builder.fixed_input("size", "Size", "Float", default=0.01)
builder.execute_input("execute_on_birth", "Execute on Birth", "execute_on_birth__prop")
builder.influences_output("emitter", "Emitter")

View File

@@ -0,0 +1,13 @@
import bpy
from bpy.props import *
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class SizeOverTimeNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_SizeOverTimeNode"
bl_label = "Size Over Time"
def declaration(self, builder: NodeBuilder):
builder.fixed_input("final_size", "Final Size", "Float", default=0.0)
builder.fixed_input("final_age", "Final Age", "Float", default=3)
builder.influences_output("influence", "Influence")

View File

@@ -0,0 +1,16 @@
import bpy
from bpy.props import *
from .. base import SimulationNode
from .. node_builder import NodeBuilder
class ParticleTrailsNode(bpy.types.Node, SimulationNode):
bl_idname = "fn_ParticleTrailsNode"
bl_label = "Particle Trails"
execute_on_birth__prop: NodeBuilder.ExecuteInputProperty()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("rate", "Rate", "Float", default=20)
builder.execute_input("execute_on_birth", "Execute on Birth", "execute_on_birth__prop")
builder.influences_output("main_system", "Main System")
builder.influences_output("trail_system", "Trail System")

View File

@@ -0,0 +1,12 @@
from . base import NoDefaultValue
from . fixed_type import FixedSocketDecl
from . dynamic_list import ListSocketDecl
from . base_list_variadic import BaseListVariadic
from . vectorized import VectorizedInputDecl, VectorizedOutputDecl
from . bparticles import (
InfluencesSocketDecl,
ExecuteOutputDecl,
ExecuteInputDecl,
ExecuteInputListDecl,
)

View File

@@ -0,0 +1,38 @@
NoDefaultValue = object()
class SocketDeclBase:
def init(self):
pass
def build(self, node_sockets):
raise NotImplementedError()
def init_default(self, node_sockets):
pass
def amount(self):
raise NotImplementedError()
def validate(self, sockets):
raise NotImplementedError()
def draw_node(self, layout):
pass
def draw_socket(self, layout, socket, index):
socket.draw_self(layout, self, socket.name)
def operator_socket_call(self, own_socket, other_socket):
pass
def _data_socket_test(self, socket, name, data_type, identifier):
from .. base import DataSocket
if not isinstance(socket, DataSocket):
return False
if socket.name != name:
return False
if socket.data_type != data_type:
return False
if socket.identifier != identifier:
return False
return True

View File

@@ -0,0 +1,152 @@
import bpy
import uuid
from bpy.props import *
from . base import SocketDeclBase
from .. base import DataSocket
from .. types import type_infos
from .. sockets import OperatorSocket
class BaseListVariadic(SocketDeclBase):
def __init__(self, node, identifier: str, prop_name: str, base_type: str, default_amount: int):
self.node = node
self.identifier_suffix = identifier
self.prop_name = prop_name
self.base_type = base_type
self.list_type = type_infos.to_list(base_type)
self.default_amount = default_amount
def init(self):
collection = self.get_collection()
for _ in range(self.default_amount):
item = collection.add()
item.state = "BASE"
item.identifier = str(uuid.uuid4())
def build(self, node_sockets):
return list(self._build(node_sockets))
def _build(self, node_sockets):
for item in self.get_collection():
data_type = self.base_type if item.state == "BASE" else self.list_type
yield type_infos.build(
data_type,
node_sockets,
"",
item.identifier)
yield node_sockets.new("fn_OperatorSocket", "Operator")
def validate(self, sockets):
collection = self.get_collection()
if len(sockets) != len(collection) + 1:
return False
for socket, item in zip(sockets[:-1], collection):
data_type = self.base_type if item.state == "BASE" else self.list_type
if not self._data_socket_test(socket, "", data_type, item.identifier):
return False
if sockets[-1].bl_idname != "fn_OperatorSocket":
return False
return True
def draw_socket(self, layout, socket, index):
if isinstance(socket, OperatorSocket):
props = layout.operator("fn.new_base_list_variadic_input", text="New Input", icon='ADD')
props.tree_name = self.node.tree.name
props.node_name = self.node.name
props.prop_name = self.prop_name
else:
row = layout.row(align=True)
socket.draw_self(row, self.node, str(index))
props = row.operator("fn.remove_base_list_variadic_input", text="", icon='X')
props.tree_name = self.node.tree.name
props.node_name = self.node.name
props.prop_name = self.prop_name
props.index = index
def operator_socket_call(self, own_socket, linked_socket, connected_sockets):
if len(connected_sockets) != 1:
return
connected_socket = next(iter(connected_sockets))
if not isinstance(connected_socket, DataSocket):
return
is_output = own_socket.is_output
origin_data_type = connected_socket.data_type
if type_infos.is_link_allowed(origin_data_type, self.base_type):
state = "BASE"
elif type_infos.is_link_allowed(origin_data_type, self.list_type):
state = "LIST"
else:
return
collection = self.get_collection()
item = collection.add()
item.state = state
item.identifier = str(uuid.uuid4())
self.node.rebuild()
new_socket = self.node.find_socket(item.identifier, is_output)
self.node.tree.new_link(linked_socket, new_socket)
def amount(self):
return len(self.get_collection()) + 1
def get_collection(self):
return getattr(self.node, self.prop_name)
@classmethod
def Property(cls):
return CollectionProperty(type=BaseListVariadicPropertyGroup)
class BaseListVariadicPropertyGroup(bpy.types.PropertyGroup):
bl_idname = "fn_BaseListVariadicPropertyGroup"
state: EnumProperty(
default="BASE",
items=[
("BASE", "Base", "", "NONE", 0),
("LIST", "Base", "", "NONE", 1)])
identifier: StringProperty()
class NewBaseListVariadicInputOperator(bpy.types.Operator):
bl_idname = "fn.new_base_list_variadic_input"
bl_label = "New Pack List Input"
bl_options = {'INTERNAL'}
tree_name: StringProperty()
node_name: StringProperty()
prop_name: StringProperty()
def execute(self, context):
tree = bpy.data.node_groups[self.tree_name]
node = tree.nodes[self.node_name]
collection = getattr(node, self.prop_name)
item = collection.add()
item.state = "BASE"
item.identifier = str(uuid.uuid4())
tree.sync()
return {'FINISHED'}
class RemoveBaseListVariadicInputOperator(bpy.types.Operator):
bl_idname = "fn.remove_base_list_variadic_input"
bl_label = "Remove Pack List Input"
bl_options = {'INTERNAL'}
tree_name: StringProperty()
node_name: StringProperty()
prop_name: StringProperty()
index: IntProperty()
def execute(self, context):
tree = bpy.data.node_groups[self.tree_name]
node = tree.nodes[self.node_name]
collection = getattr(node, self.prop_name)
collection.remove(self.index)
tree.sync()
return {'FINISHED'}

View File

@@ -0,0 +1,180 @@
import bpy
import uuid
from bpy.props import *
from . base import SocketDeclBase
from .. sockets import OperatorSocket, ExecuteSocket
MAX_LINK_LIMIT = 4095
class InfluencesSocketDecl(SocketDeclBase):
def __init__(self, node, identifier: str, display_name: str):
self.node = node
self.identifier = identifier
self.display_name = display_name
def build(self, node_sockets):
socket = node_sockets.new("fn_InfluencesSocket", self.display_name, identifier=self.identifier)
socket.link_limit = MAX_LINK_LIMIT
socket.display_shape = 'DIAMOND'
return [socket]
def validate(self, sockets):
if len(sockets) != 1:
return False
socket = sockets[0]
if socket.bl_idname != "fn_InfluencesSocket":
return False
if socket.name != self.display_name:
return False
if socket.link_limit != MAX_LINK_LIMIT:
return False
return True
def amount(self):
return 1
class ExecuteOutputDecl(SocketDeclBase):
def __init__(self, node, identifier: str, display_name: str):
self.node = node
self.identifier = identifier
self.display_name = display_name
def build(self, node_sockets):
socket = node_sockets.new("fn_ExecuteSocket", self.display_name, identifier=self.identifier)
socket.display_shape = 'SQUARE'
return [socket]
def amount(self):
return 1
def validate(self, sockets):
if len(sockets) != 1:
return False
socket = sockets[0]
if socket.name != self.display_name:
return False
elif socket.identifier != self.identifier:
return False
elif socket.bl_idname != "fn_ExecuteSocket":
return False
return True
class ExecuteInputDecl(SocketDeclBase):
def __init__(self, node, identifier: str, display_name: str):
self.node = node
self.identifier = identifier
self.display_name = display_name
def build(self, node_sockets):
socket = node_sockets.new("fn_ExecuteSocket", self.display_name, identifier=self.identifier)
socket.display_shape = "SQUARE"
return [socket]
def amount(self):
return 1
def validate(self, sockets):
if len(sockets) != 1:
return False
if sockets[0].bl_idname != "fn_ExecuteSocket":
return False
return True
class ExecuteInputListDecl(SocketDeclBase):
def __init__(self, node, identifier: str, prop_name: str, display_name: str):
self.node = node
self.identifier = identifier
self.display_name = display_name
self.prop_name = prop_name
def build(self, node_sockets):
return list(self._build(node_sockets))
def _build(self, node_sockets):
items = self.get_items()
for i, item in enumerate(items):
socket = node_sockets.new(
"fn_ExecuteSocket",
self.display_name if i == 0 else "Then",
identifier=item.identifier)
socket.display_shape = 'SQUARE'
yield socket
socket = node_sockets.new(
"fn_OperatorSocket",
self.display_name)
socket.display_shape = 'SQUARE'
yield socket
def amount(self):
return len(self.get_items()) + 1
def get_items(self):
return getattr(self.node, self.prop_name)
def validate(self, sockets):
if len(sockets) != self.amount():
return False
for socket, item in zip(sockets[:-1], self.get_items()):
if socket.identifier != item.identifier:
return False
elif socket.bl_idname != "fn_ExecuteSocket":
return False
if not isinstance(sockets[-1], OperatorSocket):
return False
if not sockets[-1].name == self.display_name:
return False
return True
def draw_socket(self, layout, socket, index):
row = layout.row(align=True)
if index == 0:
row.label(text=self.display_name)
else:
row.label(text="Then")
if isinstance(socket, ExecuteSocket):
props = row.operator("fn.remove_execute_socket", text="", icon="X")
props.tree_name = socket.id_data.name
props.node_name = self.node.name
props.prop_name = self.prop_name
props.index = index
def operator_socket_call(self, own_socket, linked_socket, connected_sockets):
item = self.get_items().add()
item.identifier = str(uuid.uuid4())
self.node.rebuild()
new_socket = self.node.find_socket(item.identifier, False)
self.node.tree.new_link(linked_socket, new_socket)
@classmethod
def Property(cls):
return CollectionProperty(type=ExecuteInputItem)
class ExecuteInputItem(bpy.types.PropertyGroup):
identifier: StringProperty()
class RemoveExecuteSocketOperator(bpy.types.Operator):
bl_idname = "fn.remove_execute_socket"
bl_label = "Remove Execute Socket"
bl_options = {'INTERNAL'}
tree_name: StringProperty()
node_name: StringProperty()
prop_name: StringProperty()
index: IntProperty()
def execute(self, context):
tree = bpy.data.node_groups[self.tree_name]
node = tree.nodes[self.node_name]
collection = getattr(node, self.prop_name)
collection.remove(self.index)
tree.sync()
return {'FINISHED'}

View File

@@ -0,0 +1,41 @@
from bpy.props import *
from . base import SocketDeclBase
from .. types import type_infos
class ListSocketDecl(SocketDeclBase):
def __init__(self, node, identifier: str, display_name: str, prop_name: str, list_or_base: str):
self.node = node
self.identifier = identifier
self.display_name = display_name
self.prop_name = prop_name
self.list_or_base = list_or_base
def build(self, node_sockets):
data_type = self.get_data_type()
return [type_infos.build(
data_type,
node_sockets,
self.display_name,
self.identifier)]
def validate(self, sockets):
if len(sockets) != 1:
return False
return self._data_socket_test(sockets[0],
self.display_name, self.get_data_type(), self.identifier)
def get_data_type(self):
base_type = getattr(self.node, self.prop_name)
if self.list_or_base == "BASE":
return base_type
elif self.list_or_base == "LIST":
return type_infos.to_list(base_type)
else:
assert False
def amount(self):
return 1
@classmethod
def Property(cls):
return StringProperty(default="Float")

View File

@@ -0,0 +1,38 @@
from . base import SocketDeclBase, NoDefaultValue
from .. types import type_infos
class FixedSocketDecl(SocketDeclBase):
def __init__(self, node, identifier: str, display_name: str, data_type: str, default, socket_settings: dict):
self.node = node
self.identifier = identifier
self.display_name = display_name
self.data_type = data_type
self.default = default
self.socket_settings = socket_settings
def build(self, node_sockets):
socket = type_infos.build(self.data_type,
node_sockets,
self.display_name,
self.identifier)
for name, value in self.socket_settings.items():
setattr(socket, name, value)
return [socket]
def init_default(self, node_sockets):
if self.default is not NoDefaultValue:
socket = node_sockets[0]
socket.restore_state(self.default)
def validate(self, sockets):
if len(sockets) != 1:
return False
socket = sockets[0]
for name, value in self.socket_settings.items():
if getattr(socket, name) != value:
return False
return self._data_socket_test(sockets[0],
self.display_name, self.data_type, self.identifier)
def amount(self):
return 1

View File

@@ -0,0 +1,94 @@
import bpy
from bpy.props import *
from . base import SocketDeclBase, NoDefaultValue
from .. types import type_infos
from .. utils.generic import getattr_recursive
class VectorizedDeclBase:
def build(self, node_sockets):
data_type, name = self.get_type_and_name()
socket = type_infos.build(
data_type,
node_sockets,
name,
self.identifier)
for prop_name, value in self.socket_settings.items():
setattr(socket, prop_name, value)
return [socket]
def validate(self, sockets):
if len(sockets) != 1:
return False
socket = sockets[0]
for prop_name, value in self.socket_settings.items():
if getattr(socket, prop_name) != value:
return False
data_type, name = self.get_type_and_name()
return self._data_socket_test(socket,
name, data_type, self.identifier)
def amount(self):
return 1
def get_type_and_name(self):
if self.is_vectorized():
return self.list_type, self.list_name
else:
return self.base_type, self.base_name
class VectorizedInputDecl(VectorizedDeclBase, SocketDeclBase):
def __init__(self,
node, identifier, prop_name,
base_name, list_name,
base_type, default, socket_settings):
self.node = node
self.identifier = identifier
self.prop_name = prop_name
self.base_name = base_name
self.list_name = list_name
self.base_type = base_type
self.list_type = type_infos.to_list(base_type)
self.default = default
self.socket_settings = socket_settings
def init_default(self, node_sockets):
if self.default is not NoDefaultValue:
socket = node_sockets[0]
socket.restore_state(self.default)
def is_vectorized(self):
stored = getattr_recursive(self.node, self.prop_name)
if stored == "BASE":
return False
elif stored == "LIST":
return True
else:
assert False
@staticmethod
def Property():
return StringProperty(default="BASE")
class VectorizedOutputDecl(VectorizedDeclBase, SocketDeclBase):
def __init__(self,
node, identifier, input_prop_names,
base_name, list_name,
base_type, socket_settings):
self.node = node
self.identifier = identifier
self.input_prop_names = input_prop_names
self.base_name = base_name
self.list_name = list_name
self.base_type = base_type
self.list_type = type_infos.to_list(base_type)
self.socket_settings = socket_settings
def is_vectorized(self):
for prop_name in self.input_prop_names:
if getattr_recursive(self.node, prop_name) == "LIST":
return True
return False

View File

@@ -0,0 +1,14 @@
import bpy
from bpy.app.handlers import persistent
@persistent
def file_load_handler(dummy):
from . sync import sync_trees_and_dependent_trees
node_trees = set(tree for tree in bpy.data.node_groups if tree.bl_idname == "FunctionTree")
sync_trees_and_dependent_trees(node_trees)
def register():
bpy.app.handlers.load_post.append(file_load_handler)
def unregister():
bpy.app.handlers.load_post.remove(file_load_handler)

View File

@@ -0,0 +1,58 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class SeparateColorNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_SeparateColorNode"
bl_label = "Separate Color"
use_list__color: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input(
"color", "use_list__color",
"Color", "Colors", "Color")
builder.vectorized_output(
"red", ["use_list__color"],
"Red", "Red", "Float")
builder.vectorized_output(
"green", ["use_list__color"],
"Green", "Green", "Float")
builder.vectorized_output(
"blue", ["use_list__color"],
"Blue", "Blue", "Float")
builder.vectorized_output(
"alpha", ["use_list__color"],
"Alpha", "Alpha", "Float")
class CombineColorNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_CombineColorNode"
bl_label = "Combine Color"
use_list__red: NodeBuilder.VectorizedProperty()
use_list__green: NodeBuilder.VectorizedProperty()
use_list__blue: NodeBuilder.VectorizedProperty()
use_list__alpha: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input(
"red", "use_list__red",
"Red", "Red", "Float")
builder.vectorized_input(
"green", "use_list__green",
"Green", "Green", "Float")
builder.vectorized_input(
"blue", "use_list__blue",
"Blue", "Blue", "Float")
builder.vectorized_input(
"alpha", "use_list__alpha",
"Alpha", "Alpha", "Float",
default=1.0)
builder.vectorized_output(
"color", ["use_list__red", "use_list__green", "use_list__blue", "use_list__alpha"],
"Color", "Colors", "Color")

View File

@@ -0,0 +1,31 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class FloatRangeNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_FloatRangeNode"
bl_label = "Float Range"
mode: EnumProperty(
name="Mode",
items=[
("AMOUNT_START_STEP", "Amount / Start / Step", "", "NONE", 0),
("AMOUNT_START_STOP", "Amount / Start / Stop", "", "NONE", 1),
],
default="AMOUNT_START_STOP",
update=FunctionNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
builder.fixed_input("amount", "Amount", "Integer", default=10)
builder.fixed_input("start", "Start", "Float")
if self.mode == "AMOUNT_START_STEP":
builder.fixed_input("step", "Step", "Float")
elif self.mode == "AMOUNT_START_STOP":
builder.fixed_input("stop", "Stop", "Float", default=1)
builder.fixed_output("list", "List", "Float List")
def draw(self, layout):
layout.prop(self, "mode", text="")

View File

@@ -0,0 +1,524 @@
import bpy
from bpy.props import *
from .. types import type_infos
from .. base import BaseNode, FunctionNode, DataSocket
from .. function_tree import FunctionTree
from .. node_builder import NodeBuilder
from .. ui import NodeSidebarPanel
from .. utils.pie_menu_helper import PieMenuHelper
from .. sync import skip_syncing
interface_type_items = [
("DATA", "Data", "Some data type like integer or vector", "NONE", 0),
("EXECUTE", "Control Flow", "", "NONE", 1),
("INFLUENCES", "Influences", "", "NONE", 2),
]
class GroupInputNode(bpy.types.Node, BaseNode):
bl_idname = "fn_GroupInputNode"
bl_label = "Group Input"
input_name: StringProperty(
default="Name",
update=BaseNode.sync_tree,
)
sort_index: IntProperty()
display_settings: BoolProperty(
name="Display Settings",
default=False,
)
interface_type: EnumProperty(
items=interface_type_items,
default="DATA",
update= BaseNode.sync_tree,
)
data_type: StringProperty(
default="Float",
update=BaseNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
if self.interface_type == "DATA":
builder.fixed_output("value", "Value", self.data_type)
elif self.interface_type == "EXECUTE":
builder.execute_output("execute", "Execute")
elif self.interface_type == "INFLUENCES":
builder.influences_output("influences", "Influences")
else:
assert False
def draw(self, layout):
if not self.display_settings:
return
layout.prop(self, "interface_type", text="")
if self.interface_type == "DATA":
if hasattr(self.outputs[0], "draw_property"):
self.outputs[0].draw_property(layout, self, "Default")
self.invoke_type_selection(layout, "set_data_type", "Select Type")
def draw_socket(self, layout, socket, text, decl, index_in_decl):
row = layout.row(align=True)
row.prop(self, "input_name", text="")
row.prop(self, "display_settings", text="", icon="SETTINGS")
def draw_closed_label(self):
return self.input_name + " (Input)"
def set_data_type(self, data_type):
self.data_type = data_type
class GroupOutputNode(bpy.types.Node, BaseNode):
bl_idname = "fn_GroupOutputNode"
bl_label = "Group Output"
sort_index: IntProperty()
display_settings: BoolProperty(
name="Display Settings",
default=False,
)
output_name: StringProperty(
default="Name",
update=BaseNode.sync_tree,
)
interface_type: EnumProperty(
items=interface_type_items,
default="DATA",
update=BaseNode.sync_tree,
)
data_type: StringProperty(
default="Float",
update=BaseNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
if self.interface_type == "DATA":
builder.fixed_input("value", "Value", self.data_type)
elif self.interface_type == "EXECUTE":
builder.single_execute_input("execute", "Execute")
elif self.interface_type == "INFLUENCES":
builder.influences_input("influences", "Influences")
def draw(self, layout):
if not self.display_settings:
return
layout.prop(self, "interface_type", text="")
if self.interface_type == "DATA":
self.invoke_type_selection(layout, "set_type_type", "Select Type")
def draw_socket(self, layout, socket, text, decl, index_in_decl):
row = layout.row(align=True)
row.prop(self, "output_name", text="")
row.prop(self, "display_settings", text="", icon="SETTINGS")
def draw_closed_label(self):
return self.output_name + " (Output)"
def set_type_type(self, data_type):
self.data_type = data_type
class GroupNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GroupNode"
bl_label = "Group"
bl_icon = "NODETREE"
node_group: PointerProperty(
type=bpy.types.NodeTree,
update=FunctionNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
if not isinstance(self.node_group, FunctionTree):
return
for input_node in self.node_group.get_input_nodes():
if input_node.interface_type == "DATA":
builder.fixed_input(
input_node.identifier,
input_node.input_name,
input_node.data_type,
default=input_node.outputs[0].get_state())
elif input_node.interface_type == "EXECUTE":
builder.single_execute_input(input_node.identifier, input_node.input_name)
elif input_node.interface_type == "INFLUENCES":
builder.influences_input(input_node.identifier, input_node.input_name)
else:
assert False
for output_node in self.node_group.get_output_nodes():
if output_node.interface_type == "DATA":
builder.fixed_output(
output_node.identifier,
output_node.output_name,
output_node.data_type)
elif output_node.interface_type == "EXECUTE":
builder.execute_output(output_node.identifier, output_node.output_name)
elif output_node.interface_type == "INFLUENCES":
builder.influences_output(output_node.identifier, output_node.output_name)
else:
assert False
def draw(self, layout):
layout.scale_y = 1.3
if self.node_group is None:
self.invoke_group_selector(layout, "set_group", "Select Group", icon="NODETREE")
elif not isinstance(self.node_group, FunctionTree):
layout.label(text="Group not found!", icon="ERROR")
self.invoke_group_selector(layout, "set_group", "Change Group", icon="NODETREE")
def draw_advanced(self, layout):
col = layout.column()
text = "Select Group" if self.node_group is None else self.node_group.name
col.scale_y = 1.3
self.invoke_group_selector(col, "set_group", text, icon="NODETREE")
def draw_label(self):
if self.node_group is None:
return "(G) -"
else:
return "(G) " + self.node_group.name
def set_group(self, group):
self.node_group = group
def iter_directly_used_trees(self):
if self.node_group is not None:
yield self.node_group
class GroupInterfacePanel(bpy.types.Panel, NodeSidebarPanel):
bl_idname = "FN_PT_group_interface_panel"
bl_label = "Group Interface"
@classmethod
def poll(self, context):
try: return isinstance(context.space_data.edit_tree, FunctionTree)
except: return False
def draw(self, context):
layout = self.layout
tree = context.space_data.edit_tree
draw_group_interface_panel(layout, tree)
def draw_group_interface_panel(layout, tree):
col = layout.column(align=True)
col.label(text="Inputs:")
box = col.box().column(align=True)
for i, node in enumerate(tree.get_input_nodes()):
row = box.row(align=True)
row.prop(node, "input_name", text="")
props = row.operator("fn.move_group_interface", text="", icon="TRIA_UP")
props.is_input = True
props.from_index = i
props.offset = -1
props = row.operator("fn.move_group_interface", text="", icon="TRIA_DOWN")
props.is_input = True
props.from_index = i
props.offset = 1
col = layout.column(align=True)
col.label(text="Outputs:")
box = col.box().column(align=True)
for i, node in enumerate(tree.get_output_nodes()):
row = box.row(align=True)
row.prop(node, "output_name", text="")
props = row.operator("fn.move_group_interface", text="", icon="TRIA_UP")
props.is_input = False
props.from_index = i
props.offset = -1
props = row.operator("fn.move_group_interface", text="", icon="TRIA_DOWN")
props.is_input = False
props.from_index = i
props.offset = 1
class MoveGroupInterface(bpy.types.Operator):
bl_idname = "fn.move_group_interface"
bl_label = "Move Group Interface"
is_input: BoolProperty()
from_index: IntProperty()
offset: IntProperty()
def execute(self, context):
tree = context.space_data.node_tree
if self.is_input:
nodes = tree.get_input_nodes()
else:
nodes = tree.get_output_nodes()
from_index = self.from_index
to_index = min(max(self.from_index + self.offset, 0), len(nodes) - 1)
nodes[from_index], nodes[to_index] = nodes[to_index], nodes[from_index]
with skip_syncing():
for i, node in enumerate(nodes):
node.sort_index = i
tree.sync()
return {"FINISHED"}
def update_sort_indices(tree):
for i, node in enumerate(tree.get_input_nodes()):
node.sort_index = i
for i, node in enumerate(tree.get_output_nodes()):
node.sort_index = i
class ManageGroupPieMenu(bpy.types.Menu, PieMenuHelper):
bl_idname = "FN_MT_manage_group_pie"
bl_label = "Manage Group"
@classmethod
def poll(cls, context):
try:
return isinstance(context.space_data.node_tree, FunctionTree)
except:
return False
def draw_top(self, layout):
layout.operator("fn.open_group_management_popup", text="Group Management")
def draw_left(self, layout):
node = bpy.context.active_node
if node is None:
self.empty(layout)
return
possible_inputs = [(i, socket) for i, socket in enumerate(node.inputs)
if socket_can_become_group_input(socket)]
if len(possible_inputs) == 0:
self.empty(layout, "No inputs.")
elif len(possible_inputs) == 1:
props = layout.operator("fn.create_group_input_for_socket", text="New Group Input")
props.input_index = possible_inputs[0][0]
else:
layout.operator("fn.create_group_input_for_socket_invoker", text="New Group Input")
def draw_right(self, layout):
node = bpy.context.active_node
if node is None:
self.empty(layout)
return
possible_outputs = [(i, socket) for i, socket in enumerate(node.outputs)
if socket_can_become_group_output(socket)]
if len(possible_outputs) == 0:
self.empty(layout, "No outputs.")
elif len(possible_outputs) == 1:
props = layout.operator("fn.create_group_output_for_socket", text="New Group Output")
props.output_index = possible_outputs[0][0]
else:
layout.operator("fn.create_group_output_for_socket_invoker", text="New Group Output")
class OpenGroupManagementPopup(bpy.types.Operator):
bl_idname = "fn.open_group_management_popup"
bl_label = "Group Management"
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def draw(self, context):
draw_group_interface_panel(self.layout, context.space_data.node_tree)
def execute(self, context):
return {"INTERFACE"}
class CreateGroupInputForSocketInvoker(bpy.types.Operator):
bl_idname = "fn.create_group_input_for_socket_invoker"
bl_label = "Create Group Input for Socket Invoker"
def invoke(self, context, event):
context.window_manager.popup_menu(self.draw_menu)
return {"CANCELLED"}
@staticmethod
def draw_menu(menu, context):
node = bpy.context.active_node
if node is None:
return
layout = menu.layout.column()
layout.operator_context = "INVOKE_DEFAULT"
for i, socket in enumerate(node.inputs):
if socket_can_become_group_input(socket):
props = layout.operator("fn.create_group_input_for_socket", text=socket.name)
props.input_index = i
class CreateGroupOutputForSocketInvoker(bpy.types.Operator):
bl_idname = "fn.create_group_output_for_socket_invoker"
bl_label = "Create Group Output for Socket Invoker"
def invoke(self, context, event):
context.window_manager.popup_menu(self.draw_menu)
return {"CANCELLED"}
@staticmethod
def draw_menu(menu, context):
node = bpy.context.active_node
if node is None:
return
layout = menu.layout.column()
layout.operator_context = "INVOKE_DEFAULT"
for i, socket in enumerate(node.outputs):
if socket_can_become_group_output(socket):
props = layout.operator("fn.create_group_output_for_socket", text=socket.name)
props.output_index = i
class CreateGroupInputForSocket(bpy.types.Operator):
bl_idname = "fn.create_group_input_for_socket"
bl_label = "Create Group Input for Socket"
input_index: IntProperty()
def invoke(self, context, event):
tree = context.space_data.node_tree
node = context.active_node
socket = node.inputs[self.input_index]
node.select = False
with skip_syncing():
new_node = tree.nodes.new(type="fn_GroupInputNode")
new_node.sort_index = 1000
new_node.input_name = socket.name
update_sort_indices(tree)
if isinstance(socket, DataSocket):
new_node.interface_type = "DATA"
new_node.data_type = socket.data_type
elif socket.bl_idname == "fn_ExecuteSocket":
new_node.interface_type = "EXECUTE"
elif socket.bl_idname == "fn_InfluencesSocket":
new_node.interface_type = "INFLUENCES"
new_node.rebuild()
new_node.select = True
new_node.parent = node.parent
new_node.location = node.location
new_node.location.x -= 200
new_node.outputs[0].restore_state(socket.get_state())
tree.new_link(new_node.outputs[0], socket)
tree.sync()
bpy.ops.node.translate_attach("INVOKE_DEFAULT")
return {"FINISHED"}
class CreateGroupOutputForSocket(bpy.types.Operator):
bl_idname = "fn.create_group_output_for_socket"
bl_label = "Create Group Output for Socket"
output_index: IntProperty()
def invoke(self, context, event):
tree = context.space_data.node_tree
node = context.active_node
socket = node.outputs[self.output_index]
node.select = False
with skip_syncing():
new_node = tree.nodes.new(type="fn_GroupOutputNode")
new_node.sort_index = 1000
update_sort_indices(tree)
new_node.output_name = socket.name
if isinstance(socket, DataSocket):
new_node.interface_type = "DATA"
new_node.data_type = socket.data_type
elif socket.bl_idname == "fn_ExecuteSocket":
new_node.interface_type = "EXECUTE"
elif socket.bl_idname == "fn_InfluencesSocket":
new_node.interface_type = "INFLUENCES"
new_node.rebuild()
new_node.select = True
new_node.parent = node.parent
new_node.location = node.location
new_node.location.x += 200
tree.new_link(new_node.inputs[0], socket)
tree.sync()
bpy.ops.node.translate_attach("INVOKE_DEFAULT")
return {"FINISHED"}
class OpenCloseGroupOperator(bpy.types.Operator):
bl_idname = "fn.open_close_group"
bl_label = "Open/Close Group"
bl_options = {"INTERNAL"}
@classmethod
def poll(cls, context):
try: return context.space_data.node_tree.bl_idname == "FunctionTree"
except: return False
def invoke(self, context, event):
space_data = context.space_data
active_node = context.active_node
if isinstance(active_node, GroupNode) and active_node.node_group is not None and active_node.select:
space_data.path.append(active_node.node_group, node=active_node)
else:
space_data.path.pop()
return {"FINISHED"}
def socket_can_become_group_input(socket):
return socket.bl_idname != "fn_OperatorSocket" and not socket.is_linked
def socket_can_become_group_output(socket):
return socket.bl_idname != "fn_OperatorSocket"
keymap = None
def register():
global keymap
if not bpy.app.background:
keymap = bpy.context.window_manager.keyconfigs.addon.keymaps.new(
name="Node Editor", space_type="NODE_EDITOR")
kmi = keymap.keymap_items.new("wm.call_menu_pie", type="V", value="PRESS")
kmi.properties.name = "FN_MT_manage_group_pie"
keymap.keymap_items.new("fn.open_close_group", type="TAB", value="PRESS")
def unregister():
global keymap
if not bpy.app.background:
bpy.context.window_manager.keyconfigs.addon.keymaps.remove(keymap)
keymap = None

View File

@@ -0,0 +1,69 @@
import bpy
from bpy.props import *
from .. types import type_infos
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class GetListElementNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetListElementNode"
bl_label = "Get List Element"
active_type: NodeBuilder.DynamicListProperty()
def declaration(self, builder: NodeBuilder):
builder.dynamic_list_input("list", "List", "active_type")
builder.fixed_input("index", "Index", "Integer")
builder.dynamic_base_input("fallback", "Fallback", "active_type")
builder.dynamic_base_output("value", "Value", "active_type")
class GetListElementsNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetListElementsNode"
bl_label = "Get List Elements"
active_type: NodeBuilder.DynamicListProperty()
def declaration(self, builder: NodeBuilder):
builder.dynamic_list_input("list", "List", "active_type")
builder.fixed_input("indices", "Indices", "Integer List")
builder.dynamic_base_input("fallback", "Fallback", "active_type")
builder.dynamic_list_output("values", "Values", "active_type")
class ListLengthNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_ListLengthNode"
bl_label = "List Length"
active_type: NodeBuilder.DynamicListProperty()
def declaration(self, builder: NodeBuilder):
builder.dynamic_list_input("list", "List", "active_type")
builder.fixed_output("length", "Length", "Integer")
class PackListNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_PackListNode"
bl_label = "Pack List"
active_type: StringProperty(
default="Float",
update=FunctionNode.sync_tree)
variadic: NodeBuilder.BaseListVariadicProperty()
def declaration(self, builder):
builder.base_list_variadic_input("inputs", "variadic", self.active_type)
builder.fixed_output("output", "List", type_infos.to_list(self.active_type))
def draw_advanced(self, layout):
self.invoke_type_selection(layout, "set_type", "Change Type", mode="BASE")
def set_type(self, data_type):
self.active_type = data_type
@classmethod
def get_search_terms(cls):
for list_type in type_infos.iter_list_types():
base_type = type_infos.to_base(list_type)
yield ("Pack " + list_type, {"active_type" : base_type})

View File

@@ -0,0 +1,129 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
def create_variadic_math_node(data_type, idname, label):
class MathNode(bpy.types.Node, FunctionNode):
bl_idname = idname
bl_label = label
variadic: NodeBuilder.BaseListVariadicProperty()
def declaration(self, builder: NodeBuilder):
builder.base_list_variadic_input("inputs", "variadic", data_type)
if NodeBuilder.BaseListVariadicPropertyHasList(self.variadic):
builder.fixed_output("result", "Result", data_type + " List")
else:
builder.fixed_output("result", "Result", data_type)
return MathNode
def create_single_type_two_inputs_math_node(data_type, idname, label):
return create_two_inputs_math_node(data_type, data_type, data_type, idname, label)
def create_two_inputs_math_node(input_type1, input_type2, output_type, idname, label):
class MathNode(bpy.types.Node, FunctionNode):
bl_idname = idname
bl_label = label
use_list__a: NodeBuilder.VectorizedProperty()
use_list__b: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("a", "use_list__a", "A", "A", input_type1)
builder.vectorized_input("b", "use_list__b", "B", "B", input_type2)
builder.vectorized_output("result", ["use_list__a", "use_list__b"], "Result", "Result", output_type)
return MathNode
def create_single_input_math_node(input_type, output_type, idname, label):
class MathNode(bpy.types.Node, FunctionNode):
bl_idname = idname
bl_label = label
use_list: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("input", "use_list", "Value", "Values", input_type)
builder.vectorized_output("output", ["use_list"], "Result", "Result", output_type)
return MathNode
AddFloatsNode = create_variadic_math_node("Float", "fn_AddFloatsNode", "Add Floats")
MultiplyFloatsNode = create_variadic_math_node("Float", "fn_MultiplyFloatsNode", "Multiply Floats")
MinimumFloatsNode = create_variadic_math_node("Float", "fn_MinimumFloatsNode", "Minimum Floats")
MaximumFloatsNode = create_variadic_math_node("Float", "fn_MaximumFloatsNode", "Maximum Floats")
SubtractFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_SubtractFloatsNode", "Subtract Floats")
DivideFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_DivideFloatsNode", "Divide Floats")
PowerFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_PowerFloatsNode", "Power Floats")
SqrtFloatNode = create_single_input_math_node("Float", "Float", "fn_SqrtFloatNode", "Sqrt Float")
AbsFloatNode = create_single_input_math_node("Float", "Float", "fn_AbsoluteFloatNode", "Absolute Float")
SineFloatNode = create_single_input_math_node("Float", "Float", "fn_SineFloatNode", "Sine")
CosineFloatNode = create_single_input_math_node("Float", "Float", "fn_CosineFloatNode", "Cosine")
CeilFloatNode = create_single_input_math_node("Float", "Float", "fn_CeilFloatNode", "Ceil Float")
FloorFloatNode = create_single_input_math_node("Float", "Float", "fn_FloorFloatNode", "Floor Float")
AddVectorsNode = create_variadic_math_node("Vector", "fn_AddVectorsNode", "Add Vectors")
SubtractVectorsNode = create_single_type_two_inputs_math_node("Vector", "fn_SubtractVectorsNode", "Subtract Vectors")
MultiplyVectorsNode = create_variadic_math_node("Vector", "fn_MultiplyVectorsNode", "Multiply Vectors")
DivideVectorsNode = create_single_type_two_inputs_math_node("Vector", "fn_DivideVectorsNode", "Divide Vectors")
MultiplyVectorWithFloatNode = create_two_inputs_math_node("Vector", "Float", "Vector", "fn_MultiplyVectorWithFloatNode", "Multiply Vector with Float")
VectorCrossProductNode = create_single_type_two_inputs_math_node("Vector", "fn_VectorCrossProductNode", "Cross Product")
VectorReflectNode = create_single_type_two_inputs_math_node("Vector", "fn_ReflectVectorNode", "Reflect Vector")
VectorProjectNode = create_single_type_two_inputs_math_node("Vector", "fn_ProjectVectorNode", "Project Vector")
VectorDotProductNode = create_two_inputs_math_node("Vector", "Vector", "Float", "fn_VectorDotProductNode", "Dot Product")
VectorDistanceNode = create_two_inputs_math_node("Vector", "Vector", "Float", "fn_VectorDistanceNode", "Vector Distance")
NormalizeVectorNode = create_single_input_math_node("Vector", "Vector", "fn_NormalizeVectorNode", "Normalize Vector")
VectorLengthNode = create_single_input_math_node("Vector", "Float", "fn_VectorLengthNode", "Vector Length")
BooleanAndNode = create_variadic_math_node("Boolean", "fn_BooleanAndNode", "And")
BooleanOrNode = create_variadic_math_node("Boolean", "fn_BooleanOrNode", "Or")
BooleanNotNode = create_single_input_math_node("Boolean", "Boolean", "fn_BooleanNotNode", "Not")
LessThanFloatNode = create_two_inputs_math_node("Float", "Float", "Boolean", "fn_LessThanFloatNode", "Less Than Float")
GreaterThanFloatNode = create_two_inputs_math_node("Float", "Float", "Boolean", "fn_GreaterThanFloatNode", "Greater Than Float")
class MapRangeNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_MapRangeNode"
bl_label = "Map Range"
clamp: BoolProperty(
name="Clamp",
default=True,
)
use_list__value: NodeBuilder.VectorizedProperty()
use_list__from_min: NodeBuilder.VectorizedProperty()
use_list__from_max: NodeBuilder.VectorizedProperty()
use_list__to_min: NodeBuilder.VectorizedProperty()
use_list__to_max: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("value", "use_list__value", "Value", "Values", "Float")
builder.vectorized_input("from_min", "use_list__from_min", "From Min", "From Min", "Float")
builder.vectorized_input("from_max", "use_list__from_max", "From Max", "From Max", "Float")
builder.vectorized_input("to_min", "use_list__to_min", "To Min", "To Min", "Float")
builder.vectorized_input("to_max", "use_list__to_max", "To Max", "To Max", "Float")
builder.vectorized_output("value", [
"use_list__value", "use_list__from_min", "use_list__from_max",
"use_list__to_min", "use_list__to_max"], "Value", "Values", "Float")
def draw(self, layout):
layout.prop(self, "clamp")
class FloatClampNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_FloatClampNode"
bl_label = "Clamp"
def declaration(self, builder: NodeBuilder):
builder.fixed_input("value", "Value", "Float")
builder.fixed_input("min", "Min", "Float", default=0)
builder.fixed_input("max", "Max", "Float", default=1)
builder.fixed_output("value", "Value", "Float")

View File

@@ -0,0 +1,12 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class NodeInstanceIdentifierNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_NodeInstanceIdentifierNode"
bl_label = "Node Instance Identifier"
def declaration(self, builder):
builder.fixed_output("identifier", "Identifier", "Text")

View File

@@ -0,0 +1,143 @@
import bpy
import random
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class PerlinNoiseNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_PerlinNoiseNode"
bl_label = "Perlin Noise"
def declaration(self, builder: NodeBuilder):
builder.fixed_input("position", "Position", "Vector")
builder.fixed_input("amplitude", "Amplitude", "Float", default=1)
builder.fixed_input("scale", "Scale", "Float", default=1)
builder.fixed_output("noise_1d", "Noise", "Float")
builder.fixed_output("noise_3d", "Noise", "Vector")
class RandomFloatNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_RandomFloatNode"
bl_label = "Random Float"
node_seed: IntProperty(
name="Node Seed",
)
def init_props(self):
self.node_seed = new_node_seed()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("min", "Min", "Float", default=0)
builder.fixed_input("max", "Max", "Float", default=1)
builder.fixed_input("seed", "Seed", "Integer")
builder.fixed_output("value", "Value", "Float")
def draw_advanced(self, layout):
layout.prop(self, "node_seed")
def duplicate(self, src_node):
self.node_seed = new_node_seed()
class RandomFloatsNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_RandomFloatsNode"
bl_label = "Random Floats"
node_seed: IntProperty(
name="Node Seed",
)
def init_props(self):
self.node_seed = new_node_seed()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("amount", "Amount", "Integer", default=10)
builder.fixed_input("min", "Min", "Float")
builder.fixed_input("max", "Max", "Float", default=1)
builder.fixed_input("seed", "Seed", "Integer")
builder.fixed_output("values", "Values", "Float List")
def draw_advanced(self, layout):
layout.prop(self, "node_seed")
def duplicate(self, src_node):
self.node_seed = new_node_seed()
random_vector_mode_items = [
("UNIFORM_IN_CUBE", "Uniform in Cube", "Generate a vector that is somewhere in the volume of a cube", "NONE", 0),
("UNIFORM_ON_SPHERE", "Uniform on Sphere", "Generate a vector that is somewhere on the surface of a sphere", 1),
("UNIFORM_IN_SPHERE", "Uniform in Sphere", "Generate a vector that is somewhere in the volume of a sphere", 2),
]
class RandomVectorNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_RandomVectorNode"
bl_label = "Random Vector"
node_seed: IntProperty(
name="Node Seed",
)
mode: EnumProperty(
name="Mode",
items=random_vector_mode_items,
default="UNIFORM_IN_CUBE",
)
use_list__factor: NodeBuilder.VectorizedProperty()
use_list__seed: NodeBuilder.VectorizedProperty()
def init_props(self):
self.node_seed = new_node_seed()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("factor", "use_list__factor", "Factor", "Factors", "Vector", default=(1, 1, 1))
builder.vectorized_input("seed", "use_list__seed", "Seed", "Seeds", "Integer")
builder.vectorized_output("vector", ["use_list__factor", "use_list__seed"], "Vector", "Vectors", "Vector")
def draw(self, layout):
layout.prop(self, "mode", text="")
def draw_advanced(self, layout):
layout.prop(self, "node_seed")
def duplicate(self, src_node):
self.node_seed = new_node_seed()
class RandomVectorsNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_RandomVectorsNode"
bl_label = "Random Vectors"
node_seed: IntProperty(
name="Node Seed",
)
mode: EnumProperty(
name="Mode",
items=random_vector_mode_items,
default="UNIFORM_IN_CUBE",
)
def init_props(self):
self.node_seed = new_node_seed()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("amount", "Amount", "Integer", default=10)
builder.fixed_input("factor", "Factor", "Vector", default=(1, 1, 1))
builder.fixed_input("seed", "Seed", "Integer")
builder.fixed_output("vectors", "Vectors", "Vector List")
def draw(self, layout):
layout.prop(self, "mode", text="")
def draw_advanced(self, layout):
layout.prop(self, "node_seed")
def duplicate(self, src_node):
self.node_seed = new_node_seed()
def new_node_seed():
return random.randint(0, 10000)

View File

@@ -0,0 +1,113 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class ObjectMeshNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_ObjectMeshNode"
bl_label = "Object Mesh"
def declaration(self, builder):
builder.fixed_input("object", "Object", "Object", display_name=False)
builder.fixed_output("vertex_locations", "Vertex Locations", "Vector List")
class VertexInfo(bpy.types.Node, FunctionNode):
bl_idname = "fn_VertexInfoNode"
bl_label = "Vertex Info"
def declaration(self, builder):
builder.fixed_output("position", "Position", "Vector")
class ClosestLocationOnObjectNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_ClosestLocationOnObjectNode"
bl_label = "Closest Location on Object"
use_list__object: NodeBuilder.VectorizedProperty()
use_list__position: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("object", "use_list__object", "Object", "Objects", "Object", display_name=False)
builder.vectorized_input("position", "use_list__position", "Position", "Positions", "Vector")
vectorize_props = ["use_list__object", "use_list__position"]
builder.vectorized_output("closest_hook", vectorize_props, "Closest Hook", "Closest Hooks", "Surface Hook")
builder.vectorized_output("closest_position", vectorize_props, "Closest Position", "Closest Positions", "Vector")
builder.vectorized_output("closest_normal", vectorize_props, "Closest Normal", "Closest Normals", "Vector")
class GetPositionOnSurfaceNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetPositionOnSurfaceNode"
bl_label = "Get Position on Surface"
use_list__surface_hook: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("surface_hook", "use_list__surface_hook", "Surface Hook", "Surface Hooks", "Surface Hook")
builder.vectorized_output("position", ["use_list__surface_hook"], "Position", "Positions", "Vector")
class GetNormalOnSurfaceNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetNormalOnSurfaceNode"
bl_label = "Get Normal on Surface"
use_list__surface_hook: NodeBuilder.VectorizedProperty()
def declaration(self, builder):
builder.vectorized_input("surface_hook", "use_list__surface_hook", "Surface Hook", "Surface Hooks", "Surface Hook")
builder.vectorized_output("normal", ["use_list__surface_hook"], "Normal", "Normals", "Vector")
class GetWeightOnSurfaceNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetWeightOnSurfaceNode"
bl_label = "Get Weight on Surface"
use_list__surface_hook: NodeBuilder.VectorizedProperty()
use_list__vertex_group_name: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("surface_hook", "use_list__surface_hook", "Surface Hook", "Surface Hooks", "Surface Hook")
builder.vectorized_input("vertex_group_name", "use_list__vertex_group_name", "Name", "Names", "Text",
default="Group", display_name=False, display_icon="GROUP_VERTEX")
builder.vectorized_output("weight", ["use_list__surface_hook", "use_list__vertex_group_name"], "Weight", "Weights", "Float")
class GetImageColorOnSurfaceNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetImageColorOnSurfaceNode"
bl_label = "Get Image Color on Surface"
use_list__surface_hook: NodeBuilder.VectorizedProperty()
use_list__image: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("surface_hook", "use_list__surface_hook", "Surface Hook", "Surface Hooks", "Surface Hook")
builder.vectorized_input("image", "use_list__image", "Image", "Images", "Image", display_name=False)
builder.vectorized_output("color", ["use_list__surface_hook", "use_list__image"], "Color", "Colors", "Color")
class SampleObjectSurfaceNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_SampleObjectSurfaceNode"
bl_label = "Sample Object Surface"
weight_mode: EnumProperty(
name="Weight Mode",
items=[
("UNIFORM", "Uniform", "", "NONE", 0),
("VERTEX_WEIGHTS", "Vertex Weights", "", "NONE", 1),
],
default="UNIFORM",
update=FunctionNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
builder.fixed_input("object", "Object", "Object", display_name=False)
builder.fixed_input("amount", "Amount", "Integer", default=10)
builder.fixed_input("seed", "Seed", "Integer")
if self.weight_mode == "VERTEX_WEIGHTS":
builder.fixed_input("vertex_group_name", "Vertex Group", "Text", default="Group")
builder.fixed_output("surface_hooks", "Surface Hooks", "Surface Hook List")
def draw(self, layout):
layout.prop(self, "weight_mode", text="")

View File

@@ -0,0 +1,11 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
class ObjectTransformsNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_ObjectTransformsNode"
bl_label = "Object Transforms"
def declaration(self, builder):
builder.fixed_input("object", "Object", "Object")
builder.fixed_output("location", "Location", "Vector")

View File

@@ -0,0 +1,79 @@
import bpy
import uuid
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class SwitchNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_SwitchNode"
bl_label = "Switch"
data_type: StringProperty(
default="Float",
update=FunctionNode.sync_tree
)
def declaration(self, builder: NodeBuilder):
builder.fixed_input("condition", "Condition", "Boolean")
builder.fixed_input("true", "True", self.data_type)
builder.fixed_input("false", "False", self.data_type)
builder.fixed_output("result", "Result", self.data_type)
def draw(self, layout):
self.invoke_type_selection(layout, "set_type", "Change Type")
def set_type(self, data_type):
self.data_type = data_type
class SelectNodeItem(bpy.types.PropertyGroup):
identifier: StringProperty()
class SelectNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_SelectNode"
bl_label = "Select"
data_type: StringProperty(
default="Float",
update=FunctionNode.sync_tree,
)
input_items: CollectionProperty(
type=SelectNodeItem,
)
def init_props(self):
self.add_input()
self.add_input()
def declaration(self, builder: NodeBuilder):
builder.fixed_input("select", "Select", "Integer")
for i, item in enumerate(self.input_items):
builder.fixed_input(item.identifier, str(i), self.data_type)
builder.fixed_input("fallback", "Fallback", self.data_type)
builder.fixed_output("result", "Result", self.data_type)
def draw(self, layout):
self.invoke_type_selection(layout, "set_type", "Change Type")
self.invoke_function(layout, "add_input", "Add Input")
def draw_socket(self, layout, socket, text, decl, index_in_decl):
if len(socket.name) <= 3:
index = int(socket.name)
row = layout.row(align=True)
decl.draw_socket(row, socket, index_in_decl)
self.invoke_function(row, "remove_input", "", icon="X", settings=(index, ))
else:
decl.draw_socket(layout, socket, index_in_decl)
def set_type(self, data_type):
self.data_type = data_type
def add_input(self):
item = self.input_items.add()
item.identifier = str(uuid.uuid4())
self.sync_tree()
def remove_input(self, index):
self.input_items.remove(index)
self.sync_tree()

View File

@@ -0,0 +1,20 @@
import bpy
from .. node_builder import NodeBuilder
from .. base import FunctionNode
class TextLengthNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_TextLengthNode"
bl_label = "Text Length"
def declaration(self, builder: NodeBuilder):
builder.fixed_input("text", "Text", "Text")
builder.fixed_output("length", "Length", "Integer")
class JoinTextListNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_JoinTextListNode"
bl_label = "Join Text List"
def declaration(self, builder: NodeBuilder):
builder.fixed_input("texts", "Texts", "Text List")
builder.fixed_output("text", "Text", "Text")

View File

@@ -0,0 +1,10 @@
import bpy
from .. node_builder import NodeBuilder
from .. base import FunctionNode
class TimeInfoNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_TimeInfoNode"
bl_label = "Time Info"
def declaration(self, builder: NodeBuilder):
builder.fixed_output("frame", "Frame", "Float")

View File

@@ -0,0 +1,29 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class ValueNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_ValueNode"
bl_label = "Value"
data_type: StringProperty(
name="Data Type",
default="Float",
update=FunctionNode.sync_tree,
)
def declaration(self, builder: NodeBuilder):
builder.fixed_output("value", "Value", self.data_type)
def draw_socket(self, layout, socket, text, decl, index_in_decl):
row = layout.row(align=True)
if hasattr(socket, "draw_property"):
socket.draw_property(row, self, "")
else:
row.label(text=text)
self.invoke_type_selection(row, "set_type", text="", icon="SETTINGS")
def set_type(self, data_type):
self.data_type = data_type

View File

@@ -0,0 +1,71 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
from .. node_builder import NodeBuilder
class VectorFromValueNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_VectorFromValueNode"
bl_label = "Vector from Value"
use_list__value: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input("value", "use_list__value", "Value", "Values", "Float")
builder.vectorized_output("vector", ["use_list__value"], "Vector", "Vectors", "Vector")
class CombineVectorNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_CombineVectorNode"
bl_label = "Combine Vector"
use_list__x: NodeBuilder.VectorizedProperty()
use_list__y: NodeBuilder.VectorizedProperty()
use_list__z: NodeBuilder.VectorizedProperty()
def declaration(self, builder):
builder.vectorized_input(
"x", "use_list__x",
"X", "X", "Float")
builder.vectorized_input(
"y", "use_list__y",
"Y", "Y", "Float")
builder.vectorized_input(
"z", "use_list__z",
"Z", "Z", "Float")
builder.vectorized_output(
"vector", ["use_list__x", "use_list__y", "use_list__z"],
"Vector", "Vectors", "Vector")
class SeparateVectorNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_SeparateVectorNode"
bl_label = "Separate Vector"
use_list__vector: NodeBuilder.VectorizedProperty()
def declaration(self, builder: NodeBuilder):
builder.vectorized_input(
"vector", "use_list__vector",
"Vector", "Vectors", "Vector")
builder.vectorized_output(
"x", ["use_list__vector"],
"X", "X", "Float")
builder.vectorized_output(
"y", ["use_list__vector"],
"Y", "Y", "Float")
builder.vectorized_output(
"z", ["use_list__vector"],
"Z", "Z", "Float")
class FindNonClosePointsNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_FindNonClosePointsNode"
bl_label = "Find Non Close Point"
def declaration(self, builder: NodeBuilder):
builder.fixed_input("points", "Points", "Vector List")
builder.fixed_input("min_distance", "Min Distance", "Float", default=0.1)
builder.fixed_output("indices", "Indices", "Integer List")

View File

@@ -0,0 +1,57 @@
import bpy
from collections import namedtuple
from . base import BaseTree, BaseNode
from . graph import DirectedGraphBuilder, DirectedGraph
class FunctionTree(bpy.types.NodeTree, BaseTree):
bl_idname = "FunctionTree"
bl_icon = "MOD_DATA_TRANSFER"
bl_label = "Function Nodes"
def get_input_nodes(self):
input_nodes = [node for node in self.nodes if node.bl_idname == "fn_GroupInputNode"]
sorted_input_nodes = sorted(input_nodes, key=lambda node: (node.sort_index, node.name))
return sorted_input_nodes
def get_output_nodes(self):
output_nodes = [node for node in self.nodes if node.bl_idname == "fn_GroupOutputNode"]
sorted_output_nodes = sorted(output_nodes, key=lambda node: (node.sort_index, node.name))
return sorted_output_nodes
def get_directly_used_trees(self):
trees = set()
for node in self.nodes:
if isinstance(node, BaseNode):
trees.update(node.iter_directly_used_trees())
return trees
def find_callable_trees(self):
used_by_trees = FunctionTree.BuildInvertedCallGraph().reachable(self)
trees = [tree for tree in bpy.data.node_groups
if isinstance(tree, FunctionTree) and tree not in used_by_trees]
return trees
@staticmethod
def BuildTreeCallGraph() -> DirectedGraph:
'''
Every vertex is a tree.
Every edge (A, B) means: Tree A uses tree B.
'''
builder = DirectedGraphBuilder()
for tree in bpy.data.node_groups:
if isinstance(tree, FunctionTree):
builder.add_vertex(tree)
for dependency_tree in tree.get_directly_used_trees():
builder.add_directed_edge(
from_v=tree,
to_v=dependency_tree)
return builder.build()
@staticmethod
def BuildInvertedCallGraph() -> DirectedGraph:
'''
Builds a directed graph in which every tree is a vertex.
Every edge (A, B) means: Changes in A might affect B.
'''
return FunctionTree.BuildTreeCallGraph().inverted()

View File

@@ -0,0 +1,87 @@
from collections import namedtuple, defaultdict
class DirectedGraph:
def __init__(self, V, E):
assert all(isinstance(e, tuple) for e in E)
assert all(v1 in V and v2 in V for v1, v2 in E)
self.V = set(V)
self.E = set(E)
self.outgoing = defaultdict(set)
self.incoming = defaultdict(set)
self.neighbors = defaultdict(set)
for v1, v2 in E:
self.outgoing[v1].add(v2)
self.incoming[v2].add(v1)
self.neighbors[v1].add(v2)
self.neighbors[v2].add(v1)
def inverted(self):
return DirectedGraph(self.V, [(v2, v1) for v1, v2 in self.E])
def reachable(self, start_verts):
return self._reachable(start_verts, self.outgoing)
def reachable_inversed(self, start_verts):
return self._reachable(start_verts, self.incoming)
def connected(self, start_verts):
return self._reachable(start_verts, self.neighbors)
def _reachable(self, start_verts, next_map):
if start_verts in self.V:
start_verts = (start_verts, )
assert all(v in self.V for v in start_verts)
verts_to_check = set(start_verts)
found_verts = set()
while len(verts_to_check) > 0:
v = verts_to_check.pop()
found_verts.add(v)
for prev_v in next_map[v]:
if prev_v not in found_verts:
verts_to_check.add(prev_v)
return found_verts
def toposort(self):
return self.toposort_partial(self.V)
def toposort_partial(self, verts_to_sort):
verts_to_sort = set(verts_to_sort)
sorted_verts = list()
temp_marked_verts = set()
finished_verts = set()
def visit(v):
if v in finished_verts:
return
if v in temp_marked_verts:
raise Exception("not a DAG")
temp_marked_verts.add(v)
for prev_v in self.incoming[v]:
visit(prev_v)
finished_verts.add(v)
if v in verts_to_sort:
sorted_verts.append(v)
for v in verts_to_sort:
visit(v)
return tuple(sorted_verts)
class DirectedGraphBuilder:
def __init__(self):
self.V = set()
self.E = set()
def add_vertex(self, v):
self.V.add(v)
def add_directed_edge(self, from_v, to_v):
self.V.add(from_v)
self.V.add(to_v)
self.E.add((from_v, to_v))
def build(self):
return DirectedGraph(self.V, self.E)

View File

@@ -0,0 +1,291 @@
from collections import namedtuple, defaultdict
from . utils.graph import iter_connected_components
from . types import type_infos
from . tree_data import TreeData
from . declaration import (
FixedSocketDecl,
ListSocketDecl,
BaseListVariadic,
VectorizedInputDecl,
VectorizedOutputDecl,
)
DecisionID = namedtuple("DecisionID", ("node", "prop_name"))
def get_inferencing_decisions(tree_data: TreeData):
list_decisions = make_list_decisions(tree_data)
vector_decisions = make_vector_decisions(tree_data, list_decisions)
base_list_variadic_decisions = make_base_list_variadic_decisions(tree_data, list_decisions, vector_decisions)
decisions = dict()
decisions.update(list_decisions)
decisions.update(vector_decisions)
decisions.update(base_list_variadic_decisions)
return decisions
# Inference list type decisions
#################################################
def make_list_decisions(tree_data):
decision_users = get_list_decision_ids_with_users(tree_data)
decision_links = get_list_decision_links(tree_data)
decisions = dict()
for component in iter_connected_components(decision_users.keys(), decision_links):
possible_types = set(iter_possible_list_component_types(
component, decision_users, tree_data))
if len(possible_types) == 1:
base_type = next(iter(possible_types))
for decision_id in component:
decisions[decision_id] = base_type
return decisions
def get_list_decision_ids_with_users(tree_data):
decision_users = defaultdict(lambda: {"BASE": [], "LIST": []})
for node in tree_data.iter_nodes():
for decl, sockets in node.decl_map.iter_decl_with_sockets():
if isinstance(decl, ListSocketDecl):
decision_id = DecisionID(node, decl.prop_name)
decision_users[decision_id][decl.list_or_base].append(sockets[0])
return decision_users
def get_list_decision_links(tree_data):
linked_decisions = defaultdict(set)
for from_socket, to_socket in tree_data.iter_connections():
from_node = tree_data.get_node(from_socket)
to_node = tree_data.get_node(to_socket)
from_decl = from_socket.get_decl(from_node)
to_decl = to_socket.get_decl(to_node)
if isinstance(from_decl, ListSocketDecl) and isinstance(to_decl, ListSocketDecl):
if from_decl.list_or_base == to_decl.list_or_base:
from_decision_id = DecisionID(from_node, from_decl.prop_name)
to_decision_id = DecisionID(to_node, to_decl.prop_name)
linked_decisions[from_decision_id].add(to_decision_id)
linked_decisions[to_decision_id].add(from_decision_id)
return linked_decisions
def iter_possible_list_component_types(component, decision_users, tree_data):
for decision_id in component:
for socket in decision_users[decision_id]["LIST"]:
for other_node, other_socket in tree_data.iter_connected_sockets_with_nodes(socket):
other_decl = other_socket.get_decl(other_node)
if data_sockets_are_static(other_decl):
data_type = other_socket.data_type
if type_infos.is_list(data_type):
yield type_infos.to_base(data_type)
elif isinstance(other_decl, BaseListVariadic):
yield other_decl.base_type
elif isinstance(other_decl, VectorizedInputDecl):
yield other_decl.base_type
elif isinstance(other_decl, VectorizedOutputDecl):
yield other_decl.base_type
for socket in decision_users[decision_id]["BASE"]:
for other_node, other_socket in tree_data.iter_connected_sockets_with_nodes(socket):
other_decl = other_socket.get_decl(other_node)
if data_sockets_are_static(other_decl):
data_type = other_socket.data_type
if type_infos.is_base(data_type):
yield data_type
elif isinstance(other_decl, BaseListVariadic):
yield other_decl.base_type
elif isinstance(other_decl, VectorizedInputDecl):
yield other_decl.base_type
elif isinstance(other_decl, VectorizedOutputDecl):
yield other_decl.base_type
# Inference vectorization decisions
########################################
def make_vector_decisions(tree_data, list_decisions):
graph, input_sockets, output_sockets = get_vector_decisions_graph(tree_data)
decisions = dict()
decision_ids_with_collision = set()
for initial_decision_id, decision in iter_obligatory_vector_decisions(graph, input_sockets, output_sockets, tree_data, list_decisions):
for decision_id in graph.reachable(initial_decision_id):
if decision_id in decisions:
if decisions[decision_id] != decision:
decision_ids_with_collision.add(decision_id)
else:
decisions[decision_id] = decision
for decision_id in graph.V:
decisions.setdefault(decision_id, "BASE")
while len(decision_ids_with_collision) > 0:
collision_decision_id = decision_ids_with_collision.pop()
connected_decision_ids = graph.connected(collision_decision_id)
for decision_id in connected_decision_ids:
decisions.pop(decision_id, None)
decision_ids_with_collision.discard(decision_id)
return decisions
def get_vector_decisions_graph(tree_data):
'''
Builds a directed graph.
Vertices in that graph are decision IDs.
A directed edge (A, B) means: If A is a list, then B has to be a list.
'''
from . graph import DirectedGraphBuilder
builder = DirectedGraphBuilder()
input_sockets = set()
output_sockets = set()
for node in tree_data.iter_nodes():
for decl, sockets in node.decl_map.iter_decl_with_sockets():
if isinstance(decl, VectorizedInputDecl):
decision_id = DecisionID(node, decl.prop_name)
builder.add_vertex(decision_id)
input_sockets.add(sockets[0])
elif isinstance(decl, VectorizedOutputDecl):
output_sockets.add(sockets[0])
for from_socket, to_socket in tree_data.iter_connections():
from_node = tree_data.get_node(from_socket)
to_node = tree_data.get_node(to_socket)
from_decl = from_socket.get_decl(from_node)
to_decl = to_socket.get_decl(to_node)
if isinstance(from_decl, VectorizedOutputDecl) and isinstance(to_decl, VectorizedInputDecl):
for prop_name in from_decl.input_prop_names:
from_decision_id = DecisionID(from_node, prop_name)
to_decision_id = DecisionID(to_node, to_decl.prop_name)
builder.add_directed_edge(from_decision_id, to_decision_id)
return builder.build(), input_sockets, output_sockets
def iter_obligatory_vector_decisions(graph, input_sockets, output_sockets, tree_data, list_decisions):
for socket in input_sockets:
other_node, other_socket = tree_data.try_get_origin_with_node(socket)
if other_node is None:
continue
node = tree_data.get_node(socket)
decl = socket.get_decl(node)
decision_id = DecisionID(node, decl.prop_name)
other_decl = other_socket.get_decl(other_node)
if data_sockets_are_static(other_decl):
other_data_type = other_socket.data_type
if type_infos.is_list(other_data_type) and type_infos.is_link_allowed(other_data_type, decl.list_type):
yield decision_id, "LIST"
elif isinstance(other_decl, ListSocketDecl):
if other_decl.list_or_base == "LIST":
list_decision_id = DecisionID(other_node, other_decl.prop_name)
if list_decision_id in list_decisions:
other_base_type = list_decisions[list_decision_id]
if type_infos.is_link_allowed(other_base_type, decl.base_type):
yield decision_id, "LIST"
else:
old_data_type = other_socket.data_type
if type_infos.is_link_allowed(old_data_type, decl.list_type):
yield decision_id, "LIST"
for socket in output_sockets:
node = tree_data.get_node(socket)
decl = socket.get_decl(node)
decision_ids = [DecisionID(node, p) for p in decl.input_prop_names]
for other_node, other_socket in tree_data.iter_connected_sockets_with_nodes(socket):
other_decl = other_socket.get_decl(other_node)
if data_sockets_are_static(other_decl):
other_data_type = other_socket.data_type
if type_infos.is_base(other_data_type) and type_infos.is_link_allowed(other_data_type, decl.base_type):
for decision_id in decision_ids:
yield decision_id, "BASE"
elif isinstance(other_decl, ListSocketDecl):
if other_decl.list_or_base == "BASE":
list_decision_id = DecisionID(other_node, other_decl.prop_name)
if list_decision_id in list_decisions:
other_base_type = list_decisions[list_decision_id]
if type_infos.is_link_allowed(decl.base_type, other_base_type):
for decision_id in decision_ids:
yield decision_id, "BASE"
else:
old_data_type = other_socket.data_type
if type_infos.is_link_allowed(decl.base_type, old_data_type):
for decision_id in decision_ids:
yield decision_id, "BASE"
# Inference pack list decisions
########################################
def make_base_list_variadic_decisions(tree_data, list_decisions, vector_decisions):
decisions = dict()
for decision_id, decl, socket in iter_base_list_variadic_sockets(tree_data):
assert not socket.is_output
origin_node, origin_socket = tree_data.try_get_origin_with_node(socket)
if origin_socket is None:
decisions[decision_id] = "BASE"
continue
origin_decl = origin_socket.get_decl(origin_node)
if data_sockets_are_static(origin_decl):
data_type = origin_socket.data_type
if type_infos.is_link_allowed(data_type, decl.base_type):
decisions[decision_id] = "BASE"
elif type_infos.is_link_allowed(data_type, decl.list_type):
decisions[decision_id] = "LIST"
else:
decisions[decision_id] = "BASE"
elif isinstance(origin_decl, ListSocketDecl):
list_decision_id = DecisionID(origin_node, origin_decl.prop_name)
if list_decision_id in list_decisions:
other_base_type = list_decisions[list_decision_id]
if type_infos.is_link_allowed(other_base_type, decl.base_type):
decisions[decision_id] = origin_decl.list_or_base
else:
decisions[decision_id] = "BASE"
else:
old_origin_type = origin_socket.data_type
if type_infos.is_link_allowed(old_origin_type, decl.base_type):
decisions[decision_id] = "BASE"
elif type_infos.is_link_allowed(old_origin_type, decl.list_type):
decisions[decision_id] = "LIST"
else:
decisions[decision_id] = "BASE"
elif isinstance(origin_decl, VectorizedOutputDecl):
other_base_type = origin_decl.base_type
if type_infos.is_link_allowed(other_base_type, decl.base_type):
for input_prop_name in origin_decl.input_prop_names:
input_decision_id = DecisionID(origin_node, input_prop_name)
if input_decision_id in vector_decisions:
if vector_decisions[input_decision_id] == "LIST":
decisions[decision_id] = "LIST"
break
else:
decisions[decision_id] = "BASE"
else:
decisions[decision_id] = "BASE"
else:
decisions[decision_id] = "BASE"
return decisions
def data_sockets_are_static(decl):
return isinstance(decl, FixedSocketDecl)
def iter_base_list_variadic_sockets(tree_data):
for node in tree_data.iter_nodes():
for decl, sockets in node.decl_map.iter_decl_with_sockets():
if isinstance(decl, BaseListVariadic):
collection = decl.get_collection()
for i, socket in enumerate(sockets[:-1]):
decision_id = DecisionID(node, f"{decl.prop_name}[{i}].state")
yield decision_id, decl, socket

View File

@@ -0,0 +1,16 @@
import bpy
def register():
wm = bpy.context.window_manager
if wm.keyconfigs.addon is None:
return
km = wm.keyconfigs.addon.keymaps.new(
name="Node Editor",
space_type='NODE_EDITOR')
km.keymap_items.new(
"fn.node_search",
type='A',
value='PRESS',
ctrl=True)

View File

@@ -0,0 +1,95 @@
import bpy
from . function_tree import FunctionTree
def draw_menu(self, context):
tree = context.space_data.node_tree
if not isinstance(tree, FunctionTree):
return
layout = self.layout
layout.operator_context = 'INVOKE_DEFAULT'
layout.operator("fn.node_search", text="Search", icon='VIEWZOOM')
layout.separator()
layout.menu("FN_MT_function_nodes_menu", text="Function Nodes")
layout.separator()
insert_node(layout, "fn_ParticleSystemNode", "Particle System")
layout.menu("BP_MT_influences_nodes_menu", text="Influences")
layout.menu("BP_MT_action_nodes_menu", text="Actions")
class FunctionNodesMenu(bpy.types.Menu):
bl_idname = "FN_MT_function_nodes_menu"
bl_label = "Function Nodes Menu"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_DEFAULT'
insert_node(layout, "fn_SwitchNode", "Switch")
layout.separator()
insert_node(layout, "fn_FloatRangeNode", "Float Range")
layout.separator()
insert_node(layout, "fn_CombineVectorNode", "Combine Vector")
insert_node(layout, "fn_SeparateVectorNode", "Separate Vector")
insert_node(layout, "fn_VectorDistanceNode", "Vector Distance")
layout.separator()
insert_node(layout, "fn_SeparateColorNode", "Separate Color")
insert_node(layout, "fn_CombineColorNode", "Combine Color")
layout.separator()
insert_node(layout, "fn_GetListElementNode", "Get List Element")
insert_node(layout, "fn_ListLengthNode", "List Length")
insert_node(layout, "fn_PackListNode", "Pack List")
layout.separator()
insert_node(layout, "fn_ObjectMeshNode", "Object Mesh")
insert_node(layout, "fn_ObjectTransformsNode", "Object Transforms")
insert_node(layout, "fn_TextLengthNode", "Text Length")
class InfluencesNodesMenu(bpy.types.Menu):
bl_idname = "BP_MT_influences_nodes_menu"
bl_label = "Influences Nodes Menu"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_DEFAULT'
insert_node(layout, "fn_CombineInfluencesNode", "Combine Influences")
layout.separator()
insert_node(layout, "fn_InitialGridEmitterNode", "Initial Grid Emitter")
insert_node(layout, "fn_MeshEmitterNode", "Mesh Emitter")
insert_node(layout, "fn_PointEmitterNode", "Point Emitter")
layout.separator()
insert_node(layout, "fn_AgeReachedEventNode", "Age Reached Event")
insert_node(layout, "fn_MeshCollisionEventNode", "Mesh Collision Event")
insert_node(layout, "fn_CustomEventNode", "Custom Event")
layout.separator()
insert_node(layout, "fn_ForceNode", "Force")
layout.separator()
insert_node(layout, "fn_SizeOverTimeNode", "Size Over Time")
insert_node(layout, "fn_ParticleTrailsNode", "Trails")
insert_node(layout, "fn_AlwaysExecuteNode", "Always Execute")
class ActionNodesMenu(bpy.types.Menu):
bl_idname = "BP_MT_action_nodes_menu"
bl_label = "Action Nodes Menu"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_DEFAULT'
insert_node(layout, "fn_ParticleConditionNode", "Condition")
def insert_node(layout, type, text, settings = {}, icon = "NONE"):
operator = layout.operator("node.add_node", text = text, icon = icon)
operator.type = type
operator.use_transform = True
for name, value in settings.items():
item = operator.settings.add()
item.name = name
item.value = value
return operator
def register():
bpy.types.NODE_MT_add.append(draw_menu)

View File

@@ -0,0 +1,240 @@
from . declaration import (
FixedSocketDecl,
ListSocketDecl,
BaseListVariadic,
VectorizedInputDecl,
VectorizedOutputDecl,
InfluencesSocketDecl,
ExecuteOutputDecl,
ExecuteInputListDecl,
ExecuteInputDecl,
NoDefaultValue,
)
class NodeBuilder:
def __init__(self, node):
self.node = node
self.input_declarations = []
self.output_declarations = []
self._background_color = None
def _add_input(self, decl):
self.input_declarations.append(decl)
def _add_output(self, decl):
self.output_declarations.append(decl)
def initialize_decls(self):
for decl in self.input_declarations:
decl.init()
for decl in self.output_declarations:
decl.init()
def build(self):
from . sync import skip_syncing
with skip_syncing():
self.node.inputs.clear()
self.node.outputs.clear()
for decl in self.input_declarations:
sockets = decl.build(self.node.inputs)
assert len(sockets) == decl.amount()
decl.init_default(sockets)
for decl in self.output_declarations:
sockets = decl.build(self.node.outputs)
assert len(sockets) == decl.amount()
decl.init_default(sockets)
if self._background_color is not None:
self.node.use_custom_color = True
self.node.color = self._background_color
def get_sockets_decl_map(self):
return SocketDeclMap(
self.node,
self.input_declarations,
self.output_declarations)
def matches_sockets(self):
if not self._declarations_matches_sockets(self.input_declarations, self.node.inputs):
return False
if not self._declarations_matches_sockets(self.output_declarations, self.node.outputs):
return False
return True
def _declarations_matches_sockets(self, declarations, all_sockets):
sockets_iter = iter(all_sockets)
for decl in declarations:
amount = decl.amount()
try: sockets = [next(sockets_iter) for _ in range(amount)]
except StopIteration: return False
if not decl.validate(sockets):
return False
if len(tuple(sockets_iter)) > 0:
return False
return True
# General Node Properties
###################################
def background_color(self, color):
assert len(color) == 3
self._background_color = color
# Fixed Data Types
###################################
def fixed_input(self, identifier, name, data_type,
*, default=NoDefaultValue, **kwargs):
decl = FixedSocketDecl(self.node, identifier, name, data_type, default, kwargs)
self._add_input(decl)
def fixed_output(self, identifier, name, data_type,
*, default=NoDefaultValue, **kwargs):
decl = FixedSocketDecl(self.node, identifier, name, data_type, default, kwargs)
self._add_output(decl)
def fixed_pass_through(self, identifier, name, data_type, *, default=NoDefaultValue):
self.fixed_input(identifier, name, data_type, default=default)
self.fixed_output(identifier, name, data_type, default=default)
# Packed List
###################################
@staticmethod
def BaseListVariadicProperty():
return BaseListVariadic.Property()
@staticmethod
def BaseListVariadicPropertyHasList(prop):
return any(v.state == "LIST" for v in prop)
def base_list_variadic_input(self, identifier, prop_name, base_type, default_amount=2):
decl = BaseListVariadic(self.node, identifier, prop_name, base_type, default_amount)
self._add_input(decl)
# Dynamic List
###################################
@staticmethod
def DynamicListProperty():
return ListSocketDecl.Property()
def dynamic_list_input(self, identifier, name, prop_name):
decl = ListSocketDecl(self.node, identifier, name, prop_name, "LIST")
self._add_input(decl)
def dynamic_list_output(self, identifier, name, prop_name):
decl = ListSocketDecl(self.node, identifier, name, prop_name, "LIST")
self._add_output(decl)
def dynamic_base_input(self, identifier, name, prop_name):
decl = ListSocketDecl(self.node, identifier, name, prop_name, "BASE")
self._add_input(decl)
def dynamic_base_output(self, identifier, name, prop_name):
decl = ListSocketDecl(self.node, identifier, name, prop_name, "BASE")
self._add_output(decl)
# Vectorized
##################################
@staticmethod
def VectorizedProperty():
return VectorizedInputDecl.Property()
def vectorized_input(self, identifier, prop_name, base_name, list_name, base_type,
*, default=NoDefaultValue, **kwargs):
decl = VectorizedInputDecl(
self.node, identifier, prop_name,
base_name, list_name, base_type,
default, kwargs)
self._add_input(decl)
def vectorized_output(self, identifier, input_prop_names, base_name, list_name, base_type,
**kwargs):
decl = VectorizedOutputDecl(
self.node, identifier, input_prop_names,
base_name, list_name, base_type, kwargs)
self._add_output(decl)
# BParticles
###################################
def influences_input(self, identifier, name):
decl = InfluencesSocketDecl(self.node, identifier, name)
self._add_input(decl)
def influences_output(self, identifier, name):
decl = InfluencesSocketDecl(self.node, identifier, name)
self._add_output(decl)
@staticmethod
def ExecuteInputProperty():
return ExecuteInputListDecl.Property()
def execute_input(self, identifier, display_name, prop_name):
decl = ExecuteInputListDecl(self.node, identifier, prop_name, display_name)
self._add_input(decl)
def single_execute_input(self, identifier, name):
decl = ExecuteInputDecl(self.node, identifier, name)
self._add_input(decl)
def execute_output(self, identifier, name):
decl = ExecuteOutputDecl(self.node, identifier, name)
self._add_output(decl)
class SocketDeclMap:
def __init__(self, node, input_declarations, output_declarations):
self.node = node
self._sockets_by_decl = dict()
self._decl_by_socket = dict()
self._socket_index_in_decl = dict()
for decl, sockets in iter_sockets_by_decl(node.inputs, input_declarations):
self._sockets_by_decl[decl] = sockets
for i, socket in enumerate(sockets):
self._decl_by_socket[socket] = decl
self._socket_index_in_decl[socket] = i
for decl, sockets in iter_sockets_by_decl(node.outputs, output_declarations):
self._sockets_by_decl[decl] = sockets
for i, socket in enumerate(sockets):
self._decl_by_socket[socket] = decl
self._socket_index_in_decl[socket] = i
def get_decl_by_socket(self, socket):
return self._decl_by_socket[socket]
def get_socket_index_in_decl(self, socket):
return self._socket_index_in_decl[socket]
def get_sockets_by_decl(self, decl):
return self._sockets_by_decl[decl]
def iter_decl_with_sockets(self):
yield from self._sockets_by_decl.items()
def iter_decls(self):
yield from self._sockets_by_decl.keys()
def iter_sockets_by_decl(node_sockets, declarations):
node_sockets_iter = iter(node_sockets)
for decl in declarations:
amount = decl.amount()
sockets_of_decl = tuple(next(node_sockets_iter) for _ in range(amount))
assert decl.validate(sockets_of_decl)
yield decl, sockets_of_decl

View File

@@ -0,0 +1,151 @@
import bpy
from bpy.props import *
from . types import type_infos
from . function_tree import FunctionTree
def try_find_node(tree_name, node_name):
tree = bpy.data.node_groups.get(tree_name)
if tree is not None:
return tree.nodes.get(node_name)
return None
class NodeOperatorBase:
tree_name: StringProperty()
node_name: StringProperty()
function_name: StringProperty()
settings_repr: StringProperty()
def call(self, *args):
node = try_find_node(self.tree_name, self.node_name)
if node is None:
return {'CANCELLED'}
function = getattr(node, self.function_name)
settings = eval(self.settings_repr)
function(*args, *settings)
return {'FINISHED'}
class NodeOperator(bpy.types.Operator, NodeOperatorBase):
bl_idname = "fn.node_operator"
bl_label = "Generic Node Operator"
bl_options = {'INTERNAL'}
def execute(self, context):
return self.call()
class NodeDataTypeSelector(bpy.types.Operator, NodeOperatorBase):
bl_idname = "fn.node_data_type_selector"
bl_label = "Generic Node Data Type Selector"
bl_options = {'INTERNAL'}
bl_property = "item"
mode: EnumProperty(
items=[
("ALL", "All", ""),
("BASE", "Base", ""),
])
def get_items(self, context):
if self.mode == "ALL":
return type_infos.get_data_type_items()
elif self.mode == "BASE":
return type_infos.get_base_type_items()
else:
assert False
item: EnumProperty(items=get_items)
def invoke(self, context, event):
context.window_manager.invoke_search_popup(self)
return {'CANCELLED'}
def execute(self, context):
return self.call(self.item)
class NodeGroupSelector(bpy.types.Operator, NodeOperatorBase):
bl_idname = "fn.node_group_selector"
bl_label = "Node Group Selector"
bl_options = {'INTERNAL'}
bl_property = "item"
def get_items(self, context):
tree = bpy.data.node_groups.get(self.tree_name)
possible_trees = tree.find_callable_trees()
items = []
for tree in possible_trees:
items.append((tree.name, tree.name, ""))
items.append(("NONE", "None", ""))
return items
item: EnumProperty(items=get_items)
def invoke(self, context, event):
context.window_manager.invoke_search_popup(self)
return {'CANCELLED'}
def execute(self, context):
if self.item == "NONE":
return self.call(None)
else:
return self.call(bpy.data.node_groups.get(self.item))
class MoveViewToNode(bpy.types.Operator):
bl_idname = "fn.move_view_to_node"
bl_label = "Move View to Node"
bl_options = {'INTERNAL'}
tree_name: StringProperty()
node_name: StringProperty()
def execute(self, context):
target_node = try_find_node(self.tree_name, self.node_name)
if target_node is None:
return {'CANCELLED'}
tree = target_node.tree
context.space_data.node_tree = tree
for node in tree.nodes:
node.select = False
target_node.select = True
tree.nodes.active = target_node
bpy.ops.node.view_selected('INVOKE_DEFAULT')
return {'FINISHED'}
def new_function_tree(name, inputs, outputs):
tree = bpy.data.node_groups.new(name, "FunctionTree")
for i, (data_type, input_name) in enumerate(inputs):
input_node = tree.nodes.new("fn_GroupInputNode")
input_node.sort_index = i
input_node.interface_type = "DATA"
input_node.input_name = input_name
input_node.data_type = data_type
input_node.location = (-200, -i * 130)
for i, (data_type, output_name) in enumerate(outputs):
output_node = tree.nodes.new("fn_GroupOutputNode")
output_node.sort_index = i
output_node.output_name = output_name
output_node.data_type = data_type
output_node.location = (200, -i * 130)
tree.sync()
return tree
class NewParticleSystem(bpy.types.Operator):
bl_idname = "fn.new_particle_system"
bl_label = "New Particle System"
def execute(self, context):
mesh = bpy.data.meshes.new("Particle Simulation")
ob = bpy.data.objects.new("Particle Simulation", mesh)
modifier = ob.modifiers.new("BParticles", 'BPARTICLES')
bpy.ops.fn.new_particle_simulation_tree(object_name=ob.name, modifier_name=modifier.name)
context.collection.objects.link(ob)
return {'FINISHED'}

View File

@@ -0,0 +1,34 @@
import bpy
from bpy.props import *
from . ui import NodeSidebarPanel
warnings = []
def report_warning(node, msg):
warnings.append((node, msg))
class ProblemsPanel(bpy.types.Panel, NodeSidebarPanel):
bl_idname = "FN_PT_problems"
bl_label = "Problems"
def draw(self, context):
layout = self.layout
for i, (node, msg) in enumerate(warnings):
row = layout.row(align=True)
row.label(text=msg)
props = row.operator("fn.move_view_to_node", text="Find")
props.tree_name = node.tree.name
props.node_name = node.name
props = row.operator("fn.remove_warning", text="", icon='X')
props.index = i
class RemoveWarning(bpy.types.Operator):
bl_idname = "fn.remove_warning"
bl_label = "Remove Warning"
bl_options = {'INTERNAL'}
index: IntProperty()
def execute(self, context):
del warnings[self.index]
return {'FINISHED'}

View File

@@ -0,0 +1,94 @@
import os
import bpy
from bpy.props import *
from pathlib import Path
from . base import BaseNode
from . utils.enum_items_cache import cache_enum_items
from functools import lru_cache
@lru_cache()
def get_node_group_names_in_file(path: str):
with bpy.data.libraries.load(path) as (data_from, data_to):
return list(data_from.node_groups)
class NodeSearch(bpy.types.Operator):
bl_idname = "fn.node_search"
bl_label = "Node Search"
bl_options = {'REGISTER', 'UNDO'}
bl_property = "item"
def get_search_items(self, context):
items = []
tree = context.space_data.edit_tree
for node_cls in BaseNode.iter_final_subclasses():
for search_term, settings in node_cls.get_search_terms():
item = encode_search_item(("BUILTIN", node_cls.bl_idname, settings), search_term)
items.append(item)
current_tree = context.space_data.node_tree
for tree in current_tree.find_callable_trees():
item = encode_search_item(("EXISTING_GROUP", tree.name), tree.name + " (G)")
items.append(item)
nodelibdir = context.preferences.filepaths.nodelib_directory
if len(nodelibdir) > 0 and os.path.exists(nodelibdir):
local_group_names = set(tree.name for tree in bpy.data.node_groups)
for path in Path(nodelibdir).glob("**/*.blend"):
if not path.is_file():
continue
for group_name in get_node_group_names_in_file(str(path)):
if group_name not in local_group_names:
item = encode_search_item(("LIB_GROUP", str(path), group_name), group_name + " (G)")
items.append(item)
sorted_items = list(sorted(items, key=lambda item: item[1]))
return sorted_items
item: EnumProperty(items=cache_enum_items(get_search_items))
@classmethod
def poll(cls, context):
try: return context.space_data.node_tree.bl_idname == "FunctionTree"
except: return False
def invoke(self, context, event):
context.window_manager.invoke_search_popup(self)
return {'CANCELLED'}
def execute(self, context):
tree = context.space_data.node_tree
for node in tree.nodes:
node.select = False
item_data = decode_search_item(self.item)
item_type = item_data[0]
if item_type == "BUILTIN":
idname, settings = item_data[1:]
bpy.ops.node.add_node('INVOKE_DEFAULT', type=idname)
new_node = context.active_node
for key, value in settings.items():
setattr(new_node, key, value)
elif item_type == "EXISTING_GROUP":
group_name = item_data[1]
bpy.ops.node.add_node('INVOKE_DEFAULT', type="fn_GroupNode")
new_node = context.active_node
new_node.node_group = bpy.data.node_groups[group_name]
elif item_type == "LIB_GROUP":
path, group_name = item_data[1:]
bpy.ops.node.add_node('INVOKE_DEFAULT', type="fn_GroupNode")
new_node = context.active_node
with bpy.data.libraries.load(path, link=True) as (data_from, data_to):
data_to.node_groups = [group_name]
new_node.node_group = bpy.data.node_groups[group_name]
bpy.ops.node.translate_attach("INVOKE_DEFAULT")
return {'FINISHED'}
def encode_search_item(data, search_term):
identifier = repr(data)
return (identifier, search_term, "")
def decode_search_item(identifier):
return eval(identifier)

View File

@@ -0,0 +1,228 @@
import bpy
from . base import DataSocket, BaseSocket
from bpy.props import *
class OperatorSocket(bpy.types.NodeSocket, BaseSocket):
bl_idname = "fn_OperatorSocket"
bl_label = "Operator Socket"
def draw_color(self, context, node):
return (0, 0, 0, 0)
class FloatSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_FloatSocket"
bl_label = "Float Socket"
data_type = "Float"
color = (0, 0.3, 0.5, 1)
value: FloatProperty(
name="Value",
default=0.0,
)
def draw_property(self, layout, node, text):
layout.prop(self, "value", text=text)
def get_state(self):
return self.value
def restore_state(self, state):
self.value = state
class IntegerSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_IntegerSocket"
bl_label = "Integer Socket"
data_type = "Integer"
color = (0.3, 0.7, 0.5, 1)
value: IntProperty(
name="Value",
default=0,
)
def draw_property(self, layout, node, text):
layout.prop(self, "value", text=text)
def get_state(self):
return self.value
def restore_state(self, state):
self.value = state
class VectorSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_VectorSocket"
bl_label = "Vector Socket"
data_type = "Vector"
color = (0, 0, 0.5, 1)
value: FloatVectorProperty(
name="Value",
size=3,
default=(0.0, 0.0, 0.0),
)
def draw_property(self, layout, node, text):
layout.column().prop(self, "value", text=text)
def get_state(self):
return tuple(self.value)
def restore_state(self, state):
self.value = state
class BooleanSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_BooleanSocket"
bl_label = "Boolean Socket"
data_type = "Boolean"
color = (0.3, 0.3, 0.3, 1)
value: BoolProperty(
name="Value",
default=False,
)
def draw_property(self, layout, node, text):
layout.prop(self, "value", text=text)
def get_state(self):
return self.value
def restore_state(self, state):
self.value = state
class ObjectSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_ObjectSocket"
bl_label = "Object Socket"
data_type = "Object"
color = (0, 0, 0, 1)
value: PointerProperty(
name="Value",
type=bpy.types.Object,
)
display_name: BoolProperty(default=True)
def draw_property(self, layout, node, text):
if not self.display_name:
text = ""
layout.prop(self, "value", text=text)
def get_state(self):
return self.value
def restore_state(self, state):
self.value = state
class ImageSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_ImageSocket"
bl_label = "Image Socket"
data_type = "Image"
color = (0.6, 0.6, 0.6, 1)
value: PointerProperty(
name="Value",
type=bpy.types.Image,
)
display_name: BoolProperty()
def draw_property(self, layout, node, text):
if not self.display_name:
text = ""
layout.prop(self, "value", text=text)
def get_state(self):
return self.value
def restore_state(self, state):
self.value = state
class ColorSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_ColorSocket"
bl_label = "Color Socket"
data_type = "Color"
color = (0.8, 0.8, 0.2, 1)
value: FloatVectorProperty(
name="Value",
size=4,
default=(0.8, 0.8, 0.8, 1.0),
subtype='COLOR',
soft_min=0.0,
soft_max=0.0,
)
def draw_property(self, layout, node, text):
layout.prop(self, "value", text=text)
def get_state(self):
return tuple(self.value)
def restore_state(self, state):
self.value = state
class TextSocket(bpy.types.NodeSocket, DataSocket):
bl_idname = "fn_TextSocket"
bl_label = "Text Socket"
data_type = "Text"
color = (0.8, 0.8, 0.8, 1)
value: StringProperty(
name="Value",
default="",
)
display_name: BoolProperty(default=True)
display_icon: StringProperty(default="NONE")
def draw_property(self, layout, node, text):
if not self.display_name:
text = ""
layout.prop(self, "value", text=text, icon=self.display_icon)
def get_state(self):
return self.value
def restore_state(self, state):
self.value = state
def create_simple_data_socket(idname, data_type, color):
return type(idname, (bpy.types.NodeSocket, DataSocket),
{
"bl_idname" : idname,
"bl_label" : idname,
"data_type" : data_type,
"color" : color,
})
FloatListSocket = create_simple_data_socket(
"fn_FloatListSocket", "Float List", (0, 0.3, 0.5, 0.5))
VectorListSocket = create_simple_data_socket(
"fn_VectorListSocket", "Vector List", (0, 0, 0.5, 0.5))
IntegerListSocket = create_simple_data_socket(
"fn_IntegerListSocket", "Integer List", (0.3, 0.7, 0.5, 0.5))
BooleanListSocket = create_simple_data_socket(
"fn_BooleanListSocket", "Boolean List", (0.3, 0.3, 0.3, 0.5))
ObjectListSocket = create_simple_data_socket(
"fn_ObjectListSocket", "Object List", (0, 0, 0, 0.5))
ImageListSocket = create_simple_data_socket(
"fn_ImageListSocket", "Image List", (0.6, 0.6, 0.6, 0.5))
ColorListSocket = create_simple_data_socket(
"fn_ColorListSocket", "Color List", (0.8, 0.8, 0.2, 0.5))
TextListSocket = create_simple_data_socket(
"fn_TextListSocket", "Text List", (0.8, 0.8, 0.8, 0.5))
SurfaceHookSocket = create_simple_data_socket(
"fn_SurfaceHookSocket", "Surface Hook", (0.2, 0.8, 0.2, 1.0))
SurfaceHookListSocket = create_simple_data_socket(
"fn_SurfaceHookListSocket", "Surface Hook List", (0.2, 0.8, 0.2, 0.5))
class ExecuteSocket(bpy.types.NodeSocket, BaseSocket):
bl_idname = "fn_ExecuteSocket"
bl_label = "Control Flow Socket"
color = (0.8, 0.2, 0.2, 1)
class InfluencesSocket(bpy.types.NodeSocket, BaseSocket):
bl_idname = "fn_InfluencesSocket"
bl_label = "Influences Socket"
color = (0.8, 0.8, 0.2, 1)

View File

@@ -0,0 +1,183 @@
import bpy
from pprint import pprint
from contextlib import contextmanager
from . base import BaseNode
from . tree_data import TreeData
from . graph import DirectedGraphBuilder
from . function_tree import FunctionTree
from . utils.generic import getattr_recursive, setattr_recursive
_is_syncing = False
def sync_trees_and_dependent_trees(trees):
global _is_syncing
if _is_syncing:
return
if _skip_syncing:
return
_is_syncing = True
try:
for tree in iter_trees_to_sync_in_order(trees):
sync_tree(tree)
finally:
_is_syncing = False
def sync_tree(tree):
rebuild_currently_outdated_nodes(tree)
tree_data = TreeData(tree)
tree_changed = run_socket_operators(tree_data)
if tree_changed: tree_data = TreeData(tree)
tree_changed = do_inferencing_and_update_nodes(tree_data)
if tree_changed: tree_data = TreeData(tree)
tree_changed = remove_invalid_links(tree_data)
# Sync skipping
######################################
_skip_syncing = False
@contextmanager
def skip_syncing():
global _skip_syncing
last_state = _skip_syncing
_skip_syncing = True
try:
yield
finally:
_skip_syncing = last_state
# Tree sync ordering
############################################
def iter_trees_to_sync_in_order(trees):
stored_tree_ids = {id(tree) for tree in bpy.data.node_groups}
if any(id(tree) not in stored_tree_ids for tree in trees):
# can happen after undo or on load
return
dependency_graph = FunctionTree.BuildInvertedCallGraph()
all_trees_to_sync = dependency_graph.reachable(trees)
trees_in_sync_order = dependency_graph.toposort_partial(all_trees_to_sync)
yield from trees_in_sync_order
# Rebuild already outdated nodes
############################################
def rebuild_currently_outdated_nodes(tree):
outdated_nodes = list(iter_nodes_with_outdated_sockets(tree))
rebuild_nodes_and_try_keep_state(outdated_nodes)
def iter_nodes_with_outdated_sockets(tree):
for node in tree.nodes:
if isinstance(node, BaseNode):
if not node_matches_current_declaration(node):
yield node
def node_matches_current_declaration(node):
from . node_builder import NodeBuilder
builder = node.get_node_builder()
return builder.matches_sockets()
# Socket Operators
############################################
def run_socket_operators(tree_data):
from . sockets import OperatorSocket
tree_changed = False
while True:
for link in tree_data.iter_blinks():
if isinstance(link.to_socket, OperatorSocket):
own_node = link.to_node
own_socket = link.to_socket
linked_socket = link.from_socket
connected_sockets = list(tree_data.iter_connected_origins(own_socket))
elif isinstance(link.from_socket, OperatorSocket):
own_node = link.from_node
own_socket = link.from_socket
linked_socket = link.to_socket
connected_sockets = list(tree_data.iter_connected_targets(own_socket))
else:
continue
tree_data.tree.links.remove(link)
decl = own_socket.get_decl(own_node)
decl.operator_socket_call(own_socket, linked_socket, connected_sockets)
tree_changed = True
else:
return tree_changed
# Inferencing
####################################
def do_inferencing_and_update_nodes(tree_data):
from . inferencing import get_inferencing_decisions
decisions = get_inferencing_decisions(tree_data)
nodes_to_rebuild = set()
for decision_id, value in decisions.items():
if getattr_recursive(decision_id.node, decision_id.prop_name) != value:
setattr_recursive(decision_id.node, decision_id.prop_name, value)
nodes_to_rebuild.add(decision_id.node)
rebuild_nodes_and_try_keep_state(nodes_to_rebuild)
tree_changed = len(nodes_to_rebuild) > 0
return tree_changed
# Remove Invalid Links
####################################
def remove_invalid_links(tree_data):
links_to_remove = set()
for from_socket, to_socket in tree_data.iter_connections():
if not is_link_valid(tree_data, from_socket, to_socket):
links_to_remove.update(tree_data.iter_incident_links(to_socket))
tree_changed = len(links_to_remove) > 0
tree = tree_data.tree
for link in links_to_remove:
tree.links.remove(link)
return tree_changed
def is_link_valid(tree_data, from_socket, to_socket):
from . types import type_infos
from . base import DataSocket
is_data_src = isinstance(from_socket, DataSocket)
is_data_dst = isinstance(to_socket, DataSocket)
if is_data_src != is_data_dst:
return False
if is_data_src and is_data_dst:
from_type = from_socket.data_type
to_type = to_socket.data_type
return type_infos.is_link_allowed(from_type, to_type)
return True
# Utils
######################################
def rebuild_nodes_and_try_keep_state(nodes):
for node in nodes:
node.rebuild()

View File

@@ -0,0 +1,133 @@
from collections import defaultdict
from . base import BaseNode
class TreeData:
def __init__(self, tree):
self.tree = tree
self.links_mapping = find_direct_links_mapping(tree)
self.node_by_socket = get_node_by_socket_mapping(tree)
self.connections_mapping = find_links_following_reroutes(self.links_mapping, self.node_by_socket)
self.link_by_sockets = get_link_by_sockets_mapping(tree)
def iter_nodes(self):
for node in self.tree.nodes:
if isinstance(node, BaseNode):
yield node
def iter_blinks(self):
yield from self.tree.links
def iter_connections(self):
for socket, others in self.connections_mapping.items():
if socket.is_output:
continue
for other in others:
yield other, socket
def get_node(self, socket):
return self.node_by_socket[socket]
def iter_connected_origins(self, socket):
node = self.get_node(socket)
if is_reroute(node):
socket = node.inputs[0]
for other_socket in self.links_mapping[socket]:
yield from self.iter_connected_origins(other_socket)
else:
if socket.is_output:
yield socket
else:
yield from self.iter_connected_sockets(socket)
def iter_connected_targets(self, socket):
node = self.get_node(socket)
if is_reroute(node):
socket = node.outputs[0]
for other_socket in self.links_mapping[socket]:
yield from self.iter_connected_targets(other_socket)
else:
if socket.is_output:
yield from self.iter_connected_sockets(socket)
else:
yield socket
def iter_connected_sockets(self, socket):
yield from self.connections_mapping[socket]
def iter_connected_sockets_with_nodes(self, socket):
for other_socket in self.iter_connected_sockets(socket):
other_node = self.get_node(other_socket)
yield other_node, other_socket
def try_get_origin_with_node(self, socket):
linked_sockets = self.connections_mapping[socket]
amount = len(linked_sockets)
if amount == 0:
return None, None
elif amount == 1:
origin_socket = next(iter(linked_sockets))
origin_node = self.get_node(origin_socket)
return origin_node, origin_socket
else:
assert False
def iter_incident_links(self, socket):
if socket.is_output:
for other_socket in self.links_mapping[socket]:
yield self.link_by_sockets[(socket, other_socket)]
else:
for other_socket in self.links_mapping[socket]:
yield self.link_by_sockets[(other_socket, socket)]
def find_direct_links_mapping(tree):
direct_links = defaultdict(set)
for link in tree.links:
direct_links[link.from_socket].add(link.to_socket)
direct_links[link.to_socket].add(link.from_socket)
return dict(direct_links)
def get_node_by_socket_mapping(tree):
node_by_socket = dict()
for node in tree.nodes:
for socket in node.inputs:
node_by_socket[socket] = node
for socket in node.outputs:
node_by_socket[socket] = node
return node_by_socket
def get_link_by_sockets_mapping(tree):
link_by_sockets = dict()
for link in tree.links:
link_by_sockets[(link.from_socket, link.to_socket)] = link
return link_by_sockets
def find_links_following_reroutes(direct_links, node_by_socket):
links = defaultdict(set)
for socket, direct_linked_sockets in direct_links.items():
node = node_by_socket[socket]
if socket.is_output:
# handle every link only once
continue
if is_reroute(node):
continue
for other_socket in direct_linked_sockets:
for origin_socket in iter_non_reroute_outputs(direct_links, node_by_socket, other_socket):
links[socket].add(origin_socket)
links[origin_socket].add(socket)
return links
def iter_non_reroute_outputs(direct_links, node_by_socket, socket):
assert socket.is_output
node = node_by_socket[socket]
if is_reroute(node):
input_socket = node.inputs[0]
if input_socket in direct_links:
for origin_socket in direct_links[input_socket]:
yield from iter_non_reroute_outputs(direct_links, node_by_socket, origin_socket)
else:
yield socket
def is_reroute(node):
return node.bl_idname == "NodeReroute"

View File

@@ -0,0 +1,17 @@
import bpy
from . ui import NodeSidebarPanel
from . base import BaseTree
class TreePanel(bpy.types.Panel, NodeSidebarPanel):
bl_idname = "FN_PT_tree_panel"
bl_label = "Tree"
@classmethod
def poll(self, context):
try: return isinstance(context.space_data.edit_tree, BaseTree)
except: return False
def draw(self, context):
layout = self.layout
tree = context.space_data.edit_tree

View File

@@ -0,0 +1,16 @@
from . import sockets as s
from . types_base import DataTypesInfo
type_infos = DataTypesInfo()
type_infos.insert_data_type(s.FloatSocket, s.FloatListSocket)
type_infos.insert_data_type(s.VectorSocket, s.VectorListSocket)
type_infos.insert_data_type(s.IntegerSocket, s.IntegerListSocket)
type_infos.insert_data_type(s.BooleanSocket, s.BooleanListSocket)
type_infos.insert_data_type(s.ObjectSocket, s.ObjectListSocket)
type_infos.insert_data_type(s.ImageSocket, s.ImageListSocket)
type_infos.insert_data_type(s.ColorSocket, s.ColorListSocket)
type_infos.insert_data_type(s.TextSocket, s.TextListSocket)
type_infos.insert_data_type(s.SurfaceHookSocket, s.SurfaceHookListSocket)
type_infos.insert_conversion_group(["Boolean", "Integer", "Float"])

View File

@@ -0,0 +1,164 @@
import itertools
from collections import namedtuple
'''
Type Rules
==========
A -> B means, Type A can be converted to type B implicitely.
A -!> B means, Type A cannot be converted to type B implicitely.
A_List is the type that contains a list of elements of type A
Iff T1 -> T2, then T1_List -> T2_List.
T -> T_List.
T_List -!> T.
Types always come in pairs: T and T_List.
There are no lists of lists.
A type can be in zero or one conversion group.
Every type in this group can be converted to any other implicitely.
The types within a group are ordered by their "rank".
When two types with different rank are used in one expression,
the type with lower rank is converted to the other.
'''
# Type Info Container
#####################################
ImplicitConversion = namedtuple("ImplicitConversion", ("from_type", "to_type"))
class DataTypesInfo:
def __init__(self):
self.data_types = set()
self.cls_by_data_type = dict()
self.list_by_base = dict()
self.base_by_list = dict()
self.unidirectional_conversions = set()
self.conversion_groups = dict()
self.all_implicit_conversions = set()
# Insert New Information
#############################
def insert_data_type(self, base_socket_cls, list_socket_cls):
base_type = base_socket_cls.data_type
list_type = list_socket_cls.data_type
assert base_type not in self.data_types
assert list_type not in self.data_types
self.data_types.add(base_type)
self.data_types.add(list_type)
self.list_by_base[base_type] = list_type
self.base_by_list[list_type] = base_type
self.cls_by_data_type[base_type] = base_socket_cls
self.cls_by_data_type[list_type] = list_socket_cls
self.all_implicit_conversions.add(ImplicitConversion(base_type, list_type))
def insert_conversion_group(self, types_by_rank):
'''lowest rank comes first'''
for data_type in types_by_rank:
assert self.is_data_type(data_type)
assert self.is_base(data_type)
assert data_type not in self.conversion_groups
group = tuple(types_by_rank)
for data_type in types_by_rank:
self.conversion_groups[data_type] = group
for from_base_type, to_base_type in itertools.combinations(group, 2):
from_list_type = self.to_list(from_base_type)
to_list_type = self.to_list(to_base_type)
self.all_implicit_conversions.add(ImplicitConversion(from_base_type, to_base_type))
self.all_implicit_conversions.add(ImplicitConversion(to_base_type, from_base_type))
self.all_implicit_conversions.add(ImplicitConversion(from_list_type, to_list_type))
self.all_implicit_conversions.add(ImplicitConversion(to_list_type, from_list_type))
def insert_unidirectional_conversion(self, from_type, to_type):
assert self.is_data_type(from_type)
assert self.is_data_type(to_type)
assert self.is_base(from_type)
assert self.is_base(to_type)
base_conversion = ImplicitConversion(from_type, to_type)
assert base_conversion not in self.implicit_conversions
self.implicit_conversions.add(base_conversion)
self.all_implicit_conversions.add(base_conversion)
list_conversion = ImplicitConversion(
self.to_list(from_type), self.to_list(to_type))
assert list_conversion not in self.implicit_conversions
self.implicit_conversions.add(list_conversion)
self.all_implicit_conversions.add(list_conversion)
# Query Information
##########################
def is_data_type(self, data_type):
return data_type in self.data_types
def is_base(self, data_type):
return data_type in self.list_by_base
def is_list(self, data_type):
return data_type in self.base_by_list
def to_list(self, data_type):
assert self.is_base(data_type)
return self.list_by_base[data_type]
def to_base(self, data_type):
assert self.is_list(data_type)
return self.base_by_list[data_type]
def get_data_type_items(self):
items = []
for data_type in self.data_types:
items.append((data_type, data_type, ""))
return items
def get_base_type_items(self):
items = []
for data_type in self.iter_base_types():
items.append((data_type, data_type, ""))
return items
def get_data_type_items_cb(self):
def callback(_1, _2):
return self.get_data_type_items()
return callback
def get_socket_color(self, data_type):
builder = self.to_builder(data_type)
return builder.get_color()
def is_link_allowed(self, from_type, to_type):
assert self.is_data_type(from_type)
assert self.is_data_type(to_type)
if from_type == to_type:
return True
else:
return self.is_implicitly_convertable(from_type, to_type)
def is_implicitly_convertable(self, from_type, to_type):
return ImplicitConversion(from_type, to_type) in self.all_implicit_conversions
def iter_list_types(self):
yield from self.base_by_list.keys()
def iter_base_types(self):
yield from self.list_by_base.keys()
# Build
##########################
def build(self, data_type, node_sockets, name, identifier):
idname = self.cls_by_data_type[data_type].bl_idname
socket = node_sockets.new(idname, name, identifier=identifier)
return socket

View File

@@ -0,0 +1,6 @@
import bpy
class NodeSidebarPanel:
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'UI'
bl_category = "Node"

View File

@@ -0,0 +1,20 @@
import functools
from collections import defaultdict
cached_item_tuples_by_hash = defaultdict(list)
def cache_enum_items(items_cb):
@functools.wraps(items_cb)
def wrapper(self, context):
item_tuples = tuple(items_cb(self, context))
item_tuples_hash = hash(item_tuples)
for cached_item_tuple in cached_item_tuples_by_hash[item_tuples_hash]:
if cached_item_tuple == item_tuples:
return cached_item_tuple
else:
cached_item_tuples_by_hash[item_tuples_hash].append(item_tuples)
return item_tuples
return wrapper

View File

@@ -0,0 +1,21 @@
import string
import random
def iter_subclasses_recursive(cls):
for sub in cls.__subclasses__():
yield sub
yield from iter_subclasses_recursive(sub)
def getattr_recursive(obj, name: str):
if "." not in name and "[" not in name:
return getattr(obj, name)
else:
# TODO: implement without eval
return eval("obj." + name, globals(), locals())
def setattr_recursive(obj, name: str, value):
if "." not in name and "[" not in name:
setattr(obj, name, value)
else:
# TODO: implement without exec
exec("obj." + name + " = value", globals(), locals())

View File

@@ -0,0 +1,19 @@
def iter_connected_components(nodes: set, links: dict):
nodes = set(nodes)
while len(nodes) > 0:
start_node = next(iter(nodes))
component = depth_first_search(start_node, links)
yield component
nodes -= component
def depth_first_search(start_node, links):
result = set()
found = set()
found.add(start_node)
while len(found) > 0:
node = found.pop()
result.add(node)
for linked_node in links[node]:
if linked_node not in result:
found.add(linked_node)
return result

View File

@@ -0,0 +1,38 @@
class PieMenuHelper:
def draw(self, context):
pie = self.layout.menu_pie()
self.draw_left(pie)
self.draw_right(pie)
self.draw_bottom(pie)
self.draw_top(pie)
self.draw_top_left(pie)
self.draw_top_right(pie)
self.draw_bottom_left(pie)
self.draw_bottom_right(pie)
def draw_left(self, layout):
self.empty(layout)
def draw_right(self, layout):
self.empty(layout)
def draw_bottom(self, layout):
self.empty(layout)
def draw_top(self, layout):
self.empty(layout)
def draw_top_left(self, layout):
self.empty(layout)
def draw_top_right(self, layout):
self.empty(layout)
def draw_bottom_left(self, layout):
self.empty(layout)
def draw_bottom_right(self, layout):
self.empty(layout)
def empty(self, layout, text=""):
layout.row().label(text=text)

View File

@@ -113,6 +113,8 @@ add_subdirectory(nodes)
add_subdirectory(modifiers)
add_subdirectory(gpencil_modifiers)
add_subdirectory(shader_fx)
add_subdirectory(functions)
add_subdirectory(simulations)
add_subdirectory(io)
add_subdirectory(makesdna)
add_subdirectory(makesrna)

View File

@@ -257,6 +257,8 @@ struct FCurve *iter_step_fcurve(struct FCurve *fcu_iter, const char rna_path[]);
struct FCurve *id_data_find_fcurve(
ID *id, void *data, struct StructRNA *type, const char *prop_name, int index, bool *r_driven);
void *get_driver_variable_function(struct DriverVar *dvar);
/* Get list of LinkData's containing pointers to the F-Curves which control the types of data
* indicated
* e.g. numMatches = list_find_data_fcurves(matches, &act->curves, "pose.bones[", "MyFancyBone");

View File

@@ -0,0 +1,34 @@
#ifndef __BKE_ID_DATA_CACHE_H__
#define __BKE_ID_DATA_CACHE_H__
#include <mutex>
#include "BLI_kdopbvh.h"
#include "BLI_kdtree.h"
#include "BLI_map.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "BKE_bvhutils.h"
namespace BKE {
using BLI::Map;
class IDDataCache {
private:
mutable Map<Object *, BVHTreeFromMesh *> m_bvh_trees;
mutable std::mutex m_bvt_trees_mutex;
public:
IDDataCache() = default;
~IDDataCache();
BVHTreeFromMesh *get_bvh_tree(Object *object) const;
};
} // namespace BKE
#endif /* __BKE_ID_DATA_CACHE_H__ */

View File

@@ -0,0 +1,108 @@
#ifndef __BKE_ID_HANDLE_H__
#define __BKE_ID_HANDLE_H__
#include "BLI_utildefines.h"
#include "BLI_map.h"
extern "C" {
struct ID;
struct Object;
struct Image;
}
namespace BKE {
using BLI::Map;
/**
* This is a weak reference to an ID data-block. It does not contain a pointer to the actual data.
* It can happen that the IDHandle references data, that does not exist anymore. The handle does
* not know that.
*/
class IDHandle {
private:
uint32_t m_identifier;
public:
IDHandle() : m_identifier((uint32_t)-1)
{
}
IDHandle(struct ID *id);
friend bool operator==(IDHandle a, IDHandle b)
{
return a.m_identifier == b.m_identifier;
}
friend bool operator!=(IDHandle a, IDHandle b)
{
return !(a == b);
}
uint32_t internal_identifier() const
{
return m_identifier;
}
};
class ObjectIDHandle : public IDHandle {
public:
ObjectIDHandle() : IDHandle()
{
}
ObjectIDHandle(struct Object *object);
};
class ImageIDHandle : public IDHandle {
public:
ImageIDHandle() : IDHandle()
{
}
ImageIDHandle(struct Image *image);
};
class IDHandleLookup {
private:
Map<IDHandle, ID *> m_handle_to_id_map;
public:
void add(ID &id)
{
IDHandle handle(&id);
m_handle_to_id_map.add(handle, &id);
}
ID *lookup(IDHandle handle) const
{
return m_handle_to_id_map.lookup_default(handle, nullptr);
}
struct Object *lookup(ObjectIDHandle handle) const
{
return reinterpret_cast<struct Object *>(this->lookup((IDHandle)handle));
}
struct Image *lookup(ImageIDHandle handle) const
{
return reinterpret_cast<struct Image *>(this->lookup((IDHandle)handle));
}
static const IDHandleLookup &Empty();
};
} // namespace BKE
namespace BLI {
template<> struct DefaultHash<BKE::IDHandle> {
uint32_t operator()(const BKE::IDHandle &value) const
{
return value.internal_identifier();
}
};
} // namespace BLI
#endif /* __BKE_ID_HANDLE_H__ */

View File

@@ -145,6 +145,7 @@ typedef struct bNodeSocketType {
/* for standard socket types in C */
int type, subtype;
int display_shape_default;
/* When set, bNodeSocket->limit does not have any effect anymore. */
bool use_link_limits_of_type;
@@ -999,6 +1000,39 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree,
#define SH_NODE_OUTPUT_AOV 707
#define SH_NODE_VECTOR_ROTATE 708
#define SIM_NODE_PARTICLE_SIMULATION 1000
#define SIM_NODE_FORCE 1001
#define SIM_NODE_SET_PARTICLE_ATTRIBUTE 1002
#define SIM_NODE_PARTICLE_BIRTH_EVENT 1003
#define SIM_NODE_PARTICLE_TIME_STEP_EVENT 1004
#define SIM_NODE_EXECUTE_CONDITION 1005
#define SIM_NODE_MULTI_EXECUTE 1006
#define SIM_NODE_PARTICLE_MESH_EMITTER 1007
#define SIM_NODE_PARTICLE_MESH_COLLISION_EVENT 1008
#define SIM_NODE_EMIT_PARTICLES 1009
#define SIM_NODE_SIMULATION_TIME 1010
#define SIM_NODE_PARTICLE_ATTRIBUTE 1011
#define FN_NODE_COMBINE_XYZ 1100
#define FN_NODE_SEPARATE_XYZ 1101
#define FN_NODE_COMBINE_RGB 1102
#define FN_NODE_SEPARATE_RGB 1103
#define FN_NODE_COMBINE_HSV 1104
#define FN_NODE_SEPARATE_HSV 1105
#define FN_NODE_FLOAT_MATH 1106
#define FN_NODE_VECTOR_MATH 1107
#define FN_NODE_SURFACE_COLOR 1108
#define FN_NODE_SURFACE_NORMAL 1109
#define FN_NODE_SURFACE_POSITION 1110
#define FN_NODE_SURFACE_WEIGHT 1111
#define FN_NODE_CLOSEST_SURFACE 1112
#define FN_NODE_BOOLEAN_MATH 1113
#define FN_NODE_FLOAT_COMPARE 1114
#define FN_NODE_INSTANCE_IDENTIFIER 1115
#define FN_NODE_STRING_CONCATENATION 1116
#define FN_NODE_OBJECT_TRANSFORMS 1117
#define FN_NODE_SWITCH 1118
/* custom defines options for Material node */
// #define SH_NODE_MAT_DIFF 1
// #define SH_NODE_MAT_SPEC 2

View File

@@ -0,0 +1,97 @@
#ifndef __BKE_SURFACE_HOOK_H__
#define __BKE_SURFACE_HOOK_H__
#include "BLI_float3.h"
#include "BLI_utildefines.h"
#include "BKE_id_handle.h"
namespace BKE {
using BLI::float3;
namespace SurfaceHookType {
enum Enum {
None,
MeshObject,
};
}
/**
* References a point on a surface. If the surface moves, the point moves with it.
*/
class SurfaceHook {
private:
SurfaceHookType::Enum m_type;
/**
* Used to identify the object if m_type is MeshObject.
*/
ObjectIDHandle m_object_handle;
/* Index of the triangle that contains the referenced location. */
uint32_t m_triangle_index;
/* Barycentric coordinates of the referenced location inside the triangle. */
float3 m_bary_coords;
public:
SurfaceHook() : m_type(SurfaceHookType::None)
{
}
SurfaceHook(ObjectIDHandle object_handle, uint32_t triangle_index, float3 bary_coords)
: m_type(SurfaceHookType::MeshObject),
m_object_handle(object_handle),
m_triangle_index(triangle_index),
m_bary_coords(bary_coords)
{
}
SurfaceHookType::Enum type() const
{
return m_type;
}
bool is_valid() const
{
return m_type != SurfaceHookType::None;
}
ObjectIDHandle object_handle() const
{
BLI_assert(m_type == SurfaceHookType::MeshObject);
return m_object_handle;
}
uint32_t triangle_index() const
{
BLI_assert(m_type == SurfaceHookType::MeshObject);
return m_triangle_index;
}
float3 bary_coords() const
{
BLI_assert(m_type == SurfaceHookType::MeshObject);
return m_bary_coords;
}
static bool on_same_surface(const SurfaceHook &a, const SurfaceHook &b)
{
if (a.type() != b.type()) {
return false;
}
switch (a.type()) {
case BKE::SurfaceHookType::None:
return true;
case BKE::SurfaceHookType::MeshObject:
return a.object_handle() == b.object_handle();
}
BLI_assert(false);
return false;
}
};
} // namespace BKE
#endif /* __BKE_SURFACE_HOOK_H__ */

View File

@@ -0,0 +1,367 @@
#ifndef __BKE_VIRTUAL_NODE_TREE_H__
#define __BKE_VIRTUAL_NODE_TREE_H__
#include "BLI_array_cxx.h"
#include "BLI_linear_allocated_vector.h"
#include "BLI_resource_collector.h"
#include "BLI_string_map.h"
#include "BLI_string_multi_map.h"
#include "BLI_string_ref.h"
#include "BLI_utility_mixins.h"
#include "BLI_vector.h"
#include "DNA_node_types.h"
#include "RNA_access.h"
namespace BKE {
using BLI::Array;
using BLI::ArrayRef;
using BLI::LinearAllocatedVector;
using BLI::ResourceCollector;
using BLI::StringMap;
using BLI::StringMultiMap;
using BLI::StringRef;
using BLI::StringRefNull;
using BLI::Vector;
class VSocket;
class VInputSocket;
class VOutputSocket;
class VNode;
class VirtualNodeTree;
/* Virtual Node Tree declarations
******************************************/
class VSocket : BLI::NonCopyable, BLI::NonMovable {
protected:
LinearAllocatedVector<VSocket *> m_linked_sockets;
LinearAllocatedVector<VSocket *> m_directly_linked_sockets;
VNode *m_node;
bool m_is_input;
bNodeSocket *m_bsocket;
uint m_id;
PointerRNA m_rna;
uint m_index;
friend VirtualNodeTree;
public:
ArrayRef<const VSocket *> linked_sockets() const;
ArrayRef<const VSocket *> directly_linked_sockets() const;
const VNode &node() const;
const VirtualNodeTree &tree() const;
uint id() const;
uint index() const;
bool is_input() const;
bool is_output() const;
const VSocket &as_base() const;
const VInputSocket &as_input() const;
const VOutputSocket &as_output() const;
PointerRNA *rna() const;
StringRefNull idname() const;
StringRefNull name() const;
bool is_linked() const;
bNodeSocket *bsocket() const;
bNodeTree *btree() const;
};
class VInputSocket final : public VSocket {
public:
ArrayRef<const VOutputSocket *> linked_sockets() const;
ArrayRef<const VOutputSocket *> directly_linked_sockets() const;
};
class VOutputSocket final : public VSocket {
public:
ArrayRef<const VInputSocket *> linked_sockets() const;
ArrayRef<const VInputSocket *> directly_linked_sockets() const;
};
class VNode : BLI::NonCopyable, BLI::NonMovable {
private:
VirtualNodeTree *m_vtree;
LinearAllocatedVector<VInputSocket *> m_inputs;
LinearAllocatedVector<VOutputSocket *> m_outputs;
bNode *m_bnode;
uint m_id;
PointerRNA m_rna;
friend VirtualNodeTree;
public:
const VirtualNodeTree &tree() const;
ArrayRef<const VInputSocket *> inputs() const;
ArrayRef<const VOutputSocket *> outputs() const;
PointerRNA *rna() const;
StringRefNull idname() const;
StringRefNull name() const;
const VInputSocket &input(uint index) const;
const VOutputSocket &output(uint index) const;
const VInputSocket &input(uint index, StringRef expected_name) const;
const VOutputSocket &output(uint index, StringRef expected_name) const;
bNode *bnode() const;
bNodeTree *btree() const;
uint id() const;
};
class VirtualNodeTree : BLI::NonCopyable, BLI::NonMovable {
private:
BLI::LinearAllocator<> m_allocator;
bNodeTree *m_btree;
Vector<VNode *> m_nodes_by_id;
Vector<VSocket *> m_sockets_by_id;
Vector<VInputSocket *> m_input_sockets;
Vector<VOutputSocket *> m_output_sockets;
StringMultiMap<VNode *> m_nodes_by_idname;
public:
VirtualNodeTree(bNodeTree *btree);
~VirtualNodeTree();
ArrayRef<const VNode *> nodes() const;
ArrayRef<const VNode *> nodes_with_idname(StringRef idname) const;
uint socket_count() const;
ArrayRef<const VSocket *> all_sockets() const;
ArrayRef<const VInputSocket *> all_input_sockets() const;
ArrayRef<const VOutputSocket *> all_output_sockets() const;
const VSocket &socket_by_id(uint id) const;
bNodeTree *btree() const;
private:
void find_targets_skipping_reroutes(VOutputSocket &vsocket,
LinearAllocatedVector<VSocket *> &r_targets);
};
/* Virtual Node Tree inline functions
****************************************************/
inline ArrayRef<const VSocket *> VSocket::linked_sockets() const
{
return m_linked_sockets.as_ref();
}
inline ArrayRef<const VSocket *> VSocket::directly_linked_sockets() const
{
return m_directly_linked_sockets.as_ref();
}
inline const VirtualNodeTree &VSocket::tree() const
{
return m_node->tree();
}
inline const VNode &VSocket::node() const
{
return *m_node;
}
inline uint VSocket::id() const
{
return m_id;
}
inline uint VSocket::index() const
{
return m_index;
}
inline bool VSocket::is_input() const
{
return m_is_input;
}
inline bool VSocket::is_output() const
{
return !m_is_input;
}
inline bool VSocket::is_linked() const
{
return m_linked_sockets.size() > 0;
}
inline const VSocket &VSocket::as_base() const
{
return *this;
}
inline const VInputSocket &VSocket::as_input() const
{
BLI_assert(this->is_input());
return *(const VInputSocket *)this;
}
inline const VOutputSocket &VSocket::as_output() const
{
BLI_assert(this->is_output());
return *(const VOutputSocket *)this;
}
inline PointerRNA *VSocket::rna() const
{
return const_cast<PointerRNA *>(&m_rna);
}
inline StringRefNull VSocket::idname() const
{
return m_bsocket->idname;
}
inline StringRefNull VSocket::name() const
{
return m_bsocket->name;
}
inline bNodeSocket *VSocket::bsocket() const
{
return m_bsocket;
}
inline ArrayRef<const VOutputSocket *> VInputSocket::linked_sockets() const
{
return m_linked_sockets.as_ref().cast<const VOutputSocket *>();
;
}
inline ArrayRef<const VOutputSocket *> VInputSocket::directly_linked_sockets() const
{
return m_directly_linked_sockets.as_ref().cast<const VOutputSocket *>();
}
inline ArrayRef<const VInputSocket *> VOutputSocket::linked_sockets() const
{
return m_linked_sockets.as_ref().cast<const VInputSocket *>();
}
inline ArrayRef<const VInputSocket *> VOutputSocket::directly_linked_sockets() const
{
return m_directly_linked_sockets.as_ref().cast<const VInputSocket *>();
}
inline ArrayRef<const VInputSocket *> VNode::inputs() const
{
return m_inputs.as_ref();
}
inline ArrayRef<const VOutputSocket *> VNode::outputs() const
{
return m_outputs.as_ref();
}
inline const VirtualNodeTree &VNode::tree() const
{
return *m_vtree;
}
inline PointerRNA *VNode::rna() const
{
return const_cast<PointerRNA *>(&m_rna);
}
inline StringRefNull VNode::idname() const
{
return m_bnode->idname;
}
inline StringRefNull VNode::name() const
{
return m_bnode->name;
}
inline const VInputSocket &VNode::input(uint index) const
{
return *m_inputs[index];
}
inline const VOutputSocket &VNode::output(uint index) const
{
return *m_outputs[index];
}
inline const VInputSocket &VNode::input(uint index, StringRef expected_name) const
{
BLI_assert(m_inputs[index]->name() == expected_name);
UNUSED_VARS_NDEBUG(expected_name);
return *m_inputs[index];
}
inline const VOutputSocket &VNode::output(uint index, StringRef expected_name) const
{
BLI_assert(m_outputs[index]->name() == expected_name);
UNUSED_VARS_NDEBUG(expected_name);
return *m_outputs[index];
}
inline bNode *VNode::bnode() const
{
return m_bnode;
}
inline uint VNode::id() const
{
return m_id;
}
inline bNodeTree *VirtualNodeTree::btree() const
{
return m_btree;
}
inline ArrayRef<const VNode *> VirtualNodeTree::nodes() const
{
return m_nodes_by_id.as_ref();
}
inline ArrayRef<const VNode *> VirtualNodeTree::nodes_with_idname(StringRef idname) const
{
return m_nodes_by_idname.lookup_default(idname);
}
inline uint VirtualNodeTree::socket_count() const
{
return m_sockets_by_id.size();
}
inline ArrayRef<const VSocket *> VirtualNodeTree::all_sockets() const
{
return m_sockets_by_id.as_ref();
}
inline ArrayRef<const VInputSocket *> VirtualNodeTree::all_input_sockets() const
{
return m_input_sockets.as_ref();
}
inline ArrayRef<const VOutputSocket *> VirtualNodeTree::all_output_sockets() const
{
return m_output_sockets.as_ref();
}
inline const VSocket &VirtualNodeTree::socket_by_id(uint id) const
{
return *m_sockets_by_id[id];
}
} // namespace BKE
#endif /* __BKE_VIRTUAL_NODE_TREE_H__ */

View File

@@ -37,6 +37,7 @@ set(INC
../nodes
../physics
../shader_fx
../simulations
../render/extern/include
../../../intern/ghost
../../../intern/glew-mx
@@ -128,6 +129,8 @@ set(SRC
intern/icons_rasterize.c
intern/idprop.c
intern/idprop_utils.c
intern/id_data_cache.cc
intern/id_handle.cc
intern/idtype.c
intern/image.c
intern/image_gen.c
@@ -230,6 +233,7 @@ set(SRC
intern/subdiv_stats.c
intern/subdiv_topology.c
intern/subsurf_ccg.c
intern/surface_hook.cc
intern/text.c
intern/text_suggestions.c
intern/texture.c
@@ -243,6 +247,7 @@ set(SRC
intern/tracking_util.c
intern/undo_system.c
intern/unit.c
intern/virtual_node_tree.cc
intern/volume.cc
intern/volume_render.cc
intern/workspace.c
@@ -309,6 +314,8 @@ set(SRC
BKE_hair.h
BKE_icons.h
BKE_idprop.h
BKE_id_data_cache.h
BKE_id_handle.h
BKE_idtype.h
BKE_image.h
BKE_ipo.h
@@ -374,12 +381,14 @@ set(SRC
BKE_subdiv_mesh.h
BKE_subdiv_topology.h
BKE_subsurf.h
BKE_surface_hook.h
BKE_text.h
BKE_text_suggestions.h
BKE_texture.h
BKE_tracking.h
BKE_undo_system.h
BKE_unit.h
BKE_virtual_node_tree.h
BKE_volume.h
BKE_volume_render.h
BKE_workspace.h

View File

@@ -1871,15 +1871,15 @@ static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = {
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_ROT_DIFF) dvar_eval_rotDiff, /* eval callback */
2, /* number of targets used */
{"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */
{DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY,
DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */
{DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY}
/* flags */
END_DVAR_TYPEDEF,
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_LOC_DIFF) dvar_eval_locDiff, /* eval callback */
2, /* number of targets used */
{"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */
{DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY,
DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */
{DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY}
/* flags */
END_DVAR_TYPEDEF,
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_TRANSFORM_CHAN) dvar_eval_transChan, /* eval callback */
@@ -1983,6 +1983,10 @@ void driver_change_variable_type(DriverVar *dvar, int type)
if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0)) {
dtar->idtype = ID_OB;
}
if (type == DVAR_TYPE_FUNCTION) {
dtar->idtype = ID_NT;
}
}
DRIVER_TARGETS_LOOPER_END;
}

View File

@@ -0,0 +1,31 @@
#include "BKE_id_data_cache.h"
namespace BKE {
IDDataCache::~IDDataCache()
{
for (auto bvhtree : m_bvh_trees.values()) {
if (bvhtree != nullptr) {
free_bvhtree_from_mesh(bvhtree);
delete bvhtree;
}
}
}
BVHTreeFromMesh *IDDataCache::get_bvh_tree(Object *object) const
{
BLI_assert(object != nullptr);
std::lock_guard<std::mutex> lock(m_bvt_trees_mutex);
return m_bvh_trees.lookup_or_add(object, [&]() -> BVHTreeFromMesh * {
if (object->type != OB_MESH) {
return nullptr;
}
BVHTreeFromMesh *bvhtree_data = new BVHTreeFromMesh();
BKE_bvhtree_from_mesh_get(bvhtree_data, (Mesh *)object->data, BVHTREE_FROM_LOOPTRI, 2);
return bvhtree_data;
});
}
} // namespace BKE

View File

@@ -0,0 +1,33 @@
#include "BLI_hash.h"
#include "BLI_utildefines.h"
#include "BKE_id_handle.h"
#include "DNA_ID.h"
#include "DNA_image_types.h"
#include "DNA_object_types.h"
namespace BKE {
IDHandle::IDHandle(ID *id)
{
BLI_assert(id != nullptr);
m_identifier = BLI_hash_string(id->name);
}
ObjectIDHandle::ObjectIDHandle(Object *object) : IDHandle(&object->id)
{
}
ImageIDHandle::ImageIDHandle(Image *image) : IDHandle(&image->id)
{
}
static IDHandleLookup empty_id_handle_lookup;
const IDHandleLookup &IDHandleLookup::Empty()
{
return empty_id_handle_lookup;
}
} // namespace BKE

View File

@@ -204,6 +204,21 @@ static void library_foreach_idproperty_ID_link(LibraryForeachIDData *data,
FOREACH_FINALIZE_VOID;
}
static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket *sock)
{
library_foreach_idproperty_ID_link(data, sock->prop, IDWALK_CB_USER);
if (sock->type == SOCK_OBJECT) {
bNodeSocketValueObject *default_value = sock->default_value;
FOREACH_CALLBACK_INVOKE_ID_PP(data, (ID **)&default_value->object, IDWALK_CB_USER);
}
else if (sock->type == SOCK_IMAGE) {
bNodeSocketValueImage *default_value = sock->default_value;
FOREACH_CALLBACK_INVOKE_ID_PP(data, (ID **)&default_value->image, IDWALK_CB_USER);
}
FOREACH_FINALIZE_VOID;
}
static void library_foreach_rigidbodyworldSceneLooper(struct RigidBodyWorld *UNUSED(rbw),
ID **id_pointer,
void *user_data,
@@ -1025,18 +1040,18 @@ static void library_foreach_ID_link(Main *bmain,
library_foreach_idproperty_ID_link(&data, node->prop, IDWALK_CB_USER);
for (sock = node->inputs.first; sock; sock = sock->next) {
library_foreach_idproperty_ID_link(&data, sock->prop, IDWALK_CB_USER);
library_foreach_node_socket(&data, sock);
}
for (sock = node->outputs.first; sock; sock = sock->next) {
library_foreach_idproperty_ID_link(&data, sock->prop, IDWALK_CB_USER);
library_foreach_node_socket(&data, sock);
}
}
for (sock = ntree->inputs.first; sock; sock = sock->next) {
library_foreach_idproperty_ID_link(&data, sock->prop, IDWALK_CB_USER);
library_foreach_node_socket(&data, sock);
}
for (sock = ntree->outputs.first; sock; sock = sock->next) {
library_foreach_idproperty_ID_link(&data, sock->prop, IDWALK_CB_USER);
library_foreach_node_socket(&data, sock);
}
break;
}

View File

@@ -66,7 +66,9 @@
#include "NOD_common.h"
#include "NOD_composite.h"
#include "NOD_function.h"
#include "NOD_shader.h"
#include "NOD_simulation.h"
#include "NOD_socket.h"
#include "NOD_texture.h"
@@ -400,6 +402,9 @@ static void node_socket_set_typeinfo(bNodeTree *ntree,
/* deprecated integer type */
sock->type = typeinfo->type;
sock->display_shape = typeinfo->display_shape_default;
sock->limit = (sock->in_out == SOCK_IN) ? typeinfo->input_link_limit :
typeinfo->output_link_limit;
if (sock->default_value == NULL) {
/* initialize the default_value pointer used by standard socket types */
@@ -755,6 +760,14 @@ void nodeModifySocketType(
}
if (sock->default_value) {
if (sock->type == SOCK_OBJECT) {
bNodeSocketValueObject *default_value = sock->default_value;
id_us_min(&default_value->object->id);
}
else if (sock->type == SOCK_IMAGE) {
bNodeSocketValueImage *default_value = sock->default_value;
id_us_min(&default_value->image->id);
}
MEM_freeN(sock->default_value);
sock->default_value = NULL;
}
@@ -858,6 +871,20 @@ const char *nodeStaticSocketType(int type, int subtype)
return "NodeSocketString";
case SOCK_SHADER:
return "NodeSocketShader";
case SOCK_EMITTERS:
return "NodeSocketEmitters";
case SOCK_EVENTS:
return "NodeSocketEvents";
case SOCK_FORCES:
return "NodeSocketForces";
case SOCK_CONTROL_FLOW:
return "NodeSocketControlFlow";
case SOCK_OBJECT:
return "NodeSocketObject";
case SOCK_IMAGE:
return "NodeSocketImage";
case SOCK_SURFACE_HOOK:
return "NodeSocketSurfaceHook";
}
return NULL;
}
@@ -919,6 +946,20 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype)
return "NodeSocketInterfaceString";
case SOCK_SHADER:
return "NodeSocketInterfaceShader";
case SOCK_EMITTERS:
return "NodeSocketInterfaceEmitters";
case SOCK_EVENTS:
return "NodeSocketInterfaceEvents";
case SOCK_FORCES:
return "NodeSocketInterfaceForces";
case SOCK_CONTROL_FLOW:
return "NodeSocketInterfaceControlFlow";
case SOCK_OBJECT:
return "NodeSocketInterfaceObject";
case SOCK_IMAGE:
return "NodeSocketInterfaceImage";
case SOCK_SURFACE_HOOK:
return "NodeSocketInterfaceSurfaceHook";
}
return NULL;
}
@@ -977,6 +1018,16 @@ static void node_socket_free(bNodeTree *UNUSED(ntree),
}
if (sock->default_value) {
if (do_id_user) {
if (sock->type == SOCK_OBJECT) {
bNodeSocketValueObject *default_value = sock->default_value;
id_us_min(&default_value->object->id);
}
else if (sock->type == SOCK_IMAGE) {
bNodeSocketValueImage *default_value = sock->default_value;
id_us_min(&default_value->image->id);
}
}
MEM_freeN(sock->default_value);
}
}
@@ -1263,6 +1314,17 @@ static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src,
if (sock_src->default_value) {
sock_dst->default_value = MEM_dupallocN(sock_src->default_value);
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
if (sock_dst->type == SOCK_OBJECT) {
bNodeSocketValueObject *default_value = sock_dst->default_value;
id_us_plus(&default_value->object->id);
}
else if (sock_dst->type == SOCK_IMAGE) {
bNodeSocketValueImage *default_value = sock_dst->default_value;
id_us_plus(&default_value->image->id);
}
}
}
sock_dst->stack_index = 0;
@@ -2083,6 +2145,27 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
if (node->id) {
id_us_min(node->id);
}
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (sock->type == SOCK_OBJECT) {
bNodeSocketValueObject *default_value = sock->default_value;
id_us_min(&default_value->object->id);
}
else if (sock->type == SOCK_IMAGE) {
bNodeSocketValueImage *default_value = sock->default_value;
id_us_min(&default_value->image->id);
}
}
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (sock->type == SOCK_OBJECT) {
bNodeSocketValueObject *default_value = sock->default_value;
id_us_min(&default_value->object->id);
}
else if (sock->type == SOCK_IMAGE) {
bNodeSocketValueImage *default_value = sock->default_value;
id_us_min(&default_value->image->id);
}
}
}
/* Remove animation data. */
@@ -2109,6 +2192,15 @@ static void node_socket_interface_free(bNodeTree *UNUSED(ntree), bNodeSocket *so
}
if (sock->default_value) {
if (sock->type == SOCK_OBJECT) {
bNodeSocketValueObject *default_value = sock->default_value;
id_us_min(&default_value->object->id);
}
else if (sock->type == SOCK_IMAGE) {
bNodeSocketValueImage *default_value = sock->default_value;
id_us_min(&default_value->image->id);
}
MEM_freeN(sock->default_value);
}
}
@@ -4114,6 +4206,47 @@ static void registerTextureNodes(void)
register_node_type_tex_proc_distnoise();
}
static void registerSimulationNodes(void)
{
register_node_type_sim_group();
register_node_type_sim_particle_simulation();
register_node_type_sim_force();
register_node_type_sim_set_particle_attribute();
register_node_type_sim_particle_birth_event();
register_node_type_sim_particle_time_step_event();
register_node_type_sim_execute_condition();
register_node_type_sim_multi_execute();
register_node_type_sim_particle_mesh_emitter();
register_node_type_sim_particle_mesh_collision_event();
register_node_type_sim_emit_particles();
register_node_type_sim_simulation_time();
register_node_type_sim_particle_attribute();
}
static void registerFunctionNodes(void)
{
register_node_type_fn_combine_xyz();
register_node_type_fn_separate_xyz();
register_node_type_fn_combine_rgb();
register_node_type_fn_separate_rgb();
register_node_type_fn_combine_hsv();
register_node_type_fn_separate_hsv();
register_node_type_fn_float_math();
register_node_type_fn_vector_math();
register_node_type_fn_closest_surface();
register_node_type_fn_surface_color();
register_node_type_fn_surface_normal();
register_node_type_fn_surface_position();
register_node_type_fn_surface_weight();
register_node_type_fn_boolean_math();
register_node_type_fn_float_compare();
register_node_type_fn_instance_identifier();
register_node_type_fn_string_concatenation();
register_node_type_fn_object_transforms();
register_node_type_fn_switch();
}
void init_nodesystem(void)
{
nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh");
@@ -4127,6 +4260,7 @@ void init_nodesystem(void)
register_node_tree_type_cmp();
register_node_tree_type_sh();
register_node_tree_type_tex();
register_node_tree_type_sim();
register_node_type_frame();
register_node_type_reroute();
@@ -4136,6 +4270,8 @@ void init_nodesystem(void)
registerCompositNodes();
registerShaderNodes();
registerTextureNodes();
registerSimulationNodes();
registerFunctionNodes();
}
void free_nodesystem(void)

View File

@@ -721,7 +721,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
/*
* Shrinkwrap Target Surface Project mode
*
* It uses Newton's method to find a surface location with its
* It uses Newton's method to find a Surface Hook with its
* smooth normal pointing at the original point.
*
* The equation system on barycentric weights and normal multiplier:

View File

@@ -0,0 +1,7 @@
#include "BKE_surface_hook.h"
#include "BLI_hash.h"
namespace BKE {
} // namespace BKE

View File

@@ -0,0 +1,115 @@
#include "BKE_virtual_node_tree.h"
#include "BLI_listbase_wrapper.h"
#include "BLI_map.h"
namespace BKE {
using BLI::Map;
using BSocketList = BLI::IntrusiveListBaseWrapper<bNodeSocket>;
using BNodeList = BLI::IntrusiveListBaseWrapper<bNode>;
using BLinkList = BLI::IntrusiveListBaseWrapper<bNodeLink>;
static bool is_reroute_node(const VNode &vnode)
{
return vnode.idname() == "NodeReroute";
}
VirtualNodeTree::VirtualNodeTree(bNodeTree *btree) : m_btree(btree)
{
BLI_assert(btree != nullptr);
VirtualNodeTree &vtree = *this;
Map<bNode *, VNode *> node_mapping;
for (bNode *bnode : BNodeList(btree->nodes)) {
VNode &vnode = *vtree.m_allocator.construct<VNode>();
vnode.m_vtree = &vtree;
vnode.m_bnode = bnode;
vnode.m_id = vtree.m_nodes_by_id.append_and_get_index(&vnode);
RNA_pointer_create(&btree->id, &RNA_Node, bnode, &vnode.m_rna);
for (bNodeSocket *bsocket : BSocketList(bnode->inputs)) {
VInputSocket &vsocket = *vtree.m_allocator.construct<VInputSocket>();
vsocket.m_node = &vnode;
vsocket.m_index = vnode.m_inputs.append_and_get_index(&vsocket, m_allocator);
vsocket.m_is_input = true;
vsocket.m_bsocket = bsocket;
vsocket.m_id = vtree.m_sockets_by_id.append_and_get_index(&vsocket);
RNA_pointer_create(&btree->id, &RNA_NodeSocket, bsocket, &vsocket.m_rna);
vtree.m_input_sockets.append(&vsocket);
}
for (bNodeSocket *bsocket : BSocketList(bnode->outputs)) {
VOutputSocket &vsocket = *vtree.m_allocator.construct<VOutputSocket>();
vsocket.m_node = &vnode;
vsocket.m_index = vnode.m_outputs.append_and_get_index(&vsocket, m_allocator);
vsocket.m_is_input = false;
vsocket.m_bsocket = bsocket;
vsocket.m_id = vtree.m_sockets_by_id.append_and_get_index(&vsocket);
RNA_pointer_create(&btree->id, &RNA_NodeSocket, bsocket, &vsocket.m_rna);
vtree.m_output_sockets.append(&vsocket);
}
node_mapping.add_new(bnode, &vnode);
}
for (bNodeLink *blink : BLinkList(btree->links)) {
VOutputSocket &from_vsocket =
*node_mapping.lookup(blink->fromnode)
->m_outputs[BSocketList(blink->fromnode->outputs).index_of(blink->fromsock)];
VInputSocket &to_vsocket =
*node_mapping.lookup(blink->tonode)
->m_inputs[BSocketList(blink->tonode->inputs).index_of(blink->tosock)];
from_vsocket.m_directly_linked_sockets.append(&to_vsocket, m_allocator);
to_vsocket.m_directly_linked_sockets.append(&from_vsocket, m_allocator);
}
for (VOutputSocket *socket : vtree.m_output_sockets) {
if (!is_reroute_node(socket->node())) {
vtree.find_targets_skipping_reroutes(*socket, socket->m_linked_sockets);
for (VSocket *target : socket->m_linked_sockets) {
target->m_linked_sockets.append(socket, m_allocator);
}
}
}
for (VNode *vnode : vtree.m_nodes_by_id) {
vtree.m_nodes_by_idname.add(vnode->idname(), vnode);
}
}
void VirtualNodeTree::find_targets_skipping_reroutes(VOutputSocket &vsocket,
LinearAllocatedVector<VSocket *> &r_targets)
{
for (VSocket *direct_target : vsocket.m_directly_linked_sockets) {
if (is_reroute_node(*direct_target->m_node)) {
this->find_targets_skipping_reroutes(*direct_target->m_node->m_outputs[0], r_targets);
}
else if (!r_targets.contains(direct_target)) {
r_targets.append(direct_target, m_allocator);
}
}
}
VirtualNodeTree::~VirtualNodeTree()
{
for (VNode *node : m_nodes_by_id) {
node->~VNode();
}
for (VInputSocket *socket : m_input_sockets) {
socket->~VInputSocket();
}
for (VOutputSocket *socket : m_output_sockets) {
socket->~VOutputSocket();
}
}
}; // namespace BKE

View File

@@ -0,0 +1,83 @@
#ifndef __BLI_BUFFER_ALLOCATOR_H__
#define __BLI_BUFFER_ALLOCATOR_H__
#include "BLI_vector.h"
namespace BLI {
class BufferCache {
private:
static const int Alignment = 64;
struct BufferHead {
uint buffer_size_in_bytes;
void *user_ptr()
{
BLI_STATIC_ASSERT(sizeof(BufferHead) <= Alignment, "");
return POINTER_OFFSET(this, Alignment);
}
static BufferHead *FromUserPtr(void *ptr)
{
return (BufferHead *)POINTER_OFFSET(ptr, -Alignment);
}
};
Vector<BufferHead *, 16> m_all_buffers;
Vector<BufferHead *, 16> m_cached_buffers;
public:
BufferCache() = default;
~BufferCache()
{
assert_same_size(m_cached_buffers, m_all_buffers);
for (BufferHead *head : m_all_buffers) {
MEM_freeN((void *)head);
}
}
void *allocate(uint size, uint alignment)
{
UNUSED_VARS_NDEBUG(alignment);
BLI_assert(alignment <= Alignment);
/* Only use buffer sizes that are a power of two, to make them easier to reuse. */
uint padded_size = power_of_2_max_u(size);
/* Try to use a cached memory buffer. Start searching from the back to prefer buffers that have
* been used "just before". */
for (int i = m_cached_buffers.size() - 1; i >= 0; i--) {
BufferHead *head = m_cached_buffers[i];
if (head->buffer_size_in_bytes == padded_size) {
void *user_ptr = head->user_ptr();
m_cached_buffers.remove_and_reorder(i);
return user_ptr;
}
}
BufferHead *new_head = (BufferHead *)MEM_mallocN_aligned(
padded_size + Alignment, Alignment, "allocate in BufferCache");
new_head->buffer_size_in_bytes = padded_size;
m_all_buffers.append(new_head);
return new_head->user_ptr();
}
void deallocate(void *buffer)
{
BufferHead *head = BufferHead::FromUserPtr(buffer);
BLI_assert(m_all_buffers.contains(head));
m_cached_buffers.append(head);
}
void *allocate(uint element_amount, uint element_size, uint alignment)
{
return this->allocate(element_amount * element_size, alignment);
}
};
} // namespace BLI
#endif /* __BLI_BUFFER_ALLOCATOR_H__ */

View File

@@ -0,0 +1,87 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __BLI_COLOR_H__
#define __BLI_COLOR_H__
#include <array>
#include <iostream>
#include "BLI_math_color.h"
namespace BLI {
struct rgba_f {
float r, g, b, a;
rgba_f() = default;
rgba_f(float r, float g, float b, float a) : r(r), g(g), b(b), a(a)
{
}
operator float *()
{
return &r;
}
operator std::array<float, 4>()
{
return {r, g, b, a};
}
friend std::ostream &operator<<(std::ostream &stream, rgba_f c)
{
stream << "(" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ")";
return stream;
}
};
struct rgba_b {
uint8_t r, g, b, a;
rgba_b() = default;
rgba_b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a)
{
}
rgba_b(rgba_f other)
{
rgba_float_to_uchar(*this, other);
}
operator rgba_f() const
{
rgba_f result;
rgba_uchar_to_float(result, *this);
return result;
}
operator uint8_t *()
{
return &r;
}
operator const uint8_t *() const
{
return &r;
}
};
} // namespace BLI
#endif /* __BLI_COLOR_H__ */

View File

@@ -0,0 +1,274 @@
#ifndef __BLI_DOT_EXPORT_H__
#define __BLI_DOT_EXPORT_H__
/**
* Language grammar: https://www.graphviz.org/doc/info/lang.html
* Attributes: https://www.graphviz.org/doc/info/attrs.html
* Node Shapes: https://www.graphviz.org/doc/info/shapes.html
* Preview: https://dreampuf.github.io/GraphvizOnline
*/
#include "BLI_map.h"
#include "BLI_optional.h"
#include "BLI_set.h"
#include "BLI_string_map.h"
#include "BLI_utility_mixins.h"
#include "BLI_vector.h"
#include "BLI_dot_export_attribute_enums.h"
#include <sstream>
namespace BLI {
namespace DotExport {
class Graph;
class DirectedGraph;
class UndirectedGraph;
class Node;
class NodePort;
class DirectedEdge;
class UndirectedEdge;
class Cluster;
class AttributeList;
class AttributeList {
private:
Map<std::string, std::string> m_attributes;
public:
void export__as_bracket_list(std::stringstream &ss) const;
void set(StringRef key, StringRef value)
{
m_attributes.add_override(key, value);
}
};
class Graph {
private:
AttributeList m_attributes;
Vector<std::unique_ptr<Node>> m_nodes;
Vector<std::unique_ptr<Cluster>> m_clusters;
Set<Node *> m_top_level_nodes;
Set<Cluster *> m_top_level_clusters;
friend Cluster;
friend Node;
public:
Node &new_node(StringRef label);
Cluster &new_cluster(StringRef label = "");
void export__declare_nodes_and_clusters(std::stringstream &ss) const;
void set_attribute(StringRef key, StringRef value)
{
m_attributes.set(key, value);
}
void set_rankdir(Attr_rankdir::Enum rankdir)
{
this->set_attribute("rankdir", Attr_rankdir::to_string(rankdir));
}
void set_random_cluster_bgcolors();
};
class Cluster {
private:
AttributeList m_attributes;
Graph &m_graph;
Cluster *m_parent = nullptr;
Set<Cluster *> m_children;
Set<Node *> m_nodes;
friend Graph;
friend Node;
Cluster(Graph &graph) : m_graph(graph)
{
}
public:
void export__declare_nodes_and_clusters(std::stringstream &ss) const;
void set_attribute(StringRef key, StringRef value)
{
m_attributes.set(key, value);
}
void set_parent_cluster(Cluster *cluster);
void set_parent_cluster(Cluster &cluster)
{
this->set_parent_cluster(&cluster);
}
void set_random_cluster_bgcolors();
};
class Node {
private:
AttributeList m_attributes;
Graph &m_graph;
Cluster *m_cluster = nullptr;
friend Graph;
Node(Graph &graph) : m_graph(graph)
{
}
public:
const AttributeList &attributes() const
{
return m_attributes;
}
AttributeList &attributes()
{
return m_attributes;
}
void set_parent_cluster(Cluster *cluster);
void set_parent_cluster(Cluster &cluster)
{
this->set_parent_cluster(&cluster);
}
void set_attribute(StringRef key, StringRef value)
{
m_attributes.set(key, value);
}
void set_shape(Attr_shape::Enum shape)
{
this->set_attribute("shape", Attr_shape::to_string(shape));
}
/* See https://www.graphviz.org/doc/info/attrs.html#k:color. */
void set_background_color(StringRef name)
{
this->set_attribute("fillcolor", name);
this->set_attribute("style", "filled");
}
void export__as_id(std::stringstream &ss) const;
void export__as_declaration(std::stringstream &ss) const;
};
class UndirectedGraph final : public Graph {
private:
Vector<std::unique_ptr<UndirectedEdge>> m_edges;
public:
std::string to_dot_string() const;
UndirectedEdge &new_edge(NodePort a, NodePort b);
};
class DirectedGraph final : public Graph {
private:
Vector<std::unique_ptr<DirectedEdge>> m_edges;
public:
std::string to_dot_string() const;
DirectedEdge &new_edge(NodePort from, NodePort to);
};
class NodePort {
private:
Node *m_node;
Optional<std::string> m_port_name;
public:
NodePort(Node &node, Optional<std::string> port_name = {})
: m_node(&node), m_port_name(std::move(port_name))
{
}
void to_dot_string(std::stringstream &ss) const;
};
class Edge : BLI::NonCopyable, BLI::NonMovable {
protected:
AttributeList m_attributes;
NodePort m_a;
NodePort m_b;
public:
Edge(NodePort a, NodePort b) : m_a(std::move(a)), m_b(std::move(b))
{
}
void set_attribute(StringRef key, StringRef value)
{
m_attributes.set(key, value);
}
void set_arrowhead(Attr_arrowType::Enum type)
{
this->set_attribute("arrowhead", Attr_arrowType::to_string(type));
}
void set_arrowtail(Attr_arrowType::Enum type)
{
this->set_attribute("arrowtail", Attr_arrowType::to_string(type));
}
void set_dir(Attr_dirType::Enum type)
{
this->set_attribute("dir", Attr_dirType::to_string(type));
}
};
class DirectedEdge : public Edge {
public:
DirectedEdge(NodePort from, NodePort to) : Edge(std::move(from), std::move(to))
{
}
void export__as_edge_statement(std::stringstream &ss) const;
};
class UndirectedEdge : public Edge {
public:
UndirectedEdge(NodePort a, NodePort b) : Edge(std::move(a), std::move(b))
{
}
void export__as_edge_statement(std::stringstream &ss) const;
};
std::string color_attr_from_hsv(float h, float s, float v);
class NodeWithSocketsRef {
private:
Node *m_node;
public:
NodeWithSocketsRef(Node &node,
StringRef name,
ArrayRef<std::string> input_names,
ArrayRef<std::string> output_names);
NodePort input(uint index) const
{
std::string port = "\"in" + std::to_string(index) + "\"";
return NodePort(*m_node, port);
}
NodePort output(uint index) const
{
std::string port = "\"out" + std::to_string(index) + "\"";
return NodePort(*m_node, port);
}
};
} // namespace DotExport
} // namespace BLI
#endif /* __BLI_DOT_EXPORT_H__ */

View File

@@ -0,0 +1,112 @@
#ifndef __BLI_DOT_EXPORT_ATTRIBUTE_ENUMS_H__
#define __BLI_DOT_EXPORT_ATTRIBUTE_ENUMS_H__
#include "BLI_string_ref.h"
namespace BLI {
namespace DotExport {
namespace Attr_rankdir {
enum Enum {
LeftToRight,
TopToBottom,
};
static StringRef to_string(Enum value)
{
switch (value) {
case LeftToRight:
return "LR";
case TopToBottom:
return "TB";
}
return "";
}
} // namespace Attr_rankdir
namespace Attr_shape {
enum Enum {
Rectangle,
Ellipse,
Circle,
Point,
Diamond,
Square,
};
static StringRef to_string(Enum value)
{
switch (value) {
case Rectangle:
return "rectangle";
case Ellipse:
return "ellipse";
case Circle:
return "circle";
case Point:
return "point";
case Diamond:
return "diamond";
case Square:
return "square";
}
return "";
}
} // namespace Attr_shape
namespace Attr_arrowType {
enum Enum {
Normal,
Inv,
Dot,
None,
Empty,
Box,
Vee,
};
static StringRef to_string(Enum value)
{
switch (value) {
case Normal:
return "normal";
case Inv:
return "inv";
case Dot:
return "dot";
case None:
return "none";
case Empty:
return "empty";
case Box:
return "box";
case Vee:
return "vee";
}
return "";
}
} // namespace Attr_arrowType
namespace Attr_dirType {
enum Enum { Forward, Back, Both, None };
static StringRef to_string(Enum value)
{
switch (value) {
case Forward:
return "forward";
case Back:
return "back";
case Both:
return "both";
case None:
return "none";
}
return "";
}
} // namespace Attr_dirType
} // namespace DotExport
} // namespace BLI
#endif /* __BLI_DOT_EXPORT_ATTRIBUTE_ENUMS_H__ */

View File

@@ -0,0 +1,90 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __BLI_FLOAT2_H__
#define __BLI_FLOAT2_H__
#include "BLI_float3.h"
namespace BLI {
struct float2 {
float x, y;
float2() = default;
float2(const float *ptr) : x{ptr[0]}, y{ptr[1]}
{
}
float2(float x, float y) : x(x), y(y)
{
}
float2(float3 other) : x(other.x), y(other.y)
{
}
operator float *()
{
return &x;
}
float2 clamped(float min, float max)
{
return {std::min(std::max(x, min), max), std::min(std::max(y, min), max)};
}
float2 clamped_01()
{
return this->clamped(0, 1);
}
friend float2 operator+(float2 a, float2 b)
{
return {a.x + b.x, a.y + b.y};
}
friend float2 operator-(float2 a, float2 b)
{
return {a.x - b.x, a.y - b.y};
}
friend float2 operator*(float2 a, float b)
{
return {a.x * b, a.y * b};
}
friend float2 operator/(float2 a, float b)
{
return {a.x / b, a.y / b};
}
friend float2 operator*(float a, float2 b)
{
return b * a;
}
friend std::ostream &operator<<(std::ostream &stream, float2 v)
{
stream << "(" << v.x << ", " << v.y << ")";
return stream;
}
};
} // namespace BLI
#endif /* __BLI_FLOAT2_H__ */

View File

@@ -0,0 +1,229 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __BLI_FLOAT3_H__
#define __BLI_FLOAT3_H__
#include <array>
#include <iostream>
#include "BLI_math_vector.h"
namespace BLI {
struct float3 {
float x, y, z;
float3() = default;
float3(const float *ptr) : x{ptr[0]}, y{ptr[1]}, z{ptr[2]}
{
}
explicit float3(float value) : x(value), y(value), z(value)
{
}
explicit float3(int value) : x(value), y(value), z(value)
{
}
float3(float x, float y, float z) : x{x}, y{y}, z{z}
{
}
operator const float *() const
{
return (const float *)this;
}
operator float *()
{
return (float *)this;
}
operator std::array<float, 3>()
{
return {x, y, z};
}
float normalize_and_get_length()
{
return normalize_v3(*this);
}
float3 normalized() const
{
float3 result;
normalize_v3_v3(result, *this);
return result;
}
float length() const
{
return len_v3(*this);
}
float length_squared() const
{
return len_squared_v3(*this);
}
void reflect(float3 normal)
{
*this = this->reflected(normal);
}
float3 reflected(float3 normal) const
{
float3 result;
reflect_v3_v3v3(result, *this, normal);
return result;
}
static float3 safe_divide(const float3 a, const float3 b)
{
float3 result;
result.x = (b.x == 0.0f) ? 0.0f : a.x / b.x;
result.y = (b.y == 0.0f) ? 0.0f : a.y / b.y;
result.z = (b.z == 0.0f) ? 0.0f : a.z / b.z;
return result;
}
void invert()
{
x = -x;
y = -y;
z = -z;
}
bool is_zero() const
{
return x != 0.0f && y != 0.0f && z != 0.0f;
}
friend float3 operator+(float3 a, float3 b)
{
return {a.x + b.x, a.y + b.y, a.z + b.z};
}
void operator+=(float3 b)
{
this->x += b.x;
this->y += b.y;
this->z += b.z;
}
friend float3 operator-(float3 a, float3 b)
{
return {a.x - b.x, a.y - b.y, a.z - b.z};
}
friend float3 operator-(float3 a)
{
return {-a.x, -a.y, -a.z};
}
void operator-=(float3 b)
{
this->x -= b.x;
this->y -= b.y;
this->z -= b.z;
}
void operator*=(float scalar)
{
this->x *= scalar;
this->y *= scalar;
this->z *= scalar;
}
void operator*=(float3 other)
{
this->x *= other.x;
this->y *= other.y;
this->z *= other.z;
}
friend float3 operator*(float3 a, float3 b)
{
return {a.x * b.x, a.y * b.y, a.z * b.z};
}
friend float3 operator*(float3 a, float b)
{
return {a.x * b, a.y * b, a.z * b};
}
friend float3 operator*(float a, float3 b)
{
return b * a;
}
friend float3 operator/(float3 a, float3 b)
{
BLI_assert(!b.is_zero());
return {a.x / b.x, a.y / b.y, a.z / b.z};
}
friend float3 operator/(float3 a, float b)
{
BLI_assert(b != 0);
return {a.x / b, a.y / b, a.z / b};
}
friend std::ostream &operator<<(std::ostream &stream, float3 v)
{
stream << "(" << v.x << ", " << v.y << ", " << v.z << ")";
return stream;
}
static float dot(float3 a, float3 b)
{
return a.x * b.x + a.y * b.y + a.z * b.z;
}
static float3 cross_high_precision(float3 a, float3 b)
{
float3 result;
cross_v3_v3v3_hi_prec(result, a, b);
return result;
}
static float3 project(float3 a, float3 b)
{
float3 result;
project_v3_v3v3(result, a, b);
return result;
}
static float distance(float3 a, float3 b)
{
return (a - b).length();
}
static float distance_squared(float3 a, float3 b)
{
return float3::dot(a, b);
}
static float3 interpolate(float3 a, float3 b, float t)
{
return a * (1 - t) + b * t;
}
};
} // namespace BLI
#endif /* __BLI_FLOAT3_H__ */

View File

@@ -0,0 +1,103 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __BLI_FLOAT4X4_H__
#define __BLI_FLOAT4X4_H__
#include "BLI_array_ref.h"
#include "BLI_float3.h"
#include "BLI_math_matrix.h"
namespace BLI {
struct float4x4 {
float values[4][4];
float4x4() = default;
float4x4(float *matrix)
{
memcpy(values, matrix, sizeof(float) * 16);
}
float4x4(float matrix[4][4]) : float4x4((float *)matrix)
{
}
operator float *()
{
return (float *)this;
}
float4x4 inverted() const
{
float result[4][4];
invert_m4_m4(result, values);
return result;
}
float4x4 inverted__LocRotScale() const
{
return this->inverted();
}
float3 transform_position(float3 position) const
{
mul_m4_v3(values, position);
return position;
}
float3 transform_direction(float3 direction) const
{
mul_mat3_m4_v3(values, direction);
return direction;
}
static void transform_positions(ArrayRef<float4x4> matrices,
ArrayRef<float3> positions,
MutableArrayRef<float3> r_results)
{
uint amount = matrices.size();
BLI_assert(amount == positions.size());
BLI_assert(amount == r_results.size());
for (uint i = 0; i < amount; i++) {
r_results[i] = matrices[i].transform_position(positions[i]);
}
}
static void transform_directions(ArrayRef<float4x4> matrices,
ArrayRef<float3> directions,
MutableArrayRef<float3> r_results)
{
uint amount = matrices.size();
BLI_assert(amount == directions.size());
BLI_assert(amount == r_results.size());
for (uint i = 0; i < amount; i++) {
r_results[i] = matrices[i].transform_direction(directions[i]);
}
}
static float4x4 interpolate(float4x4 a, float4x4 b, float t)
{
float result[4][4];
interp_m4_m4m4(result, a.values, b.values, t);
return result;
}
};
} // namespace BLI
#endif /* __BLI_FLOAT4X4_H__ */

View File

@@ -0,0 +1,94 @@
#ifndef __BLI_TIME_SPAN_H__
#define __BLI_TIME_SPAN_H__
#include "BLI_array_ref.h"
namespace BLI {
class FloatInterval {
private:
float m_start;
float m_size;
public:
FloatInterval(float start, float size) : m_start(start), m_size(size)
{
BLI_assert(size >= 0.0f);
}
float start() const
{
return m_start;
}
float size() const
{
return m_size;
}
float end() const
{
return m_start + m_size;
}
float value_at(float factor) const
{
return m_start + factor * m_size;
}
void value_at(ArrayRef<float> factors, MutableArrayRef<float> r_values)
{
assert_same_size(factors, r_values);
for (uint i : factors.index_range()) {
r_values[i] = this->value_at(factors[i]);
}
}
void sample_linear(MutableArrayRef<float> r_values)
{
if (r_values.size() == 0) {
return;
}
if (r_values.size() == 1) {
r_values[0] = this->value_at(0.5f);
}
for (uint i : r_values.index_range()) {
float factor = (i - 1) / (float)r_values.size();
r_values[i] = this->value_at(factor);
}
}
float factor_of(float value) const
{
BLI_assert(m_size > 0.0f);
return (value - m_start) / m_size;
}
float safe_factor_of(float value) const
{
if (m_size > 0.0f) {
return this->factor_of(value);
}
else {
return 0.0f;
}
}
void uniform_sample_range(float samples_per_time,
float &r_factor_start,
float &r_factor_step) const
{
if (m_size == 0.0f) {
/* Just needs to be greater than one. */
r_factor_start = 2.0f;
return;
}
r_factor_step = 1 / (m_size * samples_per_time);
float time_start = std::ceil(m_start * samples_per_time) / samples_per_time;
r_factor_start = this->safe_factor_of(time_start);
}
};
} // namespace BLI
#endif /* __BLI_TIME_SPAN_H__ */

View File

@@ -0,0 +1,118 @@
#ifndef __BLI_INDEX_MASK_H__
#define __BLI_INDEX_MASK_H__
#include "BLI_array_ref.h"
#include "BLI_index_range.h"
#include "BLI_vector.h"
#include "BLI_vector_adaptor.h"
namespace BLI {
class IndexMask {
private:
ArrayRef<uint> m_indices;
public:
IndexMask() = default;
IndexMask(ArrayRef<uint> indices) : m_indices(indices)
{
#ifdef DEBUG
for (uint i = 1; i < indices.size(); i++) {
BLI_assert(indices[i - 1] < indices[i]);
}
#endif
}
IndexMask(IndexRange range) : m_indices(range.as_array_ref())
{
}
template<uint N, typename Allocator>
IndexMask(const Vector<uint, N, Allocator> &vector) : IndexMask(vector.as_ref())
{
}
IndexMask(const VectorAdaptor<uint> &vector) : IndexMask(ArrayRef<uint>(vector))
{
}
explicit IndexMask(uint n) : IndexMask(IndexRange(n))
{
}
operator ArrayRef<uint>() const
{
return m_indices;
}
const uint *begin() const
{
return m_indices.begin();
}
const uint *end() const
{
return m_indices.end();
}
uint operator[](uint index) const
{
return m_indices[index];
}
uint size() const
{
return m_indices.size();
}
uint min_array_size() const
{
return (m_indices.size() == 0) ? 0 : m_indices.last() + 1;
}
ArrayRef<uint> indices() const
{
return m_indices;
}
bool is_range() const
{
return m_indices.size() > 0 && m_indices.last() - m_indices.first() == m_indices.size() - 1;
}
IndexRange as_range() const
{
BLI_assert(this->is_range());
return IndexRange{m_indices.first(), m_indices.size()};
}
template<typename FuncT> void foreach_index(const FuncT &func) const
{
if (this->is_range()) {
IndexRange range = this->as_range();
for (uint i : range) {
func(i);
}
}
else {
for (uint i : m_indices) {
func(i);
}
}
}
IndexRange index_range() const
{
return m_indices.index_range();
}
uint last() const
{
return m_indices.last();
}
};
} // namespace BLI
#endif /* __BLI_INDEX_MASK_H__ */

View File

@@ -0,0 +1,121 @@
#ifndef __BLI_INDEX_TO_REF_MAP_H__
#define __BLI_INDEX_TO_REF_MAP_H__
#include "BLI_array_cxx.h"
#include "BLI_multi_map.h"
namespace BLI {
template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class IndexToRefMap {
private:
Array<T *, N, Allocator> m_array;
public:
IndexToRefMap(uint size) : m_array(size, nullptr)
{
}
uint size() const
{
return m_array.size();
}
void add(uint key, T &value)
{
m_array[key] = &value;
}
void add_new(uint key, T &value)
{
BLI_assert(m_array[key] == nullptr);
m_array[key] = &value;
}
bool contains(uint key) const
{
return m_array[key] != nullptr;
}
const T &lookup(uint key) const
{
BLI_assert(this->contains(key));
return *m_array[key];
}
T &lookup(uint key)
{
BLI_assert(this->contains(key));
return *m_array[key];
}
};
#define IndexToRefMultiMap_UNMAPPED nullptr
#define IndexToRefMultiMap_MULTIMAPPED ((T *)1)
template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class IndexToRefMultiMap {
private:
Array<T *> m_array;
MultiMap<uint, T *> m_fallback_multimap;
public:
IndexToRefMultiMap(uint max_index) : m_array(max_index, IndexToRefMultiMap_UNMAPPED)
{
}
uint max_index() const
{
return m_array.size();
}
bool contains(uint key) const
{
return m_array[key] != IndexToRefMultiMap_UNMAPPED;
}
ArrayRef<T *> lookup(uint key) const
{
T *const *stored_value_addr = &m_array[key];
const T *stored_value = *stored_value_addr;
if (stored_value == IndexToRefMultiMap_UNMAPPED) {
return {};
}
else if (stored_value == IndexToRefMultiMap_MULTIMAPPED) {
return m_fallback_multimap.lookup(key);
}
else {
return ArrayRef<T *>(stored_value_addr, 1);
}
}
T &lookup_single(uint key)
{
T *stored_value = m_array[key];
BLI_assert(stored_value != IndexToRefMultiMap_UNMAPPED &&
stored_value != IndexToRefMultiMap_MULTIMAPPED);
return *stored_value;
}
void add(uint key, T &value)
{
T **stored_value_addr = &m_array[key];
T *stored_value = *stored_value_addr;
if (stored_value == IndexToRefMultiMap_UNMAPPED) {
*stored_value_addr = &value;
}
else if (stored_value == IndexToRefMultiMap_MULTIMAPPED) {
m_fallback_multimap.add(key, &value);
}
else {
T *other_value = stored_value;
*stored_value_addr = IndexToRefMultiMap_MULTIMAPPED;
m_fallback_multimap.add_multiple_new(key, {other_value, &value});
}
}
};
#undef IndexToRefMultiMap_UNMAPPED
#undef IndexToRefMultiMap_MULTIMAPPED
} // namespace BLI
#endif /* __BLI_INDEX_TO_REF_MAP_H__ */

View File

@@ -0,0 +1,230 @@
#pragma once
#include "BLI_index_range.h"
#include "BLI_linear_allocator.h"
#include "BLI_memory_utils_cxx.h"
namespace BLI {
template<typename T> class LinearAllocatedVector : BLI::NonCopyable {
private:
T *m_begin;
T *m_end;
T *m_capacity_end;
#ifdef DEBUG
uint m_debug_size;
# define UPDATE_VECTOR_SIZE(ptr) (ptr)->m_debug_size = (ptr)->m_end - (ptr)->m_begin
#else
# define UPDATE_VECTOR_SIZE(ptr) ((void)0)
#endif
public:
LinearAllocatedVector() : m_begin(nullptr), m_end(nullptr), m_capacity_end(nullptr)
{
UPDATE_VECTOR_SIZE(this);
}
~LinearAllocatedVector()
{
destruct_n(m_begin, this->size());
}
LinearAllocatedVector(LinearAllocatedVector &&other)
{
m_begin = other.m_begin;
m_end = other.m_end;
m_capacity_end = other.m_capacity_end;
other.m_begin = nullptr;
other.m_end = nullptr;
other.m_capacity_end = nullptr;
UPDATE_VECTOR_SIZE(this);
UPDATE_VECTOR_SIZE(&other);
}
LinearAllocatedVector &operator=(LinearAllocatedVector &&other)
{
if (this == &other) {
return *this;
}
m_begin = other.m_begin;
m_end = other.m_end;
m_capacity_end = other.m_capacity_end;
other.m_begin = nullptr;
other.m_end = nullptr;
other.m_capacity_end = nullptr;
UPDATE_VECTOR_SIZE(this);
UPDATE_VECTOR_SIZE(&other);
return *this;
}
operator ArrayRef<T>() const
{
return ArrayRef<T>(m_begin, this->size());
}
operator MutableArrayRef<T>()
{
return MutableArrayRef<T>(m_begin, this->size());
}
ArrayRef<T> as_ref() const
{
return *this;
}
MutableArrayRef<T> as_mutable_ref() const
{
return *this;
}
IndexRange index_range() const
{
return IndexRange(this->size());
}
uint size() const
{
return m_end - m_begin;
}
uint capacity() const
{
return m_capacity_end - m_begin;
}
void clear()
{
destruct_n(m_begin, this->size());
m_end = m_begin;
UPDATE_VECTOR_SIZE(this);
}
void append_unchecked(const T &value)
{
BLI_assert(m_end < m_capacity_end);
new (m_end) T(value);
m_end++;
UPDATE_VECTOR_SIZE(this);
}
template<typename AllocT> void append(const T &value, LinearAllocator<AllocT> &allocator)
{
if (m_end == m_capacity_end) {
this->grow(this->size() + 1, allocator);
}
this->append_unchecked(value);
}
template<typename AllocT>
uint append_and_get_index(const T &value, LinearAllocator<AllocT> &allocator)
{
uint index = this->size();
this->append(value, allocator);
return index;
}
bool contains(const T &value) const
{
for (const T &current : *this) {
if (current == value) {
return true;
}
}
return false;
}
const T &operator[](uint index) const
{
BLI_assert(index < this->size());
return m_begin[index];
}
T &operator[](uint index)
{
BLI_assert(index < this->size());
return m_begin[index];
}
const T *begin() const
{
return m_begin;
}
const T *end() const
{
return m_end;
}
T *begin()
{
return m_begin;
}
T *end()
{
return m_end;
}
void remove_and_reorder(uint index)
{
BLI_assert(index < this->size());
T *element_to_remove = m_begin + index;
m_end--;
if (element_to_remove < m_end) {
*element_to_remove = std::move(*m_end);
}
destruct(m_end);
UPDATE_VECTOR_SIZE(this);
}
int index_try(const T &value) const
{
for (T *current = m_begin; current != m_end; current++) {
if (*current == value) {
return current - m_begin;
}
}
return -1;
}
uint index(const T &value) const
{
int index = this->index_try(value);
BLI_assert(index >= 0);
return (uint)index;
}
void remove_first_occurrence_and_reorder(const T &value)
{
uint index = this->index(value);
this->remove_and_reorder((uint)index);
}
private:
template<typename AllocT>
BLI_NOINLINE void grow(uint min_capacity, LinearAllocator<AllocT> &allocator)
{
if (min_capacity <= this->capacity()) {
return;
}
uint size = this->size();
min_capacity = power_of_2_max_u(min_capacity);
T *new_begin = (T *)allocator.allocate(sizeof(T) * min_capacity, alignof(T));
uninitialized_relocate_n(m_begin, size, new_begin);
m_begin = new_begin;
m_end = new_begin + size;
m_capacity_end = new_begin + min_capacity;
}
};
} // namespace BLI

View File

@@ -0,0 +1,172 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/** \file
* \ingroup bli
*
* A linear allocator is the simplest form of an allocator. It never reuses any memory, and
* therefore does not need a deallocation method. It simply hands out consecutive buffers of
* memory. When the current buffer is full, it reallocates a new larger buffer and continues.
*/
#pragma once
#include "BLI_stack_cxx.h"
#include "BLI_string_ref.h"
#include "BLI_timeit.h"
#include "BLI_utility_mixins.h"
#include "BLI_vector.h"
namespace BLI {
template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopyable, NonMovable {
private:
Allocator m_allocator;
Vector<void *> m_owned_buffers;
Vector<ArrayRef<char>> m_unused_borrowed_buffers;
uintptr_t m_current_begin;
uintptr_t m_current_end;
uint m_next_min_alloc_size;
#ifdef DEBUG
uint m_debug_allocated_amount = 0;
#endif
public:
LinearAllocator()
{
m_current_begin = 0;
m_current_end = 0;
m_next_min_alloc_size = 64;
}
~LinearAllocator()
{
for (void *ptr : m_owned_buffers) {
m_allocator.deallocate(ptr);
}
}
void provide_buffer(void *buffer, uint size)
{
m_unused_borrowed_buffers.append(ArrayRef<char>((char *)buffer, size));
}
template<uint Size, uint Alignment>
void provide_buffer(AlignedBuffer<Size, Alignment> &aligned_buffer)
{
this->provide_buffer(aligned_buffer.ptr(), Size);
}
template<typename T> T *allocate()
{
return (T *)this->allocate(sizeof(T), alignof(T));
}
template<typename T> MutableArrayRef<T> allocate_array(uint length)
{
return MutableArrayRef<T>((T *)this->allocate(sizeof(T) * length), length);
}
void *allocate(uint size, uint alignment = 4)
{
BLI_assert(alignment >= 1);
BLI_assert(is_power_of_2_i(alignment));
#ifdef DEBUG
m_debug_allocated_amount += size;
#endif
uintptr_t alignment_mask = alignment - 1;
uintptr_t potential_allocation_begin = (m_current_begin + alignment_mask) & ~alignment_mask;
uintptr_t potential_allocation_end = potential_allocation_begin + size;
if (potential_allocation_end <= m_current_end) {
m_current_begin = potential_allocation_end;
return (void *)potential_allocation_begin;
}
else {
this->allocate_new_buffer(size + alignment);
return this->allocate(size, alignment);
}
};
StringRefNull copy_string(StringRef str)
{
uint alloc_size = str.size() + 1;
char *buffer = (char *)this->allocate(alloc_size, 1);
str.copy(buffer, alloc_size);
return StringRefNull((const char *)buffer);
}
template<typename T, typename... Args> T *construct(Args &&... args)
{
void *buffer = this->allocate(sizeof(T), alignof(T));
T *value = new (buffer) T(std::forward<Args>(args)...);
return value;
}
template<typename T, typename... Args>
ArrayRef<T *> construct_elements_and_pointer_array(uint n, Args &&... args)
{
void *pointer_buffer = this->allocate(n * sizeof(T *), alignof(T *));
void *element_buffer = this->allocate(n * sizeof(T), alignof(T));
MutableArrayRef<T *> pointers((T **)pointer_buffer, n);
T *elements = (T *)element_buffer;
for (uint i : IndexRange(n)) {
pointers[i] = elements + i;
}
for (uint i : IndexRange(n)) {
new (elements + i) T(std::forward<Args>(args)...);
}
return pointers;
}
template<typename T> MutableArrayRef<T> construct_array_copy(ArrayRef<T> source)
{
T *buffer = (T *)this->allocate(source.byte_size(), alignof(T));
source.copy_to(buffer);
return MutableArrayRef<T>(buffer, source.size());
}
private:
void allocate_new_buffer(uint min_allocation_size)
{
for (uint i : m_unused_borrowed_buffers.index_range()) {
ArrayRef<char> buffer = m_unused_borrowed_buffers[i];
if (buffer.size() >= min_allocation_size) {
m_unused_borrowed_buffers.remove_and_reorder(i);
m_current_begin = (uintptr_t)buffer.begin();
m_current_end = (uintptr_t)buffer.end();
return;
}
}
uint size_in_bytes = power_of_2_min_u(std::max(min_allocation_size, m_next_min_alloc_size));
m_next_min_alloc_size = size_in_bytes * 2;
void *buffer = m_allocator.allocate(size_in_bytes, __func__);
m_owned_buffers.append(buffer);
m_current_begin = (uintptr_t)buffer;
m_current_end = m_current_begin + size_in_bytes;
}
};
} // namespace BLI

Some files were not shown because too many files have changed in this diff Show More