public int RebuildBVH(BVHHandle bvhHandle) { // build baker context m_baker.m_sourcePaths = new string[] { AssetDatabase.GetAssetPath(bvhHandle.SourceMeshData.sharedMesh) }; m_baker.m_guids = new string[] { "" + m_baker.m_meshes[0].GetUniqueId() }; m_baker.m_meshRenderers = new MeshRenderer[] { bvhHandle.SourceMeshData.GetComponent <MeshRenderer>() }; // parse data and fill in missing context BakeContext.BuildSceneContext(new MeshFilter[] { bvhHandle.SourceMeshData }, m_baker); #if DDR_RUNTIME_DLL_LINKING_ int err = Invoke <int, _RebuildBVH>(bvhHandle.Ptr(), m_baker.m_meshIdsPtr, m_baker.m_vertexCountsPtr, m_baker.m_triangleCountPtr , m_baker.m_matDataPtr, m_baker.m_meshDataPtr, m_baker.m_triangleDataPtr, m_baker.m_bakeOptionsPtr, 1, m_baker.m_guids, m_baker.m_sourcePaths); #else int err = _RebuildBVH(bvhHandle.Ptr(), m_baker.m_meshIdsPtr, m_baker.m_vertexCountsPtr, m_baker.m_triangleCountPtr , m_baker.m_matDataPtr, m_baker.m_meshDataPtr, m_baker.m_triangleDataPtr, m_baker.m_bakeOptionsPtr, 1, m_baker.m_guids, m_baker.m_sourcePaths); #endif m_baker.FreeContext(); if (err != 0) { string error = GetLastError(); VertexBakerLib.LogError(error); } return(err); }
public int TessellateTriangles(BVHHandle bvhHandle, Vector3 startPoint, Vector3 endPoint) { m_baker.m_sourcePaths = new string[] { AssetDatabase.GetAssetPath(bvhHandle.SourceMeshData.sharedMesh) }; m_baker.m_guids = new string[] { "" + m_baker.m_meshes[0].GetUniqueId() }; m_baker.m_meshRenderers = new MeshRenderer[] { bvhHandle.SourceMeshData.GetComponent <MeshRenderer>() }; List <MeshFilter> meshes = new List <MeshFilter>() { bvhHandle.SourceMeshData }; m_baker.InitBakeContext(meshes, null); BakeContext.IVertex vertexFormat = new BakeContext.DefaultVertex(); BakeContext.BuildSceneContext(m_baker.m_meshes.ToArray(), m_baker, vertexFormat); int[] outIndex = new int[1]; outIndex[0] = -1; #if DDR_RUNTIME_DLL_LINKING_ bool success = Invoke <bool, _TessellateTriangles>(bvhHandle.Ptr() , m_baker.m_meshIdsPtr , m_baker.m_vertexCountsPtr , m_baker.m_triangleCountPtr , vertexFormat.ElementCount , vertexFormat.Definition.ToArray() , m_baker.m_matDataPtr , m_baker.m_meshDataPtr , m_baker.m_triangleDataPtr , m_baker.m_bakeOptionsPtr , m_baker.m_guids , m_baker.m_sourcePaths , m_baker.m_settingsPtrs); #else bool success = _TessellateTriangles(bvhHandle.Ptr() , m_baker.m_meshIdsPtr , m_baker.m_vertexCountsPtr , m_baker.m_triangleCountPtr , vertexFormat.ElementCount , vertexFormat.Definition.ToArray() , m_baker.m_matDataPtr , m_baker.m_meshDataPtr , m_baker.m_triangleDataPtr , m_baker.m_bakeOptionsPtr , m_baker.m_guids , m_baker.m_sourcePaths , m_baker.m_settingsPtrs); #endif if (!success) { string error = GetLastError(); VertexBakerLib.LogError(error); } return(outIndex[0]); }