public void AddUnitRender(UnitRender render) { if (unusedIndexPool.Count > 0) { int index = unusedIndexPool[0]; DebugUtils.Assert(boundingSpheres.Length > index, "Culling Group: boundSpheresIndex out of length " + render.ToString()); BoundingSphere sphere = boundingSpheres[index]; sphere.position = render.transform.position; sphere.radius = modelRadius; boundingSpheres[index] = sphere; bool unitIsVisible = cullingGroup.IsVisible(index); render.boundSpheresIndex = index; render.OnCullingStateChange(unitIsVisible); boundingSpheresDic.Add(index, render); usedIndexPool.Add(index); unusedIndexPool.RemoveAt(0); } else { DebugUtils.Assert(false, "Culling Group: unusedIndexPool count is not enough, count = " + groupCount); } }
public void SyncPosition(UnitRender render, Vector3 position) { int index = render.boundSpheresIndex; DebugUtils.Assert(boundingSpheres.Length > index, "Culling Group: boundSpheresIndex out of length " + render.ToString()); boundingSpheres[index].position = position; }
public void RemoveUnitRender(UnitRender ur) { if (usedIndexPool.Remove(ur.boundSpheresIndex)) { unusedIndexPool.Add(ur.boundSpheresIndex); boundingSpheresDic.Remove(ur.boundSpheresIndex); } else { DebugUtils.Assert(false, "Culling Group: can't recycle a unit render " + ur.ToString()); } }