Skip to content
Permalink
Browse files
Move the nametag back to the top of the player (#6179)
read the actual height of the collisionbox
  • Loading branch information
TeTpaAka authored and SmallJoker committed Jul 29, 2017
1 parent 765fd9a commit d504831ee2adf59421e82202e350f82701bd3cd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
@@ -617,7 +617,7 @@ void Camera::drawNametags()
// shadow can remain.
continue;
}
v3f pos = nametag->parent_node->getAbsolutePosition() + v3f(0.0, 1.1 * BS, 0.0);
v3f pos = nametag->parent_node->getAbsolutePosition() + nametag->nametag_pos * BS;
f32 transformed_pos[4] = { pos.X, pos.Y, pos.Z, 1.0f };
trans.multiplyWith1x4Matrix(transformed_pos);
if (transformed_pos[3] > 0) {
@@ -641,9 +641,10 @@ void Camera::drawNametags()
}

Nametag *Camera::addNametag(scene::ISceneNode *parent_node,
std::string nametag_text, video::SColor nametag_color)
const std::string &nametag_text, video::SColor nametag_color,
const v3f &pos)
{
Nametag *nametag = new Nametag(parent_node, nametag_text, nametag_color);
Nametag *nametag = new Nametag(parent_node, nametag_text, nametag_color, pos);
m_nametags.push_back(nametag);
return nametag;
}
@@ -39,15 +39,18 @@ class WieldMeshSceneNode;
struct Nametag {
Nametag(scene::ISceneNode *a_parent_node,
const std::string &a_nametag_text,
const video::SColor &a_nametag_color):
const video::SColor &a_nametag_color,
const v3f a_nametag_pos):
parent_node(a_parent_node),
nametag_text(a_nametag_text),
nametag_color(a_nametag_color)
nametag_color(a_nametag_color),
nametag_pos(a_nametag_pos)
{
}
scene::ISceneNode *parent_node;
std::string nametag_text;
video::SColor nametag_color;
v3f nametag_pos;
};

enum CameraMode {CAMERA_MODE_FIRST, CAMERA_MODE_THIRD, CAMERA_MODE_THIRD_FRONT};
@@ -157,7 +160,8 @@ class Camera
}

Nametag *addNametag(scene::ISceneNode *parent_node,
std::string nametag_text, video::SColor nametag_color);
const std::string &nametag_text, video::SColor nametag_color,
const v3f &pos);

void removeNametag(Nametag *nametag);

@@ -895,8 +895,11 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
scene::ISceneNode *node = getSceneNode();
if (node && m_prop.nametag != "" && !m_is_local_player) {
// Add nametag
v3f pos;
pos.Y = m_prop.collisionbox.MaxEdge.Y + 0.3f;
m_nametag = m_client->getCamera()->addNametag(node,
m_prop.nametag, m_prop.nametag_color);
m_prop.nametag, m_prop.nametag_color,
pos);
}

updateNodePos();
@@ -1700,6 +1703,9 @@ void GenericCAO::processMessage(const std::string &data)
m_prop.nametag_color = readARGB8(is);
if (m_nametag != NULL) {
m_nametag->nametag_color = m_prop.nametag_color;
v3f pos;
pos.Y = m_prop.collisionbox.MaxEdge.Y + 0.3f;
m_nametag->nametag_pos = pos;
}
} else if (cmd == GENERIC_CMD_SPAWN_INFANT) {
u16 child_id = readU16(is);

0 comments on commit d504831

Please sign in to comment.