update Eye fx (WIP)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Gallop;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
@@ -10,7 +11,6 @@ public class UmaContainer : MonoBehaviour
|
||||
public GameObject Body;
|
||||
public GameObject Tail;
|
||||
public GameObject Head;
|
||||
public GameObject PhysicsController;
|
||||
|
||||
public List<Texture2D> TailTextures = new List<Texture2D>();
|
||||
|
||||
@@ -61,8 +61,9 @@ public class UmaContainer : MonoBehaviour
|
||||
[Header("Physics")]
|
||||
public bool EnablePhysics = true;
|
||||
public List<CySpringDataContainer> cySpringDataContainers;
|
||||
|
||||
|
||||
public GameObject PhysicsContainer;
|
||||
public ClothController ClothController;
|
||||
public float BodyScale = 1;
|
||||
public void Initialize()
|
||||
{
|
||||
TrackTarget = Camera.main.gameObject;
|
||||
@@ -133,7 +134,8 @@ public class UmaContainer : MonoBehaviour
|
||||
|
||||
public void SetHeight(int scale)
|
||||
{
|
||||
transform.Find("Position").localScale *= (scale / 160f);//WIP
|
||||
BodyScale = (scale / 160f);
|
||||
transform.Find("Position").localScale *= BodyScale;//WIP
|
||||
}
|
||||
|
||||
public Transform[] MergeBone(SkinnedMeshRenderer from, List<Transform> targetBones)
|
||||
@@ -167,18 +169,41 @@ public class UmaContainer : MonoBehaviour
|
||||
|
||||
public void LoadPhysics()
|
||||
{
|
||||
cySpringDataContainers = new List<CySpringDataContainer>(PhysicsController.GetComponentsInChildren<CySpringDataContainer>());
|
||||
var bones = new List<Transform>(GetComponentsInChildren<Transform>());
|
||||
var colliders = new List<GameObject>();
|
||||
cySpringDataContainers = new List<CySpringDataContainer>(PhysicsContainer.GetComponentsInChildren<CySpringDataContainer>());
|
||||
ClothController = new ClothController(gameObject);
|
||||
return;
|
||||
foreach(var springData in cySpringDataContainers)
|
||||
{
|
||||
CySpringCollisionDataAsset cySpringCollisionDataAsset = new CySpringCollisionDataAsset();
|
||||
cySpringCollisionDataAsset.dataList = springData.collisionParam;
|
||||
CySpringParamDataAsset cySpringParamDataAsset = new CySpringParamDataAsset();
|
||||
cySpringParamDataAsset.elements = springData.springParam;
|
||||
if (cySpringCollisionDataAsset != null && cySpringParamDataAsset != null)
|
||||
{
|
||||
var category = Character3DBase.Parts.eCategory.Body;
|
||||
if (springData.gameObject.name.Contains("chr"))
|
||||
{
|
||||
category = Character3DBase.Parts.eCategory.Head;
|
||||
}
|
||||
var cloth = new ClothController.Cloth(category, cySpringCollisionDataAsset, cySpringParamDataAsset, category == Character3DBase.Parts.eCategory.Head ? "Head" : "Hip");
|
||||
cloth.Build(new List<string>());
|
||||
ClothController.AddCloth(cloth);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (CySpringDataContainer spring in cySpringDataContainers)
|
||||
{
|
||||
colliders.AddRange(spring.InitiallizeCollider(bones));
|
||||
}
|
||||
foreach (CySpringDataContainer spring in cySpringDataContainers)
|
||||
{
|
||||
spring.InitializePhysics(bones, colliders);
|
||||
}
|
||||
ClothController.CreateCollision(CySpringCollisionComponent.ePurpose.Generic, BodyScale, 1);
|
||||
ClothController.BindSpring();
|
||||
//var bones = new List<Transform>(GetComponentsInChildren<Transform>());
|
||||
//var colliders = new List<GameObject>();
|
||||
|
||||
//foreach (CySpringDataContainer spring in cySpringDataContainers)
|
||||
//{
|
||||
// colliders.AddRange(spring.InitiallizeCollider(bones));
|
||||
//}
|
||||
//foreach (CySpringDataContainer spring in cySpringDataContainers)
|
||||
//{
|
||||
// spring.InitializePhysics(bones, colliders);
|
||||
//}
|
||||
}
|
||||
|
||||
public void SetDynamicBoneEnable(bool isOn)
|
||||
@@ -235,6 +260,11 @@ public class UmaContainer : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
ClothController?.Update(0);
|
||||
}
|
||||
|
||||
public void SetNextAnimationCut(string cutName)
|
||||
{
|
||||
var asset = UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.Equals(cutName));
|
||||
|
||||
@@ -731,12 +731,12 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
if (bundle.name.Contains("cloth"))
|
||||
{
|
||||
if (!CurrentUMAContainer.PhysicsController)
|
||||
if (!CurrentUMAContainer.PhysicsContainer)
|
||||
{
|
||||
CurrentUMAContainer.PhysicsController = new GameObject("PhysicsController");
|
||||
CurrentUMAContainer.PhysicsController.transform.SetParent(CurrentUMAContainer.transform);
|
||||
CurrentUMAContainer.PhysicsContainer = new GameObject("PhysicsController");
|
||||
CurrentUMAContainer.PhysicsContainer.transform.SetParent(CurrentUMAContainer.transform);
|
||||
}
|
||||
Instantiate(go, CurrentUMAContainer.PhysicsController.transform);
|
||||
Instantiate(go, CurrentUMAContainer.PhysicsContainer.transform);
|
||||
}
|
||||
else if (bundle.name.Contains("/head/"))
|
||||
{
|
||||
|
||||
@@ -27,56 +27,56 @@ namespace Gallop
|
||||
|
||||
public List<DynamicBone> DynamicBones = new List<DynamicBone>();
|
||||
|
||||
public List<GameObject> InitiallizeCollider(List<Transform> bones)
|
||||
{
|
||||
var colliders = new List<GameObject>();
|
||||
foreach (CySpringCollisionData collider in collisionParam)
|
||||
{
|
||||
if (collider._isInner) continue;
|
||||
var bone = bones.Find(a => { return a.name == collider._targetObjectName; });
|
||||
if (bone)
|
||||
{
|
||||
//public List<GameObject> InitiallizeCollider(List<Transform> bones)
|
||||
//{
|
||||
// var colliders = new List<GameObject>();
|
||||
// foreach (CySpringCollisionData collider in collisionParam)
|
||||
// {
|
||||
// if (collider._isInner) continue;
|
||||
// var bone = bones.Find(a => { return a.name == collider._targetObjectName; });
|
||||
// if (bone)
|
||||
// {
|
||||
|
||||
var child = new GameObject(collider._collisionName);
|
||||
child.transform.SetParent(bone);
|
||||
child.transform.localPosition = Vector3.zero;
|
||||
child.transform.localRotation = Quaternion.identity;
|
||||
child.transform.localScale = Vector3.one;
|
||||
colliders.Add(child);
|
||||
// var child = new GameObject(collider._collisionName);
|
||||
// child.transform.SetParent(bone);
|
||||
// child.transform.localPosition = Vector3.zero;
|
||||
// child.transform.localRotation = Quaternion.identity;
|
||||
// child.transform.localScale = Vector3.one;
|
||||
// colliders.Add(child);
|
||||
|
||||
switch (collider._type)
|
||||
{
|
||||
case CySpringCollisionData.CollisionType.Capsule:
|
||||
var dynamic = child.AddComponent<DynamicBoneCollider>();
|
||||
dynamic.ColliderName = collider._collisionName;
|
||||
child.transform.localPosition = (collider._offset + collider._offset2) / 2;
|
||||
child.transform.LookAt(child.transform.TransformPoint(collider._offset2));
|
||||
dynamic.m_Direction = DynamicBoneColliderBase.Direction.Z;
|
||||
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;
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.Sphere:
|
||||
var Spheredynamic = child.AddComponent<DynamicBoneCollider>();
|
||||
Spheredynamic.ColliderName = collider._collisionName;
|
||||
child.transform.localPosition = collider._offset;
|
||||
Spheredynamic.m_Radius = collider._radius;
|
||||
Spheredynamic.m_Height = collider._distance;
|
||||
Spheredynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||
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;
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.None:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return colliders;
|
||||
}
|
||||
// switch (collider._type)
|
||||
// {
|
||||
// case CySpringCollisionData.CollisionType.Capsule:
|
||||
// var dynamic = child.AddComponent<DynamicBoneCollider>();
|
||||
// dynamic.ColliderName = collider._collisionName;
|
||||
// child.transform.localPosition = (collider._offset + collider._offset2) / 2;
|
||||
// child.transform.LookAt(child.transform.TransformPoint(collider._offset2));
|
||||
// dynamic.m_Direction = DynamicBoneColliderBase.Direction.Z;
|
||||
// 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;
|
||||
// break;
|
||||
// case CySpringCollisionData.CollisionType.Sphere:
|
||||
// var Spheredynamic = child.AddComponent<DynamicBoneCollider>();
|
||||
// Spheredynamic.ColliderName = collider._collisionName;
|
||||
// child.transform.localPosition = collider._offset;
|
||||
// Spheredynamic.m_Radius = collider._radius;
|
||||
// Spheredynamic.m_Height = collider._distance;
|
||||
// Spheredynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||
// 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;
|
||||
// break;
|
||||
// case CySpringCollisionData.CollisionType.None:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return colliders;
|
||||
//}
|
||||
|
||||
public void InitializePhysics(List<Transform> bones, List<GameObject> colliders)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7e326f6bb0b1b0499c1f2c389fd03a6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfd1b235ed88e1445a56e29b4f2a549c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0b9ccf38ac795d4783179e43b65d268
|
||||
folderAsset: yes
|
||||
timeCreated: 1534933119
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,549 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ClothController
|
||||
{
|
||||
public class Cloth
|
||||
{
|
||||
private Character3DBase.Parts.eCategory _category = Character3DBase.Parts.eCategory.MAX;
|
||||
|
||||
private CySpringCollisionDataAsset _colAsset;
|
||||
|
||||
private CySpringParamDataAsset _prmAsset;
|
||||
|
||||
private CySpringCollision _collision;
|
||||
|
||||
private CySpring _spring;
|
||||
|
||||
private string _oftenAccessedParent;
|
||||
|
||||
public Character3DBase.Parts.eCategory category => _category;
|
||||
|
||||
public CySpringCollisionDataAsset colAsset => _colAsset;
|
||||
|
||||
public CySpringParamDataAsset prmAsset => _prmAsset;
|
||||
|
||||
public CySpringCollision collision
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collision;
|
||||
}
|
||||
set
|
||||
{
|
||||
_collision = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpring spring
|
||||
{
|
||||
get
|
||||
{
|
||||
return _spring;
|
||||
}
|
||||
set
|
||||
{
|
||||
_spring = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string oftenAccessedParent => _oftenAccessedParent;
|
||||
|
||||
public Cloth(Character3DBase.Parts.eCategory category, CySpringCollisionDataAsset collisionDataAsset, CySpringParamDataAsset paramDataAsset, string accessedParent)
|
||||
{
|
||||
_category = category;
|
||||
_colAsset = collisionDataAsset;
|
||||
_prmAsset = paramDataAsset;
|
||||
_oftenAccessedParent = accessedParent;
|
||||
}
|
||||
|
||||
public void Build(List<string> lstPartsCode)
|
||||
{
|
||||
if (_colAsset != null)
|
||||
{
|
||||
_colAsset.Build(lstPartsCode);
|
||||
}
|
||||
if (_prmAsset != null)
|
||||
{
|
||||
_prmAsset.Build(lstPartsCode);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset(bool bForceReset)
|
||||
{
|
||||
if (_spring != null)
|
||||
{
|
||||
_spring.Reset(bForceReset);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveCySpringCollision()
|
||||
{
|
||||
if (_collision != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(_collision);
|
||||
_collision = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
if (_collision != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(_collision);
|
||||
_collision = null;
|
||||
}
|
||||
if (_spring != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(_spring);
|
||||
_spring = null;
|
||||
}
|
||||
_colAsset = null;
|
||||
_prmAsset = null;
|
||||
}
|
||||
}
|
||||
|
||||
public enum WindCalcMode
|
||||
{
|
||||
None,
|
||||
Sin,
|
||||
Wind
|
||||
}
|
||||
|
||||
public static readonly string UNION_COLLISION_NAME = "ColUnion";
|
||||
|
||||
public static readonly float UNION_COLLISION_RADIUS = 0.45f;
|
||||
|
||||
public static readonly string GROUND_COLLISION_NAME = "ColGround";
|
||||
|
||||
public static readonly float GROUND_SPHERE_RADIUS = 1000000f;
|
||||
|
||||
private bool _isReady;
|
||||
|
||||
private bool _isCreated;
|
||||
|
||||
private bool _isBinded;
|
||||
|
||||
private GameObject _targetObject;
|
||||
|
||||
private Transform _targetTransform;
|
||||
|
||||
private Vector3 _bakPosition = Vector3.zero;
|
||||
|
||||
private Quaternion _bakRotation = Quaternion.identity;
|
||||
|
||||
private Cloth _rootCloth;
|
||||
|
||||
private List<Cloth> _lstCloth = new List<Cloth>();
|
||||
|
||||
private ClothParameter _clothParameter = new ClothParameter();
|
||||
|
||||
private bool _useUnionCollision;
|
||||
|
||||
private CySpringCollisionComponent _unionCollision;
|
||||
|
||||
private CySpringCollisionComponent _groundCollision;
|
||||
|
||||
private WindCalcMode _windCalcMode;
|
||||
|
||||
private float _windTime;
|
||||
|
||||
private float _windLoopTime;
|
||||
|
||||
private Vector3 _windPower;
|
||||
|
||||
public bool isReady => _isReady;
|
||||
|
||||
public bool isCreated => _isCreated;
|
||||
|
||||
public bool isBinded => _isBinded;
|
||||
|
||||
public int clothCount => _lstCloth.Count;
|
||||
|
||||
public ClothParameter clothParameter => _clothParameter;
|
||||
|
||||
public bool useUnionCollision => _useUnionCollision;
|
||||
|
||||
public CySpringCollisionComponent unionCollision => _unionCollision;
|
||||
|
||||
public CySpringCollisionComponent groundCollision => _groundCollision;
|
||||
|
||||
public List<Cloth> clothList => _lstCloth;
|
||||
|
||||
private ClothController()
|
||||
{
|
||||
}
|
||||
|
||||
public ClothController(GameObject target)
|
||||
{
|
||||
_targetObject = target;
|
||||
_targetTransform = target.transform;
|
||||
_isReady = false;
|
||||
_isCreated = false;
|
||||
_isBinded = false;
|
||||
}
|
||||
|
||||
private void Destroy(UnityEngine.Object obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(obj);
|
||||
}
|
||||
_isReady = false;
|
||||
_isCreated = false;
|
||||
_isBinded = false;
|
||||
}
|
||||
|
||||
private HashSet<string> BuildUsableCollisionList()
|
||||
{
|
||||
HashSet<string> setUsableCollision = new HashSet<string>();
|
||||
Action<CySpringParamDataAsset> action = delegate (CySpringParamDataAsset prmAsset)
|
||||
{
|
||||
Action<List<string>> fnAddusableCollision = delegate (List<string> lstCollision)
|
||||
{
|
||||
for (int l = 0; l < lstCollision.Count; l++)
|
||||
{
|
||||
if (!setUsableCollision.Contains(lstCollision[l]))
|
||||
{
|
||||
setUsableCollision.Add(lstCollision[l]);
|
||||
}
|
||||
if (lstCollision[l] == UNION_COLLISION_NAME)
|
||||
{
|
||||
_useUnionCollision = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
Action<List<CySpringParamDataChildElement>> action2 = delegate (List<CySpringParamDataChildElement> lstChild)
|
||||
{
|
||||
for (int k = 0; k < lstChild.Count; k++)
|
||||
{
|
||||
CySpringParamDataChildElement cySpringParamDataChildElement = lstChild[k];
|
||||
fnAddusableCollision(cySpringParamDataChildElement._collisionNameList);
|
||||
}
|
||||
};
|
||||
for (int j = 0; j < prmAsset.mergeDataList.Count; j++)
|
||||
{
|
||||
CySpringParamDataElement cySpringParamDataElement = prmAsset.mergeDataList[j];
|
||||
fnAddusableCollision(cySpringParamDataElement._collisionNameList);
|
||||
action2(cySpringParamDataElement._childElements);
|
||||
}
|
||||
};
|
||||
_useUnionCollision = false;
|
||||
for (int i = 0; i < _lstCloth.Count; i++)
|
||||
{
|
||||
action(_lstCloth[i].prmAsset);
|
||||
}
|
||||
return setUsableCollision;
|
||||
}
|
||||
|
||||
public void AddCloth(Cloth cloth)
|
||||
{
|
||||
if (cloth != null)
|
||||
{
|
||||
_lstCloth.Add(cloth);
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateCollision(CySpringCollisionComponent.ePurpose purpose, float unionCollisionScale = 1f, float bodyCollisionScale = 1f)
|
||||
{
|
||||
if (_isReady || _isCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
HashSet<string> setUsableCollision = BuildUsableCollisionList();
|
||||
foreach (Cloth item in _lstCloth)
|
||||
{
|
||||
if (item.category == Character3DBase.Parts.eCategory.Body)
|
||||
{
|
||||
_rootCloth = item;
|
||||
}
|
||||
if (item.collision != null)
|
||||
{
|
||||
Destroy(item.collision);
|
||||
}
|
||||
item.collision = _targetObject.AddComponent<CySpringCollision>();
|
||||
if (item.category == Character3DBase.Parts.eCategory.Body)
|
||||
{
|
||||
item.collision.CollisionScale = bodyCollisionScale;
|
||||
}
|
||||
item.collision.Create(item.colAsset, setUsableCollision);
|
||||
}
|
||||
if (_rootCloth != null)
|
||||
{
|
||||
if ((purpose & CySpringCollisionComponent.ePurpose.Union) != 0)
|
||||
{
|
||||
_unionCollision = _rootCloth.collision.CreateCollision("Chest", UNION_COLLISION_NAME, UNION_COLLISION_RADIUS * unionCollisionScale);
|
||||
if (_unionCollision != null)
|
||||
{
|
||||
_unionCollision.purpose = CySpringCollisionComponent.ePurpose.Union;
|
||||
CySpring.AddUnionCollision(_unionCollision);
|
||||
}
|
||||
}
|
||||
if ((purpose & CySpringCollisionComponent.ePurpose.Ground) != 0 && setUsableCollision.Contains(GROUND_COLLISION_NAME))
|
||||
{
|
||||
_groundCollision = _rootCloth.collision.CreateCollision("Position", GROUND_COLLISION_NAME, GROUND_SPHERE_RADIUS);
|
||||
if (_groundCollision != null)
|
||||
{
|
||||
_groundCollision.purpose = CySpringCollisionComponent.ePurpose.Ground;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Cloth item2 in _lstCloth)
|
||||
{
|
||||
item2.RemoveCySpringCollision();
|
||||
}
|
||||
_isCreated = true;
|
||||
}
|
||||
|
||||
public void BindSpring()
|
||||
{
|
||||
if (_isReady || _isBinded || !_isCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int cntCloth = _lstCloth.Count;
|
||||
CySpring.BindContext context = default(CySpring.BindContext);
|
||||
int idx = 0;
|
||||
while (idx < cntCloth)
|
||||
{
|
||||
Cloth cloth = _lstCloth[idx];
|
||||
if (cloth.spring != null)
|
||||
{
|
||||
Destroy(cloth.spring);
|
||||
}
|
||||
cloth.spring = _targetObject.AddComponent<CySpring>();
|
||||
cloth.spring.Bind(cloth.prmAsset, _groundCollision, _unionCollision, _useUnionCollision, cloth.oftenAccessedParent, ref context);
|
||||
cloth.spring.GetContext(ref context);
|
||||
int num = idx + 1;
|
||||
idx = num;
|
||||
}
|
||||
bool flag = true;
|
||||
for (int i = 0; i < cntCloth; i++)
|
||||
{
|
||||
flag &= _lstCloth[i].spring != null;
|
||||
}
|
||||
_isReady = flag;
|
||||
_isBinded = _isReady;
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
foreach (Cloth item in _lstCloth)
|
||||
{
|
||||
item.Release();
|
||||
}
|
||||
_lstCloth.Clear();
|
||||
_rootCloth = null;
|
||||
_isReady = false;
|
||||
_isCreated = false;
|
||||
_isBinded = false;
|
||||
}
|
||||
|
||||
public CySpringCollision GetCollision(int idx)
|
||||
{
|
||||
if (0 > idx || idx >= _lstCloth.Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _lstCloth[idx].collision;
|
||||
}
|
||||
|
||||
public CySpring GetSpring(int idx)
|
||||
{
|
||||
if (0 > idx || idx >= _lstCloth.Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _lstCloth[idx].spring;
|
||||
}
|
||||
|
||||
private void UpdateWind(float deltaTime)
|
||||
{
|
||||
_windTime += deltaTime;
|
||||
_windTime %= _windLoopTime;
|
||||
switch (_windCalcMode)
|
||||
{
|
||||
case WindCalcMode.Sin:
|
||||
{
|
||||
Vector3 windPower2 = _windPower * Mathf.Sin((float)Math.PI * 2f * _windTime / _windLoopTime) * 0.001f;
|
||||
for (int k = 0; k < _lstCloth.Count; k++)
|
||||
{
|
||||
CySpringRootBone[] boneList2 = _lstCloth[k].spring.boneList;
|
||||
for (int l = 0; l < boneList2.Length; l++)
|
||||
{
|
||||
boneList2[l].UpdateWindPower(windPower2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WindCalcMode.Wind:
|
||||
{
|
||||
float num = (float)Math.PI * 2f * _windTime / _windLoopTime;
|
||||
for (int m = 0; m < _lstCloth.Count; m++)
|
||||
{
|
||||
CySpringRootBone[] boneList3 = _lstCloth[m].spring.boneList;
|
||||
for (int n = 0; n < boneList3.Length; n++)
|
||||
{
|
||||
float index = 0f;
|
||||
boneList3[n].GetWindGroupIndex(ref index);
|
||||
float num2 = Mathf.Sin(num + index) * 0.001f;
|
||||
boneList3[n].UpdateWindPower(_windPower * num2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WindCalcMode.None:
|
||||
{
|
||||
Vector3 windPower = _windPower * 0.001f;
|
||||
for (int i = 0; i < _lstCloth.Count; i++)
|
||||
{
|
||||
CySpringRootBone[] boneList = _lstCloth[i].spring.boneList;
|
||||
for (int j = 0; j < boneList.Length; j++)
|
||||
{
|
||||
boneList[j].UpdateWindPower(windPower);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Update(float externalTime, bool isGather = true)
|
||||
{
|
||||
int count = _lstCloth.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (_lstCloth[i].spring == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_windLoopTime > 0f)
|
||||
{
|
||||
UpdateWind(externalTime);
|
||||
}
|
||||
if (_unionCollision != null && isGather)
|
||||
{
|
||||
_unionCollision.UpdateUnionCollision();
|
||||
}
|
||||
_bakPosition = _targetTransform.position;
|
||||
_bakRotation = _targetTransform.rotation;
|
||||
_targetTransform.position = Vector3.zero;
|
||||
_targetTransform.rotation = Quaternion.identity;
|
||||
if (isGather)
|
||||
{
|
||||
float smoothDeltaTime = Time.smoothDeltaTime;
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
_lstCloth[j].spring.GatherSpring(smoothDeltaTime, ref _bakPosition, ref _bakRotation);
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < count; k++)
|
||||
{
|
||||
_lstCloth[k].spring.UpdateSpring(_clothParameter);
|
||||
}
|
||||
for (int l = 0; l < count; l++)
|
||||
{
|
||||
_lstCloth[l].spring.PostSpring();
|
||||
}
|
||||
_targetTransform.position = _bakPosition;
|
||||
_targetTransform.rotation = _bakRotation;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ForceUpdate(float fCollisionOffSec, float fCollisionOnSec)
|
||||
{
|
||||
int count = _lstCloth.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (_lstCloth[i].spring == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
float num = 0.0166666675f;
|
||||
int num2 = (int)(fCollisionOffSec / num);
|
||||
int num3 = (int)(fCollisionOnSec / num);
|
||||
Vector3 position = _targetTransform.position;
|
||||
Quaternion rotation = _targetTransform.rotation;
|
||||
_targetTransform.position = Vector3.zero;
|
||||
_targetTransform.rotation = Quaternion.identity;
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
_lstCloth[j].spring.CollisionSwitch = false;
|
||||
}
|
||||
for (int k = 0; k < count; k++)
|
||||
{
|
||||
for (int l = 0; l < num2; l++)
|
||||
{
|
||||
_lstCloth[k].spring.UpdateSpring(_clothParameter);
|
||||
}
|
||||
}
|
||||
for (int m = 0; m < count; m++)
|
||||
{
|
||||
_lstCloth[m].spring.CollisionSwitch = true;
|
||||
}
|
||||
for (int n = 0; n < count; n++)
|
||||
{
|
||||
for (int num4 = 0; num4 < num3; num4++)
|
||||
{
|
||||
_lstCloth[n].spring.UpdateSpring(_clothParameter);
|
||||
}
|
||||
}
|
||||
for (int num5 = 0; num5 < count; num5++)
|
||||
{
|
||||
_lstCloth[num5].spring.PostSpring();
|
||||
}
|
||||
_targetTransform.position = position;
|
||||
_targetTransform.rotation = rotation;
|
||||
}
|
||||
|
||||
public void ExcludeCapability(CySpring.eCapability caps)
|
||||
{
|
||||
_clothParameter.ExcludeCapability(caps);
|
||||
}
|
||||
|
||||
public void SetCapability(CySpring.eCapability caps, int groupId, bool bSwitch, ref Vector3 direction)
|
||||
{
|
||||
switch (groupId)
|
||||
{
|
||||
case 0:
|
||||
clothParameter.capability0 = (bSwitch ? (clothParameter.capability0 | caps) : (clothParameter.capability0 & ~caps));
|
||||
clothParameter.gravityDirection0 = direction;
|
||||
break;
|
||||
case 1:
|
||||
clothParameter.capability1 = (bSwitch ? (clothParameter.capability1 | caps) : (clothParameter.capability1 & ~caps));
|
||||
clothParameter.gravityDirection1 = direction;
|
||||
break;
|
||||
case 2:
|
||||
clothParameter.capability2 = (bSwitch ? (clothParameter.capability2 | caps) : (clothParameter.capability2 & ~caps));
|
||||
clothParameter.gravityDirection2 = direction;
|
||||
break;
|
||||
case 3:
|
||||
clothParameter.capability3 = (bSwitch ? (clothParameter.capability3 | caps) : (clothParameter.capability3 & ~caps));
|
||||
clothParameter.gravityDirection3 = direction;
|
||||
break;
|
||||
case 4:
|
||||
clothParameter.capability4 = (bSwitch ? (clothParameter.capability4 | caps) : (clothParameter.capability4 & ~caps));
|
||||
clothParameter.gravityDirection4 = direction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void EnableUnionCollision(bool bEnable)
|
||||
{
|
||||
if (_unionCollision != null)
|
||||
{
|
||||
_unionCollision.EnableUnionCollision(bEnable);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWind(WindCalcMode mode, Vector3 windPower, float loopTime)
|
||||
{
|
||||
_windCalcMode = mode;
|
||||
_windPower = windPower;
|
||||
_windLoopTime = loopTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13ca4a9f1b2eca44296a18f800438fba
|
||||
timeCreated: 1539978036
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,226 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ClothParameter
|
||||
{
|
||||
private NativeClothParameter[] _nativeClothParameter = new NativeClothParameter[1]
|
||||
{
|
||||
new NativeClothParameter
|
||||
{
|
||||
_stiffnessForceRate = 1f,
|
||||
_dragForceRate = 1f,
|
||||
_gravityRate = 1f,
|
||||
_collisionSwitch = true,
|
||||
_capability0 = CySpring.eCapability.None,
|
||||
_capability1 = CySpring.eCapability.None,
|
||||
_capability2 = CySpring.eCapability.None,
|
||||
_capability3 = CySpring.eCapability.None,
|
||||
_capability4 = CySpring.eCapability.None,
|
||||
_gravityDirection0 = Vector3.down,
|
||||
_gravityDirection1 = Vector3.down,
|
||||
_gravityDirection2 = Vector3.down,
|
||||
_gravityDirection3 = Vector3.down,
|
||||
_gravityDirection4 = Vector3.down,
|
||||
_forceScale = Vector3.one
|
||||
}
|
||||
};
|
||||
|
||||
public NativeClothParameter[] nativeClothParameter => _nativeClothParameter;
|
||||
|
||||
public float stiffnessForceRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._stiffnessForceRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._stiffnessForceRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float dragForceRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._dragForceRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._dragForceRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float gravityRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._gravityRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._gravityRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool collisionSwitch
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._collisionSwitch;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._collisionSwitch = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpring.eCapability capability0
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._capability0;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._capability0 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpring.eCapability capability1
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._capability1;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._capability1 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpring.eCapability capability2
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._capability2;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._capability2 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpring.eCapability capability3
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._capability3;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._capability3 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpring.eCapability capability4
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._capability4;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._capability4 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 gravityDirection0
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._gravityDirection0;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._gravityDirection0 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 gravityDirection1
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._gravityDirection1;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._gravityDirection1 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 gravityDirection2
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._gravityDirection2;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._gravityDirection2 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 gravityDirection3
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._gravityDirection3;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._gravityDirection3 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 gravityDirection4
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._gravityDirection4;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._gravityDirection4 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 forceScale
|
||||
{
|
||||
get
|
||||
{
|
||||
return _nativeClothParameter[0]._forceScale;
|
||||
}
|
||||
set
|
||||
{
|
||||
_nativeClothParameter[0]._forceScale = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetCapability()
|
||||
{
|
||||
capability0 = CySpring.eCapability.None;
|
||||
capability1 = CySpring.eCapability.None;
|
||||
capability2 = CySpring.eCapability.None;
|
||||
capability3 = CySpring.eCapability.None;
|
||||
capability4 = CySpring.eCapability.None;
|
||||
}
|
||||
|
||||
public void ExcludeCapability(CySpring.eCapability caps)
|
||||
{
|
||||
capability0 &= ~caps;
|
||||
capability1 &= ~caps;
|
||||
capability2 &= ~caps;
|
||||
capability3 &= ~caps;
|
||||
capability4 &= ~caps;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11d7967b797cf2b4e8360b069ecb9f01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,578 @@
|
||||
// CySpring
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
//using Stage;
|
||||
using UnityEngine;
|
||||
|
||||
public class CySpring : MonoBehaviour
|
||||
{
|
||||
public enum eCapability
|
||||
{
|
||||
None,
|
||||
GravityControl,
|
||||
WindForce
|
||||
}
|
||||
|
||||
public class CollisionParent
|
||||
{
|
||||
public Transform transform;
|
||||
}
|
||||
|
||||
public struct BindContext
|
||||
{
|
||||
public NativeClothCollision[] commonNativeCollisions;
|
||||
|
||||
public CollisionParent[] commonCollisionParentTable;
|
||||
|
||||
public CySpringCollisionComponent[] commonUnionCollisionList;
|
||||
|
||||
public Vector3[] commonCollisionParentWorldPosition;
|
||||
|
||||
public Quaternion[] commonCoollisionParentWorldRotation;
|
||||
}
|
||||
|
||||
private const float DEFAULT_SPECIFIC_RATE = 0.1f;
|
||||
|
||||
private const float HALF_FPS_RATE = 1.5f;
|
||||
|
||||
private static List<CySpringCollisionComponent> _lstUnionCollision = null;
|
||||
|
||||
private static CySpringCollisionComponent _groundCollision = null;
|
||||
|
||||
private static float _stiffnessForceRate = 1f;
|
||||
|
||||
private static float _dragForceRate = 1f;
|
||||
|
||||
private static float _gravityRate = 1f;
|
||||
|
||||
private bool _bCollisionSwitch = true;
|
||||
|
||||
[SerializeField]
|
||||
private CySpringParamDataAsset _springData;
|
||||
|
||||
private bool _bUseUnionCollision;
|
||||
|
||||
private CySpringCollisionComponent _unionCollision;
|
||||
|
||||
private CySpringCollisionComponent[] _unionCollisionList;
|
||||
|
||||
private CySpringCollisionComponent[] _collisionList;
|
||||
|
||||
public NativeClothCollision[] _nativeCollisions;
|
||||
|
||||
private CollisionParent[] _collisionParentTable;
|
||||
|
||||
private Vector3[] _collisionParentWorldPosition;
|
||||
|
||||
private Quaternion[] _collisionParentWorldRotation;
|
||||
|
||||
[NonSerialized]
|
||||
private float _sqartDeltaTime;
|
||||
|
||||
[SerializeField]
|
||||
private CySpringRootBone[] _boneList;
|
||||
|
||||
[NonSerialized]
|
||||
private Transform _cachedTransform;
|
||||
|
||||
private bool _isUseSpecificValue;
|
||||
|
||||
private float _specificStiffnessForceRate = 0.1f;
|
||||
|
||||
private float _specificDragForceRate = 0.1f;
|
||||
|
||||
private float _specificGravityRate = 0.1f;
|
||||
|
||||
private bool _needWorldRotationShare;
|
||||
|
||||
private Transform _oftenAccessedParent;
|
||||
|
||||
private static readonly string[] IgnoreTransformName = new string[8] { "Pole_Arm_L", "Pole_Arm_R", "Pole_Leg_L", "Pole_Leg_R", "Eff_Leg_L", "Eff_Leg_R", "Eff_Wrist_L", "Eff_Wrist_R" };
|
||||
|
||||
private static bool _unbinded = false;
|
||||
|
||||
public static float stiffnessForceRate
|
||||
{
|
||||
set
|
||||
{
|
||||
_stiffnessForceRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static float dragForceRate
|
||||
{
|
||||
set
|
||||
{
|
||||
_dragForceRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static float gravityRate
|
||||
{
|
||||
set
|
||||
{
|
||||
_gravityRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CollisionSwitch
|
||||
{
|
||||
get
|
||||
{
|
||||
return _bCollisionSwitch;
|
||||
}
|
||||
set
|
||||
{
|
||||
_bCollisionSwitch = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpringParamDataAsset springData
|
||||
{
|
||||
set
|
||||
{
|
||||
_springData = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpringCollisionComponent[] CollisionList => _collisionList;
|
||||
|
||||
public float sqartDeltaTime => _sqartDeltaTime;
|
||||
|
||||
public CySpringRootBone[] boneList => _boneList;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Create();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_cachedTransform = base.gameObject.transform;
|
||||
SetCollision();
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void SetSuppression(bool enable, float length)
|
||||
{
|
||||
CySpringRootBone[] array = _boneList;
|
||||
foreach (CySpringRootBone obj in array)
|
||||
{
|
||||
obj.IsSuppression = enable;
|
||||
obj.SuppressionLength = length * length;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetContext(ref BindContext context)
|
||||
{
|
||||
context.commonNativeCollisions = _nativeCollisions;
|
||||
context.commonCollisionParentTable = _collisionParentTable;
|
||||
context.commonUnionCollisionList = _unionCollisionList;
|
||||
context.commonCollisionParentWorldPosition = _collisionParentWorldPosition;
|
||||
context.commonCoollisionParentWorldRotation = _collisionParentWorldRotation;
|
||||
}
|
||||
|
||||
public void Bind(CySpringParamDataAsset springData, CySpringCollisionComponent groundCollision, CySpringCollisionComponent unionCollision, bool bUseUnionCollision, string oftenAccessedParent, ref BindContext context)
|
||||
{
|
||||
_springData = springData;
|
||||
_groundCollision = groundCollision;
|
||||
_unionCollision = unionCollision;
|
||||
_bUseUnionCollision = bUseUnionCollision;
|
||||
_nativeCollisions = context.commonNativeCollisions;
|
||||
_collisionParentTable = context.commonCollisionParentTable;
|
||||
_unionCollisionList = context.commonUnionCollisionList;
|
||||
_collisionParentWorldPosition = context.commonCollisionParentWorldPosition;
|
||||
_collisionParentWorldRotation = context.commonCoollisionParentWorldRotation;
|
||||
Create();
|
||||
SetCollision();
|
||||
Reset();
|
||||
CheckNeedWorldRotationShare(oftenAccessedParent);
|
||||
}
|
||||
|
||||
public void SetSpecificSpringRatio(float fTargetFPS, float fSpringFactor, float fGravityFactor)
|
||||
{
|
||||
float num = 1f / fTargetFPS;
|
||||
num = 1f / num;
|
||||
num = (int)(num + 0.5f);
|
||||
num = 1f / num;
|
||||
float num2 = 60f;
|
||||
float num3 = 30f;
|
||||
float f = num / (1f / num2);
|
||||
float num4 = 1f;
|
||||
if (fTargetFPS == num3)
|
||||
{
|
||||
num4 = 1.5f;
|
||||
}
|
||||
_isUseSpecificValue = true;
|
||||
_specificStiffnessForceRate = fSpringFactor * num4;
|
||||
_specificDragForceRate = 1f / _specificStiffnessForceRate;
|
||||
_specificGravityRate = Mathf.Pow(f, fGravityFactor);
|
||||
}
|
||||
|
||||
public void GatherSpring(float deltaTime, ref Vector3 bakPos, ref Quaternion bakRot)
|
||||
{
|
||||
if (_boneList == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_sqartDeltaTime = deltaTime;
|
||||
int num = 0;
|
||||
CollisionParent[] collisionParentTable = _collisionParentTable;
|
||||
foreach (CollisionParent collisionParent in collisionParentTable)
|
||||
{
|
||||
_collisionParentWorldPosition[num] = collisionParent.transform.position;
|
||||
_collisionParentWorldRotation[num] = collisionParent.transform.rotation;
|
||||
num++;
|
||||
}
|
||||
CySpringCollisionComponent[] unionCollisionList = _unionCollisionList;
|
||||
for (int i = 0; i < unionCollisionList.Length; i++)
|
||||
{
|
||||
unionCollisionList[i].UpdateNativeUnionCollision(ref bakPos, ref bakRot);
|
||||
}
|
||||
Quaternion oftenAccessedParentRot = Quaternion.identity;
|
||||
if (_needWorldRotationShare)
|
||||
{
|
||||
oftenAccessedParentRot = _oftenAccessedParent.rotation;
|
||||
}
|
||||
if (sqartDeltaTime == 0f)
|
||||
{
|
||||
CySpringRootBone[] array = _boneList;
|
||||
foreach (CySpringRootBone cySpringRootBone in array)
|
||||
{
|
||||
cySpringRootBone.DoGatherAllSpringReset(ref oftenAccessedParentRot);
|
||||
cySpringRootBone._natives[0]._isSkip = cySpringRootBone._isSkip;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CySpringRootBone[] array = _boneList;
|
||||
foreach (CySpringRootBone cySpringRootBone2 in array)
|
||||
{
|
||||
cySpringRootBone2.DoGatherAllSpring(ref oftenAccessedParentRot);
|
||||
cySpringRootBone2._natives[0]._isSkip = cySpringRootBone2._isSkip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSpring(ClothParameter clothParameter)
|
||||
{
|
||||
if (_boneList != null)
|
||||
{
|
||||
float specificStiffnessForceRate = _stiffnessForceRate;
|
||||
float specificDragForceRate = _dragForceRate;
|
||||
float specificGravityRate = _gravityRate;
|
||||
if (_isUseSpecificValue)
|
||||
{
|
||||
specificStiffnessForceRate = _specificStiffnessForceRate;
|
||||
specificDragForceRate = _specificDragForceRate;
|
||||
specificGravityRate = _specificGravityRate;
|
||||
}
|
||||
clothParameter.stiffnessForceRate = specificStiffnessForceRate;
|
||||
clothParameter.dragForceRate = specificDragForceRate;
|
||||
clothParameter.gravityRate = specificGravityRate;
|
||||
clothParameter.collisionSwitch = _bCollisionSwitch;
|
||||
NativeClothParameter[] nativeClothParameter = clothParameter.nativeClothParameter;
|
||||
CySpringRootBone[] array = _boneList;
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
CySpringNative.UpdateNativeCloth(array[i]._natives, _nativeCollisions, nativeClothParameter, _collisionParentWorldPosition, _collisionParentWorldRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PostSpring()
|
||||
{
|
||||
if (_boneList == null || sqartDeltaTime == 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CySpringRootBone[] array = boneList;
|
||||
foreach (CySpringRootBone cySpringRootBone in array)
|
||||
{
|
||||
if (!cySpringRootBone._isSkip)
|
||||
{
|
||||
cySpringRootBone.DoPostAllSpring();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
_sqartDeltaTime = 0f;
|
||||
List<CySpringCollisionComponent> list = new List<CySpringCollisionComponent>(GetComponentsInChildren<CySpringCollisionComponent>());
|
||||
if (_springData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_lstUnionCollision != null && _bUseUnionCollision)
|
||||
{
|
||||
for (int i = 0; i < _lstUnionCollision.Count; i++)
|
||||
{
|
||||
CySpringCollisionComponent cySpringCollisionComponent = _lstUnionCollision[i];
|
||||
if (!list.Contains(cySpringCollisionComponent) && cySpringCollisionComponent != _unionCollision)
|
||||
{
|
||||
list.Add(cySpringCollisionComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_unionCollision != null && list.Contains(_unionCollision))
|
||||
{
|
||||
list.Remove(_unionCollision);
|
||||
}
|
||||
if (_groundCollision != null && !list.Contains(_groundCollision))
|
||||
{
|
||||
list.Add(_groundCollision);
|
||||
}
|
||||
List<CySpringRootBone> list2 = new List<CySpringRootBone>();
|
||||
for (int j = 0; j < _springData.mergeDataList.Count; j++)
|
||||
{
|
||||
CySpringRootBone cySpringRootBone = new CySpringRootBone();
|
||||
cySpringRootBone.CreateRoot(_springData.mergeDataList[j], this, cySpringRootBone, null);
|
||||
if (cySpringRootBone.Exist)
|
||||
{
|
||||
list2.Add(cySpringRootBone);
|
||||
}
|
||||
}
|
||||
_boneList = list2.ToArray();
|
||||
_collisionList = list.ToArray();
|
||||
if (_nativeCollisions != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_nativeCollisions = new NativeClothCollision[_collisionList.Length];
|
||||
List<CollisionParent> list3 = new List<CollisionParent>(32);
|
||||
List<CySpringCollisionComponent> list4 = new List<CySpringCollisionComponent>(8);
|
||||
for (int k = 0; k < _collisionList.Length; k++)
|
||||
{
|
||||
CySpringCollisionComponent cySpringCollisionComponent2 = _collisionList[k];
|
||||
Transform parent = cySpringCollisionComponent2.transform.parent;
|
||||
int num = list3.FindIndex((CollisionParent x) => x.transform == parent);
|
||||
if (num < 0)
|
||||
{
|
||||
CollisionParent collisionParent = new CollisionParent();
|
||||
collisionParent.transform = parent;
|
||||
num = list3.Count;
|
||||
list3.Add(collisionParent);
|
||||
}
|
||||
if (cySpringCollisionComponent2.CollisionType == CySpringCollisionData.CollisionType.Sphere && cySpringCollisionComponent2.purpose == CySpringCollisionComponent.ePurpose.Union)
|
||||
{
|
||||
list4.Add(cySpringCollisionComponent2);
|
||||
}
|
||||
cySpringCollisionComponent2.SetNativeCollision(_nativeCollisions, k, num);
|
||||
}
|
||||
_collisionParentTable = list3.ToArray();
|
||||
_unionCollisionList = list4.ToArray();
|
||||
_collisionParentWorldPosition = new Vector3[list3.Count];
|
||||
_collisionParentWorldRotation = new Quaternion[list3.Count];
|
||||
}
|
||||
|
||||
private void SetCollision()
|
||||
{
|
||||
if (_boneList != null)
|
||||
{
|
||||
for (int i = 0; i < _boneList.Length; i++)
|
||||
{
|
||||
_boneList[i].SetCollision();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset(bool bForceReset = true)
|
||||
{
|
||||
if (_boneList != null && _boneList.Length != 0)
|
||||
{
|
||||
if (_cachedTransform == null)
|
||||
{
|
||||
_cachedTransform = base.gameObject.transform;
|
||||
}
|
||||
Vector3 position = _cachedTransform.transform.position;
|
||||
Quaternion rotation = _cachedTransform.transform.rotation;
|
||||
_cachedTransform.position = Vector3.zero;
|
||||
_cachedTransform.rotation = Quaternion.identity;
|
||||
for (int i = 0; i < _boneList.Length; i++)
|
||||
{
|
||||
_boneList[i].Reset(bForceReset);
|
||||
}
|
||||
_cachedTransform.position = position;
|
||||
_cachedTransform.rotation = rotation;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckNeedWorldRotationShare(string oftenAccessedParentName)
|
||||
{
|
||||
_needWorldRotationShare = false;
|
||||
Transform transform = GameObjectUtility.FindChildTransform(oftenAccessedParentName, base.transform);
|
||||
if (transform == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_oftenAccessedParent = transform;
|
||||
int num = _boneList.Length;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
if (_boneList[i].CheckHasOftenAccessedParent(oftenAccessedParentName))
|
||||
{
|
||||
_needWorldRotationShare = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindGameObject(GameObject rootObject, string objectName)
|
||||
{
|
||||
if (!objectName.Contains("/"))
|
||||
{
|
||||
return FindGameObjectLoop(rootObject, objectName);
|
||||
}
|
||||
string[] array = objectName.Split('/');
|
||||
if (array.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
GameObject gameObject = rootObject;
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
gameObject = FindGameObjectLoop(gameObject, array[i]);
|
||||
if (gameObject == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
private static GameObject FindGameObjectLoop(GameObject rootObject, string objectName)
|
||||
{
|
||||
if (rootObject == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (Transform item in rootObject.transform)
|
||||
{
|
||||
if (item.name.Contains(objectName) && Array.IndexOf(IgnoreTransformName, item.name) < 0)
|
||||
{
|
||||
return item.gameObject;
|
||||
}
|
||||
}
|
||||
foreach (Transform item2 in rootObject.transform)
|
||||
{
|
||||
GameObject gameObject = FindGameObjectLoop(item2.gameObject, objectName);
|
||||
if (gameObject != null)
|
||||
{
|
||||
return gameObject;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SetAttenuationFactor(float fTargetFPS, float fSpringFactor, float fGravityFactor)
|
||||
{
|
||||
float num = 1f / fTargetFPS;
|
||||
num = 1f / num;
|
||||
num = (int)(num + 0.5f);
|
||||
num = 1f / num;
|
||||
float f = num / 0.0166666675f;
|
||||
_stiffnessForceRate = Mathf.Pow(f, 1f / fSpringFactor);
|
||||
_dragForceRate = 1f / _stiffnessForceRate;
|
||||
_gravityRate = Mathf.Pow(f, fGravityFactor);
|
||||
stiffnessForceRate = _stiffnessForceRate;
|
||||
dragForceRate = _dragForceRate;
|
||||
gravityRate = _gravityRate;
|
||||
}
|
||||
|
||||
public static void ClearUnionCollision()
|
||||
{
|
||||
if (_lstUnionCollision != null)
|
||||
{
|
||||
_lstUnionCollision.Clear();
|
||||
}
|
||||
_lstUnionCollision = null;
|
||||
}
|
||||
|
||||
public static void AddUnionCollision(CySpringCollisionComponent comp)
|
||||
{
|
||||
if (comp != null)
|
||||
{
|
||||
if (_lstUnionCollision == null)
|
||||
{
|
||||
_lstUnionCollision = new List<CySpringCollisionComponent>();
|
||||
}
|
||||
if (_lstUnionCollision != null)
|
||||
{
|
||||
_lstUnionCollision.Add(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//private static void RequestUnionCollision(CySpringCollisionComponent comp, Action<CharacterObject> fn)
|
||||
//{
|
||||
// Director instance = Director.instance;
|
||||
// if (comp != null && instance != null)
|
||||
// {
|
||||
// List<CharacterObject> characterObjects = instance.characterObjects;
|
||||
// for (int i = 0; i < characterObjects.Count; i++)
|
||||
// {
|
||||
// fn(characterObjects[i]);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//public static void RemoveUnionCollision(CySpringCollisionComponent comp)
|
||||
//{
|
||||
// RequestUnionCollision(comp, delegate (CharacterObject obj)
|
||||
// {
|
||||
// obj.UnbindUnionCollision(comp);
|
||||
// });
|
||||
// if (_lstUnionCollision != null && _lstUnionCollision.Contains(comp))
|
||||
// {
|
||||
// _lstUnionCollision.Remove(comp);
|
||||
// }
|
||||
// _unbinded = true;
|
||||
//}
|
||||
|
||||
//public static void UpdateUnionCollision(CySpringCollisionComponent comp)
|
||||
//{
|
||||
// RequestUnionCollision(comp, delegate (CharacterObject obj)
|
||||
// {
|
||||
// obj.BindUnionCollision(comp);
|
||||
// });
|
||||
// _unbinded = false;
|
||||
//}
|
||||
|
||||
public void UnbindUnionCollision(CySpringCollisionComponent comp)
|
||||
{
|
||||
if (_collisionList == null || !(comp != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
for (int num = _collisionList.Length; i < num; i++)
|
||||
{
|
||||
if (_collisionList[i] == comp)
|
||||
{
|
||||
_collisionList[i] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BindUnionCollision(CySpringCollisionComponent comp)
|
||||
{
|
||||
if (_collisionList == null || !(comp != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
for (int num = _collisionList.Length; i < num; i++)
|
||||
{
|
||||
if (_collisionList[i] == null)
|
||||
{
|
||||
_collisionList[i] = comp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int j = 0;
|
||||
for (int num2 = _collisionList.Length; j < num2; j++)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e3dc5c6665128d41a5cea73c711768c
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,387 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CySpringBoneBase
|
||||
{
|
||||
protected string _boneName;
|
||||
|
||||
protected CySpring _root;
|
||||
|
||||
protected CySpringRootBone _rootBone;
|
||||
|
||||
protected CySpringBoneBase _parentBone;
|
||||
|
||||
protected GameObject _gameObject;
|
||||
|
||||
protected Transform _transform;
|
||||
|
||||
protected Transform _parentTransform;
|
||||
|
||||
protected bool _exist;
|
||||
|
||||
public int _index;
|
||||
|
||||
public CySpringParamDataChildElement _element;
|
||||
|
||||
private List<int> _collisionIndexList;
|
||||
|
||||
public string BoneName => _boneName;
|
||||
|
||||
public GameObject GameObject => _gameObject;
|
||||
|
||||
public float StiffnessForce => _rootBone._natives[_index]._stiffnessForce;
|
||||
|
||||
public float DragForce => _rootBone._natives[_index]._dragForce;
|
||||
|
||||
public Vector3 SpringForce => _rootBone._natives[_index]._springForce;
|
||||
|
||||
public float CollisionRadius => _rootBone._natives[_index]._collisionRadius;
|
||||
|
||||
public float Gravity => _rootBone._natives[_index]._gravity;
|
||||
|
||||
public CySpring.eCapability Capability => _rootBone._natives[_index]._capability;
|
||||
|
||||
public int CapsGroupIndex => _rootBone._natives[_index]._capsGroupIndex;
|
||||
|
||||
public float InitBoneDistance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rootBone._natives[_index]._initBoneDistance;
|
||||
}
|
||||
set
|
||||
{
|
||||
_rootBone._natives[_index]._initBoneDistance = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 BoneAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rootBone._natives[_index]._boneAxis;
|
||||
}
|
||||
set
|
||||
{
|
||||
_rootBone._natives[_index]._boneAxis = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Exist
|
||||
{
|
||||
get
|
||||
{
|
||||
return _exist;
|
||||
}
|
||||
set
|
||||
{
|
||||
_exist = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsWind
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_rootBone._natives[_index]._wind & 1) != 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
_rootBone._natives[_index]._wind |= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rootBone._natives[_index]._wind &= -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float WindGroupIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rootBone._natives[_index]._windGroupIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
_rootBone._natives[_index]._windGroupIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<int> CollisionIndexList => _collisionIndexList;
|
||||
|
||||
public CySpringBoneBase()
|
||||
{
|
||||
}
|
||||
|
||||
public CySpringBoneBase(string name)
|
||||
{
|
||||
_boneName = name;
|
||||
}
|
||||
|
||||
public void Create(CySpring root, CySpringRootBone rootBone, CySpringBoneBase parentBone)
|
||||
{
|
||||
_root = root;
|
||||
_rootBone = rootBone;
|
||||
_parentBone = parentBone;
|
||||
_exist = false;
|
||||
if (!(_root == null) && _rootBone != null)
|
||||
{
|
||||
if (_parentBone != null)
|
||||
{
|
||||
_gameObject = CySpring.FindGameObject(_parentBone.GameObject, _boneName);
|
||||
}
|
||||
else
|
||||
{
|
||||
_gameObject = CySpring.FindGameObject(_root.gameObject, _boneName);
|
||||
}
|
||||
if (_gameObject == null)
|
||||
{
|
||||
_exist = false;
|
||||
return;
|
||||
}
|
||||
_transform = _gameObject.transform;
|
||||
_parentTransform = _transform.parent;
|
||||
_exist = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateChild(CySpring root, CySpringRootBone rootBone, CySpringBoneBase parentBone)
|
||||
{
|
||||
Create(root, rootBone, parentBone);
|
||||
foreach (Transform item in _transform)
|
||||
{
|
||||
if (!(item == _transform) && !(item.GetComponent<CySpringCollisionComponent>() != null))
|
||||
{
|
||||
CySpringBoneBase cySpringBoneBase = new CySpringBoneBase(item.name);
|
||||
_rootBone.TmpChildBoneList.Add(cySpringBoneBase);
|
||||
cySpringBoneBase.CreateChild(_root, _rootBone, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Initialize(int idx)
|
||||
{
|
||||
_index = idx;
|
||||
_rootBone._natives[_index]._initLocalRotation = _transform.localRotation;
|
||||
_rootBone._natives[_index]._currentPosition = _transform.position;
|
||||
_rootBone._natives[_index]._prevPosition = _rootBone._natives[_index]._currentPosition;
|
||||
_rootBone._natives[_index]._existCollision = _rootBone.ApplyCollision;
|
||||
if (_parentBone != null)
|
||||
{
|
||||
_parentBone.InitBoneDistance = Vector3.Distance(_transform.position, _parentBone.GameObject.transform.position);
|
||||
if (_parentBone.InitBoneDistance == 0f)
|
||||
{
|
||||
_parentBone.Exist = false;
|
||||
_exist = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_parentBone.BoneAxis = (_gameObject.transform.position - _parentBone.GameObject.transform.position).normalized;
|
||||
}
|
||||
if (_transform.childCount == 0)
|
||||
{
|
||||
_rootBone._natives[_index]._boneAxis = _parentBone.BoneAxis;
|
||||
_rootBone._natives[_index]._initBoneDistance = _parentBone.InitBoneDistance;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_rootBone._natives[_index]._boneAxis = Vector3.down;
|
||||
_rootBone._natives[_index]._initBoneDistance = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateCollisionIndexList()
|
||||
{
|
||||
_collisionIndexList = new List<int>();
|
||||
_rootBone._natives[_index]._activeCollision = 0;
|
||||
}
|
||||
|
||||
protected void AddCollisionIndex(int i)
|
||||
{
|
||||
CollisionIndexList.Add(i);
|
||||
switch (_rootBone._natives[_index]._activeCollision)
|
||||
{
|
||||
case 0:
|
||||
_rootBone._natives[_index]._cIndex0 = (short)i;
|
||||
break;
|
||||
case 1:
|
||||
_rootBone._natives[_index]._cIndex1 = (short)i;
|
||||
break;
|
||||
case 2:
|
||||
_rootBone._natives[_index]._cIndex2 = (short)i;
|
||||
break;
|
||||
case 3:
|
||||
_rootBone._natives[_index]._cIndex3 = (short)i;
|
||||
break;
|
||||
case 4:
|
||||
_rootBone._natives[_index]._cIndex4 = (short)i;
|
||||
break;
|
||||
case 5:
|
||||
_rootBone._natives[_index]._cIndex5 = (short)i;
|
||||
break;
|
||||
case 6:
|
||||
_rootBone._natives[_index]._cIndex6 = (short)i;
|
||||
break;
|
||||
case 7:
|
||||
_rootBone._natives[_index]._cIndex7 = (short)i;
|
||||
break;
|
||||
case 8:
|
||||
_rootBone._natives[_index]._cIndex8 = (short)i;
|
||||
break;
|
||||
case 9:
|
||||
_rootBone._natives[_index]._cIndex9 = (short)i;
|
||||
break;
|
||||
case 10:
|
||||
_rootBone._natives[_index]._cIndex10 = (short)i;
|
||||
break;
|
||||
case 11:
|
||||
_rootBone._natives[_index]._cIndex11 = (short)i;
|
||||
break;
|
||||
case 12:
|
||||
_rootBone._natives[_index]._cIndex12 = (short)i;
|
||||
break;
|
||||
case 13:
|
||||
_rootBone._natives[_index]._cIndex13 = (short)i;
|
||||
break;
|
||||
case 14:
|
||||
_rootBone._natives[_index]._cIndex14 = (short)i;
|
||||
break;
|
||||
case 15:
|
||||
_rootBone._natives[_index]._cIndex15 = (short)i;
|
||||
break;
|
||||
case 16:
|
||||
_rootBone._natives[_index]._cIndex16 = (short)i;
|
||||
break;
|
||||
case 17:
|
||||
_rootBone._natives[_index]._cIndex17 = (short)i;
|
||||
break;
|
||||
case 18:
|
||||
_rootBone._natives[_index]._cIndex18 = (short)i;
|
||||
break;
|
||||
case 19:
|
||||
_rootBone._natives[_index]._cIndex19 = (short)i;
|
||||
break;
|
||||
}
|
||||
_rootBone._natives[_index]._activeCollision++;
|
||||
}
|
||||
|
||||
public void GatherSpring()
|
||||
{
|
||||
if (_root.sqartDeltaTime == 0f)
|
||||
{
|
||||
_transform.localRotation = _rootBone._natives[_index]._initLocalRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rootBone._natives[_index]._existCollision = _rootBone.ApplyCollision;
|
||||
}
|
||||
}
|
||||
|
||||
public void DoGatherSpring()
|
||||
{
|
||||
_rootBone._natives[_index]._existCollision = _rootBone.ApplyCollision;
|
||||
}
|
||||
|
||||
public void DoGatherSpringReset()
|
||||
{
|
||||
_transform.localRotation = _rootBone._natives[_index]._initLocalRotation;
|
||||
}
|
||||
|
||||
public void PostSpring()
|
||||
{
|
||||
if (_root.sqartDeltaTime != 0f)
|
||||
{
|
||||
_transform.rotation = _rootBone._natives[_index]._finalRotation;
|
||||
}
|
||||
}
|
||||
|
||||
public void DoPostSpring()
|
||||
{
|
||||
_transform.rotation = _rootBone._natives[_index]._finalRotation;
|
||||
}
|
||||
|
||||
public virtual bool Reset(bool bForceReset = true)
|
||||
{
|
||||
if (_transform == null || (_rootBone._natives[_index]._gravity != 0f && !bForceReset))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_transform.localRotation = _rootBone._natives[_index]._initLocalRotation;
|
||||
_rootBone._natives[_index]._oldPosition = _transform.position;
|
||||
_rootBone._natives[_index]._currentPosition = _rootBone._natives[_index]._diff * _rootBone._natives[_index]._initBoneDistance + _rootBone._natives[_index]._oldPosition;
|
||||
_rootBone._natives[_index]._oldRotation = _rootBone._natives[_index]._initLocalRotation * _parentTransform.rotation;
|
||||
_rootBone._natives[_index]._aimVector = _rootBone._natives[_index]._oldRotation * _rootBone._natives[_index]._boneAxis;
|
||||
_rootBone._natives[_index]._prevPosition = _rootBone._natives[_index]._currentPosition - _rootBone._natives[_index]._aimVector;
|
||||
_rootBone._natives[_index]._finalRotation = _transform.rotation;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ChangeValue()
|
||||
{
|
||||
_rootBone._natives[_index]._existCollision = _rootBone.ApplyCollision;
|
||||
CreateCollisionIndexList();
|
||||
if (_rootBone.ChildElements != null)
|
||||
{
|
||||
string boneName = ((_index == 0) ? _boneName : _rootBone.ChildBoneList[_index - 1].BoneName);
|
||||
CySpringParamDataChildElement cySpringParamDataChildElement = (_element = _rootBone.ChildElements.Find((CySpringParamDataChildElement child) => child._boneName.Equals(boneName)));
|
||||
if (cySpringParamDataChildElement != null)
|
||||
{
|
||||
_rootBone._natives[_index]._stiffnessForce = cySpringParamDataChildElement._stiffnessForce;
|
||||
_rootBone._natives[_index]._dragForce = cySpringParamDataChildElement._dragForce;
|
||||
_rootBone._natives[_index]._springForce = cySpringParamDataChildElement._springForce;
|
||||
_rootBone._natives[_index]._collisionRadius = cySpringParamDataChildElement._collisionRadius;
|
||||
_rootBone._natives[_index]._gravity = cySpringParamDataChildElement._gravity;
|
||||
if (cySpringParamDataChildElement._collisionNameList == null || cySpringParamDataChildElement._collisionNameList.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (string collisionName in cySpringParamDataChildElement._collisionNameList)
|
||||
{
|
||||
int i = 0;
|
||||
for (int num = _root.CollisionList.Length; i < num; i++)
|
||||
{
|
||||
CySpringCollisionComponent cySpringCollisionComponent = _root.CollisionList[i];
|
||||
if (!(cySpringCollisionComponent == null) && !(collisionName != cySpringCollisionComponent.name))
|
||||
{
|
||||
AddCollisionIndex((short)i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
_element = null;
|
||||
_rootBone._natives[_index]._stiffnessForce = _rootBone.StiffnessForce;
|
||||
_rootBone._natives[_index]._dragForce = _rootBone.DragForce;
|
||||
_rootBone._natives[_index]._springForce = _rootBone.SpringForce;
|
||||
_rootBone._natives[_index]._collisionRadius = _rootBone.CollisionRadius;
|
||||
_rootBone._natives[_index]._gravity = _rootBone.Gravity;
|
||||
if (_rootBone.CollisionIndexList != null)
|
||||
{
|
||||
for (int j = 0; j < _rootBone.CollisionIndexList.Count; j++)
|
||||
{
|
||||
AddCollisionIndex(_rootBone.CollisionIndexList[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ResetClothParameter()
|
||||
{
|
||||
if (_element == null)
|
||||
{
|
||||
_rootBone._natives[_index]._stiffnessForce = _rootBone.StiffnessForce;
|
||||
_rootBone._natives[_index]._dragForce = _rootBone.DragForce;
|
||||
_rootBone._natives[_index]._gravity = _rootBone.Gravity;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rootBone._natives[_index]._stiffnessForce = _element._stiffnessForce;
|
||||
_rootBone._natives[_index]._dragForce = _element._dragForce;
|
||||
_rootBone._natives[_index]._gravity = _element._gravity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52288e519468a4348829dd3d858d92f2
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CySpringCollision : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private CySpringCollisionDataAsset _collisionData;
|
||||
|
||||
private float _collisionScale = 1f;
|
||||
|
||||
public float CollisionScale
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collisionScale;
|
||||
}
|
||||
set
|
||||
{
|
||||
_collisionScale = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Create(CySpringCollisionDataAsset data, HashSet<string> setUsableCollision)
|
||||
{
|
||||
_collisionData = data;
|
||||
if (_collisionData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (CySpringCollisionData data2 in _collisionData.dataList)
|
||||
{
|
||||
if (setUsableCollision.Contains(data2.collisionName))
|
||||
{
|
||||
data2.Create(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Create(CySpringCollisionDataAsset data)
|
||||
{
|
||||
_collisionData = data;
|
||||
if (_collisionData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (CySpringCollisionData mergedData in _collisionData.mergedDataList)
|
||||
{
|
||||
mergedData.Create(this);
|
||||
}
|
||||
}
|
||||
|
||||
public CySpringCollisionComponent CreateCollision(string targetName, string collisionName, float radius)
|
||||
{
|
||||
return new CySpringCollisionData(collisionName, targetName, Vector3.zero, radius * CollisionScale).Create(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afc6a4ef6252e2a459183f023b76a243
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class CySpringCollisionComponent : MonoBehaviour
|
||||
{
|
||||
public enum ePurpose
|
||||
{
|
||||
None = 0,
|
||||
Generic = 1,
|
||||
Union = 2,
|
||||
Ground = 4
|
||||
}
|
||||
|
||||
[NonSerialized]
|
||||
public float _radius;
|
||||
|
||||
[SerializeField]
|
||||
private CySpringCollisionData.CollisionType _collisionType;
|
||||
|
||||
private Vector3 _offset = new Vector3(0f, 0f, 0f);
|
||||
|
||||
private Vector3 _offset2 = new Vector3(0f, 0f, 0f);
|
||||
|
||||
private Transform _cacheTransform;
|
||||
|
||||
private ePurpose _purpose = ePurpose.Generic;
|
||||
|
||||
private Vector3 _unionCollisionPosition = Vector3.zero;
|
||||
|
||||
private int _nativeIndex;
|
||||
|
||||
private NativeClothCollision[] _nativeClothCollision;
|
||||
|
||||
public float Radius
|
||||
{
|
||||
get
|
||||
{
|
||||
return _radius;
|
||||
}
|
||||
set
|
||||
{
|
||||
_radius = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpringCollisionData.CollisionType CollisionType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collisionType;
|
||||
}
|
||||
set
|
||||
{
|
||||
_collisionType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Offset
|
||||
{
|
||||
get
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
set
|
||||
{
|
||||
_offset = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Offset2
|
||||
{
|
||||
get
|
||||
{
|
||||
return _offset2;
|
||||
}
|
||||
set
|
||||
{
|
||||
_offset2 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Rotation
|
||||
{
|
||||
get
|
||||
{
|
||||
return _offset2;
|
||||
}
|
||||
set
|
||||
{
|
||||
_offset2 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Transform cacheTransform => _cacheTransform;
|
||||
|
||||
public Vector3 unionCollisionPosition => _unionCollisionPosition;
|
||||
|
||||
public ePurpose purpose
|
||||
{
|
||||
get
|
||||
{
|
||||
return _purpose;
|
||||
}
|
||||
set
|
||||
{
|
||||
_purpose = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_cacheTransform = GetComponent<Transform>();
|
||||
}
|
||||
|
||||
public void UpdateUnionCollision()
|
||||
{
|
||||
_unionCollisionPosition = _cacheTransform.position;
|
||||
}
|
||||
|
||||
public void EnableUnionCollision(bool bEnable)
|
||||
{
|
||||
_collisionType = ((!bEnable) ? CySpringCollisionData.CollisionType.None : CySpringCollisionData.CollisionType.Sphere);
|
||||
}
|
||||
|
||||
private void UpdateNativeParameter()
|
||||
{
|
||||
if (_nativeClothCollision == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (CollisionType)
|
||||
{
|
||||
case CySpringCollisionData.CollisionType.Sphere:
|
||||
switch (purpose)
|
||||
{
|
||||
case ePurpose.Ground:
|
||||
{
|
||||
Vector3 offset = Offset;
|
||||
offset.y -= _radius;
|
||||
_nativeClothCollision[_nativeIndex]._position = offset;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
_nativeClothCollision[_nativeIndex]._position = Offset;
|
||||
break;
|
||||
case ePurpose.Union:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.Capsule:
|
||||
if (_cacheTransform != null)
|
||||
{
|
||||
_nativeClothCollision[_nativeIndex]._position = Vector3.Scale(Offset, _cacheTransform.lossyScale);
|
||||
_nativeClothCollision[_nativeIndex]._position2 = Vector3.Scale(Offset2, _cacheTransform.lossyScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
_nativeClothCollision[_nativeIndex]._position = Vector3.Scale(Offset, base.transform.lossyScale);
|
||||
_nativeClothCollision[_nativeIndex]._position2 = Vector3.Scale(Offset2, base.transform.lossyScale);
|
||||
}
|
||||
break;
|
||||
case CySpringCollisionData.CollisionType.None:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateNativeUnionCollision(ref Vector3 rootPosition, ref Quaternion rootRotation)
|
||||
{
|
||||
if (CollisionType == CySpringCollisionData.CollisionType.Sphere && purpose == ePurpose.Union)
|
||||
{
|
||||
Vector3 vector = unionCollisionPosition - rootPosition;
|
||||
vector = Quaternion.Inverse(rootRotation) * vector;
|
||||
_nativeClothCollision[_nativeIndex]._position = vector;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNativeCollision(NativeClothCollision[] collision, int index, int parentIndex)
|
||||
{
|
||||
_nativeIndex = index;
|
||||
_nativeClothCollision = collision;
|
||||
_nativeClothCollision[index]._radius = Radius;
|
||||
_nativeClothCollision[index]._type = (int)CollisionType;
|
||||
_nativeClothCollision[index]._purpose = (int)purpose;
|
||||
_nativeClothCollision[index]._parentIndex = parentIndex;
|
||||
UpdateNativeParameter();
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4eeb268d14c0f145b33f7bebd4a513f
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class CySpringCollisionData
|
||||
{
|
||||
public enum CollisionType
|
||||
{
|
||||
Sphere,
|
||||
None,
|
||||
Capsule,
|
||||
Plane,
|
||||
}
|
||||
|
||||
private const string CollisionScaleTargetName = "S_Col";
|
||||
|
||||
[SerializeField]
|
||||
private string _collisionName;
|
||||
|
||||
[SerializeField]
|
||||
private string _targetObjectName;
|
||||
|
||||
[SerializeField]
|
||||
private Vector3 _offset;
|
||||
|
||||
[SerializeField]
|
||||
private Vector3 _offset2;
|
||||
|
||||
[SerializeField]
|
||||
private float _radius;
|
||||
|
||||
[SerializeField]
|
||||
private CollisionType _type;
|
||||
|
||||
private Transform _transform;
|
||||
|
||||
public bool _isOtherTarget;
|
||||
public float _distance;
|
||||
public Vector3 _normal;
|
||||
public bool _isInner;
|
||||
|
||||
public string collisionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collisionName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_collisionName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CySpringCollisionData()
|
||||
{
|
||||
}
|
||||
|
||||
public CySpringCollisionData(CySpringCollisionData refData)
|
||||
{
|
||||
_type = refData._type;
|
||||
_collisionName = refData._collisionName;
|
||||
_targetObjectName = refData._targetObjectName;
|
||||
_offset = refData._offset;
|
||||
_radius = refData._radius;
|
||||
}
|
||||
|
||||
public CySpringCollisionData(string collisionName, string targetObjectName, Vector3 offset, float radius)
|
||||
{
|
||||
_type = CollisionType.Sphere;
|
||||
_collisionName = collisionName;
|
||||
_targetObjectName = targetObjectName;
|
||||
_offset = offset;
|
||||
_radius = radius;
|
||||
}
|
||||
|
||||
public CySpringCollisionData(CollisionType type, string collisionName, string targetObjectName, Vector3 offset, Vector3 offset2, float radius)
|
||||
{
|
||||
_type = type;
|
||||
_collisionName = collisionName;
|
||||
_targetObjectName = targetObjectName;
|
||||
_offset = offset;
|
||||
_offset2 = offset2;
|
||||
_radius = radius;
|
||||
}
|
||||
|
||||
public CySpringCollisionComponent Create(CySpringCollision root)
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (_collisionName == "")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (_radius == 0f)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
GameObject gameObject = CySpring.FindGameObject(root.gameObject, _targetObjectName);
|
||||
if (gameObject == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
GameObject gameObject2 = new GameObject();
|
||||
_transform = gameObject2.transform;
|
||||
_transform.SetParent(gameObject.transform, worldPositionStays: false);
|
||||
float num = 1f;
|
||||
if (_collisionName.IndexOf("S_Col", StringComparison.Ordinal) == 0)
|
||||
{
|
||||
num = root.CollisionScale;
|
||||
}
|
||||
switch (_type)
|
||||
{
|
||||
case CollisionType.Sphere:
|
||||
_transform.position += _offset * num;
|
||||
break;
|
||||
}
|
||||
_transform.name = _collisionName;
|
||||
CySpringCollisionComponent cySpringCollisionComponent = gameObject2.AddComponent<CySpringCollisionComponent>();
|
||||
cySpringCollisionComponent.CollisionType = _type;
|
||||
cySpringCollisionComponent.Radius = _radius * num;
|
||||
cySpringCollisionComponent.Offset = _offset * num;
|
||||
cySpringCollisionComponent.Offset2 = _offset2 * num;
|
||||
return cySpringCollisionComponent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8adb6395b4ed9e4fb0e4ab25dc6b4e9
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
// CySpringCollisionDataAsset
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CySpringCollisionDataAsset : ScriptableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private List<CySpringCollisionData> _dataList;
|
||||
|
||||
[SerializeField]
|
||||
private List<CySpringPartsCollisionData> _partsDataList = new List<CySpringPartsCollisionData>();
|
||||
|
||||
[NonSerialized]
|
||||
private List<CySpringCollisionData> _mergedDataList = new List<CySpringCollisionData>();
|
||||
|
||||
public List<CySpringCollisionData> dataList
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dataList;
|
||||
}
|
||||
set
|
||||
{
|
||||
_dataList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<CySpringCollisionData> mergedDataList => _mergedDataList;
|
||||
|
||||
public void Build(List<string> lstPartsCode)
|
||||
{
|
||||
Dictionary<string, CySpringPartsCollisionData> dictionary = new Dictionary<string, CySpringPartsCollisionData>();
|
||||
foreach (CySpringPartsCollisionData partsData in _partsDataList)
|
||||
{
|
||||
if (!dictionary.ContainsKey(partsData.partsCode))
|
||||
{
|
||||
dictionary.Add(partsData.partsCode, partsData);
|
||||
}
|
||||
}
|
||||
_mergedDataList.Clear();
|
||||
_mergedDataList.AddRange(_dataList);
|
||||
if (lstPartsCode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (string item in lstPartsCode)
|
||||
{
|
||||
CySpringPartsCollisionData value = null;
|
||||
if (dictionary.TryGetValue(item, out value) && value.valid)
|
||||
{
|
||||
_mergedDataList.AddRange(value.dataList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb6ffe81e81ab0440af942441a44e1d7
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,213 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
public struct CySpringNative
|
||||
{
|
||||
private const string LibraryName = "CySpringPlugin";
|
||||
|
||||
public static bool isNative = true;
|
||||
|
||||
public NativeClothWorking _clothWorking;
|
||||
|
||||
[DllImport("CySpringPlugin")]
|
||||
private static extern void NativeClothUpdate(IntPtr cond, int nCond, IntPtr collisions, IntPtr clothParams, IntPtr parentWorldPosition, IntPtr parentWorldRotation);
|
||||
/*
|
||||
private unsafe static void UpdateNativeClothInternal(NativeClothWorking[] clothWorking, NativeClothCollision[] collisions, NativeClothParameter[] clothParam, Vector3[] parentWorldPosition, Quaternion[] parentWorldRotation)
|
||||
{
|
||||
int nCond = clothWorking.Length;
|
||||
fixed (NativeClothWorking* ptr = &clothWorking[0])
|
||||
{
|
||||
fixed (NativeClothCollision* ptr2 = collisions)
|
||||
{
|
||||
fixed (NativeClothParameter* ptr3 = &clothParam[0])
|
||||
{
|
||||
fixed (Vector3* ptr4 = parentWorldPosition)
|
||||
{
|
||||
fixed (Quaternion* ptr5 = parentWorldRotation)
|
||||
{
|
||||
NativeClothUpdate((IntPtr)ptr, nCond, (IntPtr)ptr2, (IntPtr)ptr3, (IntPtr)ptr4, (IntPtr)ptr5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
public static void UpdateNativeCloth(NativeClothWorking[] clothWorkings, NativeClothCollision[] collisions, NativeClothParameter[] clothParam, Vector3[] parentCollisionWorldPosition, Quaternion[] _collisionParentWorldRotation)
|
||||
{
|
||||
if (clothWorkings[0]._isSkip)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num = clothWorkings.Length;
|
||||
|
||||
/* Native(dll)による物理演算は無効化
|
||||
if (isNative)
|
||||
{
|
||||
UpdateNativeClothInternal(clothWorkings, collisions, clothParam, parentCollisionWorldPosition, _collisionParentWorldRotation);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
for (int i = 1; i < num; i++)
|
||||
{
|
||||
clothWorkings[i]._oldPosition = clothWorkings[i - 1]._currentPosition;
|
||||
clothWorkings[i]._oldRotation = clothWorkings[i]._initLocalRotation * clothWorkings[i - 1]._finalRotation;
|
||||
}
|
||||
for (int j = 0; j < num; j++)
|
||||
{
|
||||
UpdateNativeClothInternalMono(ref clothWorkings[j], collisions, ref clothParam[0], parentCollisionWorldPosition, _collisionParentWorldRotation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void UpdateNativeClothInternalMono(ref NativeClothWorking clothWorking, NativeClothCollision[] collisions, ref NativeClothParameter clothParam, Vector3[] parentWorldPosition, Quaternion[] parentWorldRotation)
|
||||
{
|
||||
clothWorking._diff = clothWorking._prevPosition - clothWorking._currentPosition;
|
||||
clothWorking._prevPosition = clothWorking._currentPosition;
|
||||
clothWorking._aimVector = clothWorking._oldRotation * clothWorking._boneAxis;
|
||||
clothWorking._force = clothWorking._aimVector * clothWorking._stiffnessForce * clothParam._stiffnessForceRate;
|
||||
clothWorking._force += clothWorking._diff * clothWorking._dragForce * clothParam._dragForceRate;
|
||||
clothWorking._force += clothWorking._springForce;
|
||||
if ((clothWorking._capability & CySpring.eCapability.GravityControl) != 0)
|
||||
{
|
||||
bool flag = false;
|
||||
Vector3 vector = Vector3.down;
|
||||
switch (clothWorking._capsGroupIndex)
|
||||
{
|
||||
case 0:
|
||||
flag = (clothParam._capability0 & CySpring.eCapability.GravityControl) != 0;
|
||||
vector = clothParam._gravityDirection0;
|
||||
break;
|
||||
case 1:
|
||||
flag = (clothParam._capability1 & CySpring.eCapability.GravityControl) != 0;
|
||||
vector = clothParam._gravityDirection1;
|
||||
break;
|
||||
case 2:
|
||||
flag = (clothParam._capability2 & CySpring.eCapability.GravityControl) != 0;
|
||||
vector = clothParam._gravityDirection2;
|
||||
break;
|
||||
case 3:
|
||||
flag = (clothParam._capability3 & CySpring.eCapability.GravityControl) != 0;
|
||||
vector = clothParam._gravityDirection3;
|
||||
break;
|
||||
case 4:
|
||||
flag = (clothParam._capability4 & CySpring.eCapability.GravityControl) != 0;
|
||||
vector = clothParam._gravityDirection4;
|
||||
break;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
float num = clothWorking._gravity * clothParam._gravityRate;
|
||||
vector = clothWorking._oldRotation * vector * num;
|
||||
clothWorking._force -= vector;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clothWorking._force.y -= clothWorking._gravity * clothParam._gravityRate;
|
||||
}
|
||||
if (((uint)clothWorking._wind & (true ? 1u : 0u)) != 0)
|
||||
{
|
||||
clothWorking._force = Vector3.Scale(clothWorking._force, clothParam._forceScale);
|
||||
clothWorking._force += clothWorking._windPower;
|
||||
}
|
||||
clothWorking._currentPosition = clothWorking._currentPosition - clothWorking._diff + clothWorking._force;
|
||||
clothWorking._diff = (clothWorking._currentPosition - clothWorking._oldPosition).normalized;
|
||||
clothWorking._currentPosition = clothWorking._diff * clothWorking._initBoneDistance + clothWorking._oldPosition;
|
||||
if (clothWorking._existCollision && clothWorking._activeCollision > 0 && clothParam._collisionSwitch)
|
||||
{
|
||||
int[] array = new int[20]
|
||||
{
|
||||
clothWorking._cIndex0, clothWorking._cIndex1, clothWorking._cIndex2, clothWorking._cIndex3, clothWorking._cIndex4, clothWorking._cIndex5, clothWorking._cIndex6, clothWorking._cIndex7, clothWorking._cIndex8, clothWorking._cIndex9,
|
||||
clothWorking._cIndex10, clothWorking._cIndex11, clothWorking._cIndex12, clothWorking._cIndex13, clothWorking._cIndex14, clothWorking._cIndex15, clothWorking._cIndex16, clothWorking._cIndex17, clothWorking._cIndex18, clothWorking._cIndex19
|
||||
};
|
||||
for (int i = 0; i < clothWorking._activeCollision; i++)
|
||||
{
|
||||
int num2 = array[i];
|
||||
NativeClothCollision nativeClothCollision = collisions[num2];
|
||||
int parentIndex = nativeClothCollision._parentIndex;
|
||||
Vector3 vector2;
|
||||
Vector3 vector3;
|
||||
switch (nativeClothCollision._type)
|
||||
{
|
||||
default:
|
||||
vector2 = Vector3.zero;
|
||||
vector3 = clothWorking._currentPosition;
|
||||
break;
|
||||
case 0:
|
||||
{
|
||||
Vector3 vector11;
|
||||
Vector3 vector4;
|
||||
if (nativeClothCollision._purpose == 2)
|
||||
{
|
||||
vector11 = nativeClothCollision._position;
|
||||
vector3 = clothWorking._currentPosition;
|
||||
vector4 = clothWorking._oldPosition;
|
||||
vector2 = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
vector2 = parentWorldPosition[parentIndex];
|
||||
vector3 = clothWorking._currentPosition - vector2;
|
||||
vector4 = clothWorking._oldPosition - vector2;
|
||||
vector11 = parentWorldRotation[parentIndex] * nativeClothCollision._position;
|
||||
}
|
||||
if (Vector3.Distance(vector3, vector11) <= clothWorking._collisionRadius + nativeClothCollision._radius)
|
||||
{
|
||||
Vector3 normalized3 = (vector3 - vector11).normalized;
|
||||
vector3 = vector11 + normalized3 * (clothWorking._collisionRadius + nativeClothCollision._radius);
|
||||
vector3 = (vector3 - vector4).normalized * clothWorking._initBoneDistance + vector4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
vector2 = parentWorldPosition[parentIndex];
|
||||
vector3 = clothWorking._currentPosition - vector2;
|
||||
Vector3 vector4 = clothWorking._oldPosition - vector2;
|
||||
Vector3 vector5 = parentWorldRotation[parentIndex] * nativeClothCollision._position;
|
||||
Vector3 vector6 = parentWorldRotation[parentIndex] * nativeClothCollision._position2;
|
||||
Vector3 vector7 = vector6 - vector5;
|
||||
float magnitude = vector7.magnitude;
|
||||
vector7 /= magnitude;
|
||||
Vector3 vector8 = vector3 - vector5;
|
||||
float num3 = Vector3.Dot(vector8, vector7);
|
||||
bool flag2 = false;
|
||||
if (0f <= num3 && num3 < magnitude)
|
||||
{
|
||||
Vector3 vector9 = vector7 * num3;
|
||||
Vector3 vector10 = vector8 - vector9;
|
||||
float magnitude2 = vector10.magnitude;
|
||||
if (magnitude2 < clothWorking._collisionRadius + nativeClothCollision._radius)
|
||||
{
|
||||
vector3 = vector5 + vector9 + vector10 * ((clothWorking._collisionRadius + nativeClothCollision._radius) / magnitude2);
|
||||
vector3 = (vector3 - vector4).normalized * clothWorking._initBoneDistance + vector4;
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
if (!flag2)
|
||||
{
|
||||
if (Vector3.Distance(vector3, vector5) <= clothWorking._collisionRadius + nativeClothCollision._radius)
|
||||
{
|
||||
Vector3 normalized = (vector3 - vector5).normalized;
|
||||
vector3 = vector5 + normalized * (clothWorking._collisionRadius + nativeClothCollision._radius);
|
||||
vector3 = (vector3 - vector4).normalized * clothWorking._initBoneDistance + vector4;
|
||||
}
|
||||
else if (Vector3.Distance(vector3, vector6) <= clothWorking._collisionRadius + nativeClothCollision._radius)
|
||||
{
|
||||
Vector3 normalized2 = (vector3 - vector6).normalized;
|
||||
vector3 = vector6 + normalized2 * (clothWorking._collisionRadius + nativeClothCollision._radius);
|
||||
vector3 = (vector3 - vector4).normalized * clothWorking._initBoneDistance + vector4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
clothWorking._currentPosition = vector3 + vector2;
|
||||
}
|
||||
}
|
||||
clothWorking._finalRotation = Quaternion.FromToRotation(clothWorking._aimVector, clothWorking._diff) * clothWorking._oldRotation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a68b14e3f18fc348a25777b6947480d
|
||||
timeCreated: 1534933219
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CySpringParamDataAsset : ScriptableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private List<CySpringParamDataElement> _elements;
|
||||
|
||||
[SerializeField]
|
||||
private List<CySpringPartsParamDataElement> _partsElements = new List<CySpringPartsParamDataElement>();
|
||||
|
||||
[NonSerialized]
|
||||
private List<CySpringParamDataElement> _mergedDataList = new List<CySpringParamDataElement>();
|
||||
|
||||
public List<CySpringParamDataElement> elements
|
||||
{
|
||||
get
|
||||
{
|
||||
return _elements;
|
||||
}
|
||||
set
|
||||
{
|
||||
_elements = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<CySpringParamDataElement> mergeDataList => _mergedDataList;
|
||||
|
||||
public void Build(List<string> lstPartsCode)
|
||||
{
|
||||
Dictionary<string, CySpringPartsParamDataElement> dictionary = new Dictionary<string, CySpringPartsParamDataElement>();
|
||||
foreach (CySpringPartsParamDataElement partsElement in _partsElements)
|
||||
{
|
||||
if (!dictionary.ContainsKey(partsElement.partsCode))
|
||||
{
|
||||
dictionary.Add(partsElement.partsCode, partsElement);
|
||||
}
|
||||
}
|
||||
_mergedDataList.Clear();
|
||||
_mergedDataList.AddRange(_elements);
|
||||
if (lstPartsCode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (string item in lstPartsCode)
|
||||
{
|
||||
CySpringPartsParamDataElement value = null;
|
||||
if (dictionary.TryGetValue(item, out value) && value.valid)
|
||||
{
|
||||
_mergedDataList.AddRange(value.elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1e00a451c86371438af181589f578b3
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class CySpringParamDataChildElement
|
||||
{
|
||||
[SerializeField]
|
||||
public string _boneName;
|
||||
|
||||
[SerializeField]
|
||||
public float _stiffnessForce = 0.0001f;
|
||||
|
||||
[SerializeField]
|
||||
public float _dragForce = 0.05f;
|
||||
|
||||
[SerializeField]
|
||||
public Vector3 _springForce = new Vector3(0f, 0f, 0f);
|
||||
|
||||
[SerializeField]
|
||||
public float _collisionRadius = 0.01f;
|
||||
|
||||
[SerializeField]
|
||||
public List<string> _collisionNameList = new List<string>();
|
||||
|
||||
[SerializeField]
|
||||
public float _gravity;
|
||||
|
||||
[SerializeField]
|
||||
public CySpring.eCapability _capability;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0f, 4f)]
|
||||
public int _capsGroupIndex;
|
||||
|
||||
public float _verticalWindRateSlow;
|
||||
public float _horizontalWindRateSlow;
|
||||
public float _verticalWindRateFast;
|
||||
public float _horizontalWindRateFast;
|
||||
public bool _isLimit;
|
||||
public Vector3 _limitAngleMin;
|
||||
public Vector3 _limitAngleMax;
|
||||
public float MoveSpringApplyRate;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47e7f41f75eab62468171e3df8977325
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class CySpringParamDataElement
|
||||
{
|
||||
[SerializeField]
|
||||
public string _boneName;
|
||||
|
||||
[SerializeField]
|
||||
public float _stiffnessForce = 0.0001f;
|
||||
|
||||
[SerializeField]
|
||||
public float _dragForce = 0.05f;
|
||||
|
||||
[SerializeField]
|
||||
public Vector3 _springForce = new Vector3(0f, 0f, 0f);
|
||||
|
||||
[SerializeField]
|
||||
public float _collisionRadius = 0.01f;
|
||||
|
||||
[SerializeField]
|
||||
public List<string> _collisionNameList = new List<string>();
|
||||
|
||||
[SerializeField]
|
||||
public List<CySpringParamDataChildElement> _childElements = new List<CySpringParamDataChildElement>();
|
||||
|
||||
[SerializeField]
|
||||
public float _gravity;
|
||||
|
||||
[SerializeField]
|
||||
public CySpring.eCapability _capability;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0f, 4f)]
|
||||
public int _capsGroupIndex;
|
||||
|
||||
public bool _isLimit;
|
||||
public Vector3 _limitAngleMin;
|
||||
public Vector3 _limitAngleMax;
|
||||
public float MoveSpringApplyRate;
|
||||
public bool _needSimulateEndBone;
|
||||
public float _verticalWindRateSlow;
|
||||
public float _horizontalWindRateSlow;
|
||||
public float _verticalWindRateFast;
|
||||
public float _horizontalWindRateFast;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 155f1045b454be546a9be77add067068
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class CySpringPartsCollisionData
|
||||
{
|
||||
[SerializeField]
|
||||
private string _partsCode = string.Empty;
|
||||
|
||||
[SerializeField]
|
||||
private List<CySpringCollisionData> _dataList;
|
||||
|
||||
public string partsCode => _partsCode;
|
||||
|
||||
public List<CySpringCollisionData> dataList
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dataList;
|
||||
}
|
||||
set
|
||||
{
|
||||
_dataList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool valid
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Character3DBase.Parts.IsValidPartsCode(_partsCode))
|
||||
{
|
||||
if (_dataList != null)
|
||||
{
|
||||
return _dataList.Count > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08bcd0f94a23d314e8b3600575b57e65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class CySpringPartsParamDataElement
|
||||
{
|
||||
[SerializeField]
|
||||
private string _partsCode = string.Empty;
|
||||
|
||||
[SerializeField]
|
||||
private List<CySpringParamDataElement> _elements;
|
||||
|
||||
public string partsCode => _partsCode;
|
||||
|
||||
public List<CySpringParamDataElement> elements
|
||||
{
|
||||
get
|
||||
{
|
||||
return _elements;
|
||||
}
|
||||
set
|
||||
{
|
||||
_elements = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool valid
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Character3DBase.Parts.IsValidPartsCode(_partsCode))
|
||||
{
|
||||
if (_elements != null)
|
||||
{
|
||||
return _elements.Count > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e325b7e40ac15f04da8aff7ec7f1ac54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,357 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CySpringRootBone : CySpringBoneBase
|
||||
{
|
||||
public struct OverrideParameter
|
||||
{
|
||||
public bool enableGravity;
|
||||
|
||||
public float gravity;
|
||||
|
||||
public bool enableStiffness;
|
||||
|
||||
public float stiffness;
|
||||
|
||||
public bool enableDragForce;
|
||||
|
||||
public float dragForce;
|
||||
}
|
||||
|
||||
public const float DefaultSuppressionLength = 1f;
|
||||
|
||||
public List<string> _collisionNameList;
|
||||
|
||||
private List<CySpringParamDataChildElement> _childElements;
|
||||
|
||||
private int _depth;
|
||||
|
||||
private List<CySpringBoneBase> _tmpChildBoneList;
|
||||
|
||||
private CySpringBoneBase[] _childBoneList;
|
||||
|
||||
private CySpringParamDataElement _rootElement;
|
||||
|
||||
private bool _isRootElement;
|
||||
|
||||
private bool _isSuppression;
|
||||
|
||||
private float _suppressionLength = 1f;
|
||||
|
||||
private bool _applyCollision = true;
|
||||
|
||||
public NativeClothWorking[] _natives;
|
||||
|
||||
protected bool _hasOftenAccessedParent;
|
||||
|
||||
public bool _isSkip;
|
||||
|
||||
public bool ApplyCollision => _applyCollision;
|
||||
|
||||
public List<CySpringParamDataChildElement> ChildElements => _childElements;
|
||||
|
||||
public CySpringBoneBase[] ChildBoneList => _childBoneList;
|
||||
|
||||
public bool IsSuppression
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isSuppression;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isSuppression = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float SuppressionLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return _suppressionLength;
|
||||
}
|
||||
set
|
||||
{
|
||||
_suppressionLength = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<CySpringBoneBase> TmpChildBoneList => _tmpChildBoneList;
|
||||
|
||||
public void CreateRoot(CySpringParamDataElement element, CySpring root, CySpringRootBone rootBone, CySpringBoneBase parentBone)
|
||||
{
|
||||
_boneName = element._boneName;
|
||||
_collisionNameList = element._collisionNameList;
|
||||
_childElements = element._childElements;
|
||||
_rootElement = element;
|
||||
_isRootElement = _rootElement != null;
|
||||
Transform transform = root.gameObject.transform;
|
||||
Vector3 position = transform.position;
|
||||
Quaternion rotation = transform.rotation;
|
||||
transform.position = Vector3.zero;
|
||||
transform.rotation = Quaternion.identity;
|
||||
Create(root, rootBone, parentBone);
|
||||
if (!_exist)
|
||||
{
|
||||
transform.position = position;
|
||||
transform.rotation = rotation;
|
||||
return;
|
||||
}
|
||||
_tmpChildBoneList = new List<CySpringBoneBase>();
|
||||
foreach (Transform item in _transform)
|
||||
{
|
||||
if (!(item == _transform) && !(item.GetComponent<CySpringCollisionComponent>() != null))
|
||||
{
|
||||
CySpringBoneBase cySpringBoneBase = new CySpringBoneBase(item.name);
|
||||
_tmpChildBoneList.Add(cySpringBoneBase);
|
||||
cySpringBoneBase.CreateChild(_root, _rootBone, this);
|
||||
}
|
||||
}
|
||||
_childBoneList = _tmpChildBoneList.ToArray();
|
||||
_tmpChildBoneList = null;
|
||||
_depth = _childBoneList.Length;
|
||||
_natives = new NativeClothWorking[_childBoneList.Length + 1];
|
||||
for (int i = 0; i < _natives.Length; i++)
|
||||
{
|
||||
_natives[i]._stiffnessForce = 0.0001f;
|
||||
_natives[i]._dragForce = 0.05f;
|
||||
_natives[i]._springForce = new Vector3(0f, 0f, 0f);
|
||||
_natives[i]._collisionRadius = 0.01f;
|
||||
_natives[i]._boneAxis = new Vector3(0f, 1f, 0f);
|
||||
_natives[i]._gravity = 0f;
|
||||
_natives[i]._wind = 0;
|
||||
_natives[i]._windGroupIndex = 0f;
|
||||
}
|
||||
Initialize(0);
|
||||
for (int j = 0; j < _childBoneList.Length; j++)
|
||||
{
|
||||
_childBoneList[j].Initialize(j + 1);
|
||||
}
|
||||
_natives[0]._stiffnessForce = element._stiffnessForce;
|
||||
_natives[0]._dragForce = element._dragForce;
|
||||
_natives[0]._springForce = element._springForce;
|
||||
_natives[0]._collisionRadius = element._collisionRadius;
|
||||
_natives[0]._gravity = element._gravity;
|
||||
_natives[0]._capability = element._capability;
|
||||
_natives[0]._capsGroupIndex = element._capsGroupIndex;
|
||||
transform.position = position;
|
||||
transform.rotation = rotation;
|
||||
}
|
||||
|
||||
public bool CheckHasOftenAccessedParent(string oftenAccessedParent)
|
||||
{
|
||||
_hasOftenAccessedParent = false;
|
||||
if (_parentTransform != null && _parentTransform.name.Equals(oftenAccessedParent))
|
||||
{
|
||||
_hasOftenAccessedParent = true;
|
||||
}
|
||||
return _hasOftenAccessedParent;
|
||||
}
|
||||
|
||||
private void UpdateCollisionIndexList()
|
||||
{
|
||||
if (_collisionNameList == null || _collisionNameList.Count == 0 || _root.CollisionList == null || _root.CollisionList.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CreateCollisionIndexList();
|
||||
foreach (string collisionName in _collisionNameList)
|
||||
{
|
||||
int i = 0;
|
||||
for (int num = _root.CollisionList.Length; i < num; i++)
|
||||
{
|
||||
CySpringCollisionComponent cySpringCollisionComponent = _root.CollisionList[i];
|
||||
if (!(cySpringCollisionComponent == null) && !(collisionName != cySpringCollisionComponent.name))
|
||||
{
|
||||
AddCollisionIndex(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCollision()
|
||||
{
|
||||
UpdateCollisionIndexList();
|
||||
ChangeRootValue();
|
||||
}
|
||||
|
||||
public void DoGatherAllSpring(ref Quaternion oftenAccessedParentRot)
|
||||
{
|
||||
if (_depth < 0)
|
||||
{
|
||||
_isSkip = true;
|
||||
return;
|
||||
}
|
||||
_isSkip = false;
|
||||
UpdateNativeOldTransform(ref oftenAccessedParentRot);
|
||||
DoGatherSpring();
|
||||
CySpringBoneBase[] childBoneList = _childBoneList;
|
||||
for (int i = 0; i < childBoneList.Length; i++)
|
||||
{
|
||||
childBoneList[i].DoGatherSpring();
|
||||
}
|
||||
}
|
||||
|
||||
public void DoGatherAllSpringReset(ref Quaternion oftenAccessedParentRot)
|
||||
{
|
||||
if (_depth < 0)
|
||||
{
|
||||
_isSkip = true;
|
||||
return;
|
||||
}
|
||||
_isSkip = false;
|
||||
UpdateNativeOldTransform(ref oftenAccessedParentRot);
|
||||
DoGatherSpringReset();
|
||||
CySpringBoneBase[] childBoneList = _childBoneList;
|
||||
for (int i = 0; i < childBoneList.Length; i++)
|
||||
{
|
||||
childBoneList[i].DoGatherSpringReset();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateNativeOldTransform(ref Quaternion oftenAccessedParentRot)
|
||||
{
|
||||
Vector3 position = _transform.position;
|
||||
if (_hasOftenAccessedParent)
|
||||
{
|
||||
_rootBone._natives[_index]._oldRotation = oftenAccessedParentRot * _rootBone._natives[_index]._initLocalRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rootBone._natives[_index]._oldRotation = _parentTransform.rotation * _rootBone._natives[_index]._initLocalRotation;
|
||||
}
|
||||
if (_isSuppression)
|
||||
{
|
||||
Vector3 vector = position - _rootBone._natives[_index]._oldPosition;
|
||||
float sqrMagnitude = vector.sqrMagnitude;
|
||||
if (sqrMagnitude >= _suppressionLength + float.Epsilon)
|
||||
{
|
||||
float num = 0.01f;
|
||||
if (sqrMagnitude < 0.0001f)
|
||||
{
|
||||
num = Mathf.Sqrt(sqrMagnitude);
|
||||
vector.x /= num;
|
||||
vector.y /= num;
|
||||
vector.z /= num;
|
||||
}
|
||||
else
|
||||
{
|
||||
vector.Normalize();
|
||||
}
|
||||
_rootBone._natives[_index]._currentPosition = position;
|
||||
_rootBone._natives[_index]._prevPosition = position - vector * num;
|
||||
_rootBone._natives[_index]._finalRotation = _rootBone._natives[_index]._oldRotation;
|
||||
for (int i = 1; i < _rootBone._natives.Length; i++)
|
||||
{
|
||||
_rootBone._natives[i]._currentPosition = _rootBone._natives[i - 1]._currentPosition;
|
||||
_rootBone._natives[i]._prevPosition = _rootBone._natives[i - 1]._prevPosition;
|
||||
_rootBone._natives[i]._finalRotation = _rootBone._natives[i - 1]._finalRotation;
|
||||
}
|
||||
}
|
||||
_suppressionLength = 1f;
|
||||
}
|
||||
_rootBone._natives[_index]._oldPosition = position;
|
||||
}
|
||||
|
||||
public void DoPostAllSpring()
|
||||
{
|
||||
DoPostSpring();
|
||||
CySpringBoneBase[] childBoneList = _childBoneList;
|
||||
for (int i = 0; i < childBoneList.Length; i++)
|
||||
{
|
||||
childBoneList[i].DoPostSpring();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Reset(bool bForceReset = true)
|
||||
{
|
||||
if (base.Reset(bForceReset))
|
||||
{
|
||||
if (_childBoneList == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CySpringBoneBase[] childBoneList = _childBoneList;
|
||||
for (int i = 0; i < childBoneList.Length; i++)
|
||||
{
|
||||
childBoneList[i].Reset(bForceReset);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ChangeRootValue()
|
||||
{
|
||||
if (_childBoneList != null)
|
||||
{
|
||||
_rootBone._natives[_index]._existCollision = _rootBone._applyCollision;
|
||||
CySpringBoneBase[] childBoneList = _childBoneList;
|
||||
for (int i = 0; i < childBoneList.Length; i++)
|
||||
{
|
||||
childBoneList[i].ChangeValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ResetClothParameter()
|
||||
{
|
||||
if (_isRootElement)
|
||||
{
|
||||
_natives[0]._stiffnessForce = _rootElement._stiffnessForce;
|
||||
_natives[0]._dragForce = _rootElement._dragForce;
|
||||
_natives[0]._gravity = _rootElement._gravity;
|
||||
int num = _childBoneList.Length;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
_childBoneList[i].ResetClothParameter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OverrideClothParameter(ref OverrideParameter overrideParameter)
|
||||
{
|
||||
if (!_isRootElement)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (overrideParameter.enableStiffness)
|
||||
{
|
||||
_natives[0]._stiffnessForce = overrideParameter.stiffness;
|
||||
}
|
||||
if (overrideParameter.enableDragForce)
|
||||
{
|
||||
_natives[0]._dragForce = overrideParameter.dragForce;
|
||||
}
|
||||
if (overrideParameter.enableGravity)
|
||||
{
|
||||
_natives[0]._gravity = overrideParameter.gravity;
|
||||
}
|
||||
int num = _childBoneList.Length;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
int index = _childBoneList[i]._index;
|
||||
if (overrideParameter.enableStiffness)
|
||||
{
|
||||
_natives[index]._stiffnessForce = overrideParameter.stiffness;
|
||||
}
|
||||
if (overrideParameter.enableDragForce)
|
||||
{
|
||||
_natives[index]._dragForce = overrideParameter.dragForce;
|
||||
}
|
||||
if (overrideParameter.enableGravity)
|
||||
{
|
||||
_natives[index]._gravity = overrideParameter.gravity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GetWindGroupIndex(ref float index)
|
||||
{
|
||||
index = _natives[0]._windGroupIndex;
|
||||
}
|
||||
|
||||
public void UpdateWindPower(Vector3 windPower)
|
||||
{
|
||||
_natives[0]._windPower = windPower;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 068d2ea4974c10b469f8b880d2eac4c8
|
||||
timeCreated: 1534933097
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct NativeClothCollision
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vector3 _position;
|
||||
|
||||
[FieldOffset(16)]
|
||||
public Vector3 _position2;
|
||||
|
||||
[FieldOffset(32)]
|
||||
public int _type;
|
||||
|
||||
[FieldOffset(36)]
|
||||
public float _radius;
|
||||
|
||||
[FieldOffset(40)]
|
||||
public int _parentIndex;
|
||||
|
||||
[FieldOffset(44)]
|
||||
public int _purpose;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 374df1be538ee244b9897d3c967d8a1b
|
||||
timeCreated: 1530511089
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct NativeClothParameter
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public float _stiffnessForceRate;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public float _dragForceRate;
|
||||
|
||||
[FieldOffset(8)]
|
||||
public float _gravityRate;
|
||||
|
||||
[FieldOffset(12)]
|
||||
public bool _collisionSwitch;
|
||||
|
||||
[FieldOffset(16)]
|
||||
public CySpring.eCapability _capability0;
|
||||
|
||||
[FieldOffset(20)]
|
||||
public CySpring.eCapability _capability1;
|
||||
|
||||
[FieldOffset(24)]
|
||||
public CySpring.eCapability _capability2;
|
||||
|
||||
[FieldOffset(28)]
|
||||
public CySpring.eCapability _capability3;
|
||||
|
||||
[FieldOffset(32)]
|
||||
public CySpring.eCapability _capability4;
|
||||
|
||||
[FieldOffset(36)]
|
||||
public Vector3 _gravityDirection0;
|
||||
|
||||
[FieldOffset(52)]
|
||||
public Vector3 _gravityDirection1;
|
||||
|
||||
[FieldOffset(68)]
|
||||
public Vector3 _gravityDirection2;
|
||||
|
||||
[FieldOffset(84)]
|
||||
public Vector3 _gravityDirection3;
|
||||
|
||||
[FieldOffset(100)]
|
||||
public Vector3 _gravityDirection4;
|
||||
|
||||
[FieldOffset(116)]
|
||||
public Vector3 _forceScale;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a14147a7a11a95048a6802aaa0f1f09e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,138 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct NativeClothWorking
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Quaternion _initLocalRotation;
|
||||
|
||||
[FieldOffset(16)]
|
||||
public Quaternion _oldRotation;
|
||||
|
||||
[FieldOffset(32)]
|
||||
public Quaternion _finalRotation;
|
||||
|
||||
[FieldOffset(48)]
|
||||
public Vector3 _boneAxis;
|
||||
|
||||
[FieldOffset(64)]
|
||||
public Vector3 _currentPosition;
|
||||
|
||||
[FieldOffset(80)]
|
||||
public Vector3 _prevPosition;
|
||||
|
||||
[FieldOffset(96)]
|
||||
public Vector3 _force;
|
||||
|
||||
[FieldOffset(112)]
|
||||
public Vector3 _aimVector;
|
||||
|
||||
[FieldOffset(128)]
|
||||
public Vector3 _diff;
|
||||
|
||||
[FieldOffset(144)]
|
||||
public Vector3 _oldPosition;
|
||||
|
||||
[FieldOffset(160)]
|
||||
public Vector3 _springForce;
|
||||
|
||||
[FieldOffset(176)]
|
||||
public Vector3 _windPower;
|
||||
|
||||
[FieldOffset(192)]
|
||||
public float _initBoneDistance;
|
||||
|
||||
[FieldOffset(196)]
|
||||
public float _stiffnessForce;
|
||||
|
||||
[FieldOffset(200)]
|
||||
public float _dragForce;
|
||||
|
||||
[FieldOffset(204)]
|
||||
public float _collisionRadius;
|
||||
|
||||
[FieldOffset(208)]
|
||||
public float _gravity;
|
||||
|
||||
[FieldOffset(212)]
|
||||
public int _activeCollision;
|
||||
|
||||
[FieldOffset(216)]
|
||||
public short _cIndex0;
|
||||
|
||||
[FieldOffset(218)]
|
||||
public short _cIndex1;
|
||||
|
||||
[FieldOffset(220)]
|
||||
public short _cIndex2;
|
||||
|
||||
[FieldOffset(222)]
|
||||
public short _cIndex3;
|
||||
|
||||
[FieldOffset(224)]
|
||||
public short _cIndex4;
|
||||
|
||||
[FieldOffset(226)]
|
||||
public short _cIndex5;
|
||||
|
||||
[FieldOffset(228)]
|
||||
public short _cIndex6;
|
||||
|
||||
[FieldOffset(230)]
|
||||
public short _cIndex7;
|
||||
|
||||
[FieldOffset(232)]
|
||||
public short _cIndex8;
|
||||
|
||||
[FieldOffset(234)]
|
||||
public short _cIndex9;
|
||||
|
||||
[FieldOffset(236)]
|
||||
public short _cIndex10;
|
||||
|
||||
[FieldOffset(238)]
|
||||
public short _cIndex11;
|
||||
|
||||
[FieldOffset(240)]
|
||||
public short _cIndex12;
|
||||
|
||||
[FieldOffset(242)]
|
||||
public short _cIndex13;
|
||||
|
||||
[FieldOffset(244)]
|
||||
public short _cIndex14;
|
||||
|
||||
[FieldOffset(246)]
|
||||
public short _cIndex15;
|
||||
|
||||
[FieldOffset(248)]
|
||||
public short _cIndex16;
|
||||
|
||||
[FieldOffset(250)]
|
||||
public short _cIndex17;
|
||||
|
||||
[FieldOffset(252)]
|
||||
public short _cIndex18;
|
||||
|
||||
[FieldOffset(254)]
|
||||
public short _cIndex19;
|
||||
|
||||
[FieldOffset(256)]
|
||||
public bool _existCollision;
|
||||
|
||||
[FieldOffset(260)]
|
||||
public bool _isSkip;
|
||||
|
||||
[FieldOffset(264)]
|
||||
public CySpring.eCapability _capability;
|
||||
|
||||
[FieldOffset(268)]
|
||||
public int _capsGroupIndex;
|
||||
|
||||
[FieldOffset(272)]
|
||||
public int _wind;
|
||||
|
||||
[FieldOffset(276)]
|
||||
public float _windGroupIndex;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f6d46425af01d84ca3f68f91412489b
|
||||
timeCreated: 1530511089
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameObjectUtility
|
||||
{
|
||||
public static void SetTransformParentInit(GameObject childObj, Transform parent)
|
||||
{
|
||||
childObj.transform.parent = parent;
|
||||
childObj.transform.localPosition = Vector3.zero;
|
||||
childObj.transform.localScale = Vector3.one;
|
||||
childObj.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
public static void SetTransformParent(GameObject childObj, Transform parent)
|
||||
{
|
||||
Vector3 localPosition = childObj.transform.localPosition;
|
||||
Vector3 localScale = childObj.transform.localScale;
|
||||
childObj.transform.parent = parent;
|
||||
childObj.transform.localRotation = Quaternion.identity;
|
||||
childObj.transform.localPosition = new Vector3(localPosition.x, localPosition.y, localPosition.z);
|
||||
childObj.transform.localScale = new Vector3(localScale.x, localScale.y, localScale.z);
|
||||
}
|
||||
|
||||
public static void SetTransformParent(GameObject childObj, Transform parent, Vector3 position, Vector3 scale)
|
||||
{
|
||||
childObj.transform.parent = parent;
|
||||
childObj.transform.localPosition = new Vector3(position.x, position.y, position.z);
|
||||
childObj.transform.localScale = new Vector3(scale.x, scale.y, scale.z);
|
||||
childObj.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
public static Transform FindChild(string name, Transform target)
|
||||
{
|
||||
Transform transform = target.Find(name);
|
||||
if (transform == null)
|
||||
{
|
||||
for (int i = 0; i < target.childCount; i++)
|
||||
{
|
||||
transform = GameObjectUtility.FindChild(name, target.GetChild(i));
|
||||
if (transform != null)
|
||||
{
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
return transform;
|
||||
}
|
||||
|
||||
public static void SetLayer(int layer, Transform trans, System.Func<int, GameObject, bool> fnCondition)
|
||||
{
|
||||
if (trans == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fnCondition(layer, trans.gameObject))
|
||||
{
|
||||
trans.gameObject.layer = layer;
|
||||
}
|
||||
for (int i = 0; i < trans.childCount; i++)
|
||||
{
|
||||
GameObjectUtility.SetLayer(layer, trans.GetChild(i), fnCondition);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetLayer(int layer, Transform trans)
|
||||
{
|
||||
if (trans == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
trans.gameObject.layer = layer;
|
||||
for (int i = 0; i < trans.childCount; i++)
|
||||
{
|
||||
GameObjectUtility.SetLayer(layer, trans.GetChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindGameObjectOfParent(string name, GameObject parentObject)
|
||||
{
|
||||
GameObject gameObject = GameObject.Find(name);
|
||||
if (parentObject != null)
|
||||
{
|
||||
GameObject gameObject2 = gameObject;
|
||||
while (gameObject2 != null)
|
||||
{
|
||||
Transform transform = gameObject2.transform;
|
||||
if (transform.parent != null && transform.gameObject == parentObject)
|
||||
{
|
||||
return gameObject;
|
||||
}
|
||||
if (transform.parent == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
gameObject2 = transform.parent.gameObject;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
public static Transform FindChildTransform(string name, Transform target)
|
||||
{
|
||||
Transform transform = target.Find(name);
|
||||
if (transform == null)
|
||||
{
|
||||
for (int i = 0; i < target.childCount; i++)
|
||||
{
|
||||
transform = GameObjectUtility.FindChildTransform(name, target.GetChild(i));
|
||||
if (transform != null)
|
||||
{
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
return transform;
|
||||
}
|
||||
|
||||
public static void ResetTransformLocalParam(Transform transform)
|
||||
{
|
||||
if (transform == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
transform.localScale = Vector3.one;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acc5d97295fbc504d84fd3248236716c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -112,70 +112,6 @@ public class TargetInfomation
|
||||
public List<FaceGroupInfo> _faceGroupInfo;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CySpringCollisionData
|
||||
{
|
||||
public string _collisionName;
|
||||
public string _targetObjectName;
|
||||
public bool _isOtherTarget;
|
||||
public Vector3 _offset;
|
||||
public Vector3 _offset2;
|
||||
public float _radius;
|
||||
public float _distance;
|
||||
public Vector3 _normal;
|
||||
public CollisionType _type;
|
||||
public bool _isInner;
|
||||
public enum CollisionType
|
||||
{
|
||||
Sphere,
|
||||
None,
|
||||
Capsule,
|
||||
Plane,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CySpringParamDataElement
|
||||
{
|
||||
public string _boneName;
|
||||
public float _stiffnessForce;
|
||||
public float _dragForce;
|
||||
public float _gravity;
|
||||
public float _collisionRadius;
|
||||
public bool _needEnvCollision;
|
||||
public List<string> _collisionNameList;
|
||||
public bool _isLimit;
|
||||
public Vector3 _limitAngleMin;
|
||||
public Vector3 _limitAngleMax;
|
||||
public float MoveSpringApplyRate;
|
||||
public bool _needSimulateEndBone;
|
||||
public float _verticalWindRateSlow;
|
||||
public float _horizontalWindRateSlow;
|
||||
public float _verticalWindRateFast;
|
||||
public float _horizontalWindRateFast;
|
||||
public List<CySpringParamDataChildElement> _childElements;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CySpringParamDataChildElement
|
||||
{
|
||||
public string _boneName;
|
||||
public float _stiffnessForce;
|
||||
public float _dragForce;
|
||||
public float _gravity;
|
||||
public float _collisionRadius;
|
||||
public bool _needEnvCollision;
|
||||
public List<string> _collisionNameList;
|
||||
public float _verticalWindRateSlow;
|
||||
public float _horizontalWindRateSlow;
|
||||
public float _verticalWindRateFast;
|
||||
public float _horizontalWindRateFast;
|
||||
public bool _isLimit;
|
||||
public Vector3 _limitAngleMin;
|
||||
public Vector3 _limitAngleMax;
|
||||
public float MoveSpringApplyRate;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ConnectedBoneData
|
||||
|
||||
Reference in New Issue
Block a user