Esempio n. 1
0
        public void Start()
        {
            if (m_s0 == null)
            {
                m_s0 = GameObject.Find("colAABBSegStart");
                if (m_s0 == null)
                {
                    m_s0                  = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    m_s0.name             = "colAABBSegStart";
                    m_s0.transform.parent = gameObject.transform;
                    BakeFilter bf = m_s0.AddComponent <BakeFilter>();
                    bf.m_bakeFilter = BakeFilter.Filter.ExcludeFromBake;
                }
            }

            if (m_s1 == null)
            {
                m_s1 = GameObject.Find("colAABBSegEnd");
                if (m_s1 == null)
                {
                    m_s1                  = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    m_s1.name             = "colAABBSegEnd";
                    m_s1.transform.parent = gameObject.transform;
                    BakeFilter bf = m_s1.AddComponent <BakeFilter>();
                    bf.m_bakeFilter = BakeFilter.Filter.ExcludeFromBake;
                }
            }

            //BuildBVH();
        }
Esempio n. 2
0
        public bool LoadBVHScene(List <MeshFilter> meshes, out Handle bvhHandle)
        {
            // filter items
            meshes.RemoveAll(delegate(MeshFilter mf)
            {
                BakeFilter bf = mf.GetComponent <BakeFilter>();
                if (bf != null)
                {
                    return(bf.m_bakeFilter == BakeFilter.Filter.ExcludeFromBake);
                }

                return(false);
            });

            // find BVH to rebuild
            List <MeshFilter> rebuildList = new List <MeshFilter>();

            foreach (MeshFilter mf in meshes)
            {
                if (!IsValidBVH(mf))
                {
                    rebuildList.Add(mf);
                }
            }

            // build BVH for missing/out-of-date BVH's
            if (rebuildList.Count > 0)
            {
                BuildBVH(rebuildList.ToArray());
            }

            // build id list
            IntPtr meshIdsPtr = Alloc(meshes.Count * SIZE_INT);

            int[] ids = new int[meshes.Count];
            for (int m = 0; m < meshes.Count; ++m)
            {
                ids[m] = meshes[m].GetUniqueId();
            }
            CopyArray(meshIdsPtr, meshes.Count * SIZE_INT, ids, meshes.Count * SIZE_INT);

            IntPtr[] handle = new IntPtr[1];
#if DDR_RUNTIME_DLL_LINKING_
            int err = Invoke <int, _LoadBVHScene>(meshIdsPtr, meshes.Count, handle);
#else
            int err = _LoadBVHScene(meshIdsPtr, meshes.Count, handle);
#endif

            Free(meshIdsPtr);

            bvhHandle = new Handle(handle[0], this);
            if (err != 0)
            {
                string error = GetLastError();
                VertexBakerLib.LogError(error);
                return(false);
            }

            return(true);
        }