Undo JointMotionListHolder for now...

master
Ansariel 2015-12-17 09:13:47 +01:00
parent 3ecc618367
commit d48a2f407b
2 changed files with 65 additions and 230 deletions

View File

@ -42,7 +42,6 @@
#include "llvfile.h"
#include "m3math.h"
#include "message.h"
#include "lltimer.h"
#include "nd/ndexceptions.h" // <FS:ND/> For nd::exceptions::xran
@ -51,8 +50,6 @@
//-----------------------------------------------------------------------------
LLVFS* LLKeyframeMotion::sVFS = NULL;
LLKeyframeDataCache::keyframe_data_map_t LLKeyframeDataCache::sKeyframeDataMap;
LLKeyframeDataCache::tGarbage LLKeyframeDataCache::mGarbage;
//-----------------------------------------------------------------------------
// Globals
@ -67,9 +64,6 @@ static F32 MIN_ACCELERATION_SQUARED = 0.0005f * 0.0005f;
static F32 MAX_CONSTRAINTS = 10;
static U32 const MAX_CACHE_TIME_IN_SECONDS = 5*60;
static U32 const SCAN_CACHE_INTERVAL = 31;
//-----------------------------------------------------------------------------
// JointMotionList
//-----------------------------------------------------------------------------
@ -82,8 +76,7 @@ LLKeyframeMotion::JointMotionList::JointMotionList()
mEaseOutDuration(0.f),
mBasePriority(LLJoint::LOW_PRIORITY),
mHandPose(LLHandMotion::HAND_POSE_SPREAD),
mMaxPriority(LLJoint::LOW_PRIORITY),
mLocks(0)
mMaxPriority(LLJoint::LOW_PRIORITY)
{
}
@ -1245,14 +1238,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackU16(version, "version"))
{
LL_WARNS() << "can't read version number" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
if (!dp.unpackU16(sub_version, "sub_version"))
{
LL_WARNS() << "can't read sub version number" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1264,7 +1257,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
#if LL_RELEASE
LL_WARNS() << "Bad animation version " << version << "." << sub_version << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
#else
LL_ERRS() << "Bad animation version " << version << "." << sub_version << LL_ENDL;
@ -1274,7 +1267,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackS32(temp_priority, "base_priority"))
{
LL_WARNS() << "can't read animation base_priority" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
mJointMotionList->mBasePriority = (LLJoint::JointPriority) temp_priority;
@ -1287,7 +1280,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
else if (mJointMotionList->mBasePriority < LLJoint::USE_MOTION_PRIORITY)
{
LL_WARNS() << "bad animation base_priority " << mJointMotionList->mBasePriority << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1297,7 +1290,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackF32(mJointMotionList->mDuration, "duration"))
{
LL_WARNS() << "can't read duration" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1305,7 +1298,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
!llfinite(mJointMotionList->mDuration))
{
LL_WARNS() << "invalid animation duration" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1315,14 +1308,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackString(mJointMotionList->mEmoteName, "emote_name"))
{
LL_WARNS() << "can't read optional_emote_animation" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
if(mJointMotionList->mEmoteName==mID.asString())
{
LL_WARNS() << "Malformed animation mEmoteName==mID" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1333,7 +1326,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
!llfinite(mJointMotionList->mLoopInPoint))
{
LL_WARNS() << "can't read loop point" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1341,14 +1334,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
!llfinite(mJointMotionList->mLoopOutPoint))
{
LL_WARNS() << "can't read loop point" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
if (!dp.unpackS32(mJointMotionList->mLoop, "loop"))
{
LL_WARNS() << "can't read loop" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1359,7 +1352,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
!llfinite(mJointMotionList->mEaseInDuration))
{
LL_WARNS() << "can't read easeIn" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1367,7 +1360,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
!llfinite(mJointMotionList->mEaseOutDuration))
{
LL_WARNS() << "can't read easeOut" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1378,14 +1371,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackU32(word, "hand_pose"))
{
LL_WARNS() << "can't read hand pose" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
if(word > LLHandMotion::NUM_HAND_POSES)
{
LL_WARNS() << "invalid LLHandMotion::eHandPose index: " << word << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1398,20 +1391,20 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackU32(num_motions, "num_joints"))
{
LL_WARNS() << "can't read number of joints" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
if (num_motions == 0)
{
LL_WARNS() << "no joints in animation" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
else if (num_motions > LL_CHARACTER_MAX_JOINTS)
{
LL_WARNS() << "too many joints in animation" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1433,14 +1426,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackString(joint_name, "joint_name"))
{
LL_WARNS() << "can't read joint name" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
if (joint_name == "mScreen" || joint_name == "mRoot")
{
LL_WARNS() << "attempted to animate special " << joint_name << " joint" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1472,14 +1465,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackS32(joint_priority, "joint_priority"))
{
LL_WARNS() << "can't read joint priority." << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
if (joint_priority < LLJoint::USE_MOTION_PRIORITY)
{
LL_WARNS() << "joint priority unknown - too low." << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1498,7 +1491,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackS32(joint_motion->mRotationCurve.mNumKeys, "num_rot_keys") || joint_motion->mRotationCurve.mNumKeys < 0)
{
LL_WARNS() << "can't read number of rotation keys" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1524,7 +1517,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
!llfinite(time))
{
LL_WARNS() << "can't read rotation key (" << k << ")" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1534,7 +1527,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackU16(time_short, "time"))
{
LL_WARNS() << "can't read rotation key (" << k << ")" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1543,7 +1536,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (time < 0 || time > mJointMotionList->mDuration)
{
LL_WARNS() << "invalid frame time" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
}
@ -1584,7 +1577,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!success)
{
LL_WARNS() << "can't read rotation key (" << k << ")" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1597,7 +1590,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackS32(joint_motion->mPositionCurve.mNumKeys, "num_pos_keys") || joint_motion->mPositionCurve.mNumKeys < 0)
{
LL_WARNS() << "can't read number of position keys" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1623,7 +1616,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
!llfinite(pos_key.mTime))
{
LL_WARNS() << "can't read position key (" << k << ")" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
}
@ -1632,7 +1625,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackU16(time_short, "time"))
{
LL_WARNS() << "can't read position key (" << k << ")" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1667,7 +1660,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!success)
{
LL_WARNS() << "can't read position key (" << k << ")" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1689,7 +1682,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackS32(num_constraints, "num_constraints"))
{
LL_WARNS() << "can't read number of constraints" << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1713,7 +1706,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint chain length" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
constraintp->mChainLength = (S32) byte;
@ -1722,7 +1715,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "invalid constraint chain length" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1730,7 +1723,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint type" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1738,7 +1731,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "invalid constraint type" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
constraintp->mConstraintType = (EConstraintType)byte;
@ -1749,7 +1742,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read source volume name" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1761,7 +1754,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint source offset" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1769,7 +1762,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "non-finite constraint source offset" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1777,7 +1770,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read target volume name" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1798,7 +1791,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint target offset" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1806,7 +1799,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "non-finite constraint target offset" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1814,7 +1807,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint target direction" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1822,7 +1815,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "non-finite constraint target direction" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1836,7 +1829,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint ease in start time" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1844,7 +1837,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint ease in stop time" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1852,7 +1845,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint ease out start time" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1860,7 +1853,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "can't read constraint ease out stop time" << LL_ENDL;
delete constraintp;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1872,7 +1865,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
// get joint to which this collision volume is attached
if (!joint)
{
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
for (S32 i = 0; i < constraintp->mChainLength + 1; i++)
@ -1882,7 +1875,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
LL_WARNS() << "Joint with no parent: " << joint->getName()
<< " Emote: " << mJointMotionList->mEmoteName << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
joint = parent;
@ -1894,7 +1887,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if ( !constraint_joint )
{
LL_WARNS() << "Invalid joint " << j << LL_ENDL;
delete mJointMotionList.get(); // <FS:Ansariel> Mem-leak fix by Drake Arconis
delete mJointMotionList; // <FS:Ansariel> Mem-leak fix by Drake Arconis
return FALSE;
}
@ -1909,7 +1902,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
LL_WARNS() << "No joint index for constraint " << i << LL_ENDL;
// <FS:Ansariel> Mem-leak fix by Drake Arconis
//delete constraintp;
delete mJointMotionList.get();
delete mJointMotionList;
// </FS:Ansariel>
return FALSE;
}
@ -1918,7 +1911,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
}
// *FIX: support cleanup of old keyframe data
LLKeyframeDataCache::addKeyframeData(getID(), mJointMotionList.get());
LLKeyframeDataCache::addKeyframeData(getID(), mJointMotionList);
mAssetStatus = ASSET_LOADED;
setupPose();
@ -2301,7 +2294,7 @@ void LLKeyframeDataCache::dumpDiagInfo()
{
U32 joint_motion_kb;
LLKeyframeMotion::JointMotionList *motion_list_p = map_it->second.mList;
LLKeyframeMotion::JointMotionList *motion_list_p = map_it->second;
LL_INFOS() << "Motion: " << map_it->first << LL_ENDL;
@ -2323,18 +2316,7 @@ void LLKeyframeDataCache::dumpDiagInfo()
//--------------------------------------------------------------------
void LLKeyframeDataCache::addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList* joint_motion_listp)
{
keyframe_data_map_t::iterator itr = sKeyframeDataMap.find(id);
if( sKeyframeDataMap.end() != itr )
{
mGarbage.push_back( itr->second.mList );
sKeyframeDataMap.erase(itr);
}
JointMotionListCacheEntry oCacheEntry;
oCacheEntry.mList = joint_motion_listp;
oCacheEntry.mLastAccessed = LLTimer::getTotalSeconds();
sKeyframeDataMap[id] = oCacheEntry;
tryShrinkCache();
sKeyframeDataMap[id] = joint_motion_listp;
}
//--------------------------------------------------------------------
@ -2345,19 +2327,9 @@ void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id)
keyframe_data_map_t::iterator found_data = sKeyframeDataMap.find(id);
if (found_data != sKeyframeDataMap.end())
{
// <FS:ND> FIRE-5385; Do not delete data directly, instead move it into the garbabe queue, so it gets deleted once no one holds a reference anymore.
// Otherwise it leads to memory corruption etc.
// delete found_data->second.mList;
// sKeyframeDataMap.erase(found_data);
mGarbage.push_back( found_data->second.mList );
delete found_data->second;
sKeyframeDataMap.erase(found_data);
// </FS:ND>
}
tryShrinkCache();
}
//--------------------------------------------------------------------
@ -2370,11 +2342,7 @@ LLKeyframeMotion::JointMotionList* LLKeyframeDataCache::getKeyframeData(const LL
{
return NULL;
}
found_data->second.mLastAccessed = LLTimer::getTotalSeconds();
tryShrinkCache();
return found_data->second.mList;
return found_data->second;
}
//--------------------------------------------------------------------
@ -2390,69 +2358,10 @@ LLKeyframeDataCache::~LLKeyframeDataCache()
//-----------------------------------------------------------------------------
void LLKeyframeDataCache::clear()
{
// <FS:ND> FIRE-8144; Do not delete data directly, instead move it into the garbage queue, so it gets deleted once no one holds a reference anymore.
// Otherwise it leads to memory corruption etc.
// for( keyframe_data_map_t::iterator itr = sKeyframeDataMap.begin(); sKeyframeDataMap.end() != itr; ++itr )
// delete itr->second.mList;
for( keyframe_data_map_t::iterator itr = sKeyframeDataMap.begin(); sKeyframeDataMap.end() != itr; ++itr )
mGarbage.push_back( itr->second.mList );
// </FS:ND>
for_each(sKeyframeDataMap.begin(), sKeyframeDataMap.end(), DeletePairedPointer());
sKeyframeDataMap.clear();
}
void LLKeyframeDataCache::tryShrinkCache()
{
static U64 sLastRun(0);
U64 nNow = LLTimer::getTotalSeconds();
if( (sLastRun - nNow) < SCAN_CACHE_INTERVAL )
return;
tryDeleteGarbage();
int nKilled = 0;
for( keyframe_data_map_t::iterator itr = sKeyframeDataMap.begin(); sKeyframeDataMap.end() != itr; ++itr )
{
JointMotionListCacheEntry &oCacheEntry = itr->second;
if( !oCacheEntry.mList || oCacheEntry.mList->isLocked() )
continue;
if( (nNow - oCacheEntry.mLastAccessed) > MAX_CACHE_TIME_IN_SECONDS )
{
mGarbage.push_back( oCacheEntry.mList );
sKeyframeDataMap.erase( itr );
itr = sKeyframeDataMap.begin();
++nKilled;
}
}
sLastRun = LLTimer::getTotalSeconds();
}
void LLKeyframeDataCache::tryDeleteGarbage()
{
tGarbage dqGarbage;
int nZombies = 0;
for( tGarbage::iterator itr = mGarbage.begin(); mGarbage.end() != itr; ++itr )
{
if( (*itr)->isLocked() )
{
dqGarbage.push_back( *itr );
++nZombies;
}
else
delete *itr;
}
mGarbage = dqGarbage;
}
//-----------------------------------------------------------------------------
// JointConstraint()
//-----------------------------------------------------------------------------

View File

@ -152,13 +152,7 @@ public:
U32 getFileSize();
BOOL serialize(LLDataPacker& dp) const;
BOOL deserialize(LLDataPacker& dp);
BOOL isLoaded()
{
if (mJointMotionList)
return true;
else
return false;
}
BOOL isLoaded() { return mJointMotionList != NULL; }
// setters for modifying a keyframe animation
@ -419,18 +413,6 @@ public:
U32 dumpDiagInfo();
JointMotion* getJointMotion(U32 index) const { llassert(index < mJointMotionArray.size()); return mJointMotionArray[index]; }
U32 getNumJointMotions() const { return mJointMotionArray.size(); }
void lock()
{ ++mLocks; }
void unlock()
{ --mLocks; }
bool isLocked() const
{ return mLocks > 0; }
private:
long mLocks;
};
@ -440,51 +422,7 @@ protected:
//-------------------------------------------------------------------------
// Member Data
//-------------------------------------------------------------------------
class JointMotionListHolder
{
JointMotionList* mJointMotionList;
JointMotionListHolder( JointMotionListHolder const & );
JointMotionListHolder& operator=(JointMotionListHolder const& );
public:
JointMotionListHolder( JointMotionList *aIn )
: mJointMotionList( aIn )
{
if( mJointMotionList )
mJointMotionList->lock();
}
~JointMotionListHolder()
{
if( mJointMotionList )
mJointMotionList->unlock();
}
operator bool() const
{ return 0 != mJointMotionList; }
JointMotionList* get()
{ return mJointMotionList; }
JointMotionList* operator->()
{ return mJointMotionList; }
JointMotionList const* operator->() const
{ return mJointMotionList; }
void operator=( JointMotionList * aIn )
{
if( mJointMotionList )
mJointMotionList->unlock();
mJointMotionList = aIn;
if( mJointMotionList )
mJointMotionList->lock();
}
};
JointMotionListHolder mJointMotionList;
JointMotionList* mJointMotionList;
std::vector<LLPointer<LLJointState> > mJointStates;
LLJoint* mPelvisp;
LLCharacter* mCharacter;
@ -498,26 +436,14 @@ protected:
class LLKeyframeDataCache
{
struct JointMotionListCacheEntry
{
U64 mLastAccessed;
LLKeyframeMotion::JointMotionList *mList;
};
typedef std::map<LLUUID, JointMotionListCacheEntry> keyframe_data_map_t;
static keyframe_data_map_t sKeyframeDataMap;
typedef std::deque< LLKeyframeMotion::JointMotionList* > tGarbage;
static tGarbage mGarbage;
static void tryShrinkCache();
static void tryDeleteGarbage();
public:
// *FIX: implement this as an actual singleton member of LLKeyframeMotion
LLKeyframeDataCache(){};
~LLKeyframeDataCache();
typedef std::map<LLUUID, class LLKeyframeMotion::JointMotionList*> keyframe_data_map_t;
static keyframe_data_map_t sKeyframeDataMap;
static void addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList*);
static LLKeyframeMotion::JointMotionList* getKeyframeData(const LLUUID& id);