// Cons & Des for double public void Init(IntVector3 editor_size, VCMeshMgr mesh_mgr, bool for_editor, int meshIndex) { m_ForEditor = for_editor; // Create chunk data source int nx = Mathf.CeilToInt((float)(editor_size.x + 1) / CHUNK_VOXEL_NUM); int ny = Mathf.CeilToInt((float)(editor_size.y + 1) / CHUNK_VOXEL_NUM); int nz = Mathf.CeilToInt((float)(editor_size.z + 1) / CHUNK_VOXEL_NUM); m_DataSource = new VFCreationDataSource(nx, ny, nz); SN++; int nx05 = Mathf.CeilToInt(0.5f * nx); int nx0 = mesh_mgr.m_DaggerMesh ? mesh_mgr.m_LeftSidePos ? 0 : nx05 : 0; int nxMax = mesh_mgr.m_DaggerMesh ? mesh_mgr.m_LeftSidePos ? nx05 : nx : nx; // Create new chunk for (int x = nx0; x < nxMax; x++) { for (int y = 0; y < ny; y++) { for (int z = 0; z < nz; z++) { VFVoxelChunkData chunk = new VFVoxelChunkData(null, VFVoxelChunkData.S_ChunkDataAir); chunk.HelperProc = this; IntVector3 snpos = PackSNToChunkPos(new IntVector3(x, y, z), SN); m_DataSource.writeChunk(snpos.x, snpos.y, snpos.z, chunk, 0); } } } // Mesh manager m_MeshMgr = mesh_mgr; }
public void InitClone(VFCreationDataSource dataSource, VCMeshMgr mesh_mgr, bool for_editor = true) { m_ForEditor = for_editor; m_DataSource = dataSource; // Mesh manager m_MeshMgr = mesh_mgr; }
public void InitClone(WhiteCat.CreationController controller, VFCreationDataSource dataSource, VCMeshMgr mesh)//) { m_lastVisible = false; m_Visible = false; InitCreationIDClone(controller.creationData.m_ObjectID, dataSource, mesh); // InitCreationID(controller.creationData.m_ObjectID); this.creationController = controller; controller.onUpdate += UpdateMeshLoader; }
public void Destroy() { // Destroy current Data Source if (m_DataSource != null) { for (int x = 0; x < m_DataSource.ChunkNum.x; x++) { for (int y = 0; y < m_DataSource.ChunkNum.y; y++) { for (int z = 0; z < m_DataSource.ChunkNum.z; z++) { VFVoxelChunkData vc = m_DataSource.readChunk(x, y, z); if (vc != null) { vc.ClearMem(); } } } } m_DataSource = null; } m_MeshMgr = null; }
void InitCreationIDClone(int creationId, VFCreationDataSource dataSource, VCMeshMgr mesh_mgr) { if (m_Computer != null) { m_Computer.Destroy(); } CreationData crd = CreationMgr.GetCreation(creationId); if (crd != null) { m_CreationID = creationId; m_CreationData = crd; m_MeshMgr = mesh_mgr; m_MeshMgr.m_LeftSidePos = !mesh_mgr.m_LeftSidePos; m_Computer = new VCMCComputer(); m_Computer.InitClone(dataSource, m_MeshMgr, false); if (crd.m_Attribute.m_Type == ECreation.Vehicle || crd.m_Attribute.m_Type == ECreation.Aircraft || crd.m_Attribute.m_Type == ECreation.Boat || crd.m_Attribute.m_Type == ECreation.SimpleObject || crd.m_Attribute.m_Type == ECreation.AITurret) { m_Computer.m_CreateBoxCollider = true; } } else { m_CreationID = 0; m_CreationData = null; m_Computer = null; m_MeshMgr = null; } }