@@ -460,18 +460,20 @@ void GenericCAO::setChildrenVisible(bool toset)
460
460
GenericCAO *obj = m_env->getGenericCAO (cao_id);
461
461
if (obj) {
462
462
// Check if the entity is forced to appear in first person.
463
- obj->setVisible (obj->isForcedVisible () ? true : toset);
463
+ obj->setVisible (obj->m_force_visible ? true : toset);
464
464
}
465
465
}
466
466
}
467
467
468
- void GenericCAO::setAttachment (int parent_id, const std::string &bone, v3f position, v3f rotation)
468
+ void GenericCAO::setAttachment (int parent_id, const std::string &bone,
469
+ v3f position, v3f rotation, bool force_visible)
469
470
{
470
471
int old_parent = m_attachment_parent_id;
471
472
m_attachment_parent_id = parent_id;
472
473
m_attachment_bone = bone;
473
474
m_attachment_position = position;
474
475
m_attachment_rotation = rotation;
476
+ m_force_visible = force_visible;
475
477
476
478
ClientActiveObject *parent = m_env->getActiveObject (parent_id);
477
479
@@ -482,15 +484,30 @@ void GenericCAO::setAttachment(int parent_id, const std::string &bone, v3f posit
482
484
parent->addAttachmentChild (m_id);
483
485
}
484
486
updateAttachments ();
487
+
488
+ // Forcibly show attachments if required by set_attach
489
+ if (m_force_visible) {
490
+ m_is_visible = true ;
491
+ } else if (!m_is_local_player) {
492
+ // Objects attached to the local player should be hidden in first person
493
+ m_is_visible = !m_attached_to_local ||
494
+ m_client->getCamera ()->getCameraMode () != CAMERA_MODE_FIRST;
495
+ m_force_visible = false ;
496
+ } else {
497
+ // Local players need to have this set,
498
+ // otherwise first person attachments fail.
499
+ m_is_visible = true ;
500
+ }
485
501
}
486
502
487
503
void GenericCAO::getAttachment (int *parent_id, std::string *bone, v3f *position,
488
- v3f *rotation) const
504
+ v3f *rotation, bool *force_visible ) const
489
505
{
490
506
*parent_id = m_attachment_parent_id;
491
507
*bone = m_attachment_bone;
492
508
*position = m_attachment_position;
493
509
*rotation = m_attachment_rotation;
510
+ *force_visible = m_force_visible;
494
511
}
495
512
496
513
void GenericCAO::clearChildAttachments ()
@@ -509,9 +526,9 @@ void GenericCAO::clearChildAttachments()
509
526
void GenericCAO::clearParentAttachment ()
510
527
{
511
528
if (m_attachment_parent_id)
512
- setAttachment (0 , " " , m_attachment_position, m_attachment_rotation);
529
+ setAttachment (0 , " " , m_attachment_position, m_attachment_rotation, false );
513
530
else
514
- setAttachment (0 , " " , v3f (), v3f ());
531
+ setAttachment (0 , " " , v3f (), v3f (), false );
515
532
}
516
533
517
534
void GenericCAO::addAttachmentChild (int child_id)
@@ -1781,25 +1798,9 @@ void GenericCAO::processMessage(const std::string &data)
1781
1798
std::string bone = deSerializeString16 (is);
1782
1799
v3f position = readV3F32 (is);
1783
1800
v3f rotation = readV3F32 (is);
1784
- m_force_visible = readU8 (is); // Returns false for EOF
1785
-
1786
- setAttachment (parent_id, bone, position, rotation);
1787
-
1788
- // Forcibly show attachments if required by set_attach
1789
- if (m_force_visible)
1790
- m_is_visible = true ;
1791
- // localplayer itself can't be attached to localplayer
1792
- else if (!m_is_local_player) {
1793
- // Objects attached to the local player should be hidden in first
1794
- // person provided the forced boolean isn't set.
1795
- m_is_visible = !m_attached_to_local ||
1796
- m_client->getCamera ()->getCameraMode () != CAMERA_MODE_FIRST;
1797
- m_force_visible = false ;
1798
- } else {
1799
- // Local players need to have this set,
1800
- // otherwise first person attachments fail.
1801
- m_is_visible = true ;
1802
- }
1801
+ bool force_visible = readU8 (is); // Returns false for EOF
1802
+
1803
+ setAttachment (parent_id, bone, position, rotation, force_visible);
1803
1804
} else if (cmd == AO_CMD_PUNCHED) {
1804
1805
u16 result_hp = readU16 (is);
1805
1806
0 commit comments