aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/camera.cpp42
-rw-r--r--src/collision.cpp75
-rw-r--r--src/collision.h9
-rw-r--r--src/content_sao.cpp1
-rw-r--r--src/main.cpp1
-rw-r--r--src/mapgen_singlenode.cpp1
-rw-r--r--src/mapgen_v5.cpp1
-rw-r--r--src/mapgen_v6.cpp1
-rw-r--r--src/mapgen_v7.cpp1
-rw-r--r--src/player.cpp31
10 files changed, 14 insertions, 149 deletions
diff --git a/src/camera.cpp b/src/camera.cpp
index ca28555d2..46df0575c 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -162,55 +162,37 @@ void Camera::step(f32 dtime)
{
//f32 offset = dtime * m_view_bobbing_speed * 0.035;
f32 offset = dtime * m_view_bobbing_speed * 0.030;
- if (m_view_bobbing_state == 2)
- {
-#if 0
+ if (m_view_bobbing_state == 2) {
// Animation is getting turned off
- if (m_view_bobbing_anim < 0.5)
+ if (m_view_bobbing_anim < 0.25) {
m_view_bobbing_anim -= offset;
- else
+ } else if (m_view_bobbing_anim > 0.75) {
m_view_bobbing_anim += offset;
- if (m_view_bobbing_anim <= 0 || m_view_bobbing_anim >= 1)
- {
- m_view_bobbing_anim = 0;
- m_view_bobbing_state = 0;
}
-#endif
-#if 1
- // Animation is getting turned off
- if(m_view_bobbing_anim < 0.25)
- {
- m_view_bobbing_anim -= offset;
- } else if(m_view_bobbing_anim > 0.75) {
- m_view_bobbing_anim += offset;
- }
- if(m_view_bobbing_anim < 0.5)
- {
+
+ if (m_view_bobbing_anim < 0.5) {
m_view_bobbing_anim += offset;
- if(m_view_bobbing_anim > 0.5)
+ if (m_view_bobbing_anim > 0.5)
m_view_bobbing_anim = 0.5;
} else {
m_view_bobbing_anim -= offset;
- if(m_view_bobbing_anim < 0.5)
+ if (m_view_bobbing_anim < 0.5)
m_view_bobbing_anim = 0.5;
}
- if(m_view_bobbing_anim <= 0 || m_view_bobbing_anim >= 1 ||
- fabs(m_view_bobbing_anim - 0.5) < 0.01)
- {
+
+ if (m_view_bobbing_anim <= 0 || m_view_bobbing_anim >= 1 ||
+ fabs(m_view_bobbing_anim - 0.5) < 0.01) {
m_view_bobbing_anim = 0;
m_view_bobbing_state = 0;
}
-#endif
}
- else
- {
+ else {
float was = m_view_bobbing_anim;
m_view_bobbing_anim = my_modf(m_view_bobbing_anim + offset);
bool step = (was == 0 ||
(was < 0.5f && m_view_bobbing_anim >= 0.5f) ||
(was > 0.5f && m_view_bobbing_anim <= 0.5f));
- if(step)
- {
+ if(step) {
MtEvent *e = new SimpleTriggerEvent("ViewBobbingStep");
m_gamedef->event()->put(e);
}
diff --git a/src/collision.cpp b/src/collision.cpp
index 27e3b5e94..6afc79ab7 100644
--- a/src/collision.cpp
+++ b/src/collision.cpp
@@ -458,7 +458,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
pos_f += speed_f * nearest_dtime;
dtime -= nearest_dtime;
}
-
+
bool is_collision = true;
if(is_unloaded[nearest_boxindex])
is_collision = false;
@@ -561,76 +561,3 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
return result;
}
-
-#if 0
-// This doesn't seem to work and isn't used
-collisionMoveResult collisionMovePrecise(Map *map, IGameDef *gamedef,
- f32 pos_max_d, const aabb3f &box_0,
- f32 stepheight, f32 dtime,
- v3f &pos_f, v3f &speed_f, v3f &accel_f)
-{
- //TimeTaker tt("collisionMovePrecise");
- ScopeProfiler sp(g_profiler, "collisionMovePrecise avg", SPT_AVG);
-
- collisionMoveResult final_result;
-
- // If there is no speed, there are no collisions
- if(speed_f.getLength() == 0)
- return final_result;
-
- // Don't allow overly huge dtime
- if(dtime > 2.0)
- dtime = 2.0;
-
- f32 dtime_downcount = dtime;
-
- u32 loopcount = 0;
- do
- {
- loopcount++;
-
- // Maximum time increment (for collision detection etc)
- // time = distance / speed
- f32 dtime_max_increment = 1.0;
- if(speed_f.getLength() != 0)
- dtime_max_increment = pos_max_d / speed_f.getLength();
-
- // Maximum time increment is 10ms or lower
- if(dtime_max_increment > 0.01)
- dtime_max_increment = 0.01;
-
- f32 dtime_part;
- if(dtime_downcount > dtime_max_increment)
- {
- dtime_part = dtime_max_increment;
- dtime_downcount -= dtime_part;
- }
- else
- {
- dtime_part = dtime_downcount;
- /*
- Setting this to 0 (no -=dtime_part) disables an infinite loop
- when dtime_part is so small that dtime_downcount -= dtime_part
- does nothing
- */
- dtime_downcount = 0;
- }
-
- collisionMoveResult result = collisionMoveSimple(map, gamedef,
- pos_max_d, box_0, stepheight, dtime_part,
- pos_f, speed_f, accel_f);
-
- if(result.touching_ground)
- final_result.touching_ground = true;
- if(result.collides)
- final_result.collides = true;
- if(result.collides_xz)
- final_result.collides_xz = true;
- if(result.standing_on_unloaded)
- final_result.standing_on_unloaded = true;
- }
- while(dtime_downcount > 0.001);
-
- return final_result;
-}
-#endif
diff --git a/src/collision.h b/src/collision.h
index 32086aae3..fc4187eda 100644
--- a/src/collision.h
+++ b/src/collision.h
@@ -75,15 +75,6 @@ collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef,
v3f &accel_f,ActiveObject* self=0,
bool collideWithObjects=true);
-#if 0
-// This doesn't seem to work and isn't used
-// Moves using as many iterations as needed
-collisionMoveResult collisionMovePrecise(Map *map, IGameDef *gamedef,
- f32 pos_max_d, const aabb3f &box_0,
- f32 stepheight, f32 dtime,
- v3f &pos_f, v3f &speed_f, v3f &accel_f);
-#endif
-
// Helper function:
// Checks for collision of a moving aabbox with a static aabbox
// Returns -1 if no collision, 0 if X collision, 1 if Y collision, 2 if Z collision
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index eab1e6279..add1726fc 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "collision.h"
#include "environment.h"
#include "settings.h"
-#include "profiler.h"
#include "serialization.h" // For compressZlib
#include "tool.h" // For ToolCapabilities
#include "gamedef.h"
diff --git a/src/main.cpp b/src/main.cpp
index 79daa7b8c..1d73b4025 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -40,7 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "game.h"
#include "defaultsettings.h"
#include "gettext.h"
-#include "profiler.h"
#include "log.h"
#include "quicktune.h"
#include "httpfetch.h"
diff --git a/src/mapgen_singlenode.cpp b/src/mapgen_singlenode.cpp
index a40020ab3..a8b84e849 100644
--- a/src/mapgen_singlenode.cpp
+++ b/src/mapgen_singlenode.cpp
@@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h"
#include "nodedef.h"
#include "voxelalgorithms.h"
-#include "profiler.h"
#include "emerge.h"
diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp
index 00a1b915d..f23dad4ec 100644
--- a/src/mapgen_v5.cpp
+++ b/src/mapgen_v5.cpp
@@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h"
#include "nodedef.h"
#include "voxelalgorithms.h"
-#include "profiler.h"
#include "settings.h" // For g_settings
#include "emerge.h"
#include "dungeongen.h"
diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp
index 86e2f89ae..09acec783 100644
--- a/src/mapgen_v6.cpp
+++ b/src/mapgen_v6.cpp
@@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h"
#include "content_mapnode.h" // For content_mapnode_get_new_name
#include "voxelalgorithms.h"
-#include "profiler.h"
#include "settings.h" // For g_settings
#include "emerge.h"
#include "dungeongen.h"
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp
index 4eb305dc5..a46bf8f17 100644
--- a/src/mapgen_v7.cpp
+++ b/src/mapgen_v7.cpp
@@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h"
#include "nodedef.h"
#include "voxelalgorithms.h"
-#include "profiler.h"
#include "settings.h" // For g_settings
#include "emerge.h"
#include "dungeongen.h"
diff --git a/src/player.cpp b/src/player.cpp
index 26496259c..668d490cc 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -119,31 +119,12 @@ void Player::accelerateHorizontal(v3f target_speed, f32 max_increase)
f32 dl = d_wanted.getLength();
if(dl > max_increase)
dl = max_increase;
-
+
v3f d = d_wanted.normalize() * dl;
m_speed.X += d.X;
m_speed.Z += d.Z;
-#if 0 // old code
- if(m_speed.X < target_speed.X - max_increase)
- m_speed.X += max_increase;
- else if(m_speed.X > target_speed.X + max_increase)
- m_speed.X -= max_increase;
- else if(m_speed.X < target_speed.X)
- m_speed.X = target_speed.X;
- else if(m_speed.X > target_speed.X)
- m_speed.X = target_speed.X;
-
- if(m_speed.Z < target_speed.Z - max_increase)
- m_speed.Z += max_increase;
- else if(m_speed.Z > target_speed.Z + max_increase)
- m_speed.Z -= max_increase;
- else if(m_speed.Z < target_speed.Z)
- m_speed.Z = target_speed.Z;
- else if(m_speed.Z > target_speed.Z)
- m_speed.Z = target_speed.Z;
-#endif
}
// Vertical acceleration (Y), X and Z directions are ignored
@@ -160,16 +141,6 @@ void Player::accelerateVertical(v3f target_speed, f32 max_increase)
m_speed.Y += d_wanted;
-#if 0 // old code
- if(m_speed.Y < target_speed.Y - max_increase)
- m_speed.Y += max_increase;
- else if(m_speed.Y > target_speed.Y + max_increase)
- m_speed.Y -= max_increase;
- else if(m_speed.Y < target_speed.Y)
- m_speed.Y = target_speed.Y;
- else if(m_speed.Y > target_speed.Y)
- m_speed.Y = target_speed.Y;
-#endif
}
v3s16 Player::getLightPosition() const