public void Exec() { if (_reqList.Count == 0 || Pause) { return; } foreach (SurfExtractReqTrans req in _reqList.Values) { // Not check out of date because add_req is just called before this method in the same thread. if (req._faceMask != 0) { TransVertices verts = new TransVertices(); List <int> indexedIndices = new List <int>(); float cellSize = 0.01f; TransvoxelExtractor2.BuildTransitionCells(req._faceMask, req._chunkData, cellSize, verts, indexedIndices); //int nVerts = verts.Count; int chunkVertsCurCnt = TransvoxelGoCreator.UnindexedVertex(verts, indexedIndices, out req.vert, out req.norm01, out req.norm2t); req.indice = new int[chunkVertsCurCnt]; Array.Copy(SurfExtractorsMan.s_indiceMax, req.indice, chunkVertsCurCnt); } lock (_reqFinishedList){ _reqFinishedList.Add(req); } } _reqList.Clear(); }
public static int UnindexedVertex(TransVertices verts, List <int> indices, out Vector3[] vert, out Vector2[] norm01, out Vector2[] norm2t) { int nVert = indices.Count; vert = new Vector3[nVert]; norm01 = new Vector2[nVert]; norm2t = new Vector2[nVert]; int idxVert; Vector4 normal; float type0, type1, type2; for (int i = 0; i < nVert;) { idxVert = indices[i]; vert[i] = verts.Position[idxVert]; normal = verts.Normal_t[idxVert]; norm01[i] = new Vector2(-normal.x, -normal.y); norm2t[i] = new Vector2(normal.z, 0.0f); type0 = normal.w; i++; idxVert = indices[i]; vert[i] = verts.Position[idxVert]; normal = verts.Normal_t[idxVert]; norm01[i] = new Vector2(-normal.x, -normal.y); norm2t[i] = new Vector2(normal.z, 0.1f); type1 = normal.w; i++; idxVert = indices[i]; vert[i] = verts.Position[idxVert]; normal = verts.Normal_t[idxVert]; norm01[i] = new Vector2(-normal.x, -normal.y); norm2t[i] = new Vector2(normal.z, 0.2f); type2 = normal.w; i++; norm2t[i - 1].x += type0 * 4 + 2; norm2t[i - 1].y += type1 * 256 + type2; norm2t[i - 2].x += type0 * 4 + 2; norm2t[i - 2].y += type1 * 256 + type2; norm2t[i - 3].x += type0 * 4 + 2; norm2t[i - 3].y += type1 * 256 + type2; } return(nVert); }
public static void CreateTransvoxelGo(VFVoxelChunkGo chunkGo, int faceMask) { TransVertices verts = new TransVertices(); List <int> indexedIndices = new List <int>(); float cellSize = 0.01f; TransvoxelExtractor2.BuildTransitionCells(faceMask, chunkGo.Data, cellSize, verts, indexedIndices); Vector3[] vert; Vector2[] norm01; Vector2[] norm2t; int chunkVertsCurCnt = UnindexedVertex(verts, indexedIndices, out vert, out norm01, out norm2t); SurfExtractReqTrans req = new SurfExtractReqTrans(0, null); req.vert = vert; req.norm01 = norm01; req.norm2t = norm2t; req.indice = new int[chunkVertsCurCnt]; Array.Copy(SurfExtractorsMan.s_indiceMax, req.indice, chunkVertsCurCnt); chunkGo.SetTransGo(req, faceMask); }