| 158 | } |
| 159 | |
| 160 | void Transform::WorldToLocal(const Transform& other, Transform& result) const |
| 161 | { |
| 162 | Vector3 invScale = Scale; |
| 163 | if (invScale.X != 0.0f) |
| 164 | invScale.X = 1.0f / invScale.X; |
| 165 | if (invScale.Y != 0.0f) |
| 166 | invScale.Y = 1.0f / invScale.Y; |
| 167 | if (invScale.Z != 0.0f) |
| 168 | invScale.Z = 1.0f / invScale.Z; |
| 169 | const Quaternion invRotation = Orientation.Conjugated(); |
| 170 | Quaternion::Multiply(invRotation, other.Orientation, result.Orientation); |
| 171 | result.Orientation.Normalize(); |
| 172 | Float3::Multiply(other.Scale, invScale, result.Scale); |
| 173 | const Vector3 tmp = other.Translation - Translation; |
| 174 | Vector3::Transform(tmp, invRotation, result.Translation); |
| 175 | Vector3::Multiply(result.Translation, invScale, result.Translation); |
| 176 | } |
| 177 | |
| 178 | void Transform::WorldToLocal(const Vector3& point, Vector3& result) const |
| 179 | { |