Upload project files
This commit is contained in:
8
Runtime/Cloner/Helper/Converter.meta
Normal file
8
Runtime/Cloner/Helper/Converter.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fb3963eff3a815418c93ea649c97569
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Runtime/Cloner/Helper/Converter/BoolToDisplayConvertor.cs
Normal file
30
Runtime/Cloner/Helper/Converter/BoolToDisplayConvertor.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
public struct BoolToDisplayConverter
|
||||
{
|
||||
public static StyleEnum<DisplayStyle> ConvertTo(bool value)
|
||||
{
|
||||
return value ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
}
|
||||
|
||||
public static bool ConvertBack(StyleEnum<DisplayStyle> value)
|
||||
{
|
||||
return value == DisplayStyle.Flex;
|
||||
}
|
||||
}
|
||||
|
||||
public struct InverseBoolToDisplayConverter
|
||||
{
|
||||
public static StyleEnum<DisplayStyle> ConvertTo(bool value)
|
||||
{
|
||||
return value ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
}
|
||||
|
||||
public static bool ConvertBack(StyleEnum<DisplayStyle> value)
|
||||
{
|
||||
return value == DisplayStyle.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b81c44f05fc751c48826ea9ce03b7c01
|
||||
45
Runtime/Cloner/Helper/Converter/ConverterInitializer.cs
Normal file
45
Runtime/Cloner/Helper/Converter/ConverterInitializer.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Unity.Mathematics;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
internal class ConverterInitializer
|
||||
{
|
||||
[InitializeOnLoadMethod]
|
||||
public static void Initialize()
|
||||
{
|
||||
var boolToDisplayGroup = new ConverterGroup("BoolToDisplayConvertor");
|
||||
|
||||
boolToDisplayGroup.AddConverter((ref bool v) => BoolToDisplayConverter.ConvertTo(v));
|
||||
boolToDisplayGroup.AddConverter((ref StyleEnum<DisplayStyle> v) => BoolToDisplayConverter.ConvertBack(v));
|
||||
|
||||
ConverterGroups.RegisterConverterGroup(boolToDisplayGroup);
|
||||
|
||||
|
||||
var inverseBoolToDisplayGroup = new ConverterGroup("InverseBoolToDisplayConverter");
|
||||
|
||||
inverseBoolToDisplayGroup.AddConverter((ref bool v) => InverseBoolToDisplayConverter.ConvertTo(v));
|
||||
inverseBoolToDisplayGroup.AddConverter((ref StyleEnum<DisplayStyle> v) => InverseBoolToDisplayConverter.ConvertBack(v));
|
||||
|
||||
ConverterGroups.RegisterConverterGroup(inverseBoolToDisplayGroup);
|
||||
|
||||
|
||||
var float2ToVector2Group = new ConverterGroup("Float2ToVector2Converter");
|
||||
|
||||
float2ToVector2Group.AddConverter((ref float2 v) => Float2ToVector2Converter.ConvertTo(v));
|
||||
float2ToVector2Group.AddConverter((ref Vector2 v) => Float2ToVector2Converter.ConvertBack(v));
|
||||
|
||||
ConverterGroups.RegisterConverterGroup(float2ToVector2Group);
|
||||
|
||||
|
||||
var float3ToVector3Group = new ConverterGroup("Float3ToVector3Converter");
|
||||
|
||||
float3ToVector3Group.AddConverter((ref float3 v) => Float3ToVector3Converter.ConvertTo(v));
|
||||
float3ToVector3Group.AddConverter((ref Vector3 v) => Float3ToVector3Converter.ConvertBack(v));
|
||||
|
||||
ConverterGroups.RegisterConverterGroup(float3ToVector3Group);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c562049c7c1eae74cabb57e558e84cd6
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
public struct DistributionModeToDisplayStyleConverter
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc563d199e512194591ea87c5554c7fd
|
||||
31
Runtime/Cloner/Helper/Converter/FloatToVectorConverter.cs
Normal file
31
Runtime/Cloner/Helper/Converter/FloatToVectorConverter.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
public struct Float2ToVector2Converter
|
||||
{
|
||||
public static Vector2 ConvertTo(float2 value)
|
||||
{
|
||||
return (Vector2)value;
|
||||
}
|
||||
|
||||
public static float2 ConvertBack(Vector2 value)
|
||||
{
|
||||
return (float2)value;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Float3ToVector3Converter
|
||||
{
|
||||
public static Vector3 ConvertTo(float3 value)
|
||||
{
|
||||
return (Vector3)value;
|
||||
}
|
||||
|
||||
public static float3 ConvertBack(Vector3 value)
|
||||
{
|
||||
return (float3)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e4440b512db4634782a08acd72568a3
|
||||
78
Runtime/Cloner/Helper/MatrixHelper.cs
Normal file
78
Runtime/Cloner/Helper/MatrixHelper.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
internal static class MatrixHelper
|
||||
{
|
||||
internal static void DecomposeMatrix(float4x4 matrix, out float3 position, out quaternion rotation, out float3 scale)
|
||||
{
|
||||
position = matrix.c3.xyz;
|
||||
scale = new float3(
|
||||
math.length(matrix.c0.xyz),
|
||||
math.length(matrix.c1.xyz),
|
||||
math.length(matrix.c2.xyz)
|
||||
);
|
||||
|
||||
rotation = quaternion.LookRotation(matrix.c2.xyz / scale.z, matrix.c1.xyz / scale.y);
|
||||
}
|
||||
|
||||
internal static void DecomposeMatrixToVector(float4x4 matrix, out Vector3 position, out Quaternion rotation, out Vector3 scale)
|
||||
{
|
||||
position = matrix.c3.xyz;
|
||||
scale = new Vector3(
|
||||
math.length(matrix.c0.xyz),
|
||||
math.length(matrix.c1.xyz),
|
||||
math.length(matrix.c2.xyz)
|
||||
);
|
||||
|
||||
rotation = Quaternion.LookRotation(matrix.c2.xyz / scale.z, matrix.c1.xyz / scale.y);
|
||||
}
|
||||
|
||||
internal static void DecomposeMatrixListAsSpan(in IList<Matrix4x4> matrixList, Span<Vector3> positions, Span<Quaternion> rotations, Span<Vector3> scales)
|
||||
{
|
||||
if (matrixList.Count != positions.Length || matrixList.Count != rotations.Length || matrixList.Count != scales.Length)
|
||||
{
|
||||
throw new ArgumentException("The length of the spans must match the number of matrices in the list.");
|
||||
}
|
||||
|
||||
for (var i = 0; i < matrixList.Count; i++)
|
||||
{
|
||||
DecomposeMatrixToVector(matrixList[i], out positions[i], out rotations[i], out scales[i]);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void DecomposeMatrixListAsSpan(ReadOnlySpan<float4x4> matrixList, Span<Vector3> positions, Span<Quaternion> rotations, Span<Vector3> scales)
|
||||
{
|
||||
if (matrixList.Length != positions.Length || matrixList.Length != rotations.Length || matrixList.Length != scales.Length)
|
||||
{
|
||||
throw new ArgumentException("The length of the spans must match the number of matrices in the list.");
|
||||
}
|
||||
|
||||
for (var i = 0; i < matrixList.Length; i++)
|
||||
{
|
||||
DecomposeMatrixToVector(matrixList[i], out positions[i], out rotations[i], out scales[i]);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void DecomposeMatrixListAsSpan(ReadOnlySpan<PointData> matrixList, Span<Vector3> positions, Span<Quaternion> rotations, Span<Vector3> scales)
|
||||
{
|
||||
if (matrixList.Length != positions.Length || matrixList.Length != rotations.Length || matrixList.Length != scales.Length)
|
||||
{
|
||||
throw new ArgumentException("The length of the spans must match the number of matrices in the list.");
|
||||
}
|
||||
|
||||
for (var i = 0; i < matrixList.Length; i++)
|
||||
{
|
||||
DecomposeMatrixToVector(matrixList[i].matrix, out positions[i], out rotations[i], out scales[i]);
|
||||
}
|
||||
}
|
||||
|
||||
internal static float3 GetScale(this float4x4 matrix)
|
||||
{
|
||||
return new float3(math.length(matrix.c0.xyz), math.length(matrix.c1.xyz), math.length(matrix.c2.xyz));
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Cloner/Helper/MatrixHelper.cs.meta
Normal file
2
Runtime/Cloner/Helper/MatrixHelper.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d449f80c59d696f4d8cabfff475f3b7b
|
||||
55
Runtime/Cloner/Helper/ShapeHelper.cs
Normal file
55
Runtime/Cloner/Helper/ShapeHelper.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
internal static class ShapeHelper
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static float Linear01DistanceToSphereCenter(float3 pointPosition, float3 spherePosition, float3 sphereSize)
|
||||
{
|
||||
var x = (pointPosition.x - spherePosition.x) / sphereSize.x;
|
||||
var y = (pointPosition.y - spherePosition.y) / sphereSize.y;
|
||||
var z = (pointPosition.z - spherePosition.z) / sphereSize.z;
|
||||
|
||||
var normalizedDistance = math.sqrt(x * x + y * y + z * z);
|
||||
|
||||
return math.saturate(normalizedDistance);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static bool IsInsideSphere(float3 pointPosition, float3 spherePosition, float3 sphereSize)
|
||||
{
|
||||
sphereSize /= 2.0f;
|
||||
|
||||
var x = (pointPosition.x - spherePosition.x) / sphereSize.x;
|
||||
var y = (pointPosition.y - spherePosition.y) / sphereSize.y;
|
||||
var z = (pointPosition.z - spherePosition.z) / sphereSize.z;
|
||||
|
||||
return (x * x + y * y + z * z) <= 1.0f;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static bool IsInsideCylinder(float3 pointPosition, float3 cylinderPosition, float3 cylinderSize)
|
||||
{
|
||||
cylinderSize /= 2.0f;
|
||||
|
||||
var dx = (pointPosition.x - cylinderPosition.x) / cylinderSize.x;
|
||||
var dz = (pointPosition.z - cylinderPosition.z) / cylinderSize.z;
|
||||
var distanceSquared = dx * dx + dz * dz;
|
||||
|
||||
var withinRadius = distanceSquared <= 1.0f;
|
||||
|
||||
var withinHeight = pointPosition.y >= (cylinderPosition.y - cylinderSize.y) && pointPosition.y <= (cylinderPosition.y + cylinderSize.y);
|
||||
|
||||
return withinRadius && withinHeight;
|
||||
}
|
||||
|
||||
internal static bool IsInsideMesh(float3 pointPosition, float3 meshPosition, Mesh mesh)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Cloner/Helper/ShapeHelper.cs.meta
Normal file
2
Runtime/Cloner/Helper/ShapeHelper.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11f9c68bdb3ebfa479f602ac3a988abe
|
||||
Reference in New Issue
Block a user