Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_object_info.cc
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | static void geo_node_object_info_exec(GeoNodeExecParams params) | ||||
| float3 location = {0, 0, 0}; | float3 location = {0, 0, 0}; | ||||
| float3 rotation = {0, 0, 0}; | float3 rotation = {0, 0, 0}; | ||||
| float3 scale = {0, 0, 0}; | float3 scale = {0, 0, 0}; | ||||
| GeometrySet geometry_set; | GeometrySet geometry_set; | ||||
| const Object *self_object = params.self_object(); | const Object *self_object = params.self_object(); | ||||
| if (object != nullptr) { | if (object != nullptr) { | ||||
| float transform[4][4]; | |||||
| mul_m4_m4m4(transform, self_object->imat, object->obmat); | |||||
| float quaternion[4]; | float quaternion[4]; | ||||
| mat4_decompose(location, quaternion, scale, object->obmat); | mat4_decompose(location, quaternion, scale, transform); | ||||
| quat_to_eul(rotation, quaternion); | quat_to_eul(rotation, quaternion); | ||||
| if (object != self_object) { | if (object != self_object) { | ||||
| if (object->type == OB_MESH) { | if (object->type == OB_MESH) { | ||||
| Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(object, false); | Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(object, false); | ||||
| if (mesh != nullptr) { | if (mesh != nullptr) { | ||||
| BKE_mesh_wrapper_ensure_mdata(mesh); | BKE_mesh_wrapper_ensure_mdata(mesh); | ||||
| /* Make a copy because the life time of the other mesh might be shorter. */ | /* Make a copy because the life time of the other mesh might be shorter. */ | ||||
| Mesh *copied_mesh = BKE_mesh_copy_for_eval(mesh, false); | Mesh *copied_mesh = BKE_mesh_copy_for_eval(mesh, false); | ||||
| /* Transform into the local space of the object that is being modified. */ | /* Transform into the local space of the object that is being modified. */ | ||||
| float transform[4][4]; | |||||
| mul_m4_m4m4(transform, self_object->imat, object->obmat); | |||||
| BKE_mesh_transform(copied_mesh, transform, true); | BKE_mesh_transform(copied_mesh, transform, true); | ||||
| MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>(); | MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>(); | ||||
| mesh_component.replace(copied_mesh); | mesh_component.replace(copied_mesh); | ||||
| mesh_component.copy_vertex_group_names_from_object(*object); | mesh_component.copy_vertex_group_names_from_object(*object); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Show All 18 Lines | |||||