Skip to content

Commit

Permalink
Fix bug blink Model when attach to another Parent Node
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Aug 20, 2024
1 parent 7813d60 commit 24a2904
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Projects/Skylicht/Engine/Source/Entity/CEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ namespace Skylicht

IEntityData* addDataByActivator(const char* dataType);

inline CEntityManager* getEntityManager()
{
return m_mgr;
}

inline int getDataCount()
{
return MAX_ENTITY_DATA;
Expand Down
3 changes: 3 additions & 0 deletions Projects/Skylicht/Engine/Source/Entity/CEntityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ namespace Skylicht
}
else
{
if (world->ParentIndex >= 0)
world->Parent = GET_ENTITY_DATA(m_entities[world->ParentIndex], CWorldTransformData);

if (world->Parent)
world->Depth = world->Parent->Depth + 1;
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This file is part of the "Skylicht Engine".

#include "pch.h"
#include "CWorldTransformData.h"
#include "Entity/CEntityManager.h"

namespace Skylicht
{
Expand Down Expand Up @@ -69,4 +70,11 @@ namespace Skylicht
HasChanged = true;
return true;
}

void CWorldTransformData::attachParent(CWorldTransformData* parent)
{
AttachParentIndex = parent->EntityIndex;
HasChanged = true;
Entity->getEntityManager()->notifyUpdateSortEntities();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace Skylicht
return World.getTranslation();
}

void attachParent(CWorldTransformData* parent);

DECLARE_GETTYPENAME(CWorldTransformData)
};

Expand Down

0 comments on commit 24a2904

Please sign in to comment.