[Bf-blender-cvs] [5877e34eb48] geometry-nodes: Geometry Nodes: new DupliGenerator for instances component
Jacques Lucke
noreply at git.blender.org
Thu Nov 12 13:31:15 CET 2020
Commit: 5877e34eb48abc08a6dde401970aa91422cbf339
Author: Jacques Lucke
Date: Thu Nov 12 13:27:20 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rB5877e34eb48abc08a6dde401970aa91422cbf339
Geometry Nodes: new DupliGenerator for instances component
With this, instances generated in a node tree can be rendered.
===================================================================
M source/blender/blenkernel/intern/object_dupli.c
===================================================================
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index a1b01bce6c9..4da05a39f02 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -47,6 +47,7 @@
#include "BKE_editmesh.h"
#include "BKE_editmesh_cache.h"
#include "BKE_font.h"
+#include "BKE_geometry_set.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_lattice.h"
@@ -806,6 +807,38 @@ static const DupliGenerator gen_dupli_verts_pointcloud = {
/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Instances Geometry Component Implementation
+ * \{ */
+
+static void make_duplis_instances_component(const DupliContext *ctx)
+{
+ float(*positions)[3];
+ Object **objects;
+ const int amount = BKE_geometry_set_instances(
+ ctx->object->runtime.geometry_set_eval, &positions, &objects);
+
+ for (int i = 0; i < amount; i++) {
+ Object *object = objects[i];
+ if (object == NULL) {
+ continue;
+ }
+ float mat[4][4];
+ unit_m4(mat);
+ copy_v3_v3(mat[3], positions[i]);
+ mul_m4_m4_pre(mat, ctx->object->obmat);
+ make_dupli(ctx, object, mat, i);
+ make_recursive_duplis(ctx, object, mat, i);
+ }
+}
+
+static const DupliGenerator gen_dupli_instances_component = {
+ 0,
+ make_duplis_instances_component,
+};
+
+/** \} */
+
/* -------------------------------------------------------------------- */
/** \name Dupli-Faces Implementation (#OB_DUPLIFACES)
* \{ */
@@ -1473,7 +1506,7 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
int transflag = ctx->object->transflag;
int restrictflag = ctx->object->restrictflag;
- if ((transflag & OB_DUPLI) == 0) {
+ if ((transflag & OB_DUPLI) == 0 && ctx->object->runtime.geometry_set_eval == NULL) {
return NULL;
}
@@ -1483,6 +1516,12 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
return NULL;
}
+ if (ctx->object->runtime.geometry_set_eval != NULL) {
+ if (BKE_geometry_set_has_instances(ctx->object->runtime.geometry_set_eval)) {
+ return &gen_dupli_instances_component;
+ }
+ }
+
if (transflag & OB_DUPLIPARTS) {
return &gen_dupli_particles;
}
More information about the Bf-blender-cvs
mailing list