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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-07-21 18:20:05 +0300
committerJacques Lucke <jacques@blender.org>2020-07-21 18:35:09 +0300
commit8369adabc0ec7a1fce248b688bf20860ae0434bb (patch)
treeaf767efe8c6765c5876391a5eb96923fc8d6ac68 /source/blender/functions/intern
parent6c7e62ef9be564fbee279c7467c9b6adaf51b6c8 (diff)
Particles: initial object socket and emitter node support
Object sockets work now, but only the new Object Transforms and the Particle Mesh Emitter node use it. The emitter does not actually use the mesh surface yet. Instead, new particles are just emitted around the origin of the object. Internally, handles to object data blocks are passed around in the network, instead of raw object pointers. Using handles has a couple of benefits: * The caller of the function has control over which handles can be resolved and therefore limit access to specific data. The set of data blocks that is accessed by a node tree should be known statically. This is necessary for a proper integration with the dependency graph. * When the pointer to an object changes (e.g. after restarting Blender), all handles are still valid. * When an object is deleted, the handle is invalidated without causing crashes. * The handle is just an integer that can be stored per particle and can be cached easily. The mapping between handles and their corresponding data blocks is stored in the Simulation data block.
Diffstat (limited to 'source/blender/functions/intern')
-rw-r--r--source/blender/functions/intern/multi_function_network_evaluation.cc2
-rw-r--r--source/blender/functions/intern/multi_function_network_optimization.cc30
2 files changed, 22 insertions, 10 deletions
diff --git a/source/blender/functions/intern/multi_function_network_evaluation.cc b/source/blender/functions/intern/multi_function_network_evaluation.cc
index a7e1a2f42af..58577e31c42 100644
--- a/source/blender/functions/intern/multi_function_network_evaluation.cc
+++ b/source/blender/functions/intern/multi_function_network_evaluation.cc
@@ -230,7 +230,7 @@ BLI_NOINLINE void MFNetworkEvaluator::evaluate_network_to_compute_outputs(
}
BLI_assert(node.is_function());
- BLI_assert(node.all_inputs_have_origin());
+ BLI_assert(!node.has_unlinked_inputs());
const MFFunctionNode &function_node = node.as_function();
bool all_origins_are_computed = true;
diff --git a/source/blender/functions/intern/multi_function_network_optimization.cc b/source/blender/functions/intern/multi_function_network_optimization.cc
index e76b2f51a15..f1e047f01a1 100644
--- a/source/blender/functions/intern/multi_function_network_optimization.cc
+++ b/source/blender/functions/intern/multi_function_network_optimization.cc
@@ -142,13 +142,24 @@ void dead_node_removal(MFNetwork &network)
*
* \{ */
+static bool function_node_can_be_constant(MFFunctionNode *node)
+{
+ if (node->has_unlinked_inputs()) {
+ return false;
+ }
+ if (node->function().depends_on_context()) {
+ return false;
+ }
+ return true;
+}
+
static Vector<MFNode *> find_non_constant_nodes(MFNetwork &network)
{
Vector<MFNode *> non_constant_nodes;
non_constant_nodes.extend(network.dummy_nodes());
for (MFFunctionNode *node : network.function_nodes()) {
- if (!node->all_inputs_have_origin()) {
+ if (!function_node_can_be_constant(node)) {
non_constant_nodes.append(node);
}
}
@@ -319,17 +330,18 @@ void constant_folding(MFNetwork &network, ResourceCollector &resources)
static uint64_t compute_node_hash(MFFunctionNode &node, RNG *rng, Span<uint64_t> node_hashes)
{
+ if (node.function().depends_on_context()) {
+ return BLI_rng_get_uint(rng);
+ }
+ if (node.has_unlinked_inputs()) {
+ return BLI_rng_get_uint(rng);
+ }
+
uint64_t combined_inputs_hash = 394659347u;
for (MFInputSocket *input_socket : node.inputs()) {
MFOutputSocket *origin_socket = input_socket->origin();
- uint64_t input_hash;
- if (origin_socket == nullptr) {
- input_hash = BLI_rng_get_uint(rng);
- }
- else {
- input_hash = BLI_ghashutil_combine_hash(node_hashes[origin_socket->node().id()],
- origin_socket->index());
- }
+ uint64_t input_hash = BLI_ghashutil_combine_hash(node_hashes[origin_socket->node().id()],
+ origin_socket->index());
combined_inputs_hash = BLI_ghashutil_combine_hash(combined_inputs_hash, input_hash);
}