(Crash)Grass Clusters CMeshBuilder::BeginModify Not Safe With Queued Material System
When using the multi-threaded queued materialsystem (mat_queue_mode -1, which is default in SDK2013) and modifying the grass mesh in the CGrassClusterManager::InjectMorph with CMeshBuilder's BeginModify function, there's a potential for a crash. On Windows it doesn't really happen, but on Linux/Mac it's an instant crash.
The way to handle this is to use the render context's call queue.
Here's some pseudo-code as to what that might look like.
CMatRenderContextPtr pRenderContext( materials );
ICallQueue *pCallQueue = pRenderContext->GetCallQueue();
if ( pCallQueue )
pCallQueue->QueueCall( this, &CGrassClusterManager::SomeThreadSafeMorphFunc );
else
DoSingleThreadedMorph()
You'll also want a mutex to lock using AUTO_LOCK or something to protect access to the cluster data/grass mesh.
I'm working on something like this, so I may do a pull request even though this project is dead, but I figured I'd post this issue in case somebody finds this and cares about it.