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>2021-03-16 13:53:45 +0300
committerJacques Lucke <jacques@blender.org>2021-03-16 13:53:45 +0300
commit969ad129f7bae74a65a791f110bcbfdb7eb6cf06 (patch)
tree5cc53bd3878e7389643075e130b727ca5a98152f /source/blender
parente62a8a1a9e2c5e1a035d89dc6a72cb6dea892818 (diff)
initial asset tools
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_asset_tool.h35
-rw-r--r--source/blender/blenkernel/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/intern/asset_tool.cc44
-rw-r--r--source/blender/blenkernel/intern/node.cc15
-rw-r--r--source/blender/makesdna/DNA_node_types.h10
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c64
7 files changed, 171 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_asset_tool.h b/source/blender/blenkernel/BKE_asset_tool.h
new file mode 100644
index 00000000000..8967881eae8
--- /dev/null
+++ b/source/blender/blenkernel/BKE_asset_tool.h
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+#pragma once
+
+/** \file
+ * \ingroup bke
+ */
+
+struct AssetTool;
+struct bNodeTree;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct AssetTool *BKE_asset_tool_new(void);
+struct AssetTool *BKE_asset_tool_copy(struct AssetTool *src);
+void BKE_asset_tool_free(struct AssetTool *asset_tool);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 310ac6c4903..e7c67ff5019 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -80,6 +80,7 @@ set(SRC
intern/armature_pose.cc
intern/armature_update.c
intern/asset.cc
+ intern/asset_tool.cc
intern/attribute.c
intern/attribute_access.cc
intern/attribute_math.cc
@@ -284,6 +285,7 @@ set(SRC
BKE_appdir.h
BKE_armature.h
BKE_asset.h
+ BKE_asset_tool.h
BKE_attribute.h
BKE_attribute_access.hh
BKE_attribute_math.hh
diff --git a/source/blender/blenkernel/intern/asset_tool.cc b/source/blender/blenkernel/intern/asset_tool.cc
new file mode 100644
index 00000000000..cc1fb11340a
--- /dev/null
+++ b/source/blender/blenkernel/intern/asset_tool.cc
@@ -0,0 +1,44 @@
+/*
+ * 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 bke
+ */
+
+#include "BKE_asset_tool.h"
+
+#include "DNA_node_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+
+AssetTool *BKE_asset_tool_new()
+{
+ AssetTool *asset_tool = (AssetTool *)MEM_callocN(sizeof(AssetTool), __func__);
+ return asset_tool;
+}
+
+AssetTool *BKE_asset_tool_copy(AssetTool *src)
+{
+ AssetTool *asset_tool = (AssetTool *)MEM_dupallocN(src);
+ return asset_tool;
+}
+
+void BKE_asset_tool_free(AssetTool *asset_tool)
+{
+ MEM_freeN(asset_tool);
+}
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 66c0e724fdf..4d955aef3fb 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -60,6 +60,7 @@
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
+#include "BKE_asset_tool.h"
#include "BKE_colortools.h"
#include "BKE_cryptomatte.h"
#include "BKE_global.h"
@@ -221,6 +222,12 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
/* Don't copy error messages in the runtime struct.
* They should be filled during execution anyway. */
ntree_dst->ui_storage = nullptr;
+
+ BLI_listbase_clear(&ntree_dst->asset_tools);
+ LISTBASE_FOREACH (AssetTool *, asset_tool_src, &ntree_src->asset_tools) {
+ AssetTool *asset_tool_dst = BKE_asset_tool_copy(asset_tool_src);
+ BLI_addtail(&ntree_dst->asset_tools, asset_tool_dst);
+ }
}
static void ntree_free_data(ID *id)
@@ -276,6 +283,10 @@ static void ntree_free_data(ID *id)
}
delete ntree->ui_storage;
+
+ LISTBASE_FOREACH_MUTABLE (AssetTool *, asset_tool, &ntree->asset_tools) {
+ BKE_asset_tool_free(asset_tool);
+ }
}
static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket *sock)
@@ -583,6 +594,8 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) {
write_node_socket_interface(writer, sock);
}
+
+ BLO_write_struct_list(writer, AssetTool, &ntree->asset_tools);
}
static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_address)
@@ -759,6 +772,8 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
BLO_read_data_address(reader, &link->tosock);
}
+ BLO_read_list(reader, &ntree->asset_tools);
+
/* TODO, should be dealt by new generic cache handling of IDs... */
ntree->previews = nullptr;
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 967258f1b81..ef8231c116b 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -473,6 +473,9 @@ typedef struct bNodeTree {
*/
ListBase inputs, outputs;
+ /* List of #AssetTool. */
+ ListBase asset_tools;
+
/* Node preview hash table
* Only available in base node trees (e.g. scene->node_tree)
*/
@@ -537,6 +540,13 @@ typedef enum eNodeTreeUpdate {
NTREE_UPDATE_GROUP = (NTREE_UPDATE_GROUP_IN | NTREE_UPDATE_GROUP_OUT),
} eNodeTreeUpdate;
+typedef struct AssetTool {
+ struct AssetTool *next;
+ struct AssetTool *prev;
+
+ char weight_group_name[64];
+} AssetTool;
+
/* socket value structs for input buttons
* DEPRECATED now using ID properties
*/
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index a9125c78229..076cc97dd4d 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -73,6 +73,7 @@ extern StructRNA RNA_Attribute;
extern StructRNA RNA_AttributeGroup;
extern StructRNA RNA_AssetMetaData;
extern StructRNA RNA_AssetTag;
+extern StructRNA RNA_AssetTool;
extern StructRNA RNA_BackgroundImage;
extern StructRNA RNA_BevelModifier;
extern StructRNA RNA_BezierSplinePoint;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 35c319c2f79..0418cf3e2c3 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -37,6 +38,7 @@
#include "DNA_texture_types.h"
#include "BKE_animsys.h"
+#include "BKE_asset_tool.h"
#include "BKE_attribute.h"
#include "BKE_cryptomatte.h"
#include "BKE_image.h"
@@ -4297,6 +4299,24 @@ static void rna_NodeInputString_string_set(PointerRNA *ptr, const char *value)
storage->string = NULL;
}
}
+
+static PointerRNA rna_AssetToolGroup_new(bNodeTree *ntree)
+{
+ AssetTool *asset_tool = BKE_asset_tool_new();
+ BLI_addtail(&ntree->asset_tools, asset_tool);
+ PointerRNA ptr;
+ RNA_pointer_create(&ntree->id, &RNA_AssetTool, asset_tool, &ptr);
+ return ptr;
+}
+
+static void rna_AssetToolGroup_remove(bNodeTree *ntree, PointerRNA *asset_tool_ptr)
+{
+ AssetTool *asset_tool = (AssetTool *)asset_tool_ptr->data;
+ BLI_remlink(&ntree->asset_tools, asset_tool);
+ BKE_asset_tool_free(asset_tool);
+ RNA_POINTER_INVALIDATE(asset_tool_ptr);
+}
+
#else
static const EnumPropertyItem prop_image_layer_items[] = {
@@ -10963,6 +10983,41 @@ static void rna_def_node_tree_sockets_api(BlenderRNA *brna, PropertyRNA *cprop,
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
+static void rna_def_asset_tool(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "AssetTool", NULL);
+ RNA_def_struct_ui_text(srna, "Asset Tool", "Tool for a specific asset");
+
+ prop = RNA_def_property(srna, "weight_group_name", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Weight Group Name", "Name of a vertex group");
+}
+
+static void rna_def_asset_tool_group(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ srna = RNA_def_struct(brna, "AssetToolGroup", NULL);
+ RNA_def_struct_ui_text(srna, "Asset Tool Group", "Group of asset tools");
+ RNA_def_struct_sdna(srna, "bNodeTree");
+
+ func = RNA_def_function(srna, "new", "rna_AssetToolGroup_new");
+ RNA_def_function_ui_description(func, "Add an asset tool");
+ parm = RNA_def_pointer(func, "asset_tool", "AssetTool", "", "New asset tool");
+ RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_AssetToolGroup_remove");
+ RNA_def_function_ui_description(func, "Remove an asset tool");
+ parm = RNA_def_pointer(func, "asset_tool", "AssetTool", "", "Asset tool to remove");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+}
+
static void rna_def_nodetree(BlenderRNA *brna)
{
StructRNA *srna;
@@ -10988,6 +11043,12 @@ static void rna_def_nodetree(BlenderRNA *brna)
RNA_def_struct_refine_func(srna, "rna_NodeTree_refine");
RNA_def_struct_register_funcs(srna, "rna_NodeTree_register", "rna_NodeTree_unregister", NULL);
+ prop = RNA_def_property(srna, "asset_tools", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "asset_tools", NULL);
+ RNA_def_property_struct_type(prop, "AssetTool");
+ RNA_def_property_ui_text(prop, "Asset Tools", "Tools for this asset");
+ RNA_def_property_srna(prop, "AssetToolGroup");
+
prop = RNA_def_property(srna, "view_center", PROP_FLOAT, PROP_XYZ);
RNA_def_property_array(prop, 2);
RNA_def_property_float_sdna(prop, NULL, "view_center");
@@ -11300,6 +11361,9 @@ void RNA_def_nodetree(BlenderRNA *brna)
rna_def_nodetree(brna);
+ rna_def_asset_tool(brna);
+ rna_def_asset_tool_group(brna);
+
rna_def_node_socket_standard_types(brna);
rna_def_composite_nodetree(brna);