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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2020-03-17 16:41:48 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-03-18 13:23:05 +0300
commitb0a1cf2c9ae696b07f7a236bc855a5ab4a493dcb (patch)
tree92295af11db5e984da42bfac7ca60190b8549a3f /source/blender/makesrna/intern/rna_main_api.c
parent8dcfd392e4e62f193b666304425bc5ae635ecffe (diff)
Objects: add Volume object type, and prototypes for Hair and PointCloud
Only the volume object is exposed in the user interface. It is based on OpenVDB internally. Drawing and rendering code will follow in another commit. https://wiki.blender.org/wiki/Source/Objects/Volume https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Volumes Hair and PointCloud object types are hidden behind a WITH_NEW_OBJECT_TYPES build option. These are unfinished, and included only to make it easier to cooperate on development in the future and avoid tricky merges. https://wiki.blender.org/wiki/Source/Objects/New_Object_Types Ref T73201, T68981 Differential Revision: https://developer.blender.org/D6945
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c187
1 files changed, 187 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index bb851365997..dfd94ccc927 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -49,6 +49,7 @@
# include "BKE_displist.h"
# include "BKE_font.h"
# include "BKE_gpencil.h"
+# include "BKE_hair.h"
# include "BKE_icons.h"
# include "BKE_idcode.h"
# include "BKE_image.h"
@@ -66,11 +67,13 @@
# include "BKE_object.h"
# include "BKE_paint.h"
# include "BKE_particle.h"
+# include "BKE_pointcloud.h"
# include "BKE_scene.h"
# include "BKE_sound.h"
# include "BKE_speaker.h"
# include "BKE_text.h"
# include "BKE_texture.h"
+# include "BKE_volume.h"
# include "BKE_workspace.h"
# include "BKE_world.h"
@@ -80,6 +83,7 @@
# include "DNA_armature_types.h"
# include "DNA_camera_types.h"
# include "DNA_curve_types.h"
+# include "DNA_hair_types.h"
# include "DNA_light_types.h"
# include "DNA_material_types.h"
# include "DNA_mesh_types.h"
@@ -94,7 +98,9 @@
# include "DNA_meta_types.h"
# include "DNA_world_types.h"
# include "DNA_particle_types.h"
+# include "DNA_pointcloud_types.h"
# include "DNA_vfont_types.h"
+# include "DNA_volume_types.h"
# include "DNA_node_types.h"
# include "DNA_movieclip_types.h"
# include "DNA_mask_types.h"
@@ -253,6 +259,15 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char
case ID_LP:
type = OB_LIGHTPROBE;
break;
+ case ID_HA:
+ type = OB_HAIR;
+ break;
+ case ID_PT:
+ type = OB_POINTCLOUD;
+ break;
+ case ID_VO:
+ type = OB_VOLUME;
+ break;
default: {
const char *idname;
if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) {
@@ -691,6 +706,38 @@ static bGPdata *rna_Main_gpencils_new(Main *bmain, const char *name)
return gpd;
}
+# ifdef WITH_NEW_OBJECT_TYPES
+static Hair *rna_Main_hairs_new(Main *bmain, const char *name)
+{
+ char safe_name[MAX_ID_NAME - 2];
+ rna_idname_validate(name, safe_name);
+
+ Hair *hair = BKE_hair_add(bmain, safe_name);
+ id_us_min(&hair->id);
+ return hair;
+}
+
+static PointCloud *rna_Main_pointclouds_new(Main *bmain, const char *name)
+{
+ char safe_name[MAX_ID_NAME - 2];
+ rna_idname_validate(name, safe_name);
+
+ PointCloud *pointcloud = BKE_pointcloud_add(bmain, safe_name);
+ id_us_min(&pointcloud->id);
+ return pointcloud;
+}
+# endif
+
+static Volume *rna_Main_volumes_new(Main *bmain, const char *name)
+{
+ char safe_name[MAX_ID_NAME - 2];
+ rna_idname_validate(name, safe_name);
+
+ Volume *volume = BKE_volume_add(bmain, safe_name);
+ id_us_min(&volume->id);
+ return volume;
+}
+
/* tag functions, all the same */
# define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \
static void rna_Main_##_func_name##_tag(Main *bmain, bool value) \
@@ -733,6 +780,11 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF)
RNA_MAIN_ID_TAG_FUNCS_DEF(paintcurves, paintcurves, ID_PC)
RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS)
RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobes, ID_LP)
+# ifdef WITH_NEW_OBJECT_TYPES
+RNA_MAIN_ID_TAG_FUNCS_DEF(hairs, hairs, ID_HA)
+RNA_MAIN_ID_TAG_FUNCS_DEF(pointclouds, pointclouds, ID_PT)
+# endif
+RNA_MAIN_ID_TAG_FUNCS_DEF(volumes, volumes, ID_VO)
# undef RNA_MAIN_ID_TAG_FUNCS_DEF
@@ -2117,4 +2169,139 @@ void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
+void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "BlendDataHairs");
+ srna = RNA_def_struct(brna, "BlendDataHairs", NULL);
+ RNA_def_struct_sdna(srna, "Main");
+ RNA_def_struct_ui_text(srna, "Main Hairs", "Collection of hairs");
+
+ func = RNA_def_function(srna, "new", "rna_Main_hairs_new");
+ RNA_def_function_ui_description(func, "Add a new hair to the main database");
+ parm = RNA_def_string(func, "name", "Hair", 0, "", "New name for the data-block");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ /* return type */
+ parm = RNA_def_pointer(func, "hair", "Hair", "", "New hair data-block");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove a hair from the current blendfile");
+ parm = RNA_def_pointer(func, "hair", "Hair", "", "Hair to remove");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+ RNA_def_boolean(func,
+ "do_unlink",
+ true,
+ "",
+ "Unlink all usages of this hair before deleting it "
+ "(WARNING: will also delete objects instancing that hair data)");
+ RNA_def_boolean(func,
+ "do_id_user",
+ true,
+ "",
+ "Decrement user counter of all datablocks used by this hair data");
+ RNA_def_boolean(
+ func, "do_ui_user", true, "", "Make sure interface does not reference this hair data");
+
+ func = RNA_def_function(srna, "tag", "rna_Main_hairs_tag");
+ parm = RNA_def_boolean(func, "value", 0, "Value", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+}
+
+void RNA_def_main_pointclouds(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "BlendDataPointClouds");
+ srna = RNA_def_struct(brna, "BlendDataPointClouds", NULL);
+ RNA_def_struct_sdna(srna, "Main");
+ RNA_def_struct_ui_text(srna, "Main Point Clouds", "Collection of point clouds");
+
+ func = RNA_def_function(srna, "new", "rna_Main_pointclouds_new");
+ RNA_def_function_ui_description(func, "Add a new point cloud to the main database");
+ parm = RNA_def_string(func, "name", "PointCloud", 0, "", "New name for the data-block");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ /* return type */
+ parm = RNA_def_pointer(func, "pointcloud", "PointCloud", "", "New point cloud data-block");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove a point cloud from the current blendfile");
+ parm = RNA_def_pointer(func, "pointcloud", "PointCloud", "", "Point cloud to remove");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+ RNA_def_boolean(func,
+ "do_unlink",
+ true,
+ "",
+ "Unlink all usages of this point cloud before deleting it "
+ "(WARNING: will also delete objects instancing that point cloud data)");
+ RNA_def_boolean(func,
+ "do_id_user",
+ true,
+ "",
+ "Decrement user counter of all datablocks used by this point cloud data");
+ RNA_def_boolean(func,
+ "do_ui_user",
+ true,
+ "",
+ "Make sure interface does not reference this point cloud data");
+
+ func = RNA_def_function(srna, "tag", "rna_Main_pointclouds_tag");
+ parm = RNA_def_boolean(func, "value", 0, "Value", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+}
+
+void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "BlendDataVolumes");
+ srna = RNA_def_struct(brna, "BlendDataVolumes", NULL);
+ RNA_def_struct_sdna(srna, "Main");
+ RNA_def_struct_ui_text(srna, "Main Volumes", "Collection of volumes");
+
+ func = RNA_def_function(srna, "new", "rna_Main_volumes_new");
+ RNA_def_function_ui_description(func, "Add a new volume to the main database");
+ parm = RNA_def_string(func, "name", "Volume", 0, "", "New name for the data-block");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ /* return type */
+ parm = RNA_def_pointer(func, "volume", "Volume", "", "New volume data-block");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove a volume from the current blendfile");
+ parm = RNA_def_pointer(func, "volume", "Volume", "", "Volume to remove");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+ RNA_def_boolean(func,
+ "do_unlink",
+ true,
+ "",
+ "Unlink all usages of this volume before deleting it "
+ "(WARNING: will also delete objects instancing that volume data)");
+ RNA_def_boolean(func,
+ "do_id_user",
+ true,
+ "",
+ "Decrement user counter of all datablocks used by this volume data");
+ RNA_def_boolean(
+ func, "do_ui_user", true, "", "Make sure interface does not reference this volume data");
+
+ func = RNA_def_function(srna, "tag", "rna_Main_volumes_tag");
+ parm = RNA_def_boolean(func, "value", 0, "Value", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+}
+
#endif