public void PrepareForDraw(ref VRageRender.MyBillboard effectBillboard) { m_billboards.Clear(); if (m_particles.Count == 0) { return; } if (UseLayerSorting && effectBillboard == null) { effectBillboard = MyTransparentGeometry.AddBillboardEffect(m_effect); if (effectBillboard != null) { m_billboards.Add(effectBillboard); } } using (ParticlesLock.AcquireSharedUsing()) { foreach (MyAnimatedParticle particle in m_particles) { MyTransparentGeometry.StartParticleProfilingBlock("m_preallocatedBillboards.Allocate()"); VRageRender.MyBillboard billboard = MyTransparentGeometry.AddBillboardParticle(particle, effectBillboard, !UseLayerSorting); if (billboard != null) { if (!UseLayerSorting) { billboard.Position0.AssertIsValid(); billboard.Position1.AssertIsValid(); billboard.Position2.AssertIsValid(); billboard.Position3.AssertIsValid(); m_billboards.Add(billboard); } } MyTransparentGeometry.EndParticleProfilingBlock(); if (billboard == null) { break; } } } }