256256// mDecompositionRequests mMutex rw.repo.mMutex, ro.repo.none [5]
257257// mPhysicsShapeRequests mMutex rw.repo.mMutex, ro.repo.none [5]
258258// mDecompositionQ mMutex rw.repo.mLoadedMutex, rw.main.mLoadedMutex [5] (was: [0])
259+ // mPhysicsQ mMutex rw.repo.mLoadedMutex, rw.main.mLoadedMutex [5] (was: [0])
259260// mHeaderReqQ mMutex ro.repo.none [5], rw.repo.mMutex, rw.any.mMutex
260261// mLODReqQ mMutex ro.repo.none [5], rw.repo.mMutex, rw.any.mMutex
261262// mUnavailableQ mMutex rw.repo.none [0], ro.main.none [5], rw.main.mLoadedMutex
@@ -975,6 +976,12 @@ LLMeshRepoThread::~LLMeshRepoThread()
975976 mDecompositionQ .pop_front ();
976977 }
977978
979+ while (!mPhysicsQ .empty ())
980+ {
981+ delete mPhysicsQ .front ();
982+ mPhysicsQ .pop_front ();
983+ }
984+
978985 delete mHttpRequest ;
979986 mHttpRequest = nullptr ;
980987 delete mMutex ;
@@ -2558,7 +2565,7 @@ EMeshProcessingResult LLMeshRepoThread::physicsShapeReceived(const LLUUID& mesh_
25582565
25592566 {
25602567 LLMutexLock lock (mLoadedMutex );
2561- mDecompositionQ .push_back (d);
2568+ mPhysicsQ .push_back (d);
25622569 }
25632570 return MESH_OK;
25642571}
@@ -3434,13 +3441,14 @@ void LLMeshRepoThread::notifyLoadedMeshes()
34343441 }
34353442 }
34363443
3437- if (!mSkinInfoQ .empty () || !mSkinUnavailableQ .empty () || ! mDecompositionQ .empty ())
3444+ if (!mSkinInfoQ .empty () || !mSkinUnavailableQ .empty () || !mDecompositionQ . empty () || ! mPhysicsQ .empty ())
34383445 {
34393446 if (mLoadedMutex ->trylock ())
34403447 {
34413448 std::deque<LLPointer<LLMeshSkinInfo>> skin_info_q;
34423449 std::deque<UUIDBasedRequest> skin_info_unavail_q;
34433450 std::list<LLModel::Decomposition*> decomp_q;
3451+ std::list<LLModel::Decomposition*> physics_q;
34443452
34453453 if (! mSkinInfoQ .empty ())
34463454 {
@@ -3457,6 +3465,11 @@ void LLMeshRepoThread::notifyLoadedMeshes()
34573465 decomp_q.swap (mDecompositionQ );
34583466 }
34593467
3468+ if (!mPhysicsQ .empty ())
3469+ {
3470+ physics_q.swap (mPhysicsQ );
3471+ }
3472+
34603473 mLoadedMutex ->unlock ();
34613474
34623475 // Process the elements free of the lock
@@ -3473,9 +3486,15 @@ void LLMeshRepoThread::notifyLoadedMeshes()
34733486
34743487 while (! decomp_q.empty ())
34753488 {
3476- gMeshRepo .notifyDecompositionReceived (decomp_q.front ());
3489+ gMeshRepo .notifyDecompositionReceived (decomp_q.front (), false );
34773490 decomp_q.pop_front ();
34783491 }
3492+
3493+ while (!physics_q.empty ())
3494+ {
3495+ gMeshRepo .notifyDecompositionReceived (physics_q.front (), true );
3496+ physics_q.pop_front ();
3497+ }
34793498 }
34803499 }
34813500
@@ -4717,24 +4736,31 @@ void LLMeshRepository::notifySkinInfoUnavailable(const LLUUID& mesh_id)
47174736 }
47184737}
47194738
4720- void LLMeshRepository::notifyDecompositionReceived (LLModel::Decomposition* decomp)
4739+ void LLMeshRepository::notifyDecompositionReceived (LLModel::Decomposition* decomp, bool physics_mesh )
47214740{
4722- decomposition_map::iterator iter = mDecompositionMap .find (decomp->mMeshID );
4741+ LLUUID decomp_id = decomp->mMeshID ; // Copy to avoid invalidation in below deletion
4742+ decomposition_map::iterator iter = mDecompositionMap .find (decomp_id);
47234743 if (iter == mDecompositionMap .end ())
47244744 { // just insert decomp into map
4725- mDecompositionMap [decomp->mMeshID ] = decomp;
4726- mLoadingDecompositions .erase (decomp->mMeshID );
4745+ mDecompositionMap [decomp_id] = decomp;
47274746 sCacheBytesDecomps += decomp->sizeBytes ();
47284747 }
47294748 else
47304749 { // merge decomp with existing entry
47314750 sCacheBytesDecomps -= iter->second ->sizeBytes ();
47324751 iter->second ->merge (decomp);
47334752 sCacheBytesDecomps += iter->second ->sizeBytes ();
4734-
4735- mLoadingDecompositions .erase (decomp->mMeshID );
47364753 delete decomp;
47374754 }
4755+
4756+ if (physics_mesh)
4757+ {
4758+ mLoadingPhysicsShapes .erase (decomp_id);
4759+ }
4760+ else
4761+ {
4762+ mLoadingDecompositions .erase (decomp_id);
4763+ }
47384764}
47394765
47404766void LLMeshRepository::notifyMeshLoaded (const LLVolumeParams& mesh_params, LLVolume* volume, S32 lod)
@@ -4881,7 +4907,6 @@ void LLMeshRepository::fetchPhysicsShape(const LLUUID& mesh_id)
48814907 boost::unordered_set<LLUUID>::iterator iter = mLoadingPhysicsShapes .find (mesh_id);
48824908 if (iter == mLoadingPhysicsShapes .end ())
48834909 { // no request pending for this skin info
4884- // *FIXME: Nothing ever deletes entries, can't be right
48854910 mLoadingPhysicsShapes .insert (mesh_id);
48864911 mPendingPhysicsShapeRequests .push (mesh_id);
48874912 }
0 commit comments