bugcfix
This commit is contained in:
@@ -18,7 +18,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
public List<Shader> ShaderList = new List<Shader>();
|
||||
public Material TransMaterialCharas;
|
||||
public Material TransMaterialProps;
|
||||
private UmaContainer CurrentContainer;
|
||||
public UmaContainer CurrentContainer;
|
||||
|
||||
public AnimatorOverrideController OverrideController;
|
||||
|
||||
@@ -631,8 +631,11 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
case "Gallop/3D/Chara/ToonHair/TSER":
|
||||
m.shader = Shader.Find("Nars/UmaMusume/Body");
|
||||
break;
|
||||
case "Gallop/3D/Chara/ToonHair/TSEREm":
|
||||
m.shader = Shader.Find("Nars/UmaMusume/Body");
|
||||
break;
|
||||
default:
|
||||
Debug.LogError(m.shader.name);
|
||||
Debug.Log(m.shader.name);
|
||||
// m.shader = Shader.Find("Nars/UmaMusume/Body");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -357,4 +357,16 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
|
||||
{
|
||||
LoadFacialPanels(target);
|
||||
}
|
||||
|
||||
public void SetDynamicBoneEnable(bool isOn)
|
||||
{
|
||||
if (Builder.CurrentContainer)
|
||||
{
|
||||
foreach(CySpringDataContainer cySpring in Builder.CurrentContainer.GetComponentsInChildren<CySpringDataContainer>())
|
||||
{
|
||||
cySpring.EnablePhysics(isOn);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,16 @@ namespace Gallop
|
||||
public float HipMoveInfluenceDistance;
|
||||
public float HipMoveInfluenceMaxDistance;
|
||||
|
||||
private void Start()
|
||||
public List<DynamicBone> DynamicBones = new List<DynamicBone>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
SetPhysics();
|
||||
InitializePhysics();
|
||||
}
|
||||
public void SetPhysics()
|
||||
public void InitializePhysics()
|
||||
{
|
||||
DynamicBones.Clear();
|
||||
List<Transform> gameObjects = new List<Transform>();
|
||||
Dictionary<string, DynamicBoneColliderBase> DynamicBoneColliders = new Dictionary<string, DynamicBoneColliderBase>();
|
||||
gameObjects.AddRange(transform.parent.transform.parent.GetComponentsInChildren<Transform>());
|
||||
foreach (CySpringCollisionData collider in collisionParam)
|
||||
{
|
||||
@@ -59,7 +61,6 @@ namespace Gallop
|
||||
dynamic.m_Height = (collider._offset - collider._offset2).magnitude + collider._radius;
|
||||
dynamic.m_Radius = collider._radius;
|
||||
dynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||
DynamicBoneColliders.Add(collider._collisionName, dynamic);
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.Sphere:
|
||||
var Spheredynamic = child.AddComponent<DynamicBoneCollider>();
|
||||
@@ -68,14 +69,12 @@ namespace Gallop
|
||||
Spheredynamic.m_Radius = collider._radius;
|
||||
Spheredynamic.m_Height = collider._distance;
|
||||
Spheredynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||
DynamicBoneColliders.Add(collider._collisionName, Spheredynamic);
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.Plane:
|
||||
var planedynamic = child.AddComponent<DynamicBonePlaneCollider>();
|
||||
planedynamic.ColliderName = collider._collisionName;
|
||||
child.transform.localPosition = collider._offset;
|
||||
planedynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||
DynamicBoneColliders.Add(collider._collisionName, planedynamic);
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.None:
|
||||
break;
|
||||
@@ -83,7 +82,8 @@ namespace Gallop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gameObjects.Clear();
|
||||
gameObjects.AddRange(transform.parent.transform.parent.GetComponentsInChildren<Transform>());
|
||||
foreach (CySpringParamDataElement spring in springParam)
|
||||
{
|
||||
var bone = gameObjects.Find(a => { return a.name == spring._boneName; });
|
||||
@@ -92,39 +92,52 @@ namespace Gallop
|
||||
var dynamic = gameObject.AddComponent<DynamicBone>();
|
||||
dynamic.m_Root = bone;
|
||||
dynamic.m_UpdateMode = DynamicBone.UpdateMode.Normal;
|
||||
dynamic.SetupParticles();
|
||||
dynamic.m_Gravity = new Vector3(0, -spring._gravity / 80000, 0);
|
||||
dynamic.m_Gravity = new Vector3(0, Mathf.Clamp01(-spring._gravity / 80000), 0);
|
||||
dynamic.m_Damping = 0.2f;
|
||||
dynamic.m_Stiffness = spring._stiffnessForce / 1000;
|
||||
dynamic.m_Elasticity = spring._dragForce / 4000;
|
||||
dynamic.m_Stiffness = Mathf.Clamp01(spring._stiffnessForce / 900);
|
||||
dynamic.m_Elasticity = Mathf.Clamp01(spring._dragForce / 4000);
|
||||
dynamic.m_Radius = spring._collisionRadius;
|
||||
dynamic.SetupParticles();
|
||||
DynamicBones.Add(dynamic);
|
||||
|
||||
foreach (string collisionName in spring._collisionNameList)
|
||||
{
|
||||
if (DynamicBoneColliders.TryGetValue(collisionName, out DynamicBoneColliderBase val))
|
||||
var tmp = gameObjects.Find(a => { return a.name == collisionName; });
|
||||
if (tmp)
|
||||
{
|
||||
dynamic.m_Particles[0].m_Colliders.Add(val);
|
||||
dynamic.Particles[0].m_Colliders.Add(tmp.GetComponent<DynamicBoneColliderBase>());
|
||||
}
|
||||
}
|
||||
foreach (CySpringParamDataChildElement Childcollision in spring._childElements)
|
||||
{
|
||||
var tempParticle = dynamic.m_Particles.Find(a => { return a.m_Transform.gameObject.name == Childcollision._boneName; });
|
||||
var tempParticle = dynamic.Particles.Find(a => { return a.m_Transform.gameObject.name == Childcollision._boneName; });
|
||||
if (tempParticle != null)
|
||||
{
|
||||
tempParticle.m_Damping = 0.2f;
|
||||
tempParticle.m_Stiffness = Childcollision._stiffnessForce / 1000;
|
||||
tempParticle.m_Elasticity = Childcollision._dragForce / 4000;
|
||||
tempParticle.m_Stiffness = Mathf.Clamp01(Childcollision._stiffnessForce / 900);
|
||||
tempParticle.m_Elasticity = Mathf.Clamp01(Childcollision._dragForce / 4000);
|
||||
tempParticle.m_Radius = Childcollision._collisionRadius;
|
||||
foreach (string collisionName in Childcollision._collisionNameList)
|
||||
{
|
||||
if (DynamicBoneColliders.TryGetValue(collisionName, out DynamicBoneColliderBase val))
|
||||
var tmp = gameObjects.Find(a => { return a.name == collisionName; });
|
||||
if (tmp)
|
||||
{
|
||||
tempParticle.m_Colliders.Add(val);
|
||||
tempParticle.m_Colliders.Add(tmp.GetComponent<DynamicBoneColliderBase>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void EnablePhysics(bool isOn)
|
||||
{
|
||||
foreach(DynamicBone dynamic in DynamicBones)
|
||||
{
|
||||
dynamic.enabled = isOn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class DynamicBone : MonoBehaviour
|
||||
public bool m_DistantDisable = false;
|
||||
public Transform m_ReferenceObject = null;
|
||||
public float m_DistanceToObject = 20;
|
||||
public List<Particle> m_Particles = new List<Particle>();
|
||||
public List<Particle> Particles = new List<Particle>();
|
||||
|
||||
Vector3 m_LocalGravity = Vector3.zero;
|
||||
Vector3 m_ObjectMove = Vector3.zero;
|
||||
@@ -117,7 +117,6 @@ public class DynamicBone : MonoBehaviour
|
||||
float m_Weight = 1.0f;
|
||||
bool m_DistantDisabled = false;
|
||||
|
||||
|
||||
public class Particle
|
||||
{
|
||||
public List<DynamicBoneColliderBase> m_Colliders = new List<DynamicBoneColliderBase>();
|
||||
@@ -237,12 +236,12 @@ public class DynamicBone : MonoBehaviour
|
||||
}
|
||||
|
||||
Gizmos.color = Color.white;
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
for (int i = 0; i < Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p = Particles[i];
|
||||
if (p.m_ParentIndex >= 0)
|
||||
{
|
||||
Particle p0 = m_Particles[p.m_ParentIndex];
|
||||
Particle p0 = Particles[p.m_ParentIndex];
|
||||
Gizmos.DrawLine(p.m_Position, p0.m_Position);
|
||||
}
|
||||
if (p.m_Radius > 0)
|
||||
@@ -329,7 +328,7 @@ public class DynamicBone : MonoBehaviour
|
||||
|
||||
public void SetupParticles()
|
||||
{
|
||||
m_Particles.Clear();
|
||||
Particles.Clear();
|
||||
if (m_Root == null)
|
||||
return;
|
||||
|
||||
@@ -355,7 +354,7 @@ public class DynamicBone : MonoBehaviour
|
||||
}
|
||||
else // end bone
|
||||
{
|
||||
Transform pb = m_Particles[parentIndex].m_Transform;
|
||||
Transform pb = Particles[parentIndex].m_Transform;
|
||||
if (m_EndLength > 0)
|
||||
{
|
||||
Transform ppb = pb.parent;
|
||||
@@ -373,13 +372,13 @@ public class DynamicBone : MonoBehaviour
|
||||
|
||||
if (parentIndex >= 0)
|
||||
{
|
||||
boneLength += (m_Particles[parentIndex].m_Transform.position - p.m_Position).magnitude;
|
||||
boneLength += (Particles[parentIndex].m_Transform.position - p.m_Position).magnitude;
|
||||
p.m_BoneLength = boneLength;
|
||||
m_BoneTotalLength = Mathf.Max(m_BoneTotalLength, boneLength);
|
||||
}
|
||||
|
||||
int index = m_Particles.Count;
|
||||
m_Particles.Add(p);
|
||||
int index = Particles.Count;
|
||||
Particles.Add(p);
|
||||
|
||||
if (b != null)
|
||||
{
|
||||
@@ -409,9 +408,9 @@ public class DynamicBone : MonoBehaviour
|
||||
|
||||
m_LocalGravity = m_Root.InverseTransformDirection(m_Gravity);
|
||||
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
for (int i = 0; i < Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p = Particles[i];
|
||||
p.m_Damping = m_Damping;
|
||||
p.m_Elasticity = m_Elasticity;
|
||||
p.m_Stiffness = m_Stiffness;
|
||||
@@ -447,9 +446,9 @@ public class DynamicBone : MonoBehaviour
|
||||
|
||||
void InitTransforms()
|
||||
{
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
for (int i = 0; i < Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p = Particles[i];
|
||||
if (p.m_Transform != null)
|
||||
{
|
||||
p.m_Transform.localPosition = p.m_InitLocalPosition;
|
||||
@@ -458,18 +457,18 @@ public class DynamicBone : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void ResetParticlesPosition()
|
||||
public void ResetParticlesPosition()
|
||||
{
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
for (int i = 0; i < Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p = Particles[i];
|
||||
if (p.m_Transform != null)
|
||||
{
|
||||
p.m_Position = p.m_PrevPosition = p.m_Transform.position;
|
||||
}
|
||||
else // end bone
|
||||
{
|
||||
Transform pb = m_Particles[p.m_ParentIndex].m_Transform;
|
||||
Transform pb = Particles[p.m_ParentIndex].m_Transform;
|
||||
p.m_Position = p.m_PrevPosition = pb.TransformPoint(p.m_EndOffset);
|
||||
}
|
||||
p.m_isCollide = false;
|
||||
@@ -486,9 +485,9 @@ public class DynamicBone : MonoBehaviour
|
||||
force -= pf; // remove projected gravity
|
||||
force = (force + m_Force) * (m_ObjectScale * timeVar);
|
||||
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
for (int i = 0; i < Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p = Particles[i];
|
||||
if (p.m_ParentIndex >= 0)
|
||||
{
|
||||
// verlet integration
|
||||
@@ -517,10 +516,10 @@ public class DynamicBone : MonoBehaviour
|
||||
{
|
||||
Plane movePlane = new Plane();
|
||||
|
||||
for (int i = 1; i < m_Particles.Count; ++i)
|
||||
for (int i = 1; i < Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p0 = m_Particles[p.m_ParentIndex];
|
||||
Particle p = Particles[i];
|
||||
Particle p0 = Particles[p.m_ParentIndex];
|
||||
|
||||
float restLen;
|
||||
if (p.m_Transform != null)
|
||||
@@ -594,15 +593,15 @@ public class DynamicBone : MonoBehaviour
|
||||
// only update stiffness and keep bone length
|
||||
void SkipUpdateParticles()
|
||||
{
|
||||
for (int i = 0; i < m_Particles.Count; ++i)
|
||||
for (int i = 0; i < Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p = Particles[i];
|
||||
if (p.m_ParentIndex >= 0)
|
||||
{
|
||||
p.m_PrevPosition += m_ObjectMove;
|
||||
p.m_Position += m_ObjectMove;
|
||||
|
||||
Particle p0 = m_Particles[p.m_ParentIndex];
|
||||
Particle p0 = Particles[p.m_ParentIndex];
|
||||
|
||||
float restLen;
|
||||
if (p.m_Transform != null)
|
||||
@@ -682,10 +681,10 @@ public class DynamicBone : MonoBehaviour
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 1; i < m_Particles.Count; ++i)
|
||||
for (int i = 1; i < Particles.Count; ++i)
|
||||
{
|
||||
Particle p = m_Particles[i];
|
||||
Particle p0 = m_Particles[p.m_ParentIndex];
|
||||
Particle p = Particles[i];
|
||||
Particle p0 = Particles[p.m_ParentIndex];
|
||||
|
||||
if (p0.m_Transform.childCount <= 1) // do not modify bone orientation if has more then one child
|
||||
{
|
||||
|
||||
@@ -129,9 +129,9 @@ namespace Gallop
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localRotation = Quaternion.Euler(trs.transform.localRotation.eulerAngles + (trs._rotation * morph.Weight));
|
||||
trs.transform.localPosition += trs._position * morph.Weight;
|
||||
trs.transform.localScale += trs._scale * morph.Weight;
|
||||
trs.transform.localRotation = Quaternion.Euler(trs.transform.localRotation.eulerAngles + (trs._rotation * morph.Weight));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -142,9 +142,10 @@ namespace Gallop
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -152,9 +153,10 @@ namespace Gallop
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -162,9 +164,10 @@ namespace Gallop
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -172,9 +175,10 @@ namespace Gallop
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -182,9 +186,10 @@ namespace Gallop
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
trs.transform.localRotation = Quaternion.Euler(trs._rotation);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user