Merge upstream ghosting candidate changes

This commit is contained in:
David Markowitz 2023-06-25 21:01:10 -07:00
parent 485a88dfd4
commit 3f328a18be

View File

@ -134,7 +134,7 @@ Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity)
m_PhantomCollisionCallbacks.clear(); m_PhantomCollisionCallbacks.clear();
m_ScheduleKiller = nullptr; m_ScheduleKiller = nullptr;
m_IsParentChildDirty = true; m_IsParentChildDirty = true;
m_IsGhostingCandidate = false; m_IsGhostingCandidate = true;
m_PlayerIsReadyForUpdates = false; m_PlayerIsReadyForUpdates = false;
m_ShouldDestroyAfterUpdate = false; m_ShouldDestroyAfterUpdate = false;
@ -585,35 +585,14 @@ void Entity::Initialize() {
if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) IsGhosted(); if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) IsGhosted();
} }
// Invert this check and build it into the component initialization. The ghosting property is an intrinsic property of which components the Entity has.
// Keep the first check since that is a special case for large scene elements like Brig Rock as a whole.
void Entity::IsGhosted() { void Entity::IsGhosted() {
// Don't ghost what is likely large scene elements // Don't ghost what is likely large scene elements
if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) { if (m_Components.size() == 2 && HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER)) {
return; m_IsGhostingCandidate = false;
} } else if (m_Components.size() == 3 && HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && HasComponent(eReplicaComponentType::TRIGGER)) {
m_IsGhostingCandidate = false;
/* Filter for ghosting candidates. } else if (EntityManager::IsExcludedFromGhosting(GetLOT())) {
* m_IsGhostingCandidate = false;
* Don't ghost moving platforms, until we've got proper syncing for those.
* Don't ghost big phantom physics triggers, as putting those to sleep might prevent interactions.
* Don't ghost property related objects, as the client expects those to always be loaded.
*/
if (!EntityManager::IsExcludedFromGhosting(GetLOT()) &&
!HasComponent(eReplicaComponentType::SCRIPTED_ACTIVITY) &&
!HasComponent(eReplicaComponentType::MOVING_PLATFORM) &&
!HasComponent(eReplicaComponentType::PHANTOM_PHYSICS) &&
!HasComponent(eReplicaComponentType::PROPERTY) &&
!HasComponent(eReplicaComponentType::RACING_CONTROL) &&
!HasComponent(eReplicaComponentType::VEHICLE_PHYSICS)) {
m_IsGhostingCandidate = true;
}
if (GetLOT() == LOT_3D_AMBIENT_SOUND) m_IsGhostingCandidate = true;
// Special case for collectibles in Ninjago
if (HasComponent(eReplicaComponentType::COLLECTIBLE) && Game::server->GetZoneID() == 2000) {
m_IsGhostingCandidate = true;
} }
} }
@ -806,7 +785,7 @@ void Entity::ResetFlags() {
void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) { void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) {
DluAssert(doc != nullptr); DluAssert(doc != nullptr);
for (const auto&[componentId, component] : m_Components) { for (const auto& [componentId, component] : m_Components) {
if (component) component->UpdateXml(doc); if (component) component->UpdateXml(doc);
} }
} }