1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
---|---|
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #include "Physics/BsRigidbody.h" |
4 | #include "Physics/BsPhysics.h" |
5 | #include "Scene/BsSceneObject.h" |
6 | #include "Scene/BsSceneManager.h" |
7 | |
8 | namespace bs |
9 | { |
10 | Rigidbody::Rigidbody(const HSceneObject& linkedSO) |
11 | :mLinkedSO(linkedSO) |
12 | { |
13 | |
14 | } |
15 | |
16 | void Rigidbody::_setTransform(const Vector3& position, const Quaternion& rotation) |
17 | { |
18 | mLinkedSO->setWorldPosition(position); |
19 | mLinkedSO->setWorldRotation(rotation); |
20 | } |
21 | |
22 | SPtr<Rigidbody> Rigidbody::create(const HSceneObject& linkedSO) |
23 | { |
24 | const SPtr<SceneInstance>& scene = linkedSO->getScene(); |
25 | |
26 | if(!scene) |
27 | { |
28 | LOGERR("Trying to create a Rigidbody with an uninstantiated scene object.") |
29 | return nullptr; |
30 | } |
31 | |
32 | return scene->getPhysicsScene()->createRigidbody(linkedSO); |
33 | } |
34 | } |