This commit is contained in:
ousttrue 2024-11-20 20:12:37 +09:00
parent b577c3bb9f
commit 2100a04284
8 changed files with 130 additions and 85 deletions

View File

@ -0,0 +1,52 @@
using UniGLTF.SpringBoneJobs.Blittables;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Jobs;
namespace RotateParticle.Jobs
{
public struct InputColliderJob : IJobParallelForTransform
{
[WriteOnly] public NativeArray<Matrix4x4> CurrentCollider;
public void Execute(int index, TransformAccess transform)
{
CurrentCollider[index] = transform.localToWorldMatrix;
}
}
public struct CollisionJob : IJobParallelFor
{
[ReadOnly] public NativeArray<BlittableCollider> Colliders;
[ReadOnly] public NativeArray<Matrix4x4> CurrentColliders;
[WriteOnly] public NativeArray<Vector3> NextPositions;
public void Execute(int index)
{
for (int i = 0; i < Colliders.Length; ++i)
{
var c = Colliders[i];
switch (c.colliderType)
{
case BlittableColliderType.Sphere:
break;
default:
// TODO
break;
}
}
// var d = Vector3.Distance(from, to);
// if (d > (ra + rb))
// {
// resolved = default;
// return false;
// }
// Vector3 normal = (to - from).normalized;
// resolved = new(from, from + normal * (d - rb));
// return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 874e448619fc4d54f900f52f83708a6c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,46 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UniGLTF.SpringBoneJobs.Blittables;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Jobs;
namespace RotateParticle.Jobs
{
public enum TransformType
{
Center,
WarpRootParent,
WarpRoot,
Particle,
}
public static class TransformTypeExtensions
{
public static bool PositionInput(this TransformType t)
{
return t == TransformType.WarpRoot;
}
public static bool Movable(this TransformType t)
{
return t == TransformType.Particle;
}
public static bool Writable(this TransformType t)
{
switch (t)
{
case TransformType.WarpRoot:
case TransformType.Particle:
return true;
default:
return false;
}
}
}
public struct TransformInfo
{
public TransformType TransformType;
@ -69,23 +35,7 @@ namespace RotateParticle.Jobs
}
}
public struct WarpInfo
{
public int StartIndex;
public int EndIndex;
}
// [Input]
public struct InputColliderJob : IJobParallelForTransform
{
[WriteOnly] public NativeArray<Matrix4x4> CurrentCollider;
public void Execute(int index, TransformAccess transform)
{
CurrentCollider[index] = transform.localToWorldMatrix;
}
}
public struct InputTransformJob : IJobParallelForTransform
{
[ReadOnly] public NativeArray<TransformInfo> Info;
@ -148,39 +98,6 @@ namespace RotateParticle.Jobs
}
}
public struct CollisionJob : IJobParallelFor
{
[ReadOnly] public NativeArray<BlittableCollider> Colliders;
[ReadOnly] public NativeArray<Matrix4x4> CurrentColliders;
[WriteOnly] public NativeArray<Vector3> NextPositions;
public void Execute(int index)
{
for (int i = 0; i < Colliders.Length; ++i)
{
var c = Colliders[i];
switch (c.colliderType)
{
case BlittableColliderType.Sphere:
break;
default:
// TODO
break;
}
}
// var d = Vector3.Distance(from, to);
// if (d > (ra + rb))
// {
// resolved = default;
// return false;
// }
// Vector3 normal = (to - from).normalized;
// resolved = new(from, from + normal * (d - rb));
// return true;
}
}
public struct ApplyRotationJob : IJobParallelFor
{
[ReadOnly] public NativeArray<WarpInfo> Warps;
@ -218,4 +135,4 @@ namespace RotateParticle.Jobs
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 69453c7639ad8df4c94cbe3dae50e72c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,35 @@
namespace RotateParticle.Jobs
{
public enum TransformType
{
Center,
WarpRootParent,
WarpRoot,
Particle,
}
public static class TransformTypeExtensions
{
public static bool PositionInput(this TransformType t)
{
return t == TransformType.WarpRoot;
}
public static bool Movable(this TransformType t)
{
return t == TransformType.Particle;
}
public static bool Writable(this TransformType t)
{
switch (t)
{
case TransformType.WarpRoot:
case TransformType.Particle:
return true;
default:
return false;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56860caf8e0babc41807521ed55a4f20
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
namespace RotateParticle.Jobs
{
public struct WarpInfo
{
public int StartIndex;
public int EndIndex;
}
}