Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_nodes.cc
| Show First 20 Lines • Show All 622 Lines • ▼ Show 20 Lines | default: { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void MOD_nodes_update_interface(Object *object, NodesModifierData *nmd) | void MOD_nodes_update_interface(Object *object, NodesModifierData *nmd) | ||||
| { | { | ||||
| if (nmd->node_group == nullptr) { | if (nmd->node_group == nullptr) { | ||||
| if (nmd->settings.properties) { | |||||
| IDP_FreeProperty(nmd->settings.properties); | |||||
| nmd->settings.properties = nullptr; | |||||
| } | |||||
| return; | return; | ||||
| } | } | ||||
| IDProperty *old_properties = nmd->settings.properties; | IDProperty *old_properties = nmd->settings.properties; | ||||
| { | { | ||||
| IDPropertyTemplate idprop = {0}; | IDPropertyTemplate idprop = {0}; | ||||
| nmd->settings.properties = IDP_New(IDP_GROUP, &idprop, "Nodes Modifier Settings"); | nmd->settings.properties = IDP_New(IDP_GROUP, &idprop, "Nodes Modifier Settings"); | ||||
| } | } | ||||
| Show All 36 Lines | if (socket_type_has_attribute_toggle(*socket)) { | ||||
| IDPropertyTemplate idprop = {0}; | IDPropertyTemplate idprop = {0}; | ||||
| IDProperty *use_attribute_prop = IDP_New(IDP_INT, &idprop, use_attribute_id.c_str()); | IDProperty *use_attribute_prop = IDP_New(IDP_INT, &idprop, use_attribute_id.c_str()); | ||||
| IDP_AddToGroup(nmd->settings.properties, use_attribute_prop); | IDP_AddToGroup(nmd->settings.properties, use_attribute_prop); | ||||
| IDProperty *attribute_prop = IDP_New(IDP_STRING, &idprop, attribute_name_id.c_str()); | IDProperty *attribute_prop = IDP_New(IDP_STRING, &idprop, attribute_name_id.c_str()); | ||||
| IDP_AddToGroup(nmd->settings.properties, attribute_prop); | IDP_AddToGroup(nmd->settings.properties, attribute_prop); | ||||
| if (old_properties != nullptr) { | if (old_properties == nullptr) { | ||||
| if (socket->default_attribute_name && socket->default_attribute_name[0] != '\0') { | |||||
| IDP_AssignString(attribute_prop, socket->default_attribute_name, MAX_NAME); | |||||
| IDP_Int(use_attribute_prop) = 1; | |||||
| } | |||||
| } | |||||
| else { | |||||
| IDProperty *old_prop_use_attribute = IDP_GetPropertyFromGroup(old_properties, | IDProperty *old_prop_use_attribute = IDP_GetPropertyFromGroup(old_properties, | ||||
| use_attribute_id.c_str()); | use_attribute_id.c_str()); | ||||
| if (old_prop_use_attribute != nullptr) { | if (old_prop_use_attribute != nullptr) { | ||||
| IDP_CopyPropertyContent(use_attribute_prop, old_prop_use_attribute); | IDP_CopyPropertyContent(use_attribute_prop, old_prop_use_attribute); | ||||
| } | } | ||||
| IDProperty *old_attribute_name_prop = IDP_GetPropertyFromGroup(old_properties, | IDProperty *old_attribute_name_prop = IDP_GetPropertyFromGroup(old_properties, | ||||
| attribute_name_id.c_str()); | attribute_name_id.c_str()); | ||||
| Show All 12 Lines | LISTBASE_FOREACH (bNodeSocket *, socket, &nmd->node_group->outputs) { | ||||
| const std::string idprop_name = socket->identifier + attribute_name_suffix; | const std::string idprop_name = socket->identifier + attribute_name_suffix; | ||||
| IDProperty *new_prop = IDP_NewString("", idprop_name.c_str(), MAX_NAME); | IDProperty *new_prop = IDP_NewString("", idprop_name.c_str(), MAX_NAME); | ||||
| if (socket->description[0] != '\0') { | if (socket->description[0] != '\0') { | ||||
| IDPropertyUIData *ui_data = IDP_ui_data_ensure(new_prop); | IDPropertyUIData *ui_data = IDP_ui_data_ensure(new_prop); | ||||
| ui_data->description = BLI_strdup(socket->description); | ui_data->description = BLI_strdup(socket->description); | ||||
| } | } | ||||
| IDP_AddToGroup(nmd->settings.properties, new_prop); | IDP_AddToGroup(nmd->settings.properties, new_prop); | ||||
| if (old_properties != nullptr) { | if (old_properties == nullptr) { | ||||
| if (socket->default_attribute_name && socket->default_attribute_name[0] != '\0') { | |||||
| IDP_AssignString(new_prop, socket->default_attribute_name, MAX_NAME); | |||||
| } | |||||
| } | |||||
| else { | |||||
| IDProperty *old_prop = IDP_GetPropertyFromGroup(old_properties, idprop_name.c_str()); | IDProperty *old_prop = IDP_GetPropertyFromGroup(old_properties, idprop_name.c_str()); | ||||
| if (old_prop != nullptr) { | if (old_prop != nullptr) { | ||||
| /* #IDP_CopyPropertyContent replaces the UI data as well, which we don't (we only | /* #IDP_CopyPropertyContent replaces the UI data as well, which we don't (we only | ||||
| * want to replace the values). So release it temporarily and replace it after. */ | * want to replace the values). So release it temporarily and replace it after. */ | ||||
| IDPropertyUIData *ui_data = new_prop->ui_data; | IDPropertyUIData *ui_data = new_prop->ui_data; | ||||
| new_prop->ui_data = nullptr; | new_prop->ui_data = nullptr; | ||||
| IDP_CopyPropertyContent(new_prop, old_prop); | IDP_CopyPropertyContent(new_prop, old_prop); | ||||
| if (new_prop->ui_data != nullptr) { | if (new_prop->ui_data != nullptr) { | ||||
| ▲ Show 20 Lines • Show All 1,002 Lines • ▼ Show 20 Lines | if (nmd->settings.properties != nullptr) { | ||||
| * and don't necessarily need to be written, but we can't just free them. */ | * and don't necessarily need to be written, but we can't just free them. */ | ||||
| IDP_BlendWrite(writer, nmd->settings.properties); | IDP_BlendWrite(writer, nmd->settings.properties); | ||||
| } | } | ||||
| } | } | ||||
| static void blendRead(BlendDataReader *reader, ModifierData *md) | static void blendRead(BlendDataReader *reader, ModifierData *md) | ||||
| { | { | ||||
| NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); | NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); | ||||
| if (nmd->node_group == nullptr) { | |||||
| nmd->settings.properties = nullptr; | |||||
| } | |||||
| else { | |||||
| BLO_read_data_address(reader, &nmd->settings.properties); | BLO_read_data_address(reader, &nmd->settings.properties); | ||||
| IDP_BlendDataRead(reader, &nmd->settings.properties); | IDP_BlendDataRead(reader, &nmd->settings.properties); | ||||
| } | |||||
| nmd->runtime_eval_log = nullptr; | nmd->runtime_eval_log = nullptr; | ||||
| } | } | ||||
| static void copyData(const ModifierData *md, ModifierData *target, const int flag) | static void copyData(const ModifierData *md, ModifierData *target, const int flag) | ||||
| { | { | ||||
| const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md); | const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md); | ||||
| NodesModifierData *tnmd = reinterpret_cast<NodesModifierData *>(target); | NodesModifierData *tnmd = reinterpret_cast<NodesModifierData *>(target); | ||||
| ▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines | |||||