diff --git a/source/game/BaseEntity.cpp b/source/game/BaseEntity.cpp index 5bca9322a4a7c6949491c6b6a2ee921a61cbaf88..65a8f2ac5050371187312156379bcbed47e72a6f 100644 --- a/source/game/BaseEntity.cpp +++ b/source/game/BaseEntity.cpp @@ -153,6 +153,12 @@ void CBaseEntity::getSphere(float3 * center, float * radius) void CBaseEntity::setPos(const float3 & pos) { + CBaseEntity *pParent = NULL; + if(m_pParent) + { + pParent = m_pParent; + setParent(NULL); + } m_vPosition = pos; if(m_pEditorRigidBody) @@ -160,6 +166,11 @@ void CBaseEntity::setPos(const float3 & pos) m_pEditorRigidBody->getWorldTransform().setOrigin(F3_BTVEC(m_vPosition)); SPhysics_GetDynWorld()->updateSingleAabb(m_pEditorRigidBody); } + + if(pParent) + { + setParent(pParent, m_iParentAttachment); + } } float3 CBaseEntity::getPos() @@ -619,6 +630,8 @@ CBaseEntity* CBaseEntity::getParent() void CBaseEntity::onSync() { + m_bSynced = true; + if(m_pParent) { if(!m_pParent->m_bSynced) @@ -647,7 +660,6 @@ void CBaseEntity::onSync() // m_vOrientation = m_pPhysObj->getOrient(); //} - m_bSynced = true; } void CBaseEntity::onPostLoad() diff --git a/source/game/EditorObject.cpp b/source/game/EditorObject.cpp index 9a71d4df856f6fece9cc7efb107e8646378edf6e..9bb29d1105cf9013ba7862bde423aea5157b0351 100644 --- a/source/game/EditorObject.cpp +++ b/source/game/EditorObject.cpp @@ -146,6 +146,24 @@ void XMETHODCALLTYPE CEditorObject::setOrient(const SMQuaternion &orient) m_qRot = orient; } +float3_t XMETHODCALLTYPE CEditorObject::getPos() +{ + if(m_pEntity) + { + m_vPos = m_pEntity->getPos(); + } + return(m_vPos); +} + +SMQuaternion XMETHODCALLTYPE CEditorObject::getOrient() +{ + if(m_pEntity) + { + m_qRot = m_pEntity->getOrient(); + } + return(m_qRot); +} + void XMETHODCALLTYPE CEditorObject::getBound(float3 *pvMin, float3 *pvMax) { *pvMin = *pvMax = float3(); diff --git a/source/game/EditorObject.h b/source/game/EditorObject.h index dea57821440972dd570cf2ab54641a7c2133e7a7..e9bab6d374cc047f83c735a9a8e791f532e044ea 100644 --- a/source/game/EditorObject.h +++ b/source/game/EditorObject.h @@ -42,15 +42,10 @@ public: - float3_t XMETHODCALLTYPE getPos() override - { - return(m_vPos); - } + float3_t XMETHODCALLTYPE getPos() override; + + SMQuaternion XMETHODCALLTYPE getOrient() override; - SMQuaternion XMETHODCALLTYPE getOrient() override - { - return(m_qRot); - } float3_t XMETHODCALLTYPE getScale() override { return(m_vScale);