// use for setting initial state private void UpdateCullingChunk(int i) { if (chunkCuller.IsVisible(i)) { chunks[i].gameObject.SetActive(true); } else { chunks[i].gameObject.SetActive(false); } if (chunkCuller.GetDistance(i) < 1) { //SafeSet(i, true); } else { //SafeSet(i, false); } }
/// <summary> /// 获取距离Band /// </summary> /// <param name="_index"></param> /// <returns></returns> public int GetDistanceBand(int _index) { if (cullType == CullType.ViewCull) { return(cullingGroup.IsVisible(_index) ? 0 : 1); } else { return(cullingGroup.GetDistance(_index)); } }
public static int GetDistance(IntPtr l) { int result; try { CullingGroup cullingGroup = (CullingGroup)LuaObject.checkSelf(l); int index; LuaObject.checkType(l, 2, out index); int distance = cullingGroup.GetDistance(index); LuaObject.pushValue(l, true); LuaObject.pushValue(l, distance); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public void LODSettingChanged(GPUSkinningPlayer player) { if (player.LODEnabled) { int numPlayers = players.Count; for (int i = 0; i < numPlayers; ++i) { if (players[i].Player == player) { int distanceIndex = cullingGroup.GetDistance(i); SetLODMeshByDistanceIndex(distanceIndex, players[i].Player); break; } } } else { player.SetLODMesh(null); } }
void BakeInstances() { Count = Instances.Count; Instances.CopyTo(InstancesArray); ForceUpdate.Clear(); for (int i = 0; i < Count; i++) { if (InstancesArray[i].SphereModified) { ForceUpdate.Add(i); InstancesArray[i].SphereModified = false; } SpheresArray[i] = InstancesArray[i].Sphere; } Culling.SetBoundingSpheres(SpheresArray); Culling.SetBoundingSphereCount(Count); for (int f = 0; f < ForceUpdate.Count; f++) { int i = ForceUpdate[f]; if (Culling.GetDistance(i) > 0) { if (Lod.Contains(InstancesArray[i])) { Lod.Remove(InstancesArray[i]); } } else { if (!Lod.Contains(InstancesArray[i])) { Lod.Add(InstancesArray[i]); } } } IsDirty = false; }
private void OnDrawGizmosSelected() { for (var i = 0; i < boundingSphereCount; i++) { var sphere = boundingSpheres[i]; Gizmos.color = cullingGroup.IsVisible(i) ? new Color(0.5f, 1f, 1f, 0.75f) : new Color(1f, 1f, 1f, 0.25f); Gizmos.DrawSphere(sphere.position, sphere.radius); float baseVolume = RadToVol * (sphere.radius * sphere.radius * sphere.radius); int distanceIndex = cullingGroup.GetDistance(i); for (var a = 0; a < m_distances.Length; a++) { float dist = m_distances[a]; float nextVolume = baseVolume + (RadToVol * (dist * dist * dist)); float nextRadius = Mathf.Pow(3f * (nextVolume / FourPI), OneThird); Gizmos.color = a == distanceIndex ? new Color(1f, 0.5f, 1f, 1f) : new Color(0f, 0.5f, 0f, 0.25f); Gizmos.DrawWireSphere(sphere.position, nextRadius); } } }