Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/geometry_set_instances.cc
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (object.type == OB_MESH && object.mode == OB_MODE_EDIT) { | ||||
| add_final_mesh_as_geometry_component(object, geometry_set); | add_final_mesh_as_geometry_component(object, geometry_set); | ||||
| return geometry_set; | return geometry_set; | ||||
| } | } | ||||
| if (object.runtime.geometry_set_eval != nullptr) { | if (object.runtime.geometry_set_eval != nullptr) { | ||||
| return *object.runtime.geometry_set_eval; | return *object.runtime.geometry_set_eval; | ||||
| } | } | ||||
| /* Otherwise, construct a new geometry set with the component based on the object type. */ | /* Otherwise, construct a new geometry set with the component based on the object type. */ | ||||
| GeometrySet geometry_set; | |||||
| if (object.type == OB_MESH) { | if (object.type == OB_MESH) { | ||||
| GeometrySet geometry_set; | |||||
| add_final_mesh_as_geometry_component(object, geometry_set); | add_final_mesh_as_geometry_component(object, geometry_set); | ||||
| return geometry_set; | |||||
| } | |||||
| if (object.type == OB_EMPTY && object.instance_collection != nullptr) { | |||||
| GeometrySet geometry_set; | |||||
| Collection &collection = *object.instance_collection; | |||||
| InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); | |||||
| const int handle = instances.add_reference(collection); | |||||
| instances.add_instance(handle, float4x4::identity()); | |||||
| return geometry_set; | |||||
| } | } | ||||
| /* TODO: Cover the case of point clouds without modifiers-- they may not be covered by the | /* TODO: Cover the case of point clouds without modifiers-- they may not be covered by the | ||||
| * #geometry_set_eval case above. */ | * #geometry_set_eval case above. */ | ||||
| /* TODO: Add volume support. */ | /* TODO: Add volume support. */ | ||||
| /* Return by value since there is not always an existing geometry set owned elsewhere to use. */ | /* Return by value since there is not always an existing geometry set owned elsewhere to use. */ | ||||
| return geometry_set; | return {}; | ||||
| } | } | ||||
| static void geometry_set_collect_recursive_collection_instance( | static void geometry_set_collect_recursive_collection_instance( | ||||
| const Collection &collection, const float4x4 &transform, Vector<GeometryInstanceGroup> &r_sets) | const Collection &collection, const float4x4 &transform, Vector<GeometryInstanceGroup> &r_sets) | ||||
| { | { | ||||
| float4x4 offset_matrix = float4x4::identity(); | float4x4 offset_matrix = float4x4::identity(); | ||||
| sub_v3_v3(offset_matrix.values[3], collection.instance_offset); | sub_v3_v3(offset_matrix.values[3], collection.instance_offset); | ||||
| const float4x4 instance_transform = transform * offset_matrix; | const float4x4 instance_transform = transform * offset_matrix; | ||||
| geometry_set_collect_recursive_collection(collection, instance_transform, r_sets); | geometry_set_collect_recursive_collection(collection, instance_transform, r_sets); | ||||
| } | } | ||||
| static void geometry_set_collect_recursive_object(const Object &object, | static void geometry_set_collect_recursive_object(const Object &object, | ||||
| const float4x4 &transform, | const float4x4 &transform, | ||||
| Vector<GeometryInstanceGroup> &r_sets) | Vector<GeometryInstanceGroup> &r_sets) | ||||
| { | { | ||||
| GeometrySet instance_geometry_set = object_get_evaluated_geometry_set(object); | GeometrySet instance_geometry_set = object_get_evaluated_geometry_set(object); | ||||
| geometry_set_collect_recursive(instance_geometry_set, transform, r_sets); | geometry_set_collect_recursive(instance_geometry_set, transform, r_sets); | ||||
| if (object.type == OB_EMPTY) { | |||||
| const Collection *collection_instance = object.instance_collection; | |||||
| if (collection_instance != nullptr) { | |||||
| geometry_set_collect_recursive_collection_instance(*collection_instance, transform, r_sets); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| static void geometry_set_collect_recursive_collection(const Collection &collection, | static void geometry_set_collect_recursive_collection(const Collection &collection, | ||||
| const float4x4 &transform, | const float4x4 &transform, | ||||
| Vector<GeometryInstanceGroup> &r_sets) | Vector<GeometryInstanceGroup> &r_sets) | ||||
| { | { | ||||
| LISTBASE_FOREACH (const CollectionObject *, collection_object, &collection.gobject) { | LISTBASE_FOREACH (const CollectionObject *, collection_object, &collection.gobject) { | ||||
| BLI_assert(collection_object->ob != nullptr); | BLI_assert(collection_object->ob != nullptr); | ||||
| ▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines | |||||