Move this transform to a new location in world space @param newPos the new position in world space. */
| 147 | @param newPos the new position in world space. |
| 148 | */ |
| 149 | inline void Transform::SetWorldPosition(const vector3& newPos) { |
| 150 | if (!HasParent()) { |
| 151 | SetLocalPosition(newPos); |
| 152 | } |
| 153 | else { |
| 154 | //get the world position |
| 155 | auto worldpos = GetWorldPosition(); |
| 156 | //get the displacement to the new world coords from the current local position |
| 157 | auto displacement = newPos - worldpos; |
| 158 | //update the local pos to that displacement |
| 159 | LocalTranslateDelta(displacement); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | Overwrite the rotation of this transform in local (parent) space. |