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:
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c2
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc93
-rw-r--r--source/blender/modifiers/intern/MOD_nodes_evaluator.cc194
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c12
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c2
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c2
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_extrude.c2
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_nonmanifold.c2
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c2
13 files changed, 163 insertions, 157 deletions
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 6c5baabe756..8f4a675b797 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -115,7 +115,7 @@ static void deformVerts(ModifierData *md,
float(*layerorco)[3];
if (!(layerorco = CustomData_get_layer(&mesh_src->vdata, CD_CLOTH_ORCO))) {
layerorco = CustomData_add_layer(
- &mesh_src->vdata, CD_CLOTH_ORCO, CD_CALLOC, NULL, mesh_src->totvert);
+ &mesh_src->vdata, CD_CLOTH_ORCO, CD_SET_DEFAULT, NULL, mesh_src->totvert);
}
memcpy(layerorco, kb->data, sizeof(float[3]) * verts_num);
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index d3b43176700..2908fbf5597 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -297,6 +297,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
case ID_IM:
case ID_TE: {
DEG_add_generic_id_relation(ctx->node, id, "Nodes Modifier");
+ break;
}
default: {
/* Purposefully don't add relations for materials. While there are material sockets,
@@ -755,18 +756,18 @@ void MOD_nodes_update_interface(Object *object, NodesModifierData *nmd)
}
static void initialize_group_input(NodesModifierData &nmd,
- const OutputSocketRef &socket,
+ const bNodeSocket &socket,
void *r_value)
{
- const bNodeSocketType &socket_type = *socket.typeinfo();
- const bNodeSocket &bsocket = *socket.bsocket();
+ const bNodeSocketType &socket_type = *socket.typeinfo;
+ const bNodeSocket &bsocket = socket;
const eNodeSocketDatatype socket_data_type = static_cast<eNodeSocketDatatype>(bsocket.type);
if (nmd.settings.properties == nullptr) {
socket_type.get_geometry_nodes_cpp_value(bsocket, r_value);
return;
}
const IDProperty *property = IDP_GetPropertyFromGroup(nmd.settings.properties,
- socket.identifier().c_str());
+ socket.identifier);
if (property == nullptr) {
socket_type.get_geometry_nodes_cpp_value(bsocket, r_value);
return;
@@ -776,15 +777,15 @@ static void initialize_group_input(NodesModifierData &nmd,
return;
}
- if (!input_has_attribute_toggle(*nmd.node_group, socket.index())) {
+ if (!input_has_attribute_toggle(*nmd.node_group, socket.runtime->index_in_node)) {
init_socket_cpp_value_from_property(*property, socket_data_type, r_value);
return;
}
const IDProperty *property_use_attribute = IDP_GetPropertyFromGroup(
- nmd.settings.properties, (socket.identifier() + use_attribute_suffix).c_str());
+ nmd.settings.properties, (socket.identifier + use_attribute_suffix).c_str());
const IDProperty *property_attribute_name = IDP_GetPropertyFromGroup(
- nmd.settings.properties, (socket.identifier() + attribute_name_suffix).c_str());
+ nmd.settings.properties, (socket.identifier + attribute_name_suffix).c_str());
if (property_use_attribute == nullptr || property_attribute_name == nullptr) {
init_socket_cpp_value_from_property(*property, socket_data_type, r_value);
return;
@@ -866,11 +867,11 @@ static void find_sockets_to_preview_for_spreadsheet(SpaceSpreadsheet *sspreadshe
const DTreeContext *context = &tree.root_context();
for (SpreadsheetContextNode *node_context : nested_group_contexts) {
- const NodeTreeRef &tree_ref = context->tree();
- const NodeRef *found_node = nullptr;
- for (const NodeRef *node_ref : tree_ref.nodes()) {
- if (node_ref->name() == node_context->node_name) {
- found_node = node_ref;
+ const bNodeTree &btree = context->btree();
+ const bNode *found_node = nullptr;
+ for (const bNode *bnode : btree.all_nodes()) {
+ if (STREQ(bnode->name, node_context->node_name)) {
+ found_node = bnode;
break;
}
}
@@ -883,11 +884,11 @@ static void find_sockets_to_preview_for_spreadsheet(SpaceSpreadsheet *sspreadshe
}
}
- const NodeTreeRef &tree_ref = context->tree();
- for (const NodeRef *node_ref : tree_ref.nodes_by_type("GeometryNodeViewer")) {
- if (node_ref->name() == last_context->node_name) {
- const DNode viewer_node{context, node_ref};
- for (const InputSocketRef *input_socket : node_ref->inputs()) {
+ const bNodeTree &btree = context->btree();
+ for (const bNode *bnode : btree.nodes_by_type("GeometryNodeViewer")) {
+ if (STREQ(bnode->name, last_context->node_name)) {
+ const DNode viewer_node{context, bnode};
+ for (const bNodeSocket *input_socket : bnode->input_sockets()) {
if (input_socket->is_available() && input_socket->is_logically_linked()) {
r_sockets_to_preview.add(DSocket{context, input_socket});
}
@@ -936,15 +937,15 @@ struct OutputAttributeToStore {
* can be evaluated together.
*/
static MultiValueMap<eAttrDomain, OutputAttributeInfo> find_output_attributes_to_store(
- const NodesModifierData &nmd, const NodeRef &output_node, Span<GMutablePointer> output_values)
+ const NodesModifierData &nmd, const bNode &output_node, Span<GMutablePointer> output_values)
{
MultiValueMap<eAttrDomain, OutputAttributeInfo> outputs_by_domain;
- for (const InputSocketRef *socket : output_node.inputs().drop_front(1).drop_back(1)) {
- if (!socket_type_has_attribute_toggle(*socket->bsocket())) {
+ for (const bNodeSocket *socket : output_node.input_sockets().drop_front(1).drop_back(1)) {
+ if (!socket_type_has_attribute_toggle(*socket)) {
continue;
}
- const std::string prop_name = socket->identifier() + attribute_name_suffix;
+ const std::string prop_name = socket->identifier + attribute_name_suffix;
const IDProperty *prop = IDP_GetPropertyFromGroup(nmd.settings.properties, prop_name.c_str());
if (prop == nullptr) {
continue;
@@ -964,7 +965,7 @@ static MultiValueMap<eAttrDomain, OutputAttributeInfo> find_output_attributes_to
const GField field = cpp_type->as_field(value.get());
const bNodeSocket *interface_socket = (const bNodeSocket *)BLI_findlink(
- &nmd.node_group->outputs, socket->index());
+ &nmd.node_group->outputs, index);
const eAttrDomain domain = (eAttrDomain)interface_socket->attribute_domain;
OutputAttributeInfo output_info;
output_info.field = std::move(field);
@@ -1044,7 +1045,7 @@ static void store_computed_output_attributes(
if (attributes.add(store.name,
store.domain,
blender::bke::cpp_type_to_custom_data_type(store.data.type()),
- blender::bke::AttributeInitMove(store.data.data()))) {
+ blender::bke::AttributeInitMoveArray(store.data.data()))) {
continue;
}
@@ -1063,7 +1064,7 @@ static void store_computed_output_attributes(
static void store_output_attributes(GeometrySet &geometry,
const NodesModifierData &nmd,
- const NodeRef &output_node,
+ const bNode &output_node,
Span<GMutablePointer> output_values)
{
/* All new attribute values have to be computed before the geometry is actually changed. This is
@@ -1079,8 +1080,8 @@ static void store_output_attributes(GeometrySet &geometry,
* Evaluate a node group to compute the output geometry.
*/
static GeometrySet compute_geometry(const DerivedNodeTree &tree,
- Span<const NodeRef *> group_input_nodes,
- const NodeRef &output_node,
+ Span<const bNode *> group_input_nodes,
+ const bNode &output_node,
GeometrySet input_geometry_set,
NodesModifierData *nmd,
const ModifierEvalContext *ctx)
@@ -1092,18 +1093,19 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree,
Map<DOutputSocket, GMutablePointer> group_inputs;
const DTreeContext *root_context = &tree.root_context();
- for (const NodeRef *group_input_node : group_input_nodes) {
- Span<const OutputSocketRef *> group_input_sockets = group_input_node->outputs().drop_back(1);
+ for (const bNode *group_input_node : group_input_nodes) {
+ Span<const bNodeSocket *> group_input_sockets = group_input_node->output_sockets().drop_back(
+ 1);
if (group_input_sockets.is_empty()) {
continue;
}
- Span<const OutputSocketRef *> remaining_input_sockets = group_input_sockets;
+ Span<const bNodeSocket *> remaining_input_sockets = group_input_sockets;
/* If the group expects a geometry as first input, use the geometry that has been passed to
* modifier. */
- const OutputSocketRef *first_input_socket = group_input_sockets[0];
- if (first_input_socket->bsocket()->type == SOCK_GEOMETRY) {
+ const bNodeSocket *first_input_socket = group_input_sockets[0];
+ if (first_input_socket->type == SOCK_GEOMETRY) {
GeometrySet *geometry_set_in =
allocator.construct<GeometrySet>(input_geometry_set).release();
group_inputs.add_new({root_context, first_input_socket}, geometry_set_in);
@@ -1111,8 +1113,8 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree,
}
/* Initialize remaining group inputs. */
- for (const OutputSocketRef *socket : remaining_input_sockets) {
- const CPPType &cpp_type = *socket->typeinfo()->geometry_nodes_cpp_type;
+ for (const bNodeSocket *socket : remaining_input_sockets) {
+ const CPPType &cpp_type = *socket->typeinfo->geometry_nodes_cpp_type;
void *value_in = allocator.allocate(cpp_type.size(), cpp_type.alignment());
initialize_group_input(*nmd, *socket, value_in);
group_inputs.add_new({root_context, socket}, {cpp_type, value_in});
@@ -1120,7 +1122,7 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree,
}
Vector<DInputSocket> group_outputs;
- for (const InputSocketRef *socket_ref : output_node.inputs().drop_back(1)) {
+ for (const bNodeSocket *socket_ref : output_node.input_sockets().drop_back(1)) {
group_outputs.append({root_context, socket_ref});
}
@@ -1225,8 +1227,8 @@ static void modifyGeometry(ModifierData *md,
check_property_socket_sync(ctx->object, md);
- NodeTreeRefMap tree_refs;
- DerivedNodeTree tree{*nmd->node_group, tree_refs};
+ const bNodeTree &root_tree_ref = *nmd->node_group;
+ DerivedNodeTree tree{root_tree_ref};
if (tree.has_link_cycles()) {
BKE_modifier_set_error(ctx->object, md, "Node group has cycles");
@@ -1234,25 +1236,24 @@ static void modifyGeometry(ModifierData *md,
return;
}
- const NodeTreeRef &root_tree_ref = tree.root_context().tree();
- Span<const NodeRef *> input_nodes = root_tree_ref.nodes_by_type("NodeGroupInput");
- Span<const NodeRef *> output_nodes = root_tree_ref.nodes_by_type("NodeGroupOutput");
+ Span<const bNode *> input_nodes = root_tree_ref.nodes_by_type("NodeGroupInput");
+ Span<const bNode *> output_nodes = root_tree_ref.nodes_by_type("NodeGroupOutput");
if (output_nodes.size() != 1) {
BKE_modifier_set_error(ctx->object, md, "Node group must have a single output node");
geometry_set.clear();
return;
}
- const NodeRef &output_node = *output_nodes[0];
- Span<const InputSocketRef *> group_outputs = output_node.inputs().drop_back(1);
+ const bNode &output_node = *output_nodes[0];
+ Span<const bNodeSocket *> group_outputs = output_node.input_sockets().drop_back(1);
if (group_outputs.is_empty()) {
BKE_modifier_set_error(ctx->object, md, "Node group must have an output socket");
geometry_set.clear();
return;
}
- const InputSocketRef *first_output_socket = group_outputs[0];
- if (first_output_socket->idname() != "NodeSocketGeometry") {
+ const bNodeSocket *first_output_socket = group_outputs[0];
+ if (!STREQ(first_output_socket->idname, "NodeSocketGeometry")) {
BKE_modifier_set_error(ctx->object, md, "Node group's first output must be a geometry");
geometry_set.clear();
return;
@@ -1277,13 +1278,13 @@ static void modifyGeometry(ModifierData *md,
* assumed that the output mesh does not have a mapping to the original mesh. */
Mesh &mesh = *geometry_set.get_mesh_for_write();
if (use_orig_index_verts) {
- CustomData_add_layer(&mesh.vdata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totvert);
+ CustomData_add_layer(&mesh.vdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh.totvert);
}
if (use_orig_index_edges) {
- CustomData_add_layer(&mesh.edata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totedge);
+ CustomData_add_layer(&mesh.edata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh.totedge);
}
if (use_orig_index_polys) {
- CustomData_add_layer(&mesh.pdata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totpoly);
+ CustomData_add_layer(&mesh.pdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh.totpoly);
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
index 5cf4e21ea68..dd7c87ca499 100644
--- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
+++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
@@ -2,6 +2,7 @@
#include "MOD_nodes_evaluator.hh"
+#include "BKE_node.h"
#include "BKE_type_conversions.hh"
#include "NOD_geometry_exec.hh"
@@ -319,9 +320,9 @@ class LockedNode : NonCopyable, NonMovable {
}
};
-static const CPPType *get_socket_cpp_type(const SocketRef &socket)
+static const CPPType *get_socket_cpp_type(const bNodeSocket &socket)
{
- const bNodeSocketType *typeinfo = socket.typeinfo();
+ const bNodeSocketType *typeinfo = socket.typeinfo;
if (typeinfo->geometry_nodes_cpp_type == nullptr) {
return nullptr;
}
@@ -338,24 +339,24 @@ static const CPPType *get_socket_cpp_type(const SocketRef &socket)
static const CPPType *get_socket_cpp_type(const DSocket socket)
{
- return get_socket_cpp_type(*socket.socket_ref());
+ return get_socket_cpp_type(*socket);
}
/**
* \note This is not supposed to be a long term solution. Eventually we want that nodes can
* specify more complex defaults (other than just single values) in their socket declarations.
*/
-static bool get_implicit_socket_input(const SocketRef &socket, void *r_value)
+static bool get_implicit_socket_input(const bNodeSocket &socket, void *r_value)
{
- const NodeRef &node = socket.node();
- const nodes::NodeDeclaration *node_declaration = node.declaration();
+ const bNode &node = socket.owner_node();
+ const nodes::NodeDeclaration *node_declaration = node.runtime->declaration;
if (node_declaration == nullptr) {
return false;
}
const nodes::SocketDeclaration &socket_declaration = *node_declaration->inputs()[socket.index()];
if (socket_declaration.input_field_type() == nodes::InputSocketFieldType::Implicit) {
- const bNode &bnode = *socket.bnode();
- if (socket.typeinfo()->type == SOCK_VECTOR) {
+ const bNode &bnode = socket.owner_node();
+ if (socket.typeinfo->type == SOCK_VECTOR) {
if (bnode.type == GEO_NODE_SET_CURVE_HANDLES) {
StringRef side = ((NodeGeometrySetCurveHandlePositions *)bnode.storage)->mode ==
GEO_NODE_CURVE_HANDLE_LEFT ?
@@ -372,7 +373,7 @@ static bool get_implicit_socket_input(const SocketRef &socket, void *r_value)
new (r_value) ValueOrField<float3>(bke::AttributeFieldInput::Create<float3>("position"));
return true;
}
- if (socket.typeinfo()->type == SOCK_INT) {
+ if (socket.typeinfo->type == SOCK_INT) {
if (ELEM(bnode.type, FN_NODE_RANDOM_VALUE, GEO_NODE_INSTANCE_ON_POINTS)) {
new (r_value)
ValueOrField<int>(Field<int>(std::make_shared<bke::IDAttributeFieldInput>()));
@@ -385,19 +386,19 @@ static bool get_implicit_socket_input(const SocketRef &socket, void *r_value)
return false;
}
-static void get_socket_value(const SocketRef &socket, void *r_value)
+static void get_socket_value(const bNodeSocket &socket, void *r_value)
{
if (get_implicit_socket_input(socket, r_value)) {
return;
}
- const bNodeSocketType *typeinfo = socket.typeinfo();
- typeinfo->get_geometry_nodes_cpp_value(*socket.bsocket(), r_value);
+ const bNodeSocketType *typeinfo = socket.typeinfo;
+ typeinfo->get_geometry_nodes_cpp_value(socket, r_value);
}
static bool node_supports_laziness(const DNode node)
{
- return node->typeinfo()->geometry_node_execute_supports_laziness;
+ return node->typeinfo->geometry_node_execute_supports_laziness;
}
struct NodeTaskRunState {
@@ -516,9 +517,9 @@ class GeometryNodesEvaluator {
node_states_.add_new({node, &node_state});
/* Push all linked origins on the stack. */
- for (const InputSocketRef *input_ref : node->inputs()) {
- const DInputSocket input{node.context(), input_ref};
- input.foreach_origin_socket(
+ for (const bNodeSocket *input : node->input_sockets()) {
+ const DInputSocket dinput{node.context(), input};
+ dinput.foreach_origin_socket(
[&](const DSocket origin) { nodes_to_check.push(origin.node()); });
}
}
@@ -546,11 +547,11 @@ class GeometryNodesEvaluator {
void initialize_node_state(const DNode node, NodeState &node_state, LinearAllocator<> &allocator)
{
/* Construct arrays of the correct size. */
- node_state.inputs = allocator.construct_array<InputState>(node->inputs().size());
- node_state.outputs = allocator.construct_array<OutputState>(node->outputs().size());
+ node_state.inputs = allocator.construct_array<InputState>(node->input_sockets().size());
+ node_state.outputs = allocator.construct_array<OutputState>(node->output_sockets().size());
/* Initialize input states. */
- for (const int i : node->inputs().index_range()) {
+ for (const int i : node->input_sockets().index_range()) {
InputState &input_state = node_state.inputs[i];
const DInputSocket socket = node.input(i);
if (!socket->is_available()) {
@@ -567,7 +568,7 @@ class GeometryNodesEvaluator {
continue;
}
/* Construct the correct struct that can hold the input(s). */
- if (socket->is_multi_input_socket()) {
+ if (socket->is_multi_input()) {
input_state.value.multi = allocator.construct<MultiInputValue>().release();
MultiInputValue &multi_value = *input_state.value.multi;
/* Count how many values should be added until the socket is complete. */
@@ -583,7 +584,7 @@ class GeometryNodesEvaluator {
}
}
/* Initialize output states. */
- for (const int i : node->outputs().index_range()) {
+ for (const int i : node->output_sockets().index_range()) {
OutputState &output_state = node_state.outputs[i];
const DOutputSocket socket = node.output(i);
if (!socket->is_available()) {
@@ -629,13 +630,13 @@ class GeometryNodesEvaluator {
void destruct_node_state(const DNode node, NodeState &node_state)
{
/* Need to destruct stuff manually, because it's allocated by a custom allocator. */
- for (const int i : node->inputs().index_range()) {
+ for (const int i : node->input_sockets().index_range()) {
InputState &input_state = node_state.inputs[i];
if (input_state.type == nullptr) {
continue;
}
- const InputSocketRef &socket_ref = node->input(i);
- if (socket_ref.is_multi_input_socket()) {
+ const bNodeSocket &bsocket = node->input_socket(i);
+ if (bsocket.is_multi_input()) {
MultiInputValue &multi_value = *input_state.value.multi;
for (void *value : multi_value.values) {
if (value != nullptr) {
@@ -756,7 +757,7 @@ class GeometryNodesEvaluator {
{
/* These nodes are sometimes scheduled. We could also check for them in other places, but
* it's the easiest to do it here. */
- if (node->is_group_input_node() || node->is_group_output_node()) {
+ if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
return;
}
@@ -837,7 +838,7 @@ class GeometryNodesEvaluator {
/* If there are no remaining outputs, all the inputs can be destructed and/or can become
* unused. This can also trigger a chain reaction where nodes to the left become finished
* too. */
- for (const int i : locked_node.node->inputs().index_range()) {
+ for (const int i : locked_node.node->input_sockets().index_range()) {
const DInputSocket socket = locked_node.node.input(i);
InputState &input_state = locked_node.node_state.inputs[i];
if (input_state.usage == ValueUsage::Maybe) {
@@ -883,7 +884,7 @@ class GeometryNodesEvaluator {
return;
}
/* Nodes that don't support laziness require all inputs. */
- for (const int i : locked_node.node->inputs().index_range()) {
+ for (const int i : locked_node.node->input_sockets().index_range()) {
InputState &input_state = locked_node.node_state.inputs[i];
if (input_state.type == nullptr) {
/* Ignore unavailable/non-data sockets. */
@@ -915,7 +916,7 @@ class GeometryNodesEvaluator {
continue;
}
- if (socket->is_multi_input_socket()) {
+ if (socket->is_multi_input()) {
MultiInputValue &multi_value = *input_state.value.multi;
/* Checks if all the linked sockets have been provided already. */
if (multi_value.all_values_available()) {
@@ -949,7 +950,7 @@ class GeometryNodesEvaluator {
*/
void execute_node(const DNode node, NodeState &node_state, NodeTaskRunState *run_state)
{
- const bNode &bnode = *node->bnode();
+ const bNode &bnode = *node;
if (node_state.has_been_executed) {
if (!node_supports_laziness(node)) {
@@ -978,7 +979,7 @@ class GeometryNodesEvaluator {
void execute_geometry_node(const DNode node, NodeState &node_state, NodeTaskRunState *run_state)
{
using Clock = std::chrono::steady_clock;
- const bNode &bnode = *node->bnode();
+ const bNode &bnode = *node;
NodeParamsProvider params_provider{*this, node, node_state, run_state};
GeoNodeExecParams params{params_provider};
@@ -1002,12 +1003,12 @@ class GeometryNodesEvaluator {
bool any_input_is_field = false;
Vector<const void *, 16> input_values;
Vector<const ValueOrFieldCPPType *, 16> input_types;
- for (const int i : node->inputs().index_range()) {
- const InputSocketRef &socket_ref = node->input(i);
- if (!socket_ref.is_available()) {
+ for (const int i : node->input_sockets().index_range()) {
+ const bNodeSocket &bsocket = node->input_socket(i);
+ if (!bsocket.is_available()) {
continue;
}
- BLI_assert(!socket_ref.is_multi_input_socket());
+ BLI_assert(!bsocket.is_multi_input());
InputState &input_state = node_state.inputs[i];
BLI_assert(input_state.was_ready_for_execution);
SingleInputValue &single_value = *input_state.value.single;
@@ -1055,15 +1056,15 @@ class GeometryNodesEvaluator {
}
int output_index = 0;
- for (const int i : node->outputs().index_range()) {
- const OutputSocketRef &socket_ref = node->output(i);
- if (!socket_ref.is_available()) {
+ for (const int i : node->output_sockets().index_range()) {
+ const bNodeSocket &bsocket = node->output_socket(i);
+ if (!bsocket.is_available()) {
continue;
}
OutputState &output_state = node_state.outputs[i];
- const DOutputSocket socket{node.context(), &socket_ref};
+ const DOutputSocket socket{node.context(), &bsocket};
const ValueOrFieldCPPType *cpp_type = static_cast<const ValueOrFieldCPPType *>(
- get_socket_cpp_type(socket_ref));
+ get_socket_cpp_type(bsocket));
GField new_field{operation, output_index};
void *buffer = allocator.allocate(cpp_type->size(), cpp_type->alignment());
cpp_type->construct_from_field(buffer, std::move(new_field));
@@ -1091,7 +1092,7 @@ class GeometryNodesEvaluator {
}
Vector<GMutablePointer, 16> output_buffers;
- for (const int i : node->outputs().index_range()) {
+ for (const int i : node->output_sockets().index_range()) {
const DOutputSocket socket = node.output(i);
if (!socket->is_available()) {
output_buffers.append({});
@@ -1128,7 +1129,7 @@ class GeometryNodesEvaluator {
void execute_unknown_node(const DNode node, NodeState &node_state, NodeTaskRunState *run_state)
{
LinearAllocator<> &allocator = local_allocators_.local();
- for (const OutputSocketRef *socket : node->outputs()) {
+ for (const bNodeSocket *socket : node->output_sockets()) {
if (!socket->is_available()) {
continue;
}
@@ -1182,8 +1183,8 @@ class GeometryNodesEvaluator {
const bool supports_laziness = node_supports_laziness(locked_node.node);
/* Iterating over sockets instead of the states directly, because that makes it easier to
* figure out which socket is missing when one of the asserts is hit. */
- for (const OutputSocketRef *socket_ref : locked_node.node->outputs()) {
- OutputState &output_state = locked_node.node_state.outputs[socket_ref->index()];
+ for (const bNodeSocket *bsocket : locked_node.node->output_sockets()) {
+ OutputState &output_state = locked_node.node_state.outputs[bsocket->index()];
if (supports_laziness) {
/* Expected that at least all required sockets have been computed. If more outputs become
* required later, the node will be executed again. */
@@ -1208,7 +1209,7 @@ class GeometryNodesEvaluator {
{
for (const DInputSocket &socket : params_.output_sockets) {
BLI_assert(socket->is_available());
- BLI_assert(!socket->is_multi_input_socket());
+ BLI_assert(!socket->is_multi_input());
const DNode node = socket.node();
NodeState &node_state = this->get_node_state(node);
@@ -1255,7 +1256,7 @@ class GeometryNodesEvaluator {
/* Count how many values still have to be added to this input until it is "complete". */
int missing_values = 0;
- if (input_socket->is_multi_input_socket()) {
+ if (input_socket->is_multi_input()) {
MultiInputValue &multi_value = *input_state.value.multi;
missing_values = multi_value.missing_values();
}
@@ -1402,52 +1403,51 @@ class GeometryNodesEvaluator {
Vector<DInputSocket> forward_original_value_sockets;
log_original_value_sockets.append(from_socket);
- from_socket.foreach_target_socket(
- [&](const DInputSocket to_socket, const DOutputSocket::TargetSocketPathInfo &path_info) {
- if (!this->should_forward_to_socket(to_socket)) {
- return;
- }
- BLI_assert(to_socket == path_info.sockets.last());
- GMutablePointer current_value = value_to_forward;
- for (const DSocket &next_socket : path_info.sockets) {
- const DNode next_node = next_socket.node();
- const bool is_last_socket = to_socket == next_socket;
- const bool do_conversion_if_necessary = is_last_socket ||
- next_node->is_group_output_node() ||
- (next_node->is_group_node() &&
- !next_node->is_muted());
- if (do_conversion_if_necessary) {
- const CPPType &next_type = *get_socket_cpp_type(next_socket);
- if (*current_value.type() != next_type) {
- void *buffer = allocator.allocate(next_type.size(), next_type.alignment());
- this->convert_value(*current_value.type(), next_type, current_value.get(), buffer);
- if (current_value.get() != value_to_forward.get()) {
- current_value.destruct();
- }
- current_value = {next_type, buffer};
- }
- }
- if (current_value.get() == value_to_forward.get()) {
- /* Log the original value at the current socket. */
- log_original_value_sockets.append(next_socket);
- }
- else {
- /* Multi-input sockets are logged when all values are available. */
- if (!(next_socket->is_input() && next_socket->as_input().is_multi_input_socket())) {
- /* Log the converted value at the socket. */
- this->log_socket_value({next_socket}, current_value);
- }
+ from_socket.foreach_target_socket([&](const DInputSocket to_socket,
+ const DOutputSocket::TargetSocketPathInfo &path_info) {
+ if (!this->should_forward_to_socket(to_socket)) {
+ return;
+ }
+ BLI_assert(to_socket == path_info.sockets.last());
+ GMutablePointer current_value = value_to_forward;
+ for (const DSocket &next_socket : path_info.sockets) {
+ const DNode next_node = next_socket.node();
+ const bool is_last_socket = to_socket == next_socket;
+ const bool do_conversion_if_necessary = is_last_socket ||
+ next_node->type == NODE_GROUP_OUTPUT ||
+ (next_node->is_group() && !next_node->is_muted());
+ if (do_conversion_if_necessary) {
+ const CPPType &next_type = *get_socket_cpp_type(next_socket);
+ if (*current_value.type() != next_type) {
+ void *buffer = allocator.allocate(next_type.size(), next_type.alignment());
+ this->convert_value(*current_value.type(), next_type, current_value.get(), buffer);
+ if (current_value.get() != value_to_forward.get()) {
+ current_value.destruct();
}
+ current_value = {next_type, buffer};
}
- if (current_value.get() == value_to_forward.get()) {
- /* The value has not been converted, so forward the original value. */
- forward_original_value_sockets.append(to_socket);
- }
- else {
- /* The value has been converted. */
- this->add_value_to_input_socket(to_socket, from_socket, current_value, run_state);
+ }
+ if (current_value.get() == value_to_forward.get()) {
+ /* Log the original value at the current socket. */
+ log_original_value_sockets.append(next_socket);
+ }
+ else {
+ /* Multi-input sockets are logged when all values are available. */
+ if (!(next_socket->is_input() && next_socket->is_multi_input())) {
+ /* Log the converted value at the socket. */
+ this->log_socket_value({next_socket}, current_value);
}
- });
+ }
+ }
+ if (current_value.get() == value_to_forward.get()) {
+ /* The value has not been converted, so forward the original value. */
+ forward_original_value_sockets.append(to_socket);
+ }
+ else {
+ /* The value has been converted. */
+ this->add_value_to_input_socket(to_socket, from_socket, current_value, run_state);
+ }
+ });
this->log_socket_value(log_original_value_sockets, value_to_forward);
this->forward_to_sockets_with_same_type(
allocator, forward_original_value_sockets, value_to_forward, from_socket, run_state);
@@ -1512,7 +1512,7 @@ class GeometryNodesEvaluator {
InputState &input_state = node_state.inputs[socket->index()];
this->with_locked_node(node, node_state, run_state, [&](LockedNode &locked_node) {
- if (socket->is_multi_input_socket()) {
+ if (socket->is_multi_input()) {
/* Add a new value to the multi-input. */
MultiInputValue &multi_value = *input_state.value.multi;
multi_value.add_value(origin, value.get());
@@ -1555,7 +1555,7 @@ class GeometryNodesEvaluator {
UNUSED_VARS(locked_node);
GMutablePointer value = this->get_value_from_socket(origin_socket, *input_state.type);
- if (input_socket->is_multi_input_socket()) {
+ if (input_socket->is_multi_input()) {
MultiInputValue &multi_value = *input_state.value.multi;
multi_value.add_value(origin_socket, value.get());
if (multi_value.all_values_available()) {
@@ -1580,7 +1580,7 @@ class GeometryNodesEvaluator {
void destruct_input_value_if_exists(LockedNode &locked_node, const DInputSocket socket)
{
InputState &input_state = locked_node.node_state.inputs[socket->index()];
- if (socket->is_multi_input_socket()) {
+ if (socket->is_multi_input()) {
MultiInputValue &multi_value = *input_state.value.multi;
for (void *&value : multi_value.values) {
if (value != nullptr) {
@@ -1605,7 +1605,7 @@ class GeometryNodesEvaluator {
const CPPType &type = *get_socket_cpp_type(socket);
void *buffer = allocator.allocate(type.size(), type.alignment());
- get_socket_value(*socket.socket_ref(), buffer);
+ get_socket_value(*socket.bsocket(), buffer);
if (type == required_type) {
return {type, buffer};
@@ -1762,7 +1762,7 @@ bool NodeParamsProvider::can_get_input(StringRef identifier) const
return false;
}
- if (socket->is_multi_input_socket()) {
+ if (socket->is_multi_input()) {
MultiInputValue &multi_value = *input_state.value.multi;
return multi_value.all_values_available();
}
@@ -1783,7 +1783,7 @@ GMutablePointer NodeParamsProvider::extract_input(StringRef identifier)
{
const DInputSocket socket = this->dnode.input_by_identifier(identifier);
BLI_assert(socket);
- BLI_assert(!socket->is_multi_input_socket());
+ BLI_assert(!socket->is_multi_input());
BLI_assert(this->can_get_input(identifier));
InputState &input_state = node_state_.inputs[socket->index()];
@@ -1797,7 +1797,7 @@ Vector<GMutablePointer> NodeParamsProvider::extract_multi_input(StringRef identi
{
const DInputSocket socket = this->dnode.input_by_identifier(identifier);
BLI_assert(socket);
- BLI_assert(socket->is_multi_input_socket());
+ BLI_assert(socket->is_multi_input());
BLI_assert(this->can_get_input(identifier));
InputState &input_state = node_state_.inputs[socket->index()];
@@ -1816,7 +1816,7 @@ GPointer NodeParamsProvider::get_input(StringRef identifier) const
{
const DInputSocket socket = this->dnode.input_by_identifier(identifier);
BLI_assert(socket);
- BLI_assert(!socket->is_multi_input_socket());
+ BLI_assert(!socket->is_multi_input());
BLI_assert(this->can_get_input(identifier));
InputState &input_state = node_state_.inputs[socket->index()];
@@ -1901,7 +1901,7 @@ void NodeParamsProvider::set_default_remaining_outputs()
{
LinearAllocator<> &allocator = evaluator_.local_allocators_.local();
- for (const int i : this->dnode->outputs().index_range()) {
+ for (const int i : this->dnode->output_sockets().index_range()) {
OutputState &output_state = node_state_.outputs[i];
if (output_state.has_been_computed) {
continue;
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 5a92aac6cda..9e3e06fb4dc 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -562,7 +562,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
}
if (clnors == NULL) {
- clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, loops_num);
+ clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, loops_num);
}
MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index);
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index ea9049200cc..c84d1b56cec 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -292,7 +292,7 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co
/* add uvs */
if (CustomData_number_of_layers(&result->ldata, CD_MLOOPUV) < MAX_MTFACE) {
gogd.mloopuvs = CustomData_add_layer(
- &result->ldata, CD_MLOOPUV, CD_CALLOC, NULL, polys_num * 4);
+ &result->ldata, CD_MLOOPUV, CD_SET_DEFAULT, NULL, polys_num * 4);
if (gogd.mloopuvs) { /* unlikely to fail */
gogd.ix = 1.0 / gogd.rx;
@@ -378,12 +378,16 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
const int loops_num = result->totloop;
MLoop *mloops = result->mloop;
MLoopCol *mloopcols = CustomData_add_layer_named(
- &result->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, NULL, loops_num, omd->foamlayername);
+ &result->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, NULL, loops_num, omd->foamlayername);
MLoopCol *mloopcols_spray = NULL;
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
- mloopcols_spray = CustomData_add_layer_named(
- &result->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, NULL, loops_num, omd->spraylayername);
+ mloopcols_spray = CustomData_add_layer_named(&result->ldata,
+ CD_PROP_BYTE_COLOR,
+ CD_SET_DEFAULT,
+ NULL,
+ loops_num,
+ omd->spraylayername);
}
if (mloopcols) { /* unlikely to fail */
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 3d6a8e27b08..d8b11c0e89e 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -398,7 +398,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
medge_new = result->medge;
if (!CustomData_has_layer(&result->pdata, CD_ORIGINDEX)) {
- CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, (int)maxPolys);
+ CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, NULL, (int)maxPolys);
}
int *origindex = CustomData_get_layer(&result->pdata, CD_ORIGINDEX);
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 84795cdb2d9..982f5802df6 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1888,7 +1888,7 @@ static void skin_set_orig_indices(Mesh *mesh)
int *orig, totpoly;
totpoly = mesh->totpoly;
- orig = CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, totpoly);
+ orig = CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CONSTRUCT, NULL, totpoly);
copy_vn_i(orig, totpoly, ORIGINDEX_NONE);
}
diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index 53c6ee9a1a8..aa8c49ee0b8 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -996,7 +996,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
if (dvert == NULL) {
/* Add a valid data layer! */
dvert = CustomData_add_layer(
- &result->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, result->totvert);
+ &result->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, result->totvert);
}
/* Ultimate security check. */
if (dvert != NULL) {
diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 64a00478ce8..29adbd70198 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -1981,7 +1981,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
if (dvert == NULL) {
/* Add a valid data layer! */
dvert = CustomData_add_layer(
- &result->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, result->totvert);
+ &result->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, result->totvert);
}
result->dvert = dvert;
}
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 4646ba41a74..ccef867b752 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -124,7 +124,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
* (e.g. if a preceding modifier could not preserve it). */
if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, mesh->totloop, umd->uvlayer_name);
+ &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, NULL, mesh->totloop, umd->uvlayer_name);
}
/* make sure we're using an existing layer */
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 039497b725b..5b5d464a710 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -609,7 +609,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
* it helps when generating clnor spaces and default normals. */
const bool has_clnors = clnors != NULL;
if (!clnors) {
- clnors = CustomData_add_layer(&result->ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, loops_num);
+ clnors = CustomData_add_layer(
+ &result->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, loops_num);
}
MDeformVert *dvert;
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 2a509ddf220..d71813c7dd5 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -203,7 +203,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
else {
/* Add a valid data layer! */
- dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, verts_num);
+ dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, verts_num);
}
/* Ultimate security check. */
if (!dvert) {
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index aa648eaec97..1d38333f15b 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -268,7 +268,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
else {
/* Add a valid data layer! */
- dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, verts_num);
+ dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, verts_num);
}
/* Ultimate security check. */
if (!dvert) {