-
-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add BoolVector-related methods to Packet
- Loading branch information
Showing
7 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Packages/com.github.homuler.mediapipe/Runtime/Scripts/External/StructArray.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Mediapipe | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal readonly struct StructArray | ||
{ | ||
private readonly IntPtr _data; | ||
private readonly int _size; | ||
|
||
public void Dispose() | ||
{ | ||
UnsafeNativeMethods.delete_array__Pf(_data); | ||
} | ||
|
||
public List<T> Copy<T>() where T : unmanaged | ||
{ | ||
var data = new List<T>(_size); | ||
|
||
CopyTo(data); | ||
return data; | ||
} | ||
|
||
public void CopyTo<T>(List<T> data) where T : unmanaged | ||
{ | ||
data.Clear(); | ||
|
||
unsafe | ||
{ | ||
var ptr = (T*)_data; | ||
|
||
for (var i = 0; i < _size; i++) | ||
{ | ||
data.Add(*ptr++); | ||
} | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Packages/com.github.homuler.mediapipe/Runtime/Scripts/External/StructArray.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters