Manipulation
| 673 | |
| 674 | //Manipulation |
| 675 | void Entity::setTransform(const MatrixF &mat) |
| 676 | { |
| 677 | //setMaskBits(TransformMask); |
| 678 | setMaskBits(TransformMask | NoWarpMask); |
| 679 | |
| 680 | if (isMounted()) |
| 681 | { |
| 682 | // Use transform from mounted object |
| 683 | Point3F newPos = mat.getPosition(); |
| 684 | Point3F parentPos = mMount.object->getTransform().getPosition(); |
| 685 | |
| 686 | Point3F newOffset = newPos - parentPos; |
| 687 | |
| 688 | if (!newOffset.isZero()) |
| 689 | { |
| 690 | //setMountOffset(newOffset); |
| 691 | mPos = newOffset; |
| 692 | } |
| 693 | |
| 694 | Point3F matEul = mat.toEuler(); |
| 695 | |
| 696 | //mRot = Point3F(mRadToDeg(matEul.x), mRadToDeg(matEul.y), mRadToDeg(matEul.z)); |
| 697 | |
| 698 | if (matEul != Point3F(0, 0, 0)) |
| 699 | { |
| 700 | Point3F mountEul = mMount.object->getTransform().toEuler(); |
| 701 | Point3F diff = matEul - mountEul; |
| 702 | |
| 703 | //setMountRotation(Point3F(mRadToDeg(diff.x), mRadToDeg(diff.y), mRadToDeg(diff.z))); |
| 704 | mRot = diff; |
| 705 | } |
| 706 | else |
| 707 | { |
| 708 | //setMountRotation(Point3F(0, 0, 0)); |
| 709 | mRot = Point3F(0, 0, 0); |
| 710 | } |
| 711 | |
| 712 | RotationF addRot = mRot + RotationF(mMount.object->getTransform()); |
| 713 | MatrixF transf = addRot.asMatrixF(); |
| 714 | transf.setPosition(mPos + mMount.object->getPosition()); |
| 715 | |
| 716 | Parent::setTransform(transf); |
| 717 | } |
| 718 | else |
| 719 | { |
| 720 | //Are we part of a prefab? |
| 721 | /*Prefab* p = Prefab::getPrefabByChild(this); |
| 722 | if (p) |
| 723 | { |
| 724 | //just let our prefab know we moved |
| 725 | p->childTransformUpdated(this, mat); |
| 726 | }*/ |
| 727 | //else |
| 728 | { |
| 729 | //mRot.set(mat); |
| 730 | //Parent::setTransform(mat); |
| 731 | |
| 732 | RotationF rot = RotationF(mat); |
no test coverage detected