protected static void Init(MeshFilter meshFilter, Mesh untessellatedMesh) { if (!Directory.Exists(FBSConstants.BasePath + "/Cache/")) { Directory.CreateDirectory(FBSConstants.BasePath + "/Cache/"); } if (!Directory.Exists(FBSConstants.BasePath + "/BVHCache/")) { Directory.CreateDirectory(FBSConstants.BasePath + "/BVHCache/"); } if (meshFilter.sharedMesh == null) { Debug.LogWarning(meshFilter.gameObject.GetPath() + " is missing its source mesh"); return; } s_debugState = BakeData.Instance().GetDebugState(); #if _DAYDREAM_STATIC_LIGHTING_DEBUG DateTime start = DateTime.Now; // if we still have a handle for some reason try to free it if (s_lastInstanceId != meshFilter.GetUniqueId()) { if (s_bvhHandle != null) { VertexBakerLib.Instance.FreeHandle(s_bvhHandle.Ptr()); } s_bvhHandle = null; BuildWorldVertices(meshFilter); s_debugState.m_tessFaces = null; } TryLoadBVH(meshFilter); s_lastInstanceId = meshFilter.GetUniqueId(); if (s_bvhWrapper == null) { s_bvhWrapper = new BVHNode_FBWrapper(); } string sourceAssetPath = AssetDatabase.GetAssetPath(untessellatedMesh); if (!string.IsNullOrEmpty(sourceAssetPath) && !Application.isPlaying) { Debug.LogWarning("Could not find asset " + untessellatedMesh.name + " the asset may be an instance. Some debug data may not be available."); } string path = BVH.ConvertMeshIdToBVHPath(s_lastInstanceId); s_bvhWrapper.SetPath(path); s_bvhWrapper.Validate(); s_cacheWrapper.SetPath("" + s_lastInstanceId); s_cacheWrapper.Validate(); VertexBakerLib.Log("Debug setup time: " + (DateTime.Now - start).TotalSeconds + " seconds"); #endif }
protected static void Init(MeshFilter meshFilter) { if (meshFilter.sharedMesh == null) { Debug.LogWarning(meshFilter.gameObject.GetPath() + " is missing its mesh"); return; } s_debugState = BakeData.Instance().GetDebugState(); #if _DAYDREAM_STATIC_LIGHTING_DEBUG // if we still have a handle for some reason try to free it if (s_lastInstanceId != meshFilter.GetUniqueId()) { if (s_bvhHandle != null) { VertexBakerLib.Instance.FreeHandle(s_bvhHandle.Ptr()); } s_bvhHandle = null; BuildWorldVertices(meshFilter); } TryLoadBVH(meshFilter); s_lastInstanceId = meshFilter.GetUniqueId(); if (s_bvhWrapper == null) { s_bvhWrapper = new BVHNode_FBWrapper(); } string path = BVH.ConvertMeshIdToBVHPath(s_lastInstanceId); s_bvhWrapper.SetPath(path); s_bvhWrapper.Validate(); string sourceAssetPath = AssetDatabase.GetAssetPath(meshFilter.sharedMesh); if (!string.IsNullOrEmpty(sourceAssetPath)) { s_cacheWrapper.SetPath("" + s_lastInstanceId); s_cacheWrapper.Validate(); } else if (!Application.isPlaying) { Debug.LogError("Could not find asset " + meshFilter.sharedMesh.name + " the asset may be an instance. Some debug data may not be available."); } #endif }