diff options
| author | est31 <MTest31@outlook.com> | 2015-06-20 00:30:38 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2015-06-20 02:59:53 +0200 |
| commit | 40226e52747156cbdc5128a416480b226e498fff (patch) | |
| tree | e0863a9c88f78bc578e7c8d60222c5f52dac81c5 /src/content_cao.cpp | |
| parent | 3b65a6a36c3e910359c69cd3e3e3fd89e50ba23e (diff) | |
| download | minetest-40226e52747156cbdc5128a416480b226e498fff.tar.xz | |
Make attached objects visible in 3rd person view
Diffstat (limited to 'src/content_cao.cpp')
| -rw-r--r-- | src/content_cao.cpp | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 9ee81e63f..4f1336d28 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -727,6 +727,17 @@ scene::IBillboardSceneNode* GenericCAO::getSpriteSceneNode() return m_spritenode; } +void GenericCAO::setChildrenVisible(bool toset) +{ + for (std::vector<u16>::iterator ci = m_children.begin(); + ci != m_children.end(); ci++) { + GenericCAO *obj = m_env->getGenericCAO(*ci); + if (obj) { + obj->setVisible(toset); + } + } +} + void GenericCAO::setAttachments() { updateAttachments(); @@ -1489,16 +1500,7 @@ void GenericCAO::updateBonePosition() void GenericCAO::updateAttachments() { - // localplayer itself can't be attached to localplayer - if (!m_is_local_player) - { - m_attached_to_local = getParent() != NULL && getParent()->isLocalPlayer(); - // Objects attached to the local player should always be hidden - m_is_visible = !m_attached_to_local; - } - - if(getParent() == NULL || m_attached_to_local) // Detach or don't attach - { + if (getParent() == NULL) { // Detach or don't attach scene::ISceneNode *node = getSceneNode(); if (node) { v3f old_position = node->getAbsolutePosition(); @@ -1667,14 +1669,26 @@ void GenericCAO::processMessage(const std::string &data) m_bone_position[bone] = core::vector2d<v3f>(position, rotation); updateBonePosition(); - } - else if(cmd == GENERIC_CMD_SET_ATTACHMENT) { - m_env->m_attachements[getId()] = readS16(is); - m_children.push_back(m_env->m_attachements[getId()]); + } else if (cmd == GENERIC_CMD_SET_ATTACHMENT) { + u16 parentID = readS16(is); + m_env->m_attachements[getId()] = parentID; + GenericCAO *parentobj = m_env->getGenericCAO(parentID); + + if (parentobj) { + parentobj->m_children.push_back(getId()); + } + m_attachment_bone = deSerializeString(is); m_attachment_position = readV3F1000(is); m_attachment_rotation = readV3F1000(is); + // localplayer itself can't be attached to localplayer + if (!m_is_local_player) { + m_attached_to_local = getParent() != NULL && getParent()->isLocalPlayer(); + // Objects attached to the local player should be hidden by default + m_is_visible = !m_attached_to_local; + } + updateAttachments(); } else if(cmd == GENERIC_CMD_PUNCHED) { |
