Fix variable names and comments in crawling and extended block selecting
parent
6347f4aeeb
commit
082dd7e4e1
19
src/game.cpp
19
src/game.cpp
|
@ -346,9 +346,8 @@ PointedThing getPointedThing(Client *client, v3f player_position,
|
||||||
|
|
||||||
// That didn't work, try to find a pointed at node
|
// That didn't work, try to find a pointed at node
|
||||||
|
|
||||||
static const bool extBlockSel = g_settings->getBool("extended_block_selecting");
|
static const bool ext_block_sel = g_settings->getBool("extended_block_selecting");
|
||||||
bool onlyFreeFound = false;
|
bool free_node_found = false;
|
||||||
bool freeNodeFound = false;
|
|
||||||
|
|
||||||
f32 mindistance = BS * 1001; //used for regular blocks
|
f32 mindistance = BS * 1001; //used for regular blocks
|
||||||
f32 maxdistance = -BS * 1001; //used for free blocks
|
f32 maxdistance = -BS * 1001; //used for free blocks
|
||||||
|
@ -576,7 +575,7 @@ PointedThing getPointedThing(Client *client, v3f player_position,
|
||||||
should_show_hilightbox = true;
|
should_show_hilightbox = true;
|
||||||
|
|
||||||
//if no node has been found - we try to find 'fake' pointed node
|
//if no node has been found - we try to find 'fake' pointed node
|
||||||
}else if(extBlockSel
|
}else if(ext_block_sel
|
||||||
&& result.type == POINTEDTHING_NOTHING
|
&& result.type == POINTEDTHING_NOTHING
|
||||||
&& distance < (BS*6) //is this enough?
|
&& distance < (BS*6) //is this enough?
|
||||||
&& np != pos_i
|
&& np != pos_i
|
||||||
|
@ -598,10 +597,10 @@ PointedThing getPointedThing(Client *client, v3f player_position,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//check if we can build onto this node by normally selecting it
|
//check if we can build onto this node by normally selecting it
|
||||||
if( npos.X==camdir_i.X //is it same direction as camera?
|
if( npos.X==camdir_i.X //check if it's the same direction as camera
|
||||||
|| npos.Y==camdir_i.Y
|
|| npos.Y==camdir_i.Y
|
||||||
|| npos.Z==camdir_i.Z
|
|| npos.Z==camdir_i.Z
|
||||||
|| (npos.X != 0 && cam_i.X == np.X) //is it the same axis as camera?
|
|| (npos.X != 0 && cam_i.X == np.X) //check if it's the same axis as camera
|
||||||
|| (npos.Y != 0 && cam_i.Y == np.Y)
|
|| (npos.Y != 0 && cam_i.Y == np.Y)
|
||||||
|| (npos.Z != 0 && cam_i.Z == np.Z) )
|
|| (npos.Z != 0 && cam_i.Z == np.Z) )
|
||||||
{
|
{
|
||||||
|
@ -619,10 +618,10 @@ PointedThing getPointedThing(Client *client, v3f player_position,
|
||||||
|
|
||||||
maxdistance = distance;
|
maxdistance = distance;
|
||||||
|
|
||||||
//result.type = POINTEDTHING_NODE; //we can't do this here!
|
//result.type = POINTEDTHING_NODE; //we can't do this here
|
||||||
freeNodeFound = true; //instead, we set this and check at the end
|
free_node_found = true; //instead, we set this and check at the end
|
||||||
|
|
||||||
result.node_undersurface = neigh_pos; //yes, these are swaped!
|
result.node_undersurface = neigh_pos; //yes, these are swaped
|
||||||
result.node_abovesurface = np;
|
result.node_abovesurface = np;
|
||||||
|
|
||||||
const float d = 0.502;
|
const float d = 0.502;
|
||||||
|
@ -641,7 +640,7 @@ PointedThing getPointedThing(Client *client, v3f player_position,
|
||||||
} // regular block
|
} // regular block
|
||||||
} // for coords
|
} // for coords
|
||||||
|
|
||||||
if(extBlockSel && result.type == POINTEDTHING_NOTHING && freeNodeFound){
|
if(ext_block_sel && result.type == POINTEDTHING_NOTHING && free_node_found){
|
||||||
result.is_fake = true;
|
result.is_fake = true;
|
||||||
result.type = POINTEDTHING_NODE;
|
result.type = POINTEDTHING_NODE;
|
||||||
should_show_hilightbox = true;
|
should_show_hilightbox = true;
|
||||||
|
|
|
@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "gamedef.h"
|
#include "gamedef.h"
|
||||||
|
|
||||||
f32 Player::m_eyeOffsetMax = BS+(5*BS)/8;
|
#define EYE_OFFSET_MAX (BS+(5*BS)/8)
|
||||||
f32 Player::m_eyeOffsetMin = BS * 0.9f;
|
#define EYE_OFFSET_MIN (BS * 0.9f)
|
||||||
|
|
||||||
Player::Player(IGameDef *gamedef):
|
Player::Player(IGameDef *gamedef):
|
||||||
touching_ground(false),
|
touching_ground(false),
|
||||||
|
@ -51,7 +51,7 @@ Player::Player(IGameDef *gamedef):
|
||||||
m_yaw(0),
|
m_yaw(0),
|
||||||
m_speed(0,0,0),
|
m_speed(0,0,0),
|
||||||
m_position(0,0,0),
|
m_position(0,0,0),
|
||||||
m_eyeOffset(0,m_eyeOffsetMax,0)
|
m_eye_offset(0,EYE_OFFSET_MAX,0)
|
||||||
{
|
{
|
||||||
updateName("<not set>");
|
updateName("<not set>");
|
||||||
resetInventory();
|
resetInventory();
|
||||||
|
@ -294,8 +294,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
||||||
assert(d > pos_max_d);
|
assert(d > pos_max_d);
|
||||||
|
|
||||||
float player_radius = BS*0.35;
|
float player_radius = BS*0.35;
|
||||||
float player_height = m_eyeOffset.Y + BS*0.05f;
|
float player_height = m_eye_offset.Y + BS*0.05f;
|
||||||
float player_maxheight = m_eyeOffsetMax + BS*0.05f;
|
float player_maxheight = EYE_OFFSET_MAX + BS*0.05f;
|
||||||
|
|
||||||
// Maximum distance over border for sneaking
|
// Maximum distance over border for sneaking
|
||||||
f32 sneak_max = BS*0.4;
|
f32 sneak_max = BS*0.4;
|
||||||
|
@ -603,7 +603,7 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
||||||
Check if player must crawl
|
Check if player must crawl
|
||||||
*/
|
*/
|
||||||
bool must_crawl = false;
|
bool must_crawl = false;
|
||||||
v3s16 pos_head_i = floatToInt(v3f(position.X,position.Y+m_eyeOffsetMax+BS*0.05f,position.Z), BS);
|
v3s16 pos_head_i = floatToInt(v3f(position.X,position.Y+EYE_OFFSET_MAX+BS*0.05f,position.Z), BS);
|
||||||
for(s16 z = -1; z <= 1; z++)
|
for(s16 z = -1; z <= 1; z++)
|
||||||
for(s16 x = -1; x <= 1; x++)
|
for(s16 x = -1; x <= 1; x++)
|
||||||
{
|
{
|
||||||
|
@ -613,8 +613,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
||||||
if(nodemgr->get(map.getNode(np)).walkable == false)
|
if(nodemgr->get(map.getNode(np)).walkable == false)
|
||||||
continue;
|
continue;
|
||||||
core::aabbox3d<f32> nodebox = getNodeBox(np, BS);
|
core::aabbox3d<f32> nodebox = getNodeBox(np, BS);
|
||||||
if( (m_must_crawl || control.crawl) //shall we test it?
|
if( (m_must_crawl || control.crawl) //only if we were crawling before
|
||||||
&& playerbox_standing.intersectsWithBox(nodebox) //colliding with the node?
|
&& playerbox_standing.intersectsWithBox(nodebox) //only when colliding with the node
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
must_crawl = true;
|
must_crawl = true;
|
||||||
|
@ -798,14 +798,14 @@ void LocalPlayer::applyControl(float dtime)
|
||||||
static const f32 eyes_delta = 10.f;
|
static const f32 eyes_delta = 10.f;
|
||||||
if(control.crawl){
|
if(control.crawl){
|
||||||
//crawling
|
//crawling
|
||||||
if(m_eyeOffset.Y > m_eyeOffsetMin + 0.01f)
|
if(m_eye_offset.Y > EYE_OFFSET_MIN + 0.01f)
|
||||||
m_eyeOffset.Y += (m_eyeOffsetMin-m_eyeOffset.Y) * eyes_delta * dtime;
|
m_eye_offset.Y += (EYE_OFFSET_MIN-m_eye_offset.Y) * eyes_delta * dtime;
|
||||||
else m_eyeOffset.Y = m_eyeOffsetMin;
|
else m_eye_offset.Y = EYE_OFFSET_MIN;
|
||||||
}else{
|
}else{
|
||||||
//standing
|
//standing
|
||||||
if(m_eyeOffset.Y < m_eyeOffsetMax - 0.01f)
|
if(m_eye_offset.Y < EYE_OFFSET_MAX - 0.01f)
|
||||||
m_eyeOffset.Y += (m_eyeOffsetMax-m_eyeOffset.Y) * eyes_delta * dtime;
|
m_eye_offset.Y += (EYE_OFFSET_MAX-m_eye_offset.Y) * eyes_delta * dtime;
|
||||||
else m_eyeOffset.Y = m_eyeOffsetMax;
|
else m_eye_offset.Y = EYE_OFFSET_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
// return v3f(0, BS+BS/2, 0);
|
// return v3f(0, BS+BS/2, 0);
|
||||||
// This is more like in minecraft
|
// This is more like in minecraft
|
||||||
//return v3f(0,BS+(5*BS)/8,0);
|
//return v3f(0,BS+(5*BS)/8,0);
|
||||||
return m_eyeOffset;
|
return m_eye_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
v3f getEyePosition()
|
v3f getEyePosition()
|
||||||
|
@ -170,9 +170,7 @@ protected:
|
||||||
f32 m_yaw;
|
f32 m_yaw;
|
||||||
v3f m_speed;
|
v3f m_speed;
|
||||||
v3f m_position;
|
v3f m_position;
|
||||||
v3f m_eyeOffset;
|
v3f m_eye_offset;
|
||||||
static f32 m_eyeOffsetMax;
|
|
||||||
static f32 m_eyeOffsetMin;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -274,9 +274,9 @@ std::string PointedThing::dump() const
|
||||||
{
|
{
|
||||||
const v3s16 &u = node_undersurface;
|
const v3s16 &u = node_undersurface;
|
||||||
const v3s16 &a = node_abovesurface;
|
const v3s16 &a = node_abovesurface;
|
||||||
os<<"[node under="<<u.X<<","<<u.Y<<","<<u.Z
|
os << "[node under="<<u.X<<","<<u.Y<<","<<u.Z
|
||||||
<< " above="<<a.X<<","<<a.Y<<","<<a.Z
|
<< " above="<<a.X<<","<<a.Y<<","<<a.Z
|
||||||
<< (is_fake?" fake]":"]");
|
<< (is_fake?" fake]":"]");
|
||||||
}
|
}
|
||||||
else if(type == POINTEDTHING_OBJECT)
|
else if(type == POINTEDTHING_OBJECT)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1766,7 +1766,7 @@ struct PointedThing
|
||||||
v3s16 node_undersurface;
|
v3s16 node_undersurface;
|
||||||
v3s16 node_abovesurface;
|
v3s16 node_abovesurface;
|
||||||
s16 object_id;
|
s16 object_id;
|
||||||
bool is_fake; //if true, then disallow digging! [not serialized!]
|
bool is_fake; //if true, then disallow digging [not serialized!]
|
||||||
|
|
||||||
PointedThing();
|
PointedThing();
|
||||||
std::string dump() const;
|
std::string dump() const;
|
||||||
|
|
Loading…
Reference in New Issue