diff options
author | Jacques Lucke <jacques@blender.org> | 2021-10-26 13:48:29 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-10-26 13:48:43 +0300 |
commit | d20fa6c4d48580bf5fc140cf83fd7d8829bd8e09 (patch) | |
tree | 48de1a2888711af95ac13870c15f1cb234d0036e /source/blender/nodes/intern | |
parent | 41a4c62c315508f1da8f5b020dd4e2304828453e (diff) |
Geometry Nodes: don't log full fields when not necessary
Previously, the field on every socket was logged for later use. This had
two main negative consequences:
* Increased memory usage, because the fields may contain a lot of data
under some circumstances (e.g. a Ray Cast field contains the target geometry).
* Decreased performance, because anonymous attributes could not be
removed from geometry automatically, because there were still fields that
referenced them.
Now most fields are not logged anymore. Only those that are viewed by a
spreadsheet and constant fields. The required inputs of a field are still
logged in string form to keep socket inspection working.
Diffstat (limited to 'source/blender/nodes/intern')
-rw-r--r-- | source/blender/nodes/intern/geometry_nodes_eval_log.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/nodes/intern/geometry_nodes_eval_log.cc b/source/blender/nodes/intern/geometry_nodes_eval_log.cc index 92f20656609..13dc73c7206 100644 --- a/source/blender/nodes/intern/geometry_nodes_eval_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_eval_log.cc @@ -21,9 +21,16 @@ #include "DNA_modifier_types.h" #include "DNA_space_types.h" +#include "FN_field_cpp_type.hh" + +#include "BLT_translation.h" + namespace blender::nodes::geometry_nodes_eval_log { using fn::CPPType; +using fn::FieldCPPType; +using fn::FieldInput; +using fn::GField; ModifierLog::ModifierLog(GeoLogger &logger) : input_geometry_log_(std::move(logger.input_geometry_log_)), @@ -168,6 +175,20 @@ const SocketLog *NodeLog::lookup_socket_log(const bNode &node, const bNodeSocket return this->lookup_socket_log((eNodeSocketInOut)socket.in_out, index); } +GFieldValueLog::GFieldValueLog(fn::GField field, bool log_full_field) : type_(field.cpp_type()) +{ + VectorSet<std::reference_wrapper<const FieldInput>> field_inputs; + field.node().foreach_field_input( + [&](const FieldInput &field_input) { field_inputs.add(field_input); }); + for (const FieldInput &field_input : field_inputs) { + input_tooltips_.append(field_input.socket_inspection_name()); + } + + if (log_full_field) { + field_ = std::move(field); + } +} + GeometryValueLog::GeometryValueLog(const GeometrySet &geometry_set, bool log_full_geometry) { static std::array all_component_types = {GEO_COMPONENT_TYPE_CURVE, @@ -382,6 +403,26 @@ void LocalGeoLogger::log_value_for_sockets(Span<DSocket> sockets, GPointer value geometry_set, log_full_geometry); values_.append({copied_sockets, std::move(value_log)}); } + else if (const FieldCPPType *field_type = dynamic_cast<const FieldCPPType *>(&type)) { + GField field = field_type->get_gfield(value.get()); + bool log_full_field = false; + if (!field.node().depends_on_input()) { + /* Always log constant fields so that their value can be shown in socket inspection. + * In the future we can also evaluate the field here and only store the value. */ + log_full_field = true; + } + if (!log_full_field) { + for (const DSocket &socket : sockets) { + if (main_logger_->log_full_sockets_.contains(socket)) { + log_full_field = true; + break; + } + } + } + destruct_ptr<GFieldValueLog> value_log = allocator_->construct<GFieldValueLog>( + std::move(field), log_full_field); + values_.append({copied_sockets, std::move(value_log)}); + } else { void *buffer = allocator_->allocate(type.size(), type.alignment()); type.copy_construct(value.get(), buffer); |