Optimize Physics
This commit is contained in:
@@ -691,7 +691,7 @@ RectTransform:
|
|||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 260, y: 260}
|
m_SizeDelta: {x: 265, y: 265}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &5440685832306619784
|
--- !u!222 &5440685832306619784
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
|
|||||||
@@ -82,11 +82,13 @@ public class DynamicBone : MonoBehaviour
|
|||||||
[Tooltip("The force apply to bones.")]
|
[Tooltip("The force apply to bones.")]
|
||||||
#endif
|
#endif
|
||||||
public Vector3 m_Force = Vector3.zero;
|
public Vector3 m_Force = Vector3.zero;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if UNITY_5_3_OR_NEWER
|
#if UNITY_5_3_OR_NEWER
|
||||||
[Tooltip("Bones exclude from physics simulation.")]
|
[Tooltip("The limit angle to bones.")]
|
||||||
|
#endif
|
||||||
|
public Vector3 m_LimitAngel_Min = Vector3.zero;
|
||||||
|
public Vector3 m_LimitAngel_Max = Vector3.zero;
|
||||||
|
#if UNITY_5_3_OR_NEWER
|
||||||
|
[Tooltip("Bones exclude from physics simulation.")]
|
||||||
#endif
|
#endif
|
||||||
public List<Transform> m_Exclusions = null;
|
public List<Transform> m_Exclusions = null;
|
||||||
|
|
||||||
@@ -131,6 +133,9 @@ public class DynamicBone : MonoBehaviour
|
|||||||
public float m_BoneLength = 0;
|
public float m_BoneLength = 0;
|
||||||
public bool m_isCollide = false;
|
public bool m_isCollide = false;
|
||||||
|
|
||||||
|
|
||||||
|
public Vector3 m_LimitAngel_Min = Vector3.zero;
|
||||||
|
public Vector3 m_LimitAngel_Max = Vector3.zero;
|
||||||
public Vector3 m_Position = Vector3.zero;
|
public Vector3 m_Position = Vector3.zero;
|
||||||
public Vector3 m_PrevPosition = Vector3.zero;
|
public Vector3 m_PrevPosition = Vector3.zero;
|
||||||
public Vector3 m_EndOffset = Vector3.zero;
|
public Vector3 m_EndOffset = Vector3.zero;
|
||||||
@@ -417,6 +422,8 @@ public class DynamicBone : MonoBehaviour
|
|||||||
p.m_Inert = m_Inert;
|
p.m_Inert = m_Inert;
|
||||||
p.m_Friction = m_Friction;
|
p.m_Friction = m_Friction;
|
||||||
p.m_Radius = m_Radius;
|
p.m_Radius = m_Radius;
|
||||||
|
p.m_LimitAngel_Min = m_LimitAngel_Min;
|
||||||
|
p.m_LimitAngel_Max = m_LimitAngel_Max;
|
||||||
|
|
||||||
if (m_BoneTotalLength > 0)
|
if (m_BoneTotalLength > 0)
|
||||||
{
|
{
|
||||||
@@ -529,7 +536,8 @@ public class DynamicBone : MonoBehaviour
|
|||||||
|
|
||||||
// keep shape
|
// keep shape
|
||||||
float stiffness = Mathf.Lerp(1.0f, p.m_Stiffness, m_Weight);
|
float stiffness = Mathf.Lerp(1.0f, p.m_Stiffness, m_Weight);
|
||||||
if (stiffness > 0 || p.m_Elasticity > 0)
|
float elasticity = p.m_Elasticity;
|
||||||
|
if (stiffness > 0 || elasticity > 0)
|
||||||
{
|
{
|
||||||
Matrix4x4 m0 = p0.m_Transform.localToWorldMatrix;
|
Matrix4x4 m0 = p0.m_Transform.localToWorldMatrix;
|
||||||
m0.SetColumn(3, p0.m_Position);
|
m0.SetColumn(3, p0.m_Position);
|
||||||
@@ -540,7 +548,7 @@ public class DynamicBone : MonoBehaviour
|
|||||||
restPos = m0.MultiplyPoint3x4(p.m_EndOffset);
|
restPos = m0.MultiplyPoint3x4(p.m_EndOffset);
|
||||||
|
|
||||||
Vector3 d = restPos - p.m_Position;
|
Vector3 d = restPos - p.m_Position;
|
||||||
p.m_Position += d * (p.m_Elasticity * timeVar);
|
p.m_Position += d * (elasticity * timeVar);
|
||||||
|
|
||||||
if (stiffness > 0)
|
if (stiffness > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
//Load Physics
|
//Load Physics
|
||||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/clothes")))
|
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/clothes")))
|
||||||
{
|
{
|
||||||
if (asset1.Name.Contains("cloth04"))
|
if (asset1.Name.Contains("cloth00"))
|
||||||
RecursiveLoadAsset(asset1);
|
RecursiveLoadAsset(asset1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public class UmaViewerDownload : MonoBehaviour
|
|||||||
public static IEnumerator DownloadText(string url, System.Action<string> callback)
|
public static IEnumerator DownloadText(string url, System.Action<string> callback)
|
||||||
{
|
{
|
||||||
UnityWebRequest www = UnityWebRequest.Get(url);
|
UnityWebRequest www = UnityWebRequest.Get(url);
|
||||||
|
www.timeout = 3;
|
||||||
yield return www.SendWebRequest();
|
yield return www.SendWebRequest();
|
||||||
|
|
||||||
if (www.result != UnityWebRequest.Result.Success)
|
if (www.result != UnityWebRequest.Result.Success)
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ namespace Gallop
|
|||||||
DynamicBones.Clear();
|
DynamicBones.Clear();
|
||||||
List<Transform> gameObjects = new List<Transform>();
|
List<Transform> gameObjects = new List<Transform>();
|
||||||
gameObjects.AddRange(transform.parent.transform.parent.GetComponentsInChildren<Transform>());
|
gameObjects.AddRange(transform.parent.transform.parent.GetComponentsInChildren<Transform>());
|
||||||
|
|
||||||
|
List<DynamicBoneColliderBase> colliders = new List<DynamicBoneColliderBase>();
|
||||||
|
|
||||||
foreach (CySpringCollisionData collider in collisionParam)
|
foreach (CySpringCollisionData collider in collisionParam)
|
||||||
{
|
{
|
||||||
if (collider._isInner) continue;
|
if (collider._isInner) continue;
|
||||||
@@ -61,6 +64,7 @@ namespace Gallop
|
|||||||
dynamic.m_Height = (collider._offset - collider._offset2).magnitude + collider._radius;
|
dynamic.m_Height = (collider._offset - collider._offset2).magnitude + collider._radius;
|
||||||
dynamic.m_Radius = collider._radius;
|
dynamic.m_Radius = collider._radius;
|
||||||
dynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
dynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||||
|
colliders.Add(dynamic);
|
||||||
break;
|
break;
|
||||||
case CySpringCollisionData.CollisionType.Sphere:
|
case CySpringCollisionData.CollisionType.Sphere:
|
||||||
var Spheredynamic = child.AddComponent<DynamicBoneCollider>();
|
var Spheredynamic = child.AddComponent<DynamicBoneCollider>();
|
||||||
@@ -69,12 +73,14 @@ namespace Gallop
|
|||||||
Spheredynamic.m_Radius = collider._radius;
|
Spheredynamic.m_Radius = collider._radius;
|
||||||
Spheredynamic.m_Height = collider._distance;
|
Spheredynamic.m_Height = collider._distance;
|
||||||
Spheredynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
Spheredynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||||
|
colliders.Add(Spheredynamic);
|
||||||
break;
|
break;
|
||||||
case CySpringCollisionData.CollisionType.Plane:
|
case CySpringCollisionData.CollisionType.Plane:
|
||||||
var planedynamic = child.AddComponent<DynamicBonePlaneCollider>();
|
var planedynamic = child.AddComponent<DynamicBonePlaneCollider>();
|
||||||
planedynamic.ColliderName = collider._collisionName;
|
planedynamic.ColliderName = collider._collisionName;
|
||||||
child.transform.localPosition = collider._offset;
|
child.transform.localPosition = collider._offset;
|
||||||
planedynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
planedynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||||
|
colliders.Add(planedynamic);
|
||||||
break;
|
break;
|
||||||
case CySpringCollisionData.CollisionType.None:
|
case CySpringCollisionData.CollisionType.None:
|
||||||
break;
|
break;
|
||||||
@@ -82,8 +88,7 @@ namespace Gallop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gameObjects.Clear();
|
|
||||||
gameObjects.AddRange(transform.parent.transform.parent.GetComponentsInChildren<Transform>());
|
|
||||||
foreach(CySpringParamDataElement spring in springParam)
|
foreach(CySpringParamDataElement spring in springParam)
|
||||||
{
|
{
|
||||||
var bone = gameObjects.Find(a => { return a.name == spring._boneName; });
|
var bone = gameObjects.Find(a => { return a.name == spring._boneName; });
|
||||||
@@ -94,6 +99,8 @@ namespace Gallop
|
|||||||
dynamic.m_Root = bone;
|
dynamic.m_Root = bone;
|
||||||
dynamic.m_UpdateMode = DynamicBone.UpdateMode.Normal;
|
dynamic.m_UpdateMode = DynamicBone.UpdateMode.Normal;
|
||||||
dynamic.m_Gravity = new Vector3(0, Mathf.Clamp01(-30 / spring._gravity), 0);
|
dynamic.m_Gravity = new Vector3(0, Mathf.Clamp01(-30 / spring._gravity), 0);
|
||||||
|
dynamic.m_LimitAngel_Min = spring._limitAngleMin;
|
||||||
|
dynamic.m_LimitAngel_Max = spring._limitAngleMax;
|
||||||
if (isTail)
|
if (isTail)
|
||||||
{
|
{
|
||||||
dynamic.m_Damping = 0.1f;
|
dynamic.m_Damping = 0.1f;
|
||||||
@@ -108,13 +115,13 @@ namespace Gallop
|
|||||||
|
|
||||||
}
|
}
|
||||||
dynamic.m_Radius = spring._collisionRadius;
|
dynamic.m_Radius = spring._collisionRadius;
|
||||||
|
dynamic.m_Friction = 0.5f;
|
||||||
dynamic.SetupParticles();
|
dynamic.SetupParticles();
|
||||||
DynamicBones.Add(dynamic);
|
DynamicBones.Add(dynamic);
|
||||||
|
|
||||||
foreach (string collisionName in spring._collisionNameList)
|
foreach (string collisionName in spring._collisionNameList)
|
||||||
{
|
{
|
||||||
var tmp = gameObjects.Find(a => { return a.name == collisionName; });
|
var tmp = colliders.Find(a => { return a.gameObject.name == collisionName; });
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
dynamic.Particles[0].m_Colliders.Add(tmp.GetComponent<DynamicBoneColliderBase>());
|
dynamic.Particles[0].m_Colliders.Add(tmp.GetComponent<DynamicBoneColliderBase>());
|
||||||
@@ -137,10 +144,13 @@ namespace Gallop
|
|||||||
tempParticle.m_Stiffness = Mathf.Clamp01(45 / spring._stiffnessForce);
|
tempParticle.m_Stiffness = Mathf.Clamp01(45 / spring._stiffnessForce);
|
||||||
tempParticle.m_Elasticity = Mathf.Clamp01(45 / spring._dragForce);
|
tempParticle.m_Elasticity = Mathf.Clamp01(45 / spring._dragForce);
|
||||||
}
|
}
|
||||||
|
tempParticle.m_Friction = 0.5f;
|
||||||
tempParticle.m_Radius = Childcollision._collisionRadius;
|
tempParticle.m_Radius = Childcollision._collisionRadius;
|
||||||
|
tempParticle.m_LimitAngel_Min = Childcollision._limitAngleMin;
|
||||||
|
tempParticle.m_LimitAngel_Max = Childcollision._limitAngleMax;
|
||||||
foreach (string collisionName in Childcollision._collisionNameList)
|
foreach (string collisionName in Childcollision._collisionNameList)
|
||||||
{
|
{
|
||||||
var tmp = gameObjects.Find(a => { return a.name == collisionName; });
|
var tmp = colliders.Find(a => { return a.gameObject.name == collisionName; });
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
tempParticle.m_Colliders.Add(tmp.GetComponent<DynamicBoneColliderBase>());
|
tempParticle.m_Colliders.Add(tmp.GetComponent<DynamicBoneColliderBase>());
|
||||||
@@ -148,7 +158,6 @@ namespace Gallop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user