Refactored lcObjectKeyArray::RemoveAll.

This commit is contained in:
Leonardo Zide 2023-12-27 10:21:25 -08:00
parent ec2a9bce87
commit 2990afba08
5 changed files with 19 additions and 57 deletions

View file

@ -591,14 +591,9 @@ void lcCamera::DrawInterface(lcContext* Context, const lcScene& Scene) const
void lcCamera::RemoveKeyFrames()
{
mPositionKeys.RemoveAll();
mPositionKeys.ChangeKey(mPosition, 1, true);
mTargetPositionKeys.RemoveAll();
mTargetPositionKeys.ChangeKey(mTargetPosition, 1, true);
mUpVectorKeys.RemoveAll();
mUpVectorKeys.ChangeKey(mUpVector, 1, true);
mPositionKeys.Reset(mPosition);
mTargetPositionKeys.Reset(mTargetPosition);
mUpVectorKeys.Reset(mUpVector);
}
void lcCamera::RayTest(lcObjectRayTest& ObjectRayTest) const

View file

@ -43,8 +43,6 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
void lcLight::UpdateLightType()
{
mSizeKeys.RemoveAll();
switch (mLightType)
{
case lcLightType::Point:
@ -67,7 +65,7 @@ void lcLight::UpdateLightType()
break;
}
mSizeKeys.ChangeKey(mSize, 1, true);
mSizeKeys.Reset(mSize);
}
QString lcLight::GetLightTypeString(lcLightType LightType)
@ -1077,43 +1075,15 @@ void lcLight::DrawCone(lcContext* Context, float TargetDistance) const
void lcLight::RemoveKeyFrames()
{
mPositionKeys.RemoveAll();
mPositionKeys.ChangeKey(mWorldMatrix.GetTranslation(), 1, true);
mRotationKeys.RemoveAll();
mRotationKeys.ChangeKey(lcMatrix33(mWorldMatrix), 1, true);
mColorKeys.RemoveAll();
mColorKeys.ChangeKey(mColor, 1, true);
mSpotConeAngleKeys.RemoveAll();
mSpotConeAngleKeys.ChangeKey(mSpotConeAngle, 1, false);
mSpotPenumbraAngleKeys.RemoveAll();
mSpotPenumbraAngleKeys.ChangeKey(mSpotPenumbraAngle, 1, true);
mSpotTightnessKeys.RemoveAll();
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
mAreaGridKeys.RemoveAll();
mAreaGridKeys.ChangeKey(mAreaGrid, 1, true);
mSizeKeys.RemoveAll();
mSizeKeys.ChangeKey(mSize, 1, true);
mPowerKeys.RemoveAll();
mPowerKeys.ChangeKey(mPower, 1, true);
mAttenuationDistanceKeys.RemoveAll();
mAttenuationDistanceKeys.ChangeKey(mAttenuationDistance, 1, true);
mAttenuationPowerKeys.RemoveAll();
mAttenuationPowerKeys.ChangeKey(mAttenuationPower, 1, true);
}
bool lcLight::Setup(int LightIndex)
{
Q_UNUSED(LightIndex);
return true;
mPositionKeys.Reset(mWorldMatrix.GetTranslation());
mRotationKeys.Reset(lcMatrix33(mWorldMatrix));
mColorKeys.Reset(mColor);
mSpotConeAngleKeys.Reset(mSpotConeAngle);
mSpotPenumbraAngleKeys.Reset(mSpotPenumbraAngle);
mSpotTightnessKeys.Reset(mSpotTightness);
mAreaGridKeys.Reset(mAreaGrid);
mSizeKeys.Reset(mSize);
mPowerKeys.Reset(mPower);
mAttenuationDistanceKeys.Reset(mAttenuationDistance);
mAttenuationPowerKeys.Reset(mAttenuationPower);
}

View file

@ -312,7 +312,6 @@ public:
void UpdatePosition(lcStep Step);
void MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance, bool FirstMove);
void Rotate(lcStep Step, bool AddKey, const lcMatrix33& RotationMatrix, const lcVector3& Center, const lcMatrix33& RotationFrame);
bool Setup(int LightIndex);
void CreateName(const lcArray<lcLight*>& Lights);
lcMatrix44 mWorldMatrix;

View file

@ -31,9 +31,10 @@ public:
return mKeys.empty();
}
void RemoveAll()
void Reset(const T& Value)
{
mKeys.clear();
ChangeKey(Value, 1, true);
}
void SaveKeysLDraw(QTextStream& Stream, const char* ObjectName, const char* VariableName) const;

View file

@ -659,11 +659,8 @@ void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const
void lcPiece::RemoveKeyFrames()
{
mPositionKeys.RemoveAll();
mPositionKeys.ChangeKey(mModelWorld.GetTranslation(), 1, true);
mRotationKeys.RemoveAll();
mRotationKeys.ChangeKey(lcMatrix33(mModelWorld), 1, true);
mPositionKeys.Reset(mModelWorld.GetTranslation());
mRotationKeys.Reset(lcMatrix33(mModelWorld));
}
void lcPiece::AddMainModelRenderMeshes(lcScene* Scene, bool Highlight, bool Fade) const