mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-24 23:18:04 -05:00
Add CopyIndicesJobs
This commit is contained in:
parent
4da92aa797
commit
c98a94bccb
120
Assets/VRM10/Runtime/IO/Model/CopyIndicesJob.cs
Normal file
120
Assets/VRM10/Runtime/IO/Model/CopyIndicesJob.cs
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
|
||||
#if ENABLE_VRM10_BURST
|
||||
using Unity.Burst;
|
||||
#endif
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
/// <summary>
|
||||
/// インデックス配列を、オフセットを加えながら複製するJob郡
|
||||
/// MEMO: ushortを考慮することをやめればかなりシンプルに書ける
|
||||
/// </summary>
|
||||
internal struct CopyIndicesJobs
|
||||
{
|
||||
/// <summary>
|
||||
/// unsigned int -> unsigned int
|
||||
/// </summary>
|
||||
#if ENABLE_VRM10_BURST
|
||||
[BurstCompile]
|
||||
#endif
|
||||
public struct UInt2UInt : IJobParallelFor
|
||||
{
|
||||
private readonly uint _vertexOffset;
|
||||
|
||||
[ReadOnly] private readonly NativeSlice<uint> _source;
|
||||
[WriteOnly] private NativeSlice<uint> _destination;
|
||||
|
||||
public UInt2UInt(uint vertexOffset, NativeSlice<uint> source, NativeSlice<uint> destination)
|
||||
{
|
||||
_vertexOffset = vertexOffset;
|
||||
_source = source;
|
||||
_destination = destination;
|
||||
}
|
||||
|
||||
public void Execute(int index)
|
||||
{
|
||||
_destination[index] = _source[index] + _vertexOffset;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// unsigned short -> unsigned int
|
||||
/// </summary>
|
||||
#if ENABLE_VRM10_BURST
|
||||
[BurstCompile]
|
||||
#endif
|
||||
public struct Ushort2Uint : IJobParallelFor
|
||||
{
|
||||
private readonly uint _vertexOffset;
|
||||
|
||||
[ReadOnly] private readonly NativeSlice<ushort> _source;
|
||||
[WriteOnly] private NativeSlice<uint> _destination;
|
||||
|
||||
public Ushort2Uint(uint vertexOffset, NativeSlice<ushort> source, NativeSlice<uint> destination)
|
||||
{
|
||||
_vertexOffset = vertexOffset;
|
||||
_source = source;
|
||||
_destination = destination;
|
||||
}
|
||||
|
||||
public void Execute(int index)
|
||||
{
|
||||
_destination[index] = _source[index] + _vertexOffset;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// unsigned short -> unsigned short
|
||||
/// </summary>
|
||||
#if ENABLE_VRM10_BURST
|
||||
[BurstCompile]
|
||||
#endif
|
||||
public struct Ushort2Ushort : IJobParallelFor
|
||||
{
|
||||
private readonly ushort _vertexOffset;
|
||||
|
||||
[ReadOnly] private readonly NativeSlice<ushort> _source;
|
||||
[WriteOnly] private NativeSlice<ushort> _destination;
|
||||
|
||||
public Ushort2Ushort(ushort vertexOffset, NativeSlice<ushort> source, NativeSlice<ushort> destination)
|
||||
{
|
||||
_vertexOffset = vertexOffset;
|
||||
_source = source;
|
||||
_destination = destination;
|
||||
}
|
||||
|
||||
public void Execute(int index)
|
||||
{
|
||||
_destination[index] = (ushort)(_source[index] + _vertexOffset);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// unsigned int -> unsigned short
|
||||
/// </summary>
|
||||
#if ENABLE_VRM10_BURST
|
||||
[BurstCompile]
|
||||
#endif
|
||||
public struct Uint2Ushort : IJobParallelFor
|
||||
{
|
||||
private readonly ushort _vertexOffset;
|
||||
|
||||
[ReadOnly] private readonly NativeSlice<uint> _source;
|
||||
[WriteOnly] private NativeSlice<ushort> _destination;
|
||||
|
||||
public Uint2Ushort(ushort vertexOffset, NativeSlice<uint> source, NativeSlice<ushort> destination)
|
||||
{
|
||||
_vertexOffset = vertexOffset;
|
||||
_source = source;
|
||||
_destination = destination;
|
||||
}
|
||||
|
||||
public void Execute(int index)
|
||||
{
|
||||
_destination[index] = (ushort)(_source[index] + _vertexOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/VRM10/Runtime/IO/Model/CopyIndicesJob.cs.meta
Normal file
3
Assets/VRM10/Runtime/IO/Model/CopyIndicesJob.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3c6a7113ee13415e9b8c1063a683f3f8
|
||||
timeCreated: 1637033014
|
||||
Loading…
Reference in New Issue
Block a user