| 404 | } |
| 405 | |
| 406 | void CopyTransformModifier3D::_process_copy(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, const Transform3D &p_destination, float p_amount) { |
| 407 | CopyTransform3DSetting *setting = static_cast<CopyTransform3DSetting *>(settings[p_index]); |
| 408 | |
| 409 | Transform3D destination = p_destination; |
| 410 | Vector3 dest_pos = destination.origin; |
| 411 | Quaternion dest_rot = destination.basis.get_rotation_quaternion(); |
| 412 | Vector3 dest_scl = destination.basis.get_scale(); |
| 413 | |
| 414 | // Mask pos and scale. |
| 415 | for (int i = 0; i < 3; i++) { |
| 416 | if (!setting->axis_flags.has_flag(static_cast<AxisFlag>(1 << i))) { |
| 417 | dest_pos[i] = 0.0; |
| 418 | dest_scl[i] = 1.0; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | // Mask rot. |
| 423 | switch (static_cast<int>(setting->axis_flags)) { |
| 424 | case 0: { |
| 425 | dest_rot = Quaternion(); |
| 426 | } break; |
| 427 | case AXIS_FLAG_X: { |
| 428 | Vector3 axis = get_vector_from_axis(Vector3::AXIS_X); |
| 429 | dest_rot = Quaternion(axis, get_roll_angle(dest_rot, axis)); |
| 430 | } break; |
| 431 | case AXIS_FLAG_Y: { |
| 432 | Vector3 axis = get_vector_from_axis(Vector3::AXIS_Y); |
| 433 | dest_rot = Quaternion(axis, get_roll_angle(dest_rot, axis)); |
| 434 | } break; |
| 435 | case AXIS_FLAG_Z: { |
| 436 | Vector3 axis = get_vector_from_axis(Vector3::AXIS_Z); |
| 437 | dest_rot = Quaternion(axis, get_roll_angle(dest_rot, axis)); |
| 438 | } break; |
| 439 | case AXIS_FLAG_X | AXIS_FLAG_Y: { |
| 440 | Vector3 axis = get_vector_from_axis(Vector3::AXIS_Z); |
| 441 | dest_rot = dest_rot * Quaternion(axis, get_roll_angle(dest_rot, axis)).inverse(); |
| 442 | } break; |
| 443 | case AXIS_FLAG_Y | AXIS_FLAG_Z: { |
| 444 | Vector3 axis = get_vector_from_axis(Vector3::AXIS_X); |
| 445 | dest_rot = dest_rot * Quaternion(axis, get_roll_angle(dest_rot, axis)).inverse(); |
| 446 | } break; |
| 447 | case AXIS_FLAG_Z | AXIS_FLAG_X: { |
| 448 | Vector3 axis = get_vector_from_axis(Vector3::AXIS_Y); |
| 449 | dest_rot = dest_rot * Quaternion(axis, get_roll_angle(dest_rot, axis)).inverse(); |
| 450 | } break; |
| 451 | case AXIS_FLAG_ALL: { |
| 452 | } break; |
| 453 | } |
| 454 | |
| 455 | // Process inversion. |
| 456 | for (int i = 0; i < 3; i++) { |
| 457 | AxisFlag axis = static_cast<AxisFlag>(1 << i); |
| 458 | if (setting->axis_flags.has_flag(axis) && setting->invert_flags.has_flag(axis)) { |
| 459 | dest_pos[i] *= -1; |
| 460 | dest_rot[i] *= -1; |
| 461 | dest_scl[i] = 1.0 / dest_scl[i]; |
| 462 | } |
| 463 | } |
nothing calls this directly
no test coverage detected