mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-24 23:18:04 -05:00
TransformExtensions.AbsoluteMaxValue
This commit is contained in:
parent
46e65700b2
commit
ba4d66d146
21
Assets/UniGLTF/Runtime/Extensions/TransformExtensions.cs
Normal file
21
Assets/UniGLTF/Runtime/Extensions/TransformExtensions.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public static class TransformExtensions
|
||||
{
|
||||
public static float UniformedLossyScale(this Transform transform)
|
||||
{
|
||||
var s = transform.lossyScale;
|
||||
return AbsoluteMaxValue(s);
|
||||
}
|
||||
|
||||
public static float AbsoluteMaxValue(in Vector3 s)
|
||||
{
|
||||
var x = Mathf.Abs(s.x);
|
||||
var y = Mathf.Abs(s.y);
|
||||
var z = Mathf.Abs(s.z);
|
||||
return Mathf.Max(Mathf.Max(x, y), z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
"name": "SpringBoneJobs",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"references": [
|
||||
"GUID:8d76e605759c3f64a957d63ef96ada7c"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
|
|
|
|||
|
|
@ -42,35 +42,6 @@ namespace UniGLTF.SpringBoneJobs
|
|||
// System Level
|
||||
public float DeltaTime;
|
||||
|
||||
static float MaxValue(Vector3 s)
|
||||
{
|
||||
var x = Mathf.Abs(s.x);
|
||||
var y = Mathf.Abs(s.y);
|
||||
var z = Mathf.Abs(s.z);
|
||||
if (x < y)
|
||||
{
|
||||
if (y < z)
|
||||
{
|
||||
return z;
|
||||
}
|
||||
else
|
||||
{
|
||||
return y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x < z)
|
||||
{
|
||||
return z;
|
||||
}
|
||||
else
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <param name="index">房のindex</param>
|
||||
public void Execute(int index)
|
||||
{
|
||||
|
|
@ -111,7 +82,7 @@ namespace UniGLTF.SpringBoneJobs
|
|||
var parentRotation = parentTransform?.rotation ?? Quaternion.identity;
|
||||
|
||||
// scaling 対応
|
||||
var scalingFactor = model.SupportsScalingAtRuntime ? MaxValue(headTransform.localToWorldMatrix.lossyScale) : 1.0f;
|
||||
var scalingFactor = model.SupportsScalingAtRuntime ? TransformExtensions.AbsoluteMaxValue(headTransform.localToWorldMatrix.lossyScale) : 1.0f;
|
||||
|
||||
// verlet積分で次の位置を計算
|
||||
var external = (joint.gravityDir * joint.gravityPower + model.ExternalForce) * DeltaTime;
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
public static class TransformExtensions
|
||||
{
|
||||
public static float UniformedLossyScale(this Transform transform)
|
||||
{
|
||||
// Mathf.Max(a, b, c) は GC どうなんだろう
|
||||
var s = transform.lossyScale;
|
||||
var x = Mathf.Abs(s.x);
|
||||
var y = Mathf.Abs(s.y);
|
||||
var z = Mathf.Abs(s.z);
|
||||
if (x < y)
|
||||
{
|
||||
if (y < z)
|
||||
{
|
||||
return z;
|
||||
}
|
||||
else
|
||||
{
|
||||
return y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x < z)
|
||||
{
|
||||
return z;
|
||||
}
|
||||
else
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM.SpringBone
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM.SpringBone
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM.SpringBone
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user