aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTeTpaAka <TeTpaAka@users.noreply.github.com>2017-07-29 19:24:10 +0200
committerSmallJoker <SmallJoker@users.noreply.github.com>2017-07-29 19:24:10 +0200
commitd504831ee2adf59421e82202e350f82701bd3cd0 (patch)
tree60995a1066acd095d386add25362b2a1c660fde8 /src
parent765fd9a0bc0bb9f08d12713dc586e7f4c59c421d (diff)
downloadminetest-d504831ee2adf59421e82202e350f82701bd3cd0.tar.gz
minetest-d504831ee2adf59421e82202e350f82701bd3cd0.tar.bz2
minetest-d504831ee2adf59421e82202e350f82701bd3cd0.zip
Move the nametag back to the top of the player (#6179)
read the actual height of the collisionbox
Diffstat (limited to 'src')
-rw-r--r--src/camera.cpp7
-rw-r--r--src/camera.h10
-rw-r--r--src/content_cao.cpp8
3 files changed, 18 insertions, 7 deletions
diff --git a/src/camera.cpp b/src/camera.cpp
index 027e0ffc8..efd8a3389 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -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;
}
diff --git a/src/camera.h b/src/camera.h
index 620e316de..052284cac 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -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 @@ public:
}
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);
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index 2cc675573..993087353 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -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);