Add smooth resizing of entitie when VPB are changed (wip)

38-add-smooth-resizing-of-entitie-when-vpb-are-changed
Nuno 3 years ago
parent e784c3aab1
commit 5c264fad52

@ -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 &currentTimeInMs, CEntityCL *target)
{
if (_StepCustomScale)
scale();
// Changes the skeleton state
if(!_Skeleton.empty())
{
@ -6562,6 +6594,7 @@ ADD_METHOD(void CCharacterCL::updatePos(const TTime &currentTimeInMs, CEntityCL
_OldAutomaton = _CurrentAutomaton;
// Compute the Time Step.
double frameTimeRemaining = computeTimeStep(((double)currentTimeInMs)*0.001);
// Update the LodCharacter Animation.
if(_LodCharacterAnimEnabled)
{

@ -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 &currentTime);

Loading…
Cancel
Save