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#pragma once
4
5#include "BsCorePrerequisites.h"
6#include "Math/BsVector3.h"
7#include "Math/BsQuaternion.h"
8
9namespace bs
10{
11 /** @addtogroup Physics
12 * @{
13 */
14
15 /** Specifies first or second body referenced by a Joint. */
16 enum class BS_SCRIPT_EXPORT(m:Physics) JointBody
17 {
18 Target, /**< Body the joint is influencing. */
19 Anchor /**< Body the joint is attached to (if any). */
20 };
21
22 /** @} */
23 /** @addtogroup Physics-Internal
24 * @{
25 */
26
27 /** Provides common functionality used by all Joint types. */
28 class BS_CORE_EXPORT FJoint
29 {
30 public:
31 FJoint(const JOINT_DESC& desc) { }
32 virtual ~FJoint() = default;
33
34 /** @copydoc setBody() */
35 virtual Rigidbody* getBody(JointBody body) const = 0;
36
37 /** Determines a body managed by the joint. One of the bodies must be movable (non-kinematic). */
38 virtual void setBody(JointBody body, Rigidbody* value) = 0;
39
40 /** Returns the position relative to the body, at which the body is anchored to the joint. */
41 virtual Vector3 getPosition(JointBody body) const = 0;
42
43 /** Returns the rotation relative to the body, at which the body is anchored to the joint. */
44 virtual Quaternion getRotation(JointBody body) const = 0;
45
46 /** Sets the position and rotation relative to the body, at which the body is anchored to the joint. */
47 virtual void setTransform(JointBody body, const Vector3& position, const Quaternion& rotation) = 0;
48
49 /** @copydoc setBreakForce() */
50 virtual float getBreakForce() const = 0;
51
52 /**
53 * Determines the maximum force the joint can apply before breaking. Broken joints no longer participate in physics
54 * simulation.
55 */
56 virtual void setBreakForce(float force) = 0;
57
58 /** @copydoc setBreakTorque() */
59 virtual float getBreakTorque() const = 0;
60
61 /**
62 * Determines the maximum torque the joint can apply before breaking. Broken joints no longer participate in physics
63 * simulation.
64 */
65 virtual void setBreakTorque(float torque) = 0;
66
67 /** @copydoc setEnableCollision() */
68 virtual bool getEnableCollision() const = 0;
69
70 /** Determines whether collision between the two bodies managed by the joint are enabled. */
71 virtual void setEnableCollision(bool value) = 0;
72 };
73
74 /** @} */
75}