summaryrefslogtreecommitdiffstats
path: root/source/Entities/Entity.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-09-07 17:14:37 +0200
committermadmaxoft <github@xoft.cz>2013-09-07 17:14:37 +0200
commit3f4718154bcce6fd06939fcc0f0b20ea7181be1e (patch)
treec46f4da46e44156681ed79fbe5ecb1f65c88d9f6 /source/Entities/Entity.cpp
parentRemoved an unused include (diff)
downloadcuberite-3f4718154bcce6fd06939fcc0f0b20ea7181be1e.tar
cuberite-3f4718154bcce6fd06939fcc0f0b20ea7181be1e.tar.gz
cuberite-3f4718154bcce6fd06939fcc0f0b20ea7181be1e.tar.bz2
cuberite-3f4718154bcce6fd06939fcc0f0b20ea7181be1e.tar.lz
cuberite-3f4718154bcce6fd06939fcc0f0b20ea7181be1e.tar.xz
cuberite-3f4718154bcce6fd06939fcc0f0b20ea7181be1e.tar.zst
cuberite-3f4718154bcce6fd06939fcc0f0b20ea7181be1e.zip
Diffstat (limited to 'source/Entities/Entity.cpp')
-rw-r--r--source/Entities/Entity.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index b936d8d73..a07811a96 100644
--- a/source/Entities/Entity.cpp
+++ b/source/Entities/Entity.cpp
@@ -253,6 +253,39 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
+void cEntity::SetRotationFromSpeed(void)
+{
+ const double EPS = 0.0000001;
+ if ((abs(m_Speed.x) < EPS) && (abs(m_Speed.z) < EPS))
+ {
+ // atan2() may overflow or is undefined, pick any number
+ SetRotation(0);
+ return;
+ }
+ SetRotation(atan2(m_Speed.x, m_Speed.z) * 180 / PI);
+}
+
+
+
+
+
+void cEntity::SetPitchFromSpeed(void)
+{
+ const double EPS = 0.0000001;
+ double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component
+ if ((abs(xz) < EPS) && (abs(m_Speed.y) < EPS))
+ {
+ // atan2() may overflow or is undefined, pick any number
+ SetPitch(0);
+ return;
+ }
+ SetPitch(atan2(m_Speed.y, xz) * 180 / PI);
+}
+
+
+
+
+
void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI))