diff options
author | Hans Goudey <h.goudey@me.com> | 2021-04-02 00:23:16 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-04-02 00:23:16 +0300 |
commit | c5d99683921060d1974fc0a5fb35522de9a768b0 (patch) | |
tree | a25d0e5e66d36ccbe1e4ca699e5db4c61e84bdab /source | |
parent | 3ca1cf2b5197c0c2d5afa44ac28e7b63d401b489 (diff) |
Cleanup: Remove unecessary part of instances component C API
Now that object_dupli.cc is a C++ file, we don't have to have a specific
function to retrieve the instance data from the geometry set.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/geometry_set.cc | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.cc | 39 |
3 files changed, 23 insertions, 36 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.h b/source/blender/blenkernel/BKE_geometry_set.h index 08b4a25d946..c00310408af 100644 --- a/source/blender/blenkernel/BKE_geometry_set.h +++ b/source/blender/blenkernel/BKE_geometry_set.h @@ -55,11 +55,6 @@ typedef struct InstancedData { } data; } InstancedData; -int BKE_geometry_set_instances(const struct GeometrySet *geometry_set, - float (**r_transforms)[4][4], - const int **r_almost_unique_ids, - struct InstancedData **r_instanced_data); - #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 9f57fcfb2ba..281512fe323 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -330,19 +330,4 @@ bool BKE_geometry_set_has_instances(const GeometrySet *geometry_set) return geometry_set->get_component_for_read<InstancesComponent>() != nullptr; } -int BKE_geometry_set_instances(const GeometrySet *geometry_set, - float (**r_transforms)[4][4], - const int **r_almost_unique_ids, - InstancedData **r_instanced_data) -{ - const InstancesComponent *component = geometry_set->get_component_for_read<InstancesComponent>(); - if (component == nullptr) { - return 0; - } - *r_transforms = (float(*)[4][4])component->transforms().data(); - *r_instanced_data = (InstancedData *)component->instanced_data().data(); - *r_almost_unique_ids = (const int *)component->almost_unique_ids().data(); - return component->instances_amount(); -} - /** \} */ diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index 1830870b854..17800b12b12 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -31,8 +31,10 @@ #include "BLI_string_utf8.h" #include "BLI_alloca.h" +#include "BLI_float4x4.hh" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_span.hh" #include "DNA_anim_types.h" #include "DNA_collection_types.h" @@ -48,6 +50,7 @@ #include "BKE_editmesh_cache.h" #include "BKE_font.h" #include "BKE_geometry_set.h" +#include "BKE_geometry_set.hh" #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lattice.h" @@ -65,6 +68,9 @@ #include "BLI_hash.h" #include "BLI_strict_flags.h" +using blender::float4x4; +using blender::Span; + /* -------------------------------------------------------------------- */ /** \name Internal Duplicate Context * \{ */ @@ -808,39 +814,40 @@ static const DupliGenerator gen_dupli_verts_pointcloud = { static void make_duplis_instances_component(const DupliContext *ctx) { - float(*instance_offset_matrices)[4][4]; - InstancedData *instanced_data; - const int *almost_unique_ids; - const int amount = BKE_geometry_set_instances(ctx->object->runtime.geometry_set_eval, - &instance_offset_matrices, - &almost_unique_ids, - &instanced_data); + const InstancesComponent *component = + ctx->object->runtime.geometry_set_eval->get_component_for_read<InstancesComponent>(); + if (component == nullptr) { + return; + } - for (int i = 0; i < amount; i++) { - InstancedData *data = &instanced_data[i]; + Span<float4x4> instance_offset_matrices = component->transforms(); + Span<int> almost_unique_ids = component->almost_unique_ids(); + Span<InstancedData> instanced_data = component->instanced_data(); + for (int i = 0; i < component->instances_amount(); i++) { + const InstancedData &data = instanced_data[i]; const int id = almost_unique_ids[i]; - if (data->type == INSTANCE_DATA_TYPE_OBJECT) { - Object *object = data->data.object; + if (data.type == INSTANCE_DATA_TYPE_OBJECT) { + Object *object = data.data.object; if (object != nullptr) { float matrix[4][4]; - mul_m4_m4m4(matrix, ctx->object->obmat, instance_offset_matrices[i]); + mul_m4_m4m4(matrix, ctx->object->obmat, instance_offset_matrices[i].values); make_dupli(ctx, object, matrix, id); float space_matrix[4][4]; - mul_m4_m4m4(space_matrix, instance_offset_matrices[i], object->imat); + mul_m4_m4m4(space_matrix, instance_offset_matrices[i].values, object->imat); mul_m4_m4_pre(space_matrix, ctx->object->obmat); make_recursive_duplis(ctx, object, space_matrix, id); } } - else if (data->type == INSTANCE_DATA_TYPE_COLLECTION) { - Collection *collection = data->data.collection; + else if (data.type == INSTANCE_DATA_TYPE_COLLECTION) { + Collection *collection = data.data.collection; if (collection != nullptr) { float collection_matrix[4][4]; unit_m4(collection_matrix); sub_v3_v3(collection_matrix[3], collection->instance_offset); - mul_m4_m4_pre(collection_matrix, instance_offset_matrices[i]); + mul_m4_m4_pre(collection_matrix, instance_offset_matrices[i].values); mul_m4_m4_pre(collection_matrix, ctx->object->obmat); eEvaluationMode mode = DEG_get_mode(ctx->depsgraph); |