diff --git a/source/game/BaseAnimating.cpp b/source/game/BaseAnimating.cpp index c9fe674683142874a96f177980fb08eaed65f35c..ac92c7e514b4e7e5eb7ba1a1333d9164df3d1a66 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 a20c4d1b7996804f159c5c4ae2a4634904209f9d..81e8ef7d7fb8c732110425a63fde5582f36f743e 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 2b5b68118633c92f95148d136996b2b1adc4fbfc..fcb4657c364bbbfb3ba069a4173dae2514207fa4 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 078ff78fac5a4378961ae018cba96113176c2abf..752f4753be1e8514f4b7212b017ef4b77e36a5d5 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 e783fd6de5dff72ff119e6e0ef452dbd2cacc57d..e3ae75ebaa8d31cc907d616f041ae2d412b5967f 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 7935eb5b3597a91a29ec951b3f180caf74e21d28..c245766e6b6ab1285c6e873cad4893dfb6bad4fc 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 d24d8716d035aec6ad9ed352e3e98ce311316184..c029fd961d2de9b5f041e497f9384e40f6ab4de0 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 eadd6e447fdd19c8d1cb5e39e1770d33d111ac79..e7d1be26f0c896f6c1c0c0ec6ffd0c6e65f1cbae 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 2d9b2530d6f278e22630cf6c504105867d1f2e17..6c057ad3351f40b17b47052eb870da0bbc9bc9a5 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 7de487b99d6da8d7f0be66cf3e1713d12af618ef..4145cc34e7d75510999554979944c1a1d0864747 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 8799a70a68e2561a764b8dc3ff1ac4275dfc834b..13377a0416d4f9c09ee2501cb9dfdf2c25e1bff2 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 ba49edf9c54b301377216495d931f3c5d40dc660..df643f726a9a316dfd3810f37a546483959c826e 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 0a574643462740dc379adb7ac32b5a6edabc70aa..2da0e70369b915767814abd7f6287cb3a49c0c65 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 08f933975d23dc475c2d4eddb0dd1f79cab97216..d23c80004d3e25b5b82e43102b7379c2bc59d4cc 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 cae49007db3702db2ac0c2389cf902a236fb69fb..588e56ce069e94c7f12f5cbaf7ef6c9ce46fbbb0 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 6bc428a073c955bb80d737206d900768cc2b1690..478d7c23ced60b2494b35fa7fe9acbfb5387924c 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 76d2d9ef0d70e8df665259399b06124b4757a87c..0b9a932b037def71a0bd3302eb67847a7f088643 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 4e16cdb52249e1a57513cf6da1d497de3ae32d54..0bfe9cca48b328e1910d47261e4f92628d9dc265 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 906a42e6f14bcb0a1f14778bf7da3878ff727172..d07b3b580cfe5ce78063c96525d4679a76db02e0 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 ce22847275abdbc967f4d45d6eb5bc01f6c4443a..addfa707908944d2731e4aeb19259434fcdd976e 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 6ef275b7ac28398f6ec1d29e6097690c63b39a83..154a81e4a830e28db6e7a36499457af4a93d8476 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 ca0fdaedef0d30077146438fde09b08c03647255..f9532aa51acd53f1e32e08de39678ede64a37b69 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 738cce327827bc2db0e23d1ba67e2344900a1b4b..208bb7caaa9c125d4d4ed7119e451cd518bcc1fe 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 43f840cbecc554639c82041654859d8e8c1f8e3b..a4c73963be37701f5111a9999d669601221963dd 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: