mirror of
https://github.com/leozide/leocad
synced 2024-12-25 21:58:23 +01:00
Don't create default key frame for all properties.
This commit is contained in:
parent
cba4dfb468
commit
d6499bfeb0
3 changed files with 18 additions and 33 deletions
|
@ -5,7 +5,7 @@
|
|||
#define LC_OBJECT_PROPERTY(T) \
|
||||
template void lcObjectProperty<T>::SaveKeysLDraw(QTextStream& Stream, const char* ObjectName, const char* VariableName) const; \
|
||||
template void lcObjectProperty<T>::LoadKeysLDraw(QTextStream& Stream); \
|
||||
template const T& lcObjectProperty<T>::CalculateKey(lcStep Step) const; \
|
||||
template void lcObjectProperty<T>::Update(lcStep Step); \
|
||||
template void lcObjectProperty<T>::ChangeKey(const T& Value, lcStep Step, bool AddKey); \
|
||||
template void lcObjectProperty<T>::InsertTime(lcStep Start, lcStep Time); \
|
||||
template void lcObjectProperty<T>::RemoveTime(lcStep Start, lcStep Time); \
|
||||
|
@ -87,8 +87,11 @@ void lcObjectProperty<T>::LoadKeysLDraw(QTextStream& Stream)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
const T& lcObjectProperty<T>::CalculateKey(lcStep Step) const
|
||||
void lcObjectProperty<T>::Update(lcStep Step)
|
||||
{
|
||||
if (mKeys.empty())
|
||||
return;
|
||||
|
||||
const lcObjectPropertyKey<T>* PreviousKey = &mKeys[0];
|
||||
|
||||
for (const lcObjectPropertyKey<T>& Key : mKeys)
|
||||
|
@ -99,12 +102,19 @@ const T& lcObjectProperty<T>::CalculateKey(lcStep Step) const
|
|||
PreviousKey = &Key;
|
||||
}
|
||||
|
||||
return PreviousKey->Value;
|
||||
mValue = PreviousKey->Value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void lcObjectProperty<T>::ChangeKey(const T& Value, lcStep Step, bool AddKey)
|
||||
{
|
||||
if (!AddKey && mKeys.empty())
|
||||
{
|
||||
mValue = Value;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (typename std::vector<lcObjectPropertyKey<T>>::iterator KeyIt = mKeys.begin(); KeyIt != mKeys.end(); KeyIt++)
|
||||
{
|
||||
if (KeyIt->Step < Step)
|
||||
|
@ -187,9 +197,6 @@ void lcObjectProperty<T>::RemoveTime(lcStep Start, lcStep Time)
|
|||
template<typename T>
|
||||
bool lcObjectProperty<T>::HasKeyFrame(lcStep Time) const
|
||||
{
|
||||
if (mKeys.size() <= 1)
|
||||
return false;
|
||||
|
||||
for (typename std::vector<lcObjectPropertyKey<T>>::const_iterator KeyIt = mKeys.begin(); KeyIt != mKeys.end(); KeyIt++)
|
||||
{
|
||||
if (KeyIt->Step == Time)
|
||||
|
@ -204,7 +211,7 @@ bool lcObjectProperty<T>::HasKeyFrame(lcStep Time) const
|
|||
template<typename T>
|
||||
void lcObjectProperty<T>::Save(QTextStream& Stream, const char* ObjectName, const char* VariableName) const
|
||||
{
|
||||
if (GetSize() == 1)
|
||||
if (mKeys.empty())
|
||||
{
|
||||
Stream << QLatin1String("0 !LEOCAD ") << ObjectName << ' ' << VariableName << ' ';
|
||||
|
||||
|
@ -222,7 +229,6 @@ bool lcObjectProperty<T>::Load(QTextStream& Stream, const QString& Token, const
|
|||
if (Token == VariableName)
|
||||
{
|
||||
lcObjectPropertyLoadValue(Stream, mValue);
|
||||
ChangeKey(mValue, 1, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ public:
|
|||
explicit lcObjectProperty(const T& DefaultValue)
|
||||
: mValue(DefaultValue)
|
||||
{
|
||||
ChangeKey(mValue, 1, true);
|
||||
}
|
||||
|
||||
operator const T& () const
|
||||
|
@ -72,33 +71,18 @@ public:
|
|||
return mValue;
|
||||
}
|
||||
|
||||
int GetSize() const
|
||||
{
|
||||
return static_cast<int>(mKeys.size());
|
||||
}
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return mKeys.empty();
|
||||
}
|
||||
|
||||
void Update(lcStep Step)
|
||||
{
|
||||
mValue = CalculateKey(Step);
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
mKeys.clear();
|
||||
ChangeKey(mValue, 1, true);
|
||||
}
|
||||
|
||||
void Reset(const T& Value)
|
||||
{
|
||||
mValue = Value;
|
||||
Reset();
|
||||
mKeys.clear();
|
||||
}
|
||||
|
||||
void Update(lcStep Step);
|
||||
void ChangeKey(const T& Value, lcStep Step, bool AddKey);
|
||||
void InsertTime(lcStep Start, lcStep Time);
|
||||
void RemoveTime(lcStep Start, lcStep Time);
|
||||
|
@ -110,8 +94,6 @@ public:
|
|||
void LoadKeysLDraw(QTextStream& Stream);
|
||||
|
||||
protected:
|
||||
const T& CalculateKey(lcStep Step) const;
|
||||
|
||||
T mValue;
|
||||
std::vector<lcObjectPropertyKey<T>> mKeys;
|
||||
};
|
||||
|
|
|
@ -118,11 +118,8 @@ void lcPiece::SaveLDraw(QTextStream& Stream) const
|
|||
Stream << LineEnding;
|
||||
}
|
||||
|
||||
if (mPosition.GetSize() > 1)
|
||||
mPosition.SaveKeysLDraw(Stream, "PIECE", "POSITION");
|
||||
|
||||
if (mRotation.GetSize() > 1)
|
||||
mRotation.SaveKeysLDraw(Stream, "PIECE", "ROTATION");
|
||||
mPosition.SaveKeysLDraw(Stream, "PIECE", "POSITION");
|
||||
mRotation.SaveKeysLDraw(Stream, "PIECE", "ROTATION");
|
||||
|
||||
Stream << "1 " << mColorCode << ' ';
|
||||
|
||||
|
|
Loading…
Reference in a new issue