Skip to content

Commit

Permalink
Remove profiler.h include where it's not needed. Remove some unreacha…
Browse files Browse the repository at this point in the history
…ble and very old code
  • Loading branch information
nerzhul committed Jul 21, 2015
1 parent 5ebb423 commit fa7fe51
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 149 deletions.
42 changes: 12 additions & 30 deletions src/camera.cpp
Expand Up @@ -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 {

This comment has been minimized.

Copy link
@est31

est31 Jul 21, 2015

Contributor

You have extra newline here

This comment has been minimized.

Copy link
@nerzhul

nerzhul Jul 21, 2015

Author Member

Which new line ? I removed one line

This comment has been minimized.

Copy link
@est31

est31 Jul 21, 2015

Contributor
}
else {

Is not allowed by style guide. Instead do

} else {

This comment has been minimized.

Copy link
@nerzhul

nerzhul Jul 21, 2015

Author Member

Oh i see. I will not commit only for style, will be careful in next commits to cleanup this :)

This comment has been minimized.

Copy link
@est31

est31 Jul 21, 2015

Contributor

👍

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);
}
Expand Down
75 changes: 1 addition & 74 deletions src/collision.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
9 changes: 0 additions & 9 deletions src/collision.h
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/content_sao.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/mapgen_singlenode.cpp
Expand Up @@ -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"


Expand Down
1 change: 0 additions & 1 deletion src/mapgen_v5.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/mapgen_v6.cpp
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/mapgen_v7.cpp
Expand Up @@ -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"
Expand Down
31 changes: 1 addition & 30 deletions src/player.cpp
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit fa7fe51

Please sign in to comment.