[Bf-blender-cvs] [9a06c6a0401] geometry-nodes: Geometry Nodes: Add function to create a temporary pointcloud
Hans Goudey
noreply at git.blender.org
Tue Oct 27 05:00:40 CET 2020
Commit: 9a06c6a0401c6b894ef9964260755dbcb971695e
Author: Hans Goudey
Date: Mon Oct 26 22:54:55 2020 -0500
Branches: geometry-nodes
https://developer.blender.org/rB9a06c6a0401c6b894ef9964260755dbcb971695e
Geometry Nodes: Add function to create a temporary pointcloud
We needed a "nomain" funciton similar to the one we have for meshes in
order to add a working pointcloud for the geometry nodes.
===================================================================
M source/blender/blenkernel/BKE_pointcloud.h
M source/blender/blenkernel/intern/pointcloud.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_pointcloud.h b/source/blender/blenkernel/BKE_pointcloud.h
index 985a8cc3ca7..5598a9c3645 100644
--- a/source/blender/blenkernel/BKE_pointcloud.h
+++ b/source/blender/blenkernel/BKE_pointcloud.h
@@ -38,6 +38,7 @@ extern const char *POINTCLOUD_ATTR_RADIUS;
void *BKE_pointcloud_add(struct Main *bmain, const char *name);
void *BKE_pointcloud_add_default(struct Main *bmain, const char *name);
+struct PointCloud *BKE_pointcloud_new_nomain(const int totpoint);
struct BoundBox *BKE_pointcloud_boundbox_get(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c
index 78acf7251fa..68f77d492f5 100644
--- a/source/blender/blenkernel/intern/pointcloud.c
+++ b/source/blender/blenkernel/intern/pointcloud.c
@@ -228,6 +228,29 @@ void *BKE_pointcloud_add_default(Main *bmain, const char *name)
return pointcloud;
}
+PointCloud *BKE_pointcloud_new_nomain(const int totpoint)
+{
+ PointCloud *pointcloud = BKE_libblock_alloc(
+ NULL, ID_PT, BKE_idtype_idcode_to_name(ID_PT), LIB_ID_CREATE_LOCALIZE);
+
+ pointcloud_init_data(&pointcloud->id);
+
+ pointcloud->totpoint = totpoint;
+
+ CustomData_add_layer_named(&pointcloud->pdata,
+ CD_PROP_FLOAT,
+ CD_CALLOC,
+ NULL,
+ pointcloud->totpoint,
+ POINTCLOUD_ATTR_RADIUS);
+
+ pointcloud->totpoint = totpoint;
+ CustomData_realloc(&pointcloud->pdata, pointcloud->totpoint);
+ BKE_pointcloud_update_customdata_pointers(pointcloud);
+
+ return pointcloud;
+}
+
BoundBox *BKE_pointcloud_boundbox_get(Object *ob)
{
BLI_assert(ob->type == OB_POINTCLOUD);
More information about the Bf-blender-cvs
mailing list