Skip to content

Commit

Permalink
Refactored lcObjectKeyArray::RemoveAll.
Browse files Browse the repository at this point in the history
  • Loading branch information
leozide committed Dec 27, 2023
1 parent ec2a9bc commit 2990afb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 57 deletions.
11 changes: 3 additions & 8 deletions common/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 12 additions & 42 deletions common/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)

void lcLight::UpdateLightType()
{
mSizeKeys.RemoveAll();

switch (mLightType)
{
case lcLightType::Point:
Expand All @@ -67,7 +65,7 @@ void lcLight::UpdateLightType()
break;
}

mSizeKeys.ChangeKey(mSize, 1, true);
mSizeKeys.Reset(mSize);
}

QString lcLight::GetLightTypeString(lcLightType LightType)
Expand Down Expand Up @@ -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);
}
1 change: 0 additions & 1 deletion common/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ class lcLight : public lcObject
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;
Expand Down
3 changes: 2 additions & 1 deletion common/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class lcObjectKeyArray
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;
Expand Down
7 changes: 2 additions & 5 deletions common/piece.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2990afb

Please sign in to comment.