From 5c264fad52905c482a3496f03a4366623dc4138d Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 13 Jan 2022 17:43:27 +0100 Subject: [PATCH] Add smooth resizing of entitie when VPB are changed (wip) --- ryzom/client/src/character_cl.cpp | 41 ++++++++++++++++++++++++++++--- ryzom/client/src/character_cl.h | 5 ++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/ryzom/client/src/character_cl.cpp b/ryzom/client/src/character_cl.cpp index c157c0f85..0fa4e357e 100644 --- a/ryzom/client/src/character_cl.cpp +++ b/ryzom/client/src/character_cl.cpp @@ -377,6 +377,9 @@ CCharacterCL::CCharacterCL() _CustomScale = 1.f; + _OldCustomScale = 0.f; + _StepCustomScale = 0.f; + _StartCustomScale = ryzomGetLocalTime(); }// CCharacterCL // //----------------------------------------------- @@ -1690,13 +1693,38 @@ void CCharacterCL::updateVisualPropertyVpb(const NLMISC::TGameCycle &/* gameCycl nlinfo("(%05d,%03d) CH:updtVPVpb:%d: Scale(%d)", sint32(T1%100000), NetMngr.getCurrentServerTick(), _Slot, (uint)altLookProp.PropertySubData.Scale); } - // Save old scale - float oldCustomScale = _CustomScale; + + float customScale; // Set new scale if (altLookProp.PropertySubData.Scale==0) - _CustomScale = 1.f; + customScale = 1.f; else - _CustomScale = (float)altLookProp.PropertySubData.Scale/100.f; + customScale = ((float)altLookProp.PropertySubData.Scale/100.f); + nlinfo("customScale = %f", customScale); + _StartCustomScale = ryzomGetLocalTime(); + if (_OldCustomScale == 0) // first time + { + _StartCustomScale -= 1001.f; + _OldCustomScale = 1.f; + _CustomScale = 1.f; + } + + _StepCustomScale = customScale - _CustomScale; + _OldCustomScale = _CustomScale; +} + +void CCharacterCL::scale(bool calculate) +{ + // Save old scale + float oldCustomScale = _CustomScale; + _CustomScale = _OldCustomScale + (float(ryzomGetLocalTime() - _StartCustomScale) / 1000.f) * _StepCustomScale; + if ((_StepCustomScale >= 0 && _CustomScale > _OldCustomScale+_StepCustomScale) + || (_StepCustomScale < 0 && _CustomScale < _OldCustomScale+_StepCustomScale)) + { + _CustomScale = _OldCustomScale+_StepCustomScale; + _StepCustomScale = 0; + } + // Apply modification _CustomScalePos /= oldCustomScale; _CustomScalePos *= _CustomScale; @@ -2121,6 +2149,7 @@ double CCharacterCL::computeSpeed() //----------------------------------------------- double CCharacterCL::computeSpeedFactor(double speedToDest) { + double speedFactor = 1.0; // \todo GUIGUI : optimize emotes, currently it's badly designed. @@ -6047,6 +6076,9 @@ void CCharacterCL::updateAttachedFX() //----------------------------------------------- void CCharacterCL::updateVisible (const TTime ¤tTimeInMs, CEntityCL *target) { + if (_StepCustomScale) + scale(); + // Changes the skeleton state if(!_Skeleton.empty()) { @@ -6562,6 +6594,7 @@ ADD_METHOD(void CCharacterCL::updatePos(const TTime ¤tTimeInMs, CEntityCL _OldAutomaton = _CurrentAutomaton; // Compute the Time Step. double frameTimeRemaining = computeTimeStep(((double)currentTimeInMs)*0.001); + // Update the LodCharacter Animation. if(_LodCharacterAnimEnabled) { diff --git a/ryzom/client/src/character_cl.h b/ryzom/client/src/character_cl.h index 98b5d374e..8c6cd32db 100644 --- a/ryzom/client/src/character_cl.h +++ b/ryzom/client/src/character_cl.h @@ -712,6 +712,9 @@ protected: sint64 _LastSelectBoxComputeTime; float _CustomScale; + float _OldCustomScale; + float _StepCustomScale; + NLMISC::TTime _StartCustomScale; /// Pointer on the Sheet with basic parameters. const CCharacterSheet *_Sheet; @@ -872,6 +875,8 @@ protected: /// Method to Flag the character as alive and do everything needed. virtual void setAlive(); + void scale(bool calculate = true); + /// double computeTimeStep(const double ¤tTime);