예제 #1
0
        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
        }
예제 #2
0
        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
        }
        public void TestLoadBVH(DaydreamVertexLighting source)
        {
            DateTime   start      = DateTime.Now;
            MeshFilter meshFilter = source.GetComponent <MeshFilter>();

            if (meshFilter != null)
            {
                try
                {
                    VertexBakerLib.BVHHandle bvhHandle = null;
                    if (VertexBakerLib.Instance.LoadBVH(meshFilter, ref bvhHandle))
                    {
                        VertexBakerLib.Instance.FreeHandle(bvhHandle.Ptr());
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message + "\n" + e.StackTrace);
                }
            }

            VertexBakerLib.Log("Seconds to complete: " + (DateTime.Now - start).TotalSeconds);
        }