public void ReloadConvexInfo() { geom_convex_list_.Clear(); nav_editor.editor_geom_get_convex_info(ref my_convex_info); for (int i = 0; i < my_convex_info.convex_num; ++i) { IntPtr p = new IntPtr(my_convex_info.convex.ToInt64() + (uint)(i * Marshal.SizeOf(typeof(nav_editor.MyConvexVolume)))); nav_editor.MyConvexVolume convex = nav_editor.PtrToStructure <nav_editor.MyConvexVolume>(p); ConvexInfo info = new ConvexInfo(); info.id = i; info.hmin = convex.hmin; info.hmax = convex.hmax; info.area = convex.area; for (int k = 0; k < convex.nverts; ++k) { IntPtr pv = new IntPtr(convex.verts.ToInt64() + (uint)(3 * k * Marshal.SizeOf(typeof(float)))); IntPtr pv1 = new IntPtr(pv.ToInt64() + 1 * Marshal.SizeOf(typeof(float))); IntPtr pv2 = new IntPtr(pv.ToInt64() + 2 * Marshal.SizeOf(typeof(float))); Vector3 pos = Vector3.zero; pos.x = -nav_editor.PtrToStructure <float>(pv); pos.y = nav_editor.PtrToStructure <float>(pv1); pos.z = nav_editor.PtrToStructure <float>(pv2); info.vertexs.Add(pos); } geom_convex_list_.Add(info); } }
public void Uninit() { geom_convex_list_.Clear(); for (int i = 0; i < my_convex_info.convex_num; ++i) { IntPtr p = new IntPtr(my_convex_info.convex.ToInt64() + (uint)(i * Marshal.SizeOf(typeof(nav_editor.MyConvexVolume)))); nav_editor.MyConvexVolume convex = nav_editor.PtrToStructure <nav_editor.MyConvexVolume>(p); if (convex.verts != IntPtr.Zero) { Marshal.FreeHGlobal(convex.verts); } } if (my_convex_info.convex != IntPtr.Zero) { Marshal.FreeHGlobal(my_convex_info.convex); } my_convex_info.convex_num = 0; my_convex_info.convex = IntPtr.Zero; }