void DoLoadMesh() { m_Loading = true; SetLoadingMat(); if (Valid) { // This way can avoid 'out of sync' bugs int vcnt = m_CreationData.m_IsoData.m_Voxels.Count; int[] vkeys = new int[vcnt]; m_CreationData.m_IsoData.m_Voxels.Keys.CopyTo(vkeys, 0); Dictionary <int, VCVoxel> voxels = m_CreationData.m_IsoData.m_Voxels; if (m_Computer != null) { //int step = WhiteCat.PEVCConfig.instance.vcountEveryFrame; //int step_1 = step - 1; for (int i = 0; i < vcnt; ++i) { int key = vkeys[i]; if (m_Meshdagger && m_Computer != null && m_Computer.m_MeshMgr != null) { if (voxels != null && voxels.ContainsKey(key) && m_Computer.InSide(key, m_CreationData.m_IsoData.m_HeadInfo.xSize, m_Computer.m_MeshMgr.m_LeftSidePos)) { m_Computer.AlterVoxel(key, voxels[key]); } } else { if (m_Computer != null && voxels != null && voxels.ContainsKey(key)) { m_Computer.AlterVoxel(key, voxels[key]); } } //if ( i % step == step_1) //{ // if ( m_Computer != null ) m_Computer.ReqMesh(); // yield return 0; //} } if (m_Computer != null) { m_Computer.ReqMesh(); } } creationController.AddBuildFinishedListener(RevertMat); } m_Loading = false; }
void CheckPhysicsEnabled() { var player = MainPlayer.Instance == null ? null : MainPlayer.Instance.entity; if (_enablePhysicsRequest != 0 && player != null && player.peTrans != null && (player.position - transform.position).sqrMagnitude < 10000f ) { _enablePhysicsRequest--; if (_enablePhysicsRequest == 0) { _creationController.AddBuildFinishedListener( () => { rigidbody.isKinematic = false; rigidbody.velocity = _tempVelocityForLOD; rigidbody.angularVelocity = _tempAngularVelocityForLOD; } ); } } }