diff --git a/Assets/UniGLTF/Runtime/UniHumanoid/SkeletonMeshUtility.cs b/Assets/UniGLTF/Runtime/UniHumanoid/SkeletonMeshUtility.cs
index cee8f1fa4..708dd6544 100644
--- a/Assets/UniGLTF/Runtime/UniHumanoid/SkeletonMeshUtility.cs
+++ b/Assets/UniGLTF/Runtime/UniHumanoid/SkeletonMeshUtility.cs
@@ -254,7 +254,7 @@ namespace UniHumanoid
{
if (Application.isEditor)
{
- // Debug.LogWarningFormat("{0} not found", headTail.Head);
+ Debug.LogWarningFormat("{0} not found", headTail.Head);
}
}
}
diff --git a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs
index a63d513fd..482707acc 100644
--- a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs
+++ b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs
@@ -28,36 +28,12 @@ namespace UniVRM10
public Vector3 Normal = Vector3.up;
- public Vector3 HeadWorldPosition => transform.TransformPoint(Offset);
- public Vector3 TailWorldPosition => transform.TransformPoint(TailOrNormal);
public Vector3 TailOrNormal => ColliderType == VRM10SpringBoneColliderTypes.Plane ? Normal : Tail;
public static int SelectedGuid;
public bool IsSelected => GetInstanceID() == SelectedGuid;
- public Bounds GetBounds()
- {
- switch (ColliderType)
- {
- case VRM10SpringBoneColliderTypes.Capsule:
- {
- var h = HeadWorldPosition;
- var t = TailWorldPosition;
- var d = h - t;
- var aabb = new Bounds((h + t) * 0.5f, new Vector3(Mathf.Abs(d.x), Mathf.Abs(d.y), Mathf.Abs(d.z)));
- aabb.Expand(Radius * 2);
- return aabb;
- }
-
- case VRM10SpringBoneColliderTypes.Sphere:
- return new Bounds(HeadWorldPosition, new Vector3(Radius, Radius, Radius));
-
- default:
- throw new NotImplementedException();
- }
- }
-
void OnDrawGizmosSelected()
{
DrawGizmos();
diff --git a/Assets/VRM10/Runtime/IO/Material/BuiltInRP/Import/Materials/BuiltInVrm10MToonMaterialImporter.cs b/Assets/VRM10/Runtime/IO/Material/BuiltInRP/Import/Materials/BuiltInVrm10MToonMaterialImporter.cs
index 70551e7c6..2f07ad27b 100644
--- a/Assets/VRM10/Runtime/IO/Material/BuiltInRP/Import/Materials/BuiltInVrm10MToonMaterialImporter.cs
+++ b/Assets/VRM10/Runtime/IO/Material/BuiltInRP/Import/Materials/BuiltInVrm10MToonMaterialImporter.cs
@@ -242,15 +242,9 @@ namespace UniVRM10
private static MToon10AlphaMode GetMToon10AlphaMode(glTFMaterial material)
{
- if (material == null)
- {
- return MToon10AlphaMode.Opaque;
- }
-
switch (material?.alphaMode)
{
case null:
- return MToon10AlphaMode.Opaque;
case "OPAQUE":
return MToon10AlphaMode.Opaque;
case "MASK":
diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs
index 7c19cff62..da0f48235 100644
--- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs
+++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs
@@ -366,15 +366,17 @@ namespace ClothWarpLib
///
///
///
- public bool TryCollide(UniVRM10.VRM10SpringBoneCollider c, in Vector3 p, float radius, out LineSegment resolved)
+ public bool TryCollide(VRM10SpringBoneCollider c, in Vector3 p, float radius, out LineSegment resolved)
{
- if (c.ColliderType == UniVRM10.VRM10SpringBoneColliderTypes.Capsule)
+ var headWorldPosition = c.transform.TransformPoint(c.Offset);
+ if (c.ColliderType == VRM10SpringBoneColliderTypes.Capsule)
{
- return TryCollideCapsuleAndSphere(c.HeadWorldPosition, c.TailWorldPosition, c.Radius, p, radius, out resolved);
+ var tailWorldPosition = c.transform.TransformPoint(c.TailOrNormal);
+ return TryCollideCapsuleAndSphere(headWorldPosition, tailWorldPosition, c.Radius, p, radius, out resolved);
}
else
{
- return TryCollideSphereAndSphere(c.HeadWorldPosition, c.Radius, p, radius, out resolved);
+ return TryCollideSphereAndSphere(headWorldPosition, c.Radius, p, radius, out resolved);
}
}
diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/CapsuleInfo.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/CapsuleInfo.cs
deleted file mode 100644
index 9da7d551e..000000000
--- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/CapsuleInfo.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using UnityEngine;
-using UniVRM10;
-
-namespace SphereTriangle
-{
- struct CapsuleInfo
- {
- public VRM10SpringBoneCollider Collider;
- public Triangle Triangle;
-
- public Vector3 MinOnPlane;
- public float MinDistance;
- public float MinDistanceClmap;
- public Vector3 MinOnPlaneClamp;
- public Vector3 MinPos;
- public Vector3 MinClamp;
-
- public Vector3 MaxOnPlane;
- public float MaxDistance;
- public float MaxDistanceClamp;
- public Vector3 MaxOnPlaneClamp;
- public Vector3 MaxPos;
- public Vector3 MaxClamp;
-
- ///
- /// min and max is tail and head.
- ///
- public bool Reverse;
-
- public bool Intersected;
-
- public CapsuleInfo(in Triangle t, VRM10SpringBoneCollider collider)
- {
- Collider = collider;
- Triangle = t;
- var headDistance = t.Plane.GetDistanceToPoint(collider.HeadWorldPosition);
- var tailDistance = t.Plane.GetDistanceToPoint(collider.TailWorldPosition);
- if (headDistance <= tailDistance)
- {
- Reverse = false;
- MinDistance = headDistance;
- MaxDistance = tailDistance;
- MinOnPlane = t.Plane.ClosestPointOnPlane(collider.HeadWorldPosition);
- MaxOnPlane = t.Plane.ClosestPointOnPlane(collider.TailWorldPosition);
- MinClamp = collider.HeadWorldPosition;
- MaxClamp = collider.TailWorldPosition;
- MinPos = collider.HeadWorldPosition;
- MaxPos = collider.TailWorldPosition;
- }
- else
- {
- Reverse = true;
- MaxDistance = headDistance;
- MinDistance = tailDistance;
- MaxOnPlane = t.Plane.ClosestPointOnPlane(collider.HeadWorldPosition);
- MinOnPlane = t.Plane.ClosestPointOnPlane(collider.TailWorldPosition);
- MaxClamp = collider.HeadWorldPosition;
- MinClamp = collider.TailWorldPosition;
- MaxPos = collider.HeadWorldPosition;
- MinPos = collider.TailWorldPosition;
- }
-
- // Intersect
- Intersected = true;
- MinDistanceClmap = MinDistance;
- MinOnPlaneClamp = MinOnPlane;
- MaxDistanceClamp = MaxDistance;
- MaxOnPlaneClamp = MaxOnPlane;
- if (MinDistance < -Collider.Radius)
- {
- if (MaxDistance < -Collider.Radius)
- {
- Intersected = false;
- }
- else
- {
- // clamp Min
- MinDistanceClmap = -Collider.Radius;
- }
- }
- else if (MaxDistance > Collider.Radius)
- {
- if (MinDistance > Collider.Radius)
- {
- Intersected = false;
- }
- else
- {
- // clamp Max
- MaxDistanceClamp = Collider.Radius;
- }
- }
-
- //
- MaxOnPlaneClamp = Vector3.Lerp(MinOnPlane, MaxOnPlane, (MaxDistanceClamp - MinDistance) / (MaxDistance - MinDistance));
- MinOnPlaneClamp = Vector3.Lerp(MaxOnPlane, MinOnPlane, (MinDistanceClmap - MaxDistance) / (MinDistance - MaxDistance));
- MaxClamp = Vector3.Lerp(MinPos, MaxPos, (MaxDistanceClamp - MinDistance) / (MaxDistance - MinDistance));
- MinClamp = Vector3.Lerp(MaxPos, MinPos, (MinDistanceClmap - MaxDistance) / (MinDistance - MaxDistance));
- }
-
- public void DrawGizmo()
- {
- Gizmos.color = Color.blue;
- Gizmos.DrawLine(Reverse ? Collider.TailWorldPosition : Collider.HeadWorldPosition, MinOnPlane);
- Gizmos.DrawWireSphere(MinOnPlane, 0.01f);
-
- Gizmos.color = Color.blue;
- Gizmos.DrawLine(Reverse ? Collider.HeadWorldPosition : Collider.TailWorldPosition, MaxOnPlane);
- Gizmos.DrawWireSphere(MaxOnPlane, 0.01f);
-
- Gizmos.color = Color.magenta;
- Gizmos.DrawLine(MinOnPlaneClamp, MaxOnPlaneClamp);
-
- Gizmos.color = Color.green;
- Triangle.DrawGizmos();
- }
- }
-}
\ No newline at end of file
diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/CapsuleInfo.cs.meta b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/CapsuleInfo.cs.meta
deleted file mode 100644
index 811eac0f5..000000000
--- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/CapsuleInfo.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 7a797b9c09763964d84ef1497b260fb7
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/ClothRectCollision.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/ClothRectCollision.cs
index 32a2b644c..69611295d 100644
--- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/ClothRectCollision.cs
+++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/ClothRectCollision.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using UnityEngine;
using UniVRM10;
@@ -64,8 +65,9 @@ namespace SphereTriangle
{
foreach (var collider in g.Colliders)
{
- var p = t.Plane.ClosestPointOnPlane(collider.HeadWorldPosition);
- var dot = Vector3.Dot(t.Plane.normal, collider.HeadWorldPosition - p);
+ var headWorldPosition = collider.transform.TransformPoint(collider.Offset);
+ var p = t.Plane.ClosestPointOnPlane(headWorldPosition);
+ var dot = Vector3.Dot(t.Plane.normal, headWorldPosition - p);
_initialColliderNormalSide[collider] = dot;
}
}
@@ -112,13 +114,14 @@ namespace SphereTriangle
var collider = colliders[i];
// using (new ProfileSample("EaryOut"))
{
- if (!aabb.Intersects(collider.GetBounds()))
+ if (!aabb.Intersects(GetBounds(collider)))
{
continue;
}
- var p = _triangle0.Plane.ClosestPointOnPlane(collider.HeadWorldPosition);
- var dot = Vector3.Dot(_triangle0.Plane.normal, collider.HeadWorldPosition - p);
+ var headWorldPosition = collider.transform.TransformPoint(collider.Offset);
+ var p = _triangle0.Plane.ClosestPointOnPlane(headWorldPosition);
+ var dot = Vector3.Dot(_triangle0.Plane.normal, headWorldPosition - p);
if (_initialColliderNormalSide[collider] * dot < 0)
{
// 片側
@@ -144,6 +147,30 @@ namespace SphereTriangle
}
}
+ static Bounds GetBounds(VRM10SpringBoneCollider c)
+ {
+ var headWorldPosition = c.transform.TransformPoint(c.Offset);
+ switch (c.ColliderType)
+ {
+ case VRM10SpringBoneColliderTypes.Capsule:
+ {
+ var h = headWorldPosition;
+ var t = c.transform.TransformPoint(c.TailOrNormal);
+ var d = h - t;
+ var aabb = new Bounds((h + t) * 0.5f, new Vector3(Mathf.Abs(d.x), Mathf.Abs(d.y), Mathf.Abs(d.z)));
+ aabb.Expand(c.Radius * 2);
+ return aabb;
+ }
+
+ case VRM10SpringBoneColliderTypes.Sphere:
+ return new Bounds(headWorldPosition, new Vector3(c.Radius, c.Radius, c.Radius));
+
+ default:
+ throw new NotImplementedException();
+ }
+ }
+
+
///
/// 衝突して移動デルタを得る
///
@@ -153,10 +180,12 @@ namespace SphereTriangle
///
static bool TryCollide(VRM10SpringBoneCollider collider, in Triangle t, out LineSegment l)
{
+ var headWorldPosition = collider.transform.TransformPoint(collider.Offset);
if (collider.ColliderType == VRM10SpringBoneColliderTypes.Capsule)
{
// capsule
- var result = TriangleCapsuleCollisionSolver.Collide(t, new(collider.HeadWorldPosition, collider.TailWorldPosition), collider.Radius);
+ var tailWorldPosition = collider.transform.TransformPoint(collider.TailOrNormal);
+ var result = TriangleCapsuleCollisionSolver.Collide(t, new(headWorldPosition, tailWorldPosition), collider.Radius);
var type = result.TryGetClosest(out l);
return type.HasValue;
}
@@ -164,7 +193,7 @@ namespace SphereTriangle
{
// sphere
// using var profile = new ProfileSample("Sphere");
- return TryCollideSphere(t, collider.HeadWorldPosition, collider.Radius, out l);
+ return TryCollideSphere(t, headWorldPosition, collider.Radius, out l);
}
}
diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/LineDistanceGizmo.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/LineDistanceGizmo.cs
index 963e6f0b8..43fa595e8 100644
--- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/LineDistanceGizmo.cs
+++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/SphereTriangle/LineDistanceGizmo.cs
@@ -20,8 +20,8 @@ namespace SphereTriangle
{
if (LineA.ColliderType == VRM10SpringBoneColliderTypes.Capsule && LineB.ColliderType == VRM10SpringBoneColliderTypes.Capsule)
{
- var a = new LineSegment(LineA.HeadWorldPosition, LineA.TailWorldPosition);
- var b = new LineSegment(LineB.HeadWorldPosition, LineB.TailWorldPosition);
+ var a = new LineSegment(LineA.transform.TransformPoint(LineA.Offset), LineA.transform.TransformPoint(LineA.TailOrNormal));
+ var b = new LineSegment(LineB.transform.TransformPoint(LineB.Offset), LineB.transform.TransformPoint(LineB.TailOrNormal));
var (s, t) = LineSegment.CalcClosest(a, b);
var a_s = a.GetPoint(s);
var b_t = b.GetPoint(t);
@@ -31,11 +31,11 @@ namespace SphereTriangle
Gizmos.color = Color.gray;
if (s < 0)
{
- Gizmos.DrawLine(LineA.HeadWorldPosition, a_s);
+ Gizmos.DrawLine(LineA.transform.TransformPoint(LineA.Offset), a_s);
}
else if (s > 1)
{
- Gizmos.DrawLine(LineA.TailWorldPosition, a_s);
+ Gizmos.DrawLine(LineA.transform.TransformPoint(LineA.TailOrNormal), a_s);
}
else
{
@@ -43,11 +43,11 @@ namespace SphereTriangle
}
if (t < 0)
{
- Gizmos.DrawLine(LineB.HeadWorldPosition, b_t);
+ Gizmos.DrawLine(LineB.transform.TransformPoint(LineB.Offset), b_t);
}
else if (t > 1)
{
- Gizmos.DrawLine(LineB.HeadWorldPosition, b_t);
+ Gizmos.DrawLine(LineB.transform.TransformPoint(LineB.TailOrNormal), b_t);
}
else
{
diff --git a/Assets/VRM10_Samples/VRM10Viewer/FaceCameraTarget.asset b/Assets/VRM10_Samples/VRM10Viewer/FaceCameraTarget.asset
index dc5b55f8e..c1311d8e0 100644
--- a/Assets/VRM10_Samples/VRM10Viewer/FaceCameraTarget.asset
+++ b/Assets/VRM10_Samples/VRM10Viewer/FaceCameraTarget.asset
@@ -26,7 +26,6 @@ CustomRenderTexture:
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
- m_EnableRandomWrite: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1