Skip to content

Commit

Permalink
Editor: Drag and drop object to itself leads to object disappear #420
Browse files Browse the repository at this point in the history
  • Loading branch information
eprikazchikov committed Oct 24, 2021
1 parent 095788c commit 62631f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions engine/src/components/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ void Actor::clearCloneRef() {
*/
void Actor::setParent(Object *parent, int32_t position, bool force) {
PROFILE_FUNCTION();
if(parent == this) {
return;
}

if(p_ptr->m_transform) {
Object::setParent(parent, position, force);

Expand Down
3 changes: 3 additions & 0 deletions engine/src/components/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ Vector3 &Transform::worldScale() const {
*/
void Transform::setParent(Object *parent, int32_t position, bool force) {
A_UNUSED(position);
if(parent == this) {
return;
}
Object::setParent(parent, 0, force);

Actor *p = dynamic_cast<Actor *>(actor()->parent());
Expand Down
4 changes: 4 additions & 0 deletions thirdparty/next/src/core/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,10 @@ void Object::setParent(Object *parent, int32_t position, bool force) {
PROFILE_FUNCTION();
A_UNUSED(force);

if(parent == this) {
return;
}

if(p_ptr->m_pParent) {
p_ptr->m_pParent->removeChild(this);
}
Expand Down

0 comments on commit 62631f9

Please sign in to comment.