From 3b23cf6a4dbdfdce079b9bcaf3356445069dd556 Mon Sep 17 00:00:00 2001 From: D-AIRY <admin@ds-servers.com> Date: Mon, 21 Dec 2020 11:51:21 +0300 Subject: [PATCH] Removed some onSync calls --- source/game/BaseAnimating.cpp | 5 +++- source/game/BaseEntity.cpp | 14 ++++++------ source/game/BaseEntity.h | 14 +++--------- source/game/BaseItem.cpp | 22 +++++++----------- source/game/BaseItem.h | 4 ++-- source/game/BaseLight.cpp | 17 ++++++++------ source/game/BaseLight.h | 5 ++++ source/game/BaseTool.cpp | 4 ++-- source/game/BaseTrigger.cpp | 5 +++- source/game/EntityManager.cpp | 10 +------- source/game/LightDirectional.cpp | 39 ++++++++++++++++++++------------ source/game/LightDirectional.h | 30 ++++++------------------ source/game/LightSun.cpp | 9 +++----- source/game/LightSun.h | 3 ++- source/game/NPCBase.cpp | 12 +++++----- source/game/NPCZombie.cpp | 9 +++++--- source/game/NPCZombie.h | 2 +- source/game/PathCorner.cpp | 14 ++++++------ source/game/Player.cpp | 2 +- source/game/PointCamera.cpp | 16 +++++++++---- source/game/PointCamera.h | 9 ++++---- source/game/PropDoor.cpp | 7 ++++-- source/game/PropStatic.cpp | 5 +++- source/game/SoundEmitter.h | 5 +++- 24 files changed, 132 insertions(+), 130 deletions(-) diff --git a/source/game/BaseAnimating.cpp b/source/game/BaseAnimating.cpp index c9fe67468..ac92c7e51 100644 --- a/source/game/BaseAnimating.cpp +++ b/source/game/BaseAnimating.cpp @@ -381,7 +381,10 @@ void CBaseAnimating::createPhysBody() const float fMass = 1.0f; m_pCollideShape->calculateLocalInertia(fMass, vInertia); - btDefaultMotionState * motionState = new btDefaultMotionState(btTransform(Q4_BTQUAT(m_vOrientation), F3_BTVEC(m_vPosition))); + float3 vPos = getPos(); + SMQuaternion qRot = getOrient(); + + btDefaultMotionState * motionState = new btDefaultMotionState(btTransform(Q4_BTQUAT(qRot), F3_BTVEC(vPos))); btRigidBody::btRigidBodyConstructionInfo rigidBodyCI( fMass, // mass motionState, // initial position diff --git a/source/game/BaseEntity.cpp b/source/game/BaseEntity.cpp index a20c4d1b7..81e8ef7d7 100644 --- a/source/game/BaseEntity.cpp +++ b/source/game/BaseEntity.cpp @@ -22,7 +22,7 @@ BEGIN_PROPTABLE_NOBASE(CBaseEntity) //! Позиция в мире DEFINE_FIELD_VECTORFN(m_vPosition, 0, "origin", "Origin", setPos, EDITOR_TEXTFIELD) //! Ориентация в мире, углы эйлера или кватернион - DEFINE_FIELD_ANGLES(m_vOrientation, 0, "rotation", "Rotation", EDITOR_TEXTFIELD) + DEFINE_FIELD_ANGLESFN(m_qOrientation, 0, "rotation", "Rotation", setOrient, EDITOR_TEXTFIELD) //! Родительский объект в иерархии движения DEFINE_FIELD_PARENT(m_pParent, 0, "parent", "Parent entity", EDITOR_TEXTFIELD) //! Флаги объекта @@ -182,7 +182,7 @@ float3 CBaseEntity::getPos() void CBaseEntity::setOrient(const SMQuaternion & q) { - m_vOrientation = q; + m_qOrientation = q; onParentMoved(true); @@ -196,7 +196,7 @@ void CBaseEntity::setOrient(const SMQuaternion & q) } void CBaseEntity::setOffsetOrient(const SMQuaternion & q) { - m_vOffsetOrient = q; + m_qOffsetOrient = q; } void CBaseEntity::setOffsetPos(const float3 & pos) @@ -211,7 +211,7 @@ float3 CBaseEntity::getOffsetPos() SMQuaternion CBaseEntity::getOrient() { - return(m_vOrientation); + return(m_qOrientation); } void CBaseEntity::onParentMoved(bool bAdjustOffsets) @@ -229,12 +229,12 @@ void CBaseEntity::onParentMoved(bool bAdjustOffsets) if(bAdjustOffsets) { m_vOffsetPos = (float3)(qParentOrient.Conjugate() * (m_vPosition - vParentPos)); - m_vOffsetOrient = m_vOrientation * qParentOrient.Conjugate(); + m_qOffsetOrient = m_qOrientation * qParentOrient.Conjugate(); } else { setPos(vParentPos + qParentOrient * m_vOffsetPos); - setOrient(m_vOffsetOrient * qParentOrient); + setOrient(m_qOffsetOrient * qParentOrient); } m_isInOnParentMoved = false; @@ -252,7 +252,7 @@ void CBaseEntity::setFlags(UINT f) SMMATRIX CBaseEntity::getWorldTM() { - return(m_vOrientation.GetMatrix() * SMMatrixTranslation(m_vPosition)); + return(m_qOrientation.GetMatrix() * SMMatrixTranslation(m_vPosition)); } bool CBaseEntity::setKV(const char * name, const char * value) diff --git a/source/game/BaseEntity.h b/source/game/BaseEntity.h index 2b5b68118..fcb4657c3 100644 --- a/source/game/BaseEntity.h +++ b/source/game/BaseEntity.h @@ -194,23 +194,15 @@ protected: CEntityManager *m_pMgr = NULL; + //! Позиция объекта float3_t m_vPosition; - - /*! Скорость - \note вероятно, не используется - */ - float3_t m_vSpeed; - //! вращение - SMQuaternion m_vOrientation; - //float3_t m_vDiscreteLinearVelocity; - //float3_t m_vOldPosition; - + SMQuaternion m_qOrientation; //! Позиция смещения (для иерархической структуры) float3_t m_vOffsetPos; //! Вращение смещения (для иерархической структуры) - SMQuaternion m_vOffsetOrient; + SMQuaternion m_qOffsetOrient; //! Идентификатор в системе ID m_iId = 0; diff --git a/source/game/BaseItem.cpp b/source/game/BaseItem.cpp index 078ff78fa..752f4753b 100644 --- a/source/game/BaseItem.cpp +++ b/source/game/BaseItem.cpp @@ -201,25 +201,19 @@ void CBaseItem::onModelChanged() } } -void CBaseItem::onSync() +void CBaseItem::setPos(const float3 &pos) { - BaseClass::onSync(); - - if(m_pViewModel) - { - m_pViewModel->setPosition(getPos()); - m_pViewModel->setOrientation(getOrient()); - } + BaseClass::setPos(pos); + + SAFE_CALL(m_pViewModel, setPosition, pos); + SAFE_CALL(m_pTriggerUse, setPos, pos); } -void CBaseItem::setPos(const float3 &pos) +void CBaseItem::setOrient(const SMQuaternion &q) { - BaseClass::setPos(pos); + BaseClass::setOrient(q); - if(m_pTriggerUse) - { - m_pTriggerUse->setPos(getPos()); - } + SAFE_CALL(m_pViewModel, setOrientation, q); } void CBaseItem::onIsPickableChanged(bool isPickable) diff --git a/source/game/BaseItem.h b/source/game/BaseItem.h index e783fd6de..e3ae75eba 100644 --- a/source/game/BaseItem.h +++ b/source/game/BaseItem.h @@ -46,13 +46,13 @@ public: void setHandsResource(IXResourceModelAnimated *pResource); - void setPos(const float3 &pos); + void setPos(const float3 &pos) override; + void setOrient(const SMQuaternion &q) override; protected: virtual void onModeChanged(INVENTORY_ITEM_MODE oldMode, INVENTORY_ITEM_MODE newMode); void onSetViewModel(const char *mdl); void onModelChanged(); - void onSync() override; void onPostLoad() override; diff --git a/source/game/BaseLight.cpp b/source/game/BaseLight.cpp index 7935eb5b3..c245766e6 100644 --- a/source/game/BaseLight.cpp +++ b/source/game/BaseLight.cpp @@ -12,18 +12,18 @@ See the license in LICENSE BEGIN_PROPTABLE(CBaseLight) //! Цвет - DEFINE_FIELD_VECTOR4(m_vColor, 0, "color", "Color", EDITOR_TEXTFIELD) + DEFINE_FIELD_VECTOR4FN(m_vColor, 0, "color", "Color", setColor, EDITOR_TEXTFIELD) //! Дальность DEFINE_FIELD_FLOAT(m_fDist, 0, "dist", "Distance", EDITOR_TEXTFIELD) //! Дальность дальняя //DEFINE_FIELD_FLOAT(m_fShadowDist, 0, "light_far", "Shadow far plane", EDITOR_TEXTFIELD) //! Интенсивность теней - DEFINE_FIELD_FLOAT(m_fShadowIntensity, 0, "shadow_intensity", "Shadow intensity", EDITOR_TEXTFIELD) + DEFINE_FIELD_FLOATFN(m_fShadowIntensity, 0, "shadow_intensity", "Shadow intensity", setShadowIntensity, EDITOR_TEXTFIELD) //! Связанный свет (повторяет его состояние включения) DEFINE_FIELD_ENTITYFN(m_pLinkedTo, 0, "linked_to", "Linked light to", setLinkedTo, EDITOR_TEXTFIELD) //! Тип тени - DEFINE_FIELD_INT(m_iShadowType, 0, "type_shadow", "Type shadow", EDITOR_COMBOBOX) + DEFINE_FIELD_INTFN(m_iShadowType, 0, "type_shadow", "Type shadow", setShadowType, EDITOR_COMBOBOX) //COMBO_OPTION("None", "-1") //!< Нет COMBO_OPTION("Static", "0") //!< Статическая тень COMBO_OPTION("Dynamic", "1") //!< Динамическая тень @@ -65,10 +65,6 @@ void CBaseLight::onSync() if(m_pLight) { m_pLight->setEnabled(m_isEnable); - m_pLight->setPosition(m_vPosition); - m_pLight->setColor(float3(m_vColor) * m_vColor.w); - m_pLight->setShadowIntencity(m_fShadowIntensity); - m_pLight->setShadowDynamic(m_iShadowType != 0); } } @@ -200,3 +196,10 @@ void CBaseLight::removeLinkedLight(CBaseLight *pEnt) } } } + +void CBaseLight::setPos(const float3 &pos) +{ + BaseClass::setPos(pos); + + SAFE_CALL(m_pLight, setPosition, pos); +} diff --git a/source/game/BaseLight.h b/source/game/BaseLight.h index d24d8716d..c029fd961 100644 --- a/source/game/BaseLight.h +++ b/source/game/BaseLight.h @@ -32,6 +32,7 @@ public: void setColor(const float4 &vColor) { m_vColor = vColor; + SAFE_CALL(m_pLight, setColor, float3(m_vColor) * m_vColor.w); } const float4_t& getColor() const { @@ -59,6 +60,7 @@ public: void setShadowIntensity(float fShadowIntensity) { m_fShadowIntensity = fShadowIntensity; + SAFE_CALL(m_pLight, setShadowIntencity, fShadowIntensity); } float getShadowIntensity() const { @@ -68,6 +70,7 @@ public: void setShadowType(int iShadowType) { m_iShadowType = iShadowType; + SAFE_CALL(m_pLight, setShadowDynamic, iShadowType != 0); } int getShadowType() const { @@ -84,6 +87,8 @@ public: void updateFlags(); + void setPos(const float3 &pos) override; + protected: IXLight *m_pLight = NULL; diff --git a/source/game/BaseTool.cpp b/source/game/BaseTool.cpp index eadd6e447..e7d1be26f 100644 --- a/source/game/BaseTool.cpp +++ b/source/game/BaseTool.cpp @@ -239,11 +239,11 @@ void CBaseTool::onSync() if(m_pOwner) { float3_t ang = ((CPlayer*)m_pOwner)->getWeaponDeltaAngles(); - m_vOffsetOrient = m_qSlotRotResult * SMQuaternion(ang.x, 'x') * SMQuaternion(ang.y, 'y') * SMQuaternion(ang.z, 'z'); + m_qOffsetOrient = m_qSlotRotResult * SMQuaternion(ang.x, 'x') * SMQuaternion(ang.y, 'y') * SMQuaternion(ang.z, 'z'); } else { - m_vOffsetOrient = m_qSlotRotResult; + m_qOffsetOrient = m_qSlotRotResult; } m_vOffsetPos = m_vSlotPosResult; BaseClass::onSync(); diff --git a/source/game/BaseTrigger.cpp b/source/game/BaseTrigger.cpp index 2d9b2530d..6c057ad33 100644 --- a/source/game/BaseTrigger.cpp +++ b/source/game/BaseTrigger.cpp @@ -103,8 +103,11 @@ void CBaseTrigger::createPhysBody() { if(m_pCollideShape) { + float3 vPos = getPos(); + SMQuaternion qRot = getOrient(); + m_pGhostObject = new btPairCachingGhostObject(); - m_pGhostObject->setWorldTransform(btTransform(Q4_BTQUAT(m_vOrientation), F3_BTVEC(m_vPosition))); + m_pGhostObject->setWorldTransform(btTransform(Q4_BTQUAT(qRot), F3_BTVEC(vPos))); m_pGhostObject->setUserPointer(this); m_pGhostObject->setCollisionShape(m_pCollideShape); m_pGhostObject->setCollisionFlags(m_pGhostObject->getCollisionFlags() ^ btCollisionObject::CF_NO_CONTACT_RESPONSE); diff --git a/source/game/EntityManager.cpp b/source/game/EntityManager.cpp index 7de487b99..4145cc34e 100644 --- a/source/game/EntityManager.cpp +++ b/source/game/EntityManager.cpp @@ -199,19 +199,11 @@ void CEntityManager::sync() //static time_point tOld = std::chrono::high_resolution_clock::now(); //float dt; //dt = (float)std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - tOld).count() / 1000000.0f; - for(int i = 0, l = m_vEntSyncList.size(); i < l; ++i) - { - pEnt = m_vEntSyncList[i]; - if(pEnt) - { - pEnt->m_bSynced = false; - } - } for(int i = 0, l = m_vEntSyncList.size(); i < l; ++i) { pEnt = m_vEntSyncList[i]; - if(pEnt && !pEnt->m_bSynced) + if(pEnt) { //pEnt->updateDiscreteLinearVelocity(0, dt); pEnt->onSync(); diff --git a/source/game/LightDirectional.cpp b/source/game/LightDirectional.cpp index 8799a70a6..13377a041 100644 --- a/source/game/LightDirectional.cpp +++ b/source/game/LightDirectional.cpp @@ -14,9 +14,7 @@ BEGIN_PROPTABLE(CLightDirectional) //! Внешний угол DEFINE_FIELD_FLOAT(m_fOuterAngle, 0, "angle", "Outer angle", EDITOR_TEXTFIELD) //! Внутренний угол - DEFINE_FIELD_FLOAT(m_fInnerAngle, 0, "inner_angle", "Inner angle", EDITOR_TEXTFIELD) - //! Верхний радиус - DEFINE_FIELD_FLOAT(m_fRadiusTop, 0, "radius_top", "Radius top", EDITOR_TEXTFIELD) + DEFINE_FIELD_FLOATFN(m_fInnerAngle, 0, "inner_angle", "Inner angle", setInnerAngle, EDITOR_TEXTFIELD) END_PROPTABLE() REGISTER_ENTITY(CLightDirectional, light_directional); @@ -43,19 +41,30 @@ CLightDirectional::~CLightDirectional() mem_release(m_pLight); } -void CLightDirectional::onSync() +void CLightDirectional::setOrient(const SMQuaternion &q) { - BaseClass::onSync(); + BaseClass::setOrient(q); - if(m_pLightSpot) - { - m_pLightSpot->setDirection(m_vOrientation); - m_pLightSpot->setOuterAngle(m_fOuterAngle); - m_pLightSpot->setInnerAngle(m_fInnerAngle); - } -#if 0 - if (SLight_GetTopRadius(m_idLight) != m_fRadiusTop) - SLight_SetTopRadius(m_idLight, m_fRadiusTop); -#endif + SAFE_CALL(m_pLightSpot, setDirection, q); +} + +void CLightDirectional::setOuterAngle(float fAngle) +{ + m_fOuterAngle = fAngle; + + SAFE_CALL(m_pLightSpot, setOuterAngle, fAngle); +} +float CLightDirectional::getOuterAngle() const +{ + return m_fOuterAngle; } +void CLightDirectional::setInnerAngle(float fAngle) +{ + m_fInnerAngle = fAngle; + SAFE_CALL(m_pLightSpot, setInnerAngle, fAngle); +} +float CLightDirectional::getInnerAngle() const +{ + return m_fInnerAngle; +} diff --git a/source/game/LightDirectional.h b/source/game/LightDirectional.h index ba49edf9c..df643f726 100644 --- a/source/game/LightDirectional.h +++ b/source/game/LightDirectional.h @@ -25,32 +25,16 @@ public: DECLARE_CONSTRUCTOR(); ~CLightDirectional(); - void setOuterAngle(float fAngle) - { - m_fOuterAngle = fAngle; - } - float getOuterAngle() const - { - return m_fOuterAngle; - } - void setInnerAngle(float fAngle) - { - m_fInnerAngle = fAngle; - } - float getInnerAngle() const - { - return m_fInnerAngle; - } - - void setRadiusTop(float fRadiusTop) { m_fRadiusTop = fRadiusTop; }; - float getRadiusTop() const { return m_fRadiusTop; }; - -protected: - void onSync() override; + void setOuterAngle(float fAngle); + float getOuterAngle() const; + void setInnerAngle(float fAngle); + float getInnerAngle() const; + + void setOrient(const SMQuaternion &q) override; +protected: float m_fOuterAngle = SM_PI * 0.4f; float m_fInnerAngle = SM_PI * 0.4f * 0.7f; - float m_fRadiusTop = 0.01f; IXLightSpot *m_pLightSpot = NULL; }; diff --git a/source/game/LightSun.cpp b/source/game/LightSun.cpp index 0a5746434..2da0e7036 100644 --- a/source/game/LightSun.cpp +++ b/source/game/LightSun.cpp @@ -30,12 +30,9 @@ CLightSun::~CLightSun() mem_release(m_pLight); } -void CLightSun::onSync() +void CLightSun::setOrient(const SMQuaternion &q) { - BaseClass::onSync(); + BaseClass::setOrient(q); - if(m_pSun) - { - m_pSun->setDirection(m_vOrientation); - } + SAFE_CALL(m_pSun, setDirection, q); } diff --git a/source/game/LightSun.h b/source/game/LightSun.h index 08f933975..d23c80004 100644 --- a/source/game/LightSun.h +++ b/source/game/LightSun.h @@ -25,8 +25,9 @@ public: DECLARE_CONSTRUCTOR(); ~CLightSun(); + void setOrient(const SMQuaternion &q) override; + protected: - void onSync() override; IXLightSun *m_pSun = NULL; }; diff --git a/source/game/NPCBase.cpp b/source/game/NPCBase.cpp index cae49007d..588e56ce0 100644 --- a/source/game/NPCBase.cpp +++ b/source/game/NPCBase.cpp @@ -224,7 +224,7 @@ void CNPCBase::findPathThinker(float fDelta) m_aPathQuads.resize(iCount); SAIG_GridGetPath(m_idQueueFindPath, &(m_aPathQuads[0]), m_aPathQuads.size(), true); SAIG_GridSetColorArr(&(m_aPathQuads[0]), m_ulColor, m_aPathQuads.size()); - m_vLastPathPos = m_vPosition; + m_vLastPathPos = getPos(); m_idQueueFindPath = -1; CLEAR_INTERVAL(m_idFindPathInterval); @@ -256,7 +256,7 @@ void CNPCBase::pathFollowThinker(float fDelta) float fDirLen = fMoveSpeed * fDelta; float fMovDirLen = fDirLen; - float fDist2 = SMVector3Length2(m_vLastPathPos - m_vPosition); // Расстояние между актуальным положением NPC и точкой следования + float fDist2 = SMVector3Length2(m_vLastPathPos - getPos()); // Расстояние между актуальным положением NPC и точкой следования if(m_iCurrQuaidInPath < (int)m_aPathQuads.size()) { @@ -296,7 +296,7 @@ void CNPCBase::pathFollowThinker(float fDelta) //m_vPosition = m_vLastPathPos; //m_pGhostObject->getWorldTransform().setOrigin(F3_BTVEC(m_vLastPathPos)); - float3 vDir = m_vLastPathPos - m_vPosition; + float3 vDir = m_vLastPathPos - getPos(); float fDist = SMVector3Length(vDir); vDir /= fDist; @@ -315,9 +315,9 @@ void CNPCBase::pathFollowThinker(float fDelta) //SPhysics_GetDynWorld()->getDebugDrawer()->drawLine(F3_BTVEC(m_vLastPathPos), F3_BTVEC(m_vPosition), btVector3(0, 1, 0)); m_qOrientTo = SMQuaternion(NPC_BASE_DIR, vDir); - setOrient(SMquaternionSlerp(m_vOrientation, m_qOrientTo, clampf(fDelta, 0.1f, 1.0f))); + setOrient(SMquaternionSlerp(getOrient(), m_qOrientTo, clampf(fDelta, 0.1f, 1.0f))); - if(SMVector3Length(m_vPosition - m_vLastFramePos) < fDelta * fMoveSpeed * 0.1f) // застряли, похоже + if(SMVector3Length(getPos() - m_vLastFramePos) < fDelta * fMoveSpeed * 0.1f) // застряли, похоже { if(bMayJump) { @@ -346,7 +346,7 @@ void CNPCBase::pathFollowThinker(float fDelta) { m_iStuckCount = 0; } - m_vLastFramePos = m_vPosition; + m_vLastFramePos = getPos(); // это последний, дошли! if(m_iCurrQuaidInPath >= (int)m_aPathQuads.size() && fDist < 0.5) diff --git a/source/game/NPCZombie.cpp b/source/game/NPCZombie.cpp index 6bc428a07..478d7c23c 100644 --- a/source/game/NPCZombie.cpp +++ b/source/game/NPCZombie.cpp @@ -293,9 +293,12 @@ void CNPCZombie::randWalk() {*/ float rndradius = randf(20.f, 40.f)*0.5f; float3 rndpos; - rndpos.x = m_vPosition.x + randf(-rndradius, rndradius); - rndpos.y = m_vPosition.y + randf(-rndradius, rndradius); - rndpos.z = m_vPosition.z + randf(-rndradius, rndradius); + + float3 vPos = getPos(); + + rndpos.x = vPos.x + randf(-rndradius, rndradius); + rndpos.y = vPos.y + randf(-rndradius, rndradius); + rndpos.z = vPos.z + randf(-rndradius, rndradius); //Core_RFloat3Get(G_RI_FLOAT3_OBSERVER_POSITION, &rndpos); diff --git a/source/game/NPCZombie.h b/source/game/NPCZombie.h index 76d2d9ef0..0b9a932b0 100644 --- a/source/game/NPCZombie.h +++ b/source/game/NPCZombie.h @@ -42,7 +42,7 @@ public: protected: - void onSync(); + void onSync() override; void think(float fDelta); void removeThis(float fDelta); diff --git a/source/game/PathCorner.cpp b/source/game/PathCorner.cpp index 4e16cdb52..0bfe9cca4 100644 --- a/source/game/PathCorner.cpp +++ b/source/game/PathCorner.cpp @@ -99,7 +99,7 @@ void CPathCorner::recalcPath(float t) pCur->m_fLength = SMVector3Length(vec); //pCur->m_fLength = 1.0f; pCur->m_fH = (float3)(vec / pCur->m_fLength); - pCur->m_fCoeffsA = pCur->m_pNextStop->m_vPosition; + pCur->m_fCoeffsA = pCur->m_pNextStop->getPos(); pCur = pNext; } @@ -182,7 +182,7 @@ float3 CPathCorner::getPoint(float dist) } else { - return(m_vPosition); + return(getPos()); } } else if(dist > m_fLength) @@ -193,7 +193,7 @@ float3 CPathCorner::getPoint(float dist) } else { - return(m_vPosition); + return(getPos()); } } dist -= m_fLength; @@ -210,7 +210,7 @@ SMQuaternion CPathCorner::getRot(float dist) } else { - return(m_vOrientation); + return(getOrient()); } } else if(dist > m_fLength) @@ -221,16 +221,16 @@ SMQuaternion CPathCorner::getRot(float dist) } else { - return(m_vOrientation); + return(getOrient()); } } if(m_pNextStop) { - return(SMquaternionSlerp(m_vOrientation, m_pNextStop->m_vOrientation, (dist / m_fLength)*(dist / m_fLength) * (3.0f - 2.0f * (dist / m_fLength)))); + return(SMquaternionSlerp(getOrient(), m_pNextStop->getOrient(), (dist / m_fLength)*(dist / m_fLength) * (3.0f - 2.0f * (dist / m_fLength)))); } else { - return(m_vOrientation); + return(getOrient()); } } diff --git a/source/game/Player.cpp b/source/game/Player.cpp index 906a42e6f..d07b3b580 100644 --- a/source/game/Player.cpp +++ b/source/game/Player.cpp @@ -291,7 +291,7 @@ void CPlayer::updateInput(float dt) float sin = cosf(m_fViewbobStep * 2.0f); float sin2 = sinf(m_fViewbobStep); float3 vec(1.0f, 0.0f, 0.0f); - vec = m_vOrientation * vec; + vec = m_qOrientation * vec; m_fViewbobY = (sin * ((m_uMoveDir & PM_RUN) ? *cl_bob_run_y : *cl_bob_walk_y)); m_fViewbobStrafe = (float3)(vec * sin2 * ((m_uMoveDir & PM_RUN) ? *cl_bob_run_x : *cl_bob_walk_x)); //m_vOrientation = SMQuaternion(SMToRadian(10) * sinf(m_fViewbobStep), 'z') * m_vOrientation; diff --git a/source/game/PointCamera.cpp b/source/game/PointCamera.cpp index ce2284727..addfa7079 100644 --- a/source/game/PointCamera.cpp +++ b/source/game/PointCamera.cpp @@ -28,15 +28,21 @@ CPointCamera::~CPointCamera() mem_release(m_pSXC); } -ICamera * CPointCamera::getCamera() +ICamera* CPointCamera::getCamera() { return(m_pSXC); } -void CPointCamera::onSync() +void CPointCamera::setPos(const float3 &pos) { - BaseClass::onSync(); + BaseClass::setPos(pos); - m_pSXC->setPosition(m_vPosition); - m_pSXC->setOrientation(m_vOrientation); + m_pSXC->setPosition(pos); +} + +void CPointCamera::setOrient(const SMQuaternion &q) +{ + BaseClass::setOrient(q); + + m_pSXC->setOrientation(q); } diff --git a/source/game/PointCamera.h b/source/game/PointCamera.h index 6ef275b7a..154a81e4a 100644 --- a/source/game/PointCamera.h +++ b/source/game/PointCamera.h @@ -30,12 +30,13 @@ public: ~CPointCamera(); //! Возвращает объект камеры из графической либы - ICamera * getCamera(); + ICamera* getCamera(); -protected: - ICamera * m_pSXC; + void setPos(const float3 &pos) override; + void setOrient(const SMQuaternion &q) override; - void onSync() override; +protected: + ICamera *m_pSXC; }; #endif diff --git a/source/game/PropDoor.cpp b/source/game/PropDoor.cpp index ca0fdaede..f9532aa51 100644 --- a/source/game/PropDoor.cpp +++ b/source/game/PropDoor.cpp @@ -217,8 +217,11 @@ void CPropDoor::createPhysBody() { if(m_pCollideShape) { + float3 vPos = getPos(); + SMQuaternion qRot = getOrient(); + m_pGhostObject = new btPairCachingGhostObject(); - m_pGhostObject->setWorldTransform(btTransform(Q4_BTQUAT(m_vOrientation), F3_BTVEC(m_vPosition))); + m_pGhostObject->setWorldTransform(btTransform(Q4_BTQUAT(qRot), F3_BTVEC(vPos))); m_pGhostObject->setCollisionShape(m_pCollideShape); m_pGhostObject->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT); m_pGhostObject->setUserPointer(this); @@ -265,7 +268,7 @@ void CPropDoor::createPhysBody() m_fDistance = fMax - fMin; } - m_vStartPos = m_vPosition; + m_vStartPos = vPos; m_vEndPos = (float3)(m_vStartPos + vDir * m_fDistance); if(m_bState) diff --git a/source/game/PropStatic.cpp b/source/game/PropStatic.cpp index 738cce327..208bb7caa 100644 --- a/source/game/PropStatic.cpp +++ b/source/game/PropStatic.cpp @@ -34,7 +34,10 @@ void CPropStatic::createPhysBody() { if(m_pCollideShape) { - btDefaultMotionState * motionState = new btDefaultMotionState(btTransform(Q4_BTQUAT(m_vOrientation), F3_BTVEC(m_vPosition))); + float3 vPos = getPos(); + SMQuaternion qRot = getOrient(); + + btDefaultMotionState * motionState = new btDefaultMotionState(btTransform(Q4_BTQUAT(qRot), F3_BTVEC(vPos))); btRigidBody::btRigidBodyConstructionInfo rigidBodyCI( 0, // mass motionState, // initial position diff --git a/source/game/SoundEmitter.h b/source/game/SoundEmitter.h index 43f840cbe..a4c73963b 100644 --- a/source/game/SoundEmitter.h +++ b/source/game/SoundEmitter.h @@ -34,7 +34,10 @@ public: virtual void setSound(const char *szSound); - void onSync() override; + void setPos(const float3 &pos) override; + + void setVolume(float fVolume); + float getVolume(); protected: -- GitLab