add cyspring code
This commit is contained in:
@@ -170,40 +170,17 @@ public class UmaContainer : MonoBehaviour
|
|||||||
public void LoadPhysics()
|
public void LoadPhysics()
|
||||||
{
|
{
|
||||||
cySpringDataContainers = new List<CySpringDataContainer>(PhysicsContainer.GetComponentsInChildren<CySpringDataContainer>());
|
cySpringDataContainers = new List<CySpringDataContainer>(PhysicsContainer.GetComponentsInChildren<CySpringDataContainer>());
|
||||||
ClothController = new ClothController(gameObject);
|
var bones = new List<Transform>(GetComponentsInChildren<Transform>());
|
||||||
return;
|
var colliders = new List<GameObject>();
|
||||||
foreach(var springData in cySpringDataContainers)
|
|
||||||
|
foreach (CySpringDataContainer spring in cySpringDataContainers)
|
||||||
{
|
{
|
||||||
CySpringCollisionDataAsset cySpringCollisionDataAsset = new CySpringCollisionDataAsset();
|
colliders.AddRange(spring.InitiallizeCollider(bones));
|
||||||
cySpringCollisionDataAsset.dataList = springData.collisionParam;
|
}
|
||||||
CySpringParamDataAsset cySpringParamDataAsset = new CySpringParamDataAsset();
|
foreach (CySpringDataContainer spring in cySpringDataContainers)
|
||||||
cySpringParamDataAsset.elements = springData.springParam;
|
{
|
||||||
if (cySpringCollisionDataAsset != null && cySpringParamDataAsset != null)
|
spring.InitializePhysics(bones, colliders);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
public void SetDynamicBoneEnable(bool isOn)
|
||||||
@@ -257,12 +234,14 @@ public class UmaContainer : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
TearControllers.ForEach(a => a.UpdateOffset());
|
TearControllers.ForEach(a => a.UpdateOffset());
|
||||||
|
|
||||||
|
ClothController?.Update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LateUpdate()
|
private void LateUpdate()
|
||||||
{
|
{
|
||||||
ClothController?.Update(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetNextAnimationCut(string cutName)
|
public void SetNextAnimationCut(string cutName)
|
||||||
|
|||||||
@@ -345,7 +345,6 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
CurrentUMAContainer.EyeHeight = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTableValue["head_center_offset_y"];
|
CurrentUMAContainer.EyeHeight = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTableValue["head_center_offset_y"];
|
||||||
CurrentUMAContainer.MergeModel();
|
CurrentUMAContainer.MergeModel();
|
||||||
CurrentUMAContainer.Initialize();
|
CurrentUMAContainer.Initialize();
|
||||||
|
|
||||||
CurrentUMAContainer.SetHeight(Convert.ToInt32(CurrentUMAContainer.CharaData["scale"]));
|
CurrentUMAContainer.SetHeight(Convert.ToInt32(CurrentUMAContainer.CharaData["scale"]));
|
||||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{id}_00_idle01_loop")));
|
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{id}_00_idle01_loop")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,56 +27,56 @@ namespace Gallop
|
|||||||
|
|
||||||
public List<DynamicBone> DynamicBones = new List<DynamicBone>();
|
public List<DynamicBone> DynamicBones = new List<DynamicBone>();
|
||||||
|
|
||||||
//public List<GameObject> InitiallizeCollider(List<Transform> bones)
|
public List<GameObject> InitiallizeCollider(List<Transform> bones)
|
||||||
//{
|
{
|
||||||
// var colliders = new List<GameObject>();
|
var colliders = new List<GameObject>();
|
||||||
// foreach (CySpringCollisionData collider in collisionParam)
|
foreach (CySpringCollisionData collider in collisionParam)
|
||||||
// {
|
{
|
||||||
// if (collider._isInner) continue;
|
if (collider._isInner) continue;
|
||||||
// var bone = bones.Find(a => { return a.name == collider._targetObjectName; });
|
var bone = bones.Find(a => { return a.name == collider._targetObjectName; });
|
||||||
// if (bone)
|
if (bone)
|
||||||
// {
|
{
|
||||||
|
|
||||||
// var child = new GameObject(collider._collisionName);
|
var child = new GameObject(collider._collisionName);
|
||||||
// child.transform.SetParent(bone);
|
child.transform.SetParent(bone);
|
||||||
// child.transform.localPosition = Vector3.zero;
|
child.transform.localPosition = Vector3.zero;
|
||||||
// child.transform.localRotation = Quaternion.identity;
|
child.transform.localRotation = Quaternion.identity;
|
||||||
// child.transform.localScale = Vector3.one;
|
child.transform.localScale = Vector3.one;
|
||||||
// colliders.Add(child);
|
colliders.Add(child);
|
||||||
|
|
||||||
// switch (collider._type)
|
switch (collider._type)
|
||||||
// {
|
{
|
||||||
// case CySpringCollisionData.CollisionType.Capsule:
|
case CySpringCollisionData.CollisionType.Capsule:
|
||||||
// var dynamic = child.AddComponent<DynamicBoneCollider>();
|
var dynamic = child.AddComponent<DynamicBoneCollider>();
|
||||||
// dynamic.ColliderName = collider._collisionName;
|
dynamic.ColliderName = collider._collisionName;
|
||||||
// child.transform.localPosition = (collider._offset + collider._offset2) / 2;
|
child.transform.localPosition = (collider._offset + collider._offset2) / 2;
|
||||||
// child.transform.LookAt(child.transform.TransformPoint(collider._offset2));
|
child.transform.LookAt(child.transform.TransformPoint(collider._offset2));
|
||||||
// dynamic.m_Direction = DynamicBoneColliderBase.Direction.Z;
|
dynamic.m_Direction = DynamicBoneColliderBase.Direction.Z;
|
||||||
// dynamic.m_Height = (collider._offset - collider._offset2).magnitude + collider._radius;
|
dynamic.m_Height = (collider._offset - collider._offset2).magnitude + collider._radius;
|
||||||
// dynamic.m_Radius = collider._radius;
|
dynamic.m_Radius = collider._radius;
|
||||||
// dynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
dynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||||
// break;
|
break;
|
||||||
// case CySpringCollisionData.CollisionType.Sphere:
|
case CySpringCollisionData.CollisionType.Sphere:
|
||||||
// var Spheredynamic = child.AddComponent<DynamicBoneCollider>();
|
var Spheredynamic = child.AddComponent<DynamicBoneCollider>();
|
||||||
// Spheredynamic.ColliderName = collider._collisionName;
|
Spheredynamic.ColliderName = collider._collisionName;
|
||||||
// child.transform.localPosition = collider._offset;
|
child.transform.localPosition = collider._offset;
|
||||||
// Spheredynamic.m_Radius = collider._radius;
|
Spheredynamic.m_Radius = collider._radius;
|
||||||
// Spheredynamic.m_Height = collider._distance;
|
Spheredynamic.m_Height = collider._distance;
|
||||||
// Spheredynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
Spheredynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||||
// break;
|
break;
|
||||||
// case CySpringCollisionData.CollisionType.Plane:
|
case CySpringCollisionData.CollisionType.Plane:
|
||||||
// var planedynamic = child.AddComponent<DynamicBonePlaneCollider>();
|
var planedynamic = child.AddComponent<DynamicBonePlaneCollider>();
|
||||||
// planedynamic.ColliderName = collider._collisionName;
|
planedynamic.ColliderName = collider._collisionName;
|
||||||
// child.transform.localPosition = collider._offset;
|
child.transform.localPosition = collider._offset;
|
||||||
// planedynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
planedynamic.m_Bound = collider._isInner ? DynamicBoneColliderBase.Bound.Inside : DynamicBoneColliderBase.Bound.Outside;
|
||||||
// break;
|
break;
|
||||||
// case CySpringCollisionData.CollisionType.None:
|
case CySpringCollisionData.CollisionType.None:
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// return colliders;
|
return colliders;
|
||||||
//}
|
}
|
||||||
|
|
||||||
public void InitializePhysics(List<Transform> bones, List<GameObject> colliders)
|
public void InitializePhysics(List<Transform> bones, List<GameObject> colliders)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ namespace Gallop
|
|||||||
List<Particle> particles = new List<Particle>();
|
List<Particle> particles = new List<Particle>();
|
||||||
foreach (CySpringDataContainer spring in Container.cySpringDataContainers)
|
foreach (CySpringDataContainer spring in Container.cySpringDataContainers)
|
||||||
{
|
{
|
||||||
foreach (DynamicBone dynamicBone in spring.DynamicBones)
|
foreach (DynamicBone dynamicbone in spring.DynamicBones)
|
||||||
{
|
{
|
||||||
particles.AddRange(dynamicBone.Particles);
|
particles.AddRange(dynamicbone.Particles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: b0b9ccf38ac795d4783179e43b65d268
|
guid: b0b9ccf38ac795d4783179e43b65d268
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
timeCreated: 1534933119
|
|
||||||
licenseType: Free
|
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
|
|||||||
@@ -1,549 +1,302 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class ClothController
|
public class ClothController {
|
||||||
{
|
public class Cloth {
|
||||||
public class Cloth
|
private CySpringCollisionDataAsset _colAsset;
|
||||||
{
|
|
||||||
private Character3DBase.Parts.eCategory _category = Character3DBase.Parts.eCategory.MAX;
|
|
||||||
|
|
||||||
private CySpringCollisionDataAsset _colAsset;
|
private CySpringParamDataAsset _prmAsset;
|
||||||
|
|
||||||
private CySpringParamDataAsset _prmAsset;
|
private CySpringCollision _collision;
|
||||||
|
|
||||||
private CySpringCollision _collision;
|
private CySpring _spring;
|
||||||
|
|
||||||
private CySpring _spring;
|
public CySpringCollisionDataAsset colAsset {
|
||||||
|
get {
|
||||||
private string _oftenAccessedParent;
|
return _colAsset;
|
||||||
|
}
|
||||||
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
|
public CySpringParamDataAsset prmAsset {
|
||||||
{
|
get {
|
||||||
None,
|
return _prmAsset;
|
||||||
Sin,
|
}
|
||||||
Wind
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly string UNION_COLLISION_NAME = "ColUnion";
|
public CySpringCollision collision {
|
||||||
|
get {
|
||||||
public static readonly float UNION_COLLISION_RADIUS = 0.45f;
|
return _collision;
|
||||||
|
}
|
||||||
public static readonly string GROUND_COLLISION_NAME = "ColGround";
|
set {
|
||||||
|
_collision = value;
|
||||||
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)
|
public CySpring spring {
|
||||||
{
|
get {
|
||||||
_targetObject = target;
|
return _spring;
|
||||||
_targetTransform = target.transform;
|
}
|
||||||
_isReady = false;
|
set {
|
||||||
_isCreated = false;
|
_spring = value;
|
||||||
_isBinded = false;
|
}
|
||||||
}
|
}
|
||||||
|
public Cloth(CySpringCollisionDataAsset collisionDataAsset, CySpringParamDataAsset paramDataAsset) {
|
||||||
private void Destroy(UnityEngine.Object obj)
|
_colAsset = collisionDataAsset;
|
||||||
{
|
_prmAsset = paramDataAsset;
|
||||||
if (obj != null)
|
|
||||||
{
|
|
||||||
UnityEngine.Object.Destroy(obj);
|
|
||||||
}
|
|
||||||
_isReady = false;
|
|
||||||
_isCreated = false;
|
|
||||||
_isBinded = false;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private HashSet<string> BuildUsableCollisionList()
|
public static readonly string UNION_COLLISION_NAME = "ColUnion";
|
||||||
{
|
|
||||||
HashSet<string> setUsableCollision = new HashSet<string>();
|
public static readonly float UNION_COLLISION_RADIUS = 0.45f;
|
||||||
Action<CySpringParamDataAsset> action = delegate (CySpringParamDataAsset prmAsset)
|
|
||||||
{
|
public static readonly string GROUND_COLLISION_NAME = "ColGround";
|
||||||
Action<List<string>> fnAddusableCollision = delegate (List<string> lstCollision)
|
|
||||||
{
|
public static readonly float GROUND_SPHERE_RADIUS = 1e+006f;
|
||||||
for (int l = 0; l < lstCollision.Count; l++)
|
|
||||||
{
|
private bool _bReady;
|
||||||
if (!setUsableCollision.Contains(lstCollision[l]))
|
|
||||||
{
|
private GameObject _targetObject;
|
||||||
setUsableCollision.Add(lstCollision[l]);
|
|
||||||
}
|
private Transform _targetTransform;
|
||||||
if (lstCollision[l] == UNION_COLLISION_NAME)
|
|
||||||
{
|
private Vector3 _bakPosition = Vector3.zero;
|
||||||
_useUnionCollision = true;
|
|
||||||
}
|
private Quaternion _bakRotation = Quaternion.identity;
|
||||||
}
|
|
||||||
};
|
private List<Cloth> _lstCloth = new List<Cloth>();
|
||||||
Action<List<CySpringParamDataChildElement>> action2 = delegate (List<CySpringParamDataChildElement> lstChild)
|
|
||||||
{
|
private bool _useUnionCollision;
|
||||||
for (int k = 0; k < lstChild.Count; k++)
|
|
||||||
{
|
private CySpringCollisionComponent _unionCollision;
|
||||||
CySpringParamDataChildElement cySpringParamDataChildElement = lstChild[k];
|
|
||||||
fnAddusableCollision(cySpringParamDataChildElement._collisionNameList);
|
public bool isReady {
|
||||||
}
|
get {
|
||||||
};
|
return _bReady;
|
||||||
for (int j = 0; j < prmAsset.mergeDataList.Count; j++)
|
}
|
||||||
{
|
}
|
||||||
CySpringParamDataElement cySpringParamDataElement = prmAsset.mergeDataList[j];
|
|
||||||
fnAddusableCollision(cySpringParamDataElement._collisionNameList);
|
public bool useUnionCollision {
|
||||||
action2(cySpringParamDataElement._childElements);
|
get {
|
||||||
|
return _useUnionCollision;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CySpringCollisionComponent unionCollision {
|
||||||
|
get {
|
||||||
|
return _unionCollision;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int clothCount {
|
||||||
|
get {
|
||||||
|
return _lstCloth.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClothController(GameObject target) {
|
||||||
|
_targetObject = target;
|
||||||
|
_targetTransform = target.transform;
|
||||||
|
_bReady = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Destroy(UnityEngine.Object obj) {
|
||||||
|
if (obj != null) {
|
||||||
|
UnityEngine.Object.Destroy(obj);
|
||||||
|
}
|
||||||
|
_bReady = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashSet<string> BuildUsableCollisionList() {
|
||||||
|
if (_lstCloth != null && _lstCloth.Count > 0) {
|
||||||
|
HashSet<string> setUsableCollision = new HashSet<string>();
|
||||||
|
|
||||||
|
_useUnionCollision = false;
|
||||||
|
|
||||||
|
Action<CySpringParamDataAsset> fnBuildCollisionSet = 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]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
_useUnionCollision = false;
|
Action<List<CySpringParamDataChildElement>> action = delegate(List<CySpringParamDataChildElement> lstChild) {
|
||||||
for (int i = 0; i < _lstCloth.Count; i++)
|
for (int k = 0; k < lstChild.Count; k++) {
|
||||||
{
|
CySpringParamDataChildElement cySpringParamDataChildElement = lstChild[k];
|
||||||
action(_lstCloth[i].prmAsset);
|
fnAddusableCollision(cySpringParamDataChildElement._collisionNameList);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (int j = 0; j < prmAsset._elements.Count; j++) {
|
||||||
|
CySpringParamDataElement cySpringParamDataElement = prmAsset._elements[j];
|
||||||
|
fnAddusableCollision(cySpringParamDataElement._collisionNameList);
|
||||||
|
action(cySpringParamDataElement._childElements);
|
||||||
}
|
}
|
||||||
return setUsableCollision;
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
fnBuildCollisionSet(_lstCloth[i].prmAsset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return setUsableCollision;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddCloth(CySpringCollisionDataAsset colAsset, CySpringParamDataAsset prmAsset) {
|
||||||
|
_lstCloth.Add(new Cloth(colAsset, prmAsset));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateCollision(CySpringCollisionComponent.ePurpose purpose, int idxMainCloth, float unionCollisionScale = 1f) {
|
||||||
|
if (_lstCloth != null) {
|
||||||
|
var hashlist = BuildUsableCollisionList();
|
||||||
|
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
_lstCloth[i].collision = _targetObject.AddComponent<CySpringCollision>();
|
||||||
|
_lstCloth[i].collision.Create(_lstCloth[i].colAsset, hashlist);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (_lstCloth.Count > idxMainCloth)
|
||||||
|
{
|
||||||
|
_lstCloth[idxMainCloth].collision = _targetObject.AddComponent<CySpringCollision>();
|
||||||
|
_lstCloth[idxMainCloth].collision.Create(_lstCloth[idxMainCloth].colAsset, hashlist);
|
||||||
|
|
||||||
|
var comp = _lstCloth[idxMainCloth].collision.CreateCollision("Chest", UNION_COLLISION_NAME, UNION_COLLISION_RADIUS * unionCollisionScale);
|
||||||
|
comp.purpose = CySpringCollisionComponent.ePurpose.Union;
|
||||||
|
|
||||||
|
CySpring.AddUnionCollision(comp);
|
||||||
|
|
||||||
|
if (hashlist.Contains(GROUND_COLLISION_NAME))
|
||||||
|
{
|
||||||
|
var comp2 = _lstCloth[idxMainCloth].collision.CreateCollision("Position", GROUND_COLLISION_NAME, GROUND_SPHERE_RADIUS);
|
||||||
|
comp2.purpose = CySpringCollisionComponent.ePurpose.Ground;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindSpring() {
|
||||||
|
if (_lstCloth != null) {
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
_lstCloth[i].spring = _targetObject.AddComponent<CySpring>();
|
||||||
|
_lstCloth[i].spring.Bind(_lstCloth[i].prmAsset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_bReady = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset(bool bForceReset) {
|
||||||
|
if (_lstCloth != null) {
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
Debug.LogWarning(_lstCloth[i].spring);
|
||||||
|
_lstCloth[i].spring.Reset(bForceReset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset(int idx, bool bForceReset) {
|
||||||
|
if (_lstCloth != null && _lstCloth.Count > idx) {
|
||||||
|
_lstCloth[idx].spring.Reset(bForceReset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release() {
|
||||||
|
if (_lstCloth != null) {
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
Destroy(_lstCloth[i].spring);
|
||||||
|
Destroy(_lstCloth[i].collision);
|
||||||
|
}
|
||||||
|
_lstCloth.Clear();
|
||||||
|
_bReady = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CySpringCollision GetCollision(int idx) {
|
||||||
|
if (_lstCloth.Count > idx) {
|
||||||
|
return _lstCloth[idx].collision;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CySpring GetSpring(int idx) {
|
||||||
|
if (_lstCloth.Count > idx) {
|
||||||
|
return _lstCloth[idx].spring;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(bool isGather = true) {
|
||||||
|
if (_lstCloth != null && _lstCloth.Count > 0 && _bReady) {
|
||||||
|
if (_unionCollision != null) {
|
||||||
|
//_unionCollision.UpdateUnionCollision()
|
||||||
|
}
|
||||||
|
_bakPosition = _targetTransform.position;
|
||||||
|
_bakRotation = _targetTransform.rotation;
|
||||||
|
_targetTransform.position = Vector3.zero;
|
||||||
|
_targetTransform.rotation = Quaternion.identity;
|
||||||
|
|
||||||
|
if (isGather) {
|
||||||
|
float smoothDeltaTime = Time.smoothDeltaTime;
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
_lstCloth[i].spring.GatherSpring(smoothDeltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int j = 0; j < _lstCloth.Count; j++) {
|
||||||
|
_lstCloth[j].spring.UpdateSpring();
|
||||||
|
}
|
||||||
|
for (int j = 0; j < _lstCloth.Count; j++) {
|
||||||
|
_lstCloth[j].spring.PostSpring();
|
||||||
|
}
|
||||||
|
_targetTransform.position = _bakPosition;
|
||||||
|
_targetTransform.rotation = _bakRotation;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ForceUpdate(float fCollisionOffSec, float fCollisionOnSec) {
|
||||||
|
//最初の位置を確保
|
||||||
|
Vector3 position = _targetTransform.position;
|
||||||
|
Quaternion rotation = _targetTransform.rotation;
|
||||||
|
|
||||||
|
_targetTransform.position = Vector3.zero;
|
||||||
|
_targetTransform.rotation = Quaternion.identity;
|
||||||
|
if (_lstCloth.Count > 0) {
|
||||||
|
float num = 0.0166666675f;
|
||||||
|
int num2 = (int) Mathf.Floor(fCollisionOffSec / num);
|
||||||
|
int num3 = (int) Mathf.Floor(fCollisionOnSec / num);
|
||||||
|
//CollisionSwitchをオフに
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
_lstCloth[i].spring.CollisionSwitch = false;
|
||||||
|
}
|
||||||
|
//UpdateSpring
|
||||||
|
for (int i = 0; i < num2; i++) {
|
||||||
|
for (int j = 0; j < _lstCloth.Count; j++) {
|
||||||
|
_lstCloth[j].spring.UpdateSpring();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//CollisionSwitchをオンに
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
_lstCloth[i].spring.CollisionSwitch = true;
|
||||||
|
}
|
||||||
|
//UpdateSpring
|
||||||
|
for (int i = 0; i < num3; i++) {
|
||||||
|
for (int j = 0; j < _lstCloth.Count; j++) {
|
||||||
|
_lstCloth[j].spring.UpdateSpring();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//PostSpring
|
||||||
|
for (int i = 0; i < _lstCloth.Count; i++) {
|
||||||
|
_lstCloth[i].spring.PostSpring();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddCloth(Cloth cloth)
|
//戻すよ
|
||||||
{
|
_targetTransform.position = position;
|
||||||
if (cloth != null)
|
_targetTransform.rotation = rotation;
|
||||||
{
|
}
|
||||||
_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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 13ca4a9f1b2eca44296a18f800438fba
|
guid: 71e62a5239b1859499398c28ccee9b96
|
||||||
timeCreated: 1539978036
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -1,578 +1,290 @@
|
|||||||
// CySpring
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
//using Stage;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CySpring : MonoBehaviour
|
public class CySpring : MonoBehaviour {
|
||||||
{
|
public enum eCapability {
|
||||||
public enum eCapability
|
None,
|
||||||
{
|
GravityControl,
|
||||||
None,
|
WindForce
|
||||||
GravityControl,
|
}
|
||||||
WindForce
|
|
||||||
|
private static List<CySpringCollisionComponent> _lstUnionCollision;
|
||||||
|
|
||||||
|
private static CySpringCollisionComponent _groundCollision;
|
||||||
|
|
||||||
|
private const float DEFAULT_SPECIFIC_RATE = 0.1f;
|
||||||
|
|
||||||
|
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 List<CySpringCollisionComponent> _collisionList;
|
||||||
|
|
||||||
|
public NativeClothCollision[] _nativeCollisions;
|
||||||
|
|
||||||
|
[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 const float HALF_FPS_RATE = 1.5f;
|
||||||
|
|
||||||
|
public static float stiffnessForceRate {
|
||||||
|
set {
|
||||||
|
_stiffnessForceRate = value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class CollisionParent
|
public static float dragForceRate {
|
||||||
{
|
set {
|
||||||
public Transform transform;
|
_dragForceRate = value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct BindContext
|
public static float gravityRate {
|
||||||
{
|
set {
|
||||||
public NativeClothCollision[] commonNativeCollisions;
|
_gravityRate = value;
|
||||||
|
|
||||||
public CollisionParent[] commonCollisionParentTable;
|
|
||||||
|
|
||||||
public CySpringCollisionComponent[] commonUnionCollisionList;
|
|
||||||
|
|
||||||
public Vector3[] commonCollisionParentWorldPosition;
|
|
||||||
|
|
||||||
public Quaternion[] commonCoollisionParentWorldRotation;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private const float DEFAULT_SPECIFIC_RATE = 0.1f;
|
public bool CollisionSwitch {
|
||||||
|
get {
|
||||||
|
return _bCollisionSwitch;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_bCollisionSwitch = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private const float HALF_FPS_RATE = 1.5f;
|
public CySpringParamDataAsset springData {
|
||||||
|
set {
|
||||||
|
_springData = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static List<CySpringCollisionComponent> _lstUnionCollision = null;
|
public List<CySpringCollisionComponent> CollisionList {
|
||||||
|
get {
|
||||||
|
return _collisionList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static CySpringCollisionComponent _groundCollision = null;
|
public float sqartDeltaTime {
|
||||||
|
get {
|
||||||
|
return _sqartDeltaTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static float _stiffnessForceRate = 1f;
|
public CySpringRootBone[] boneList {
|
||||||
|
get {
|
||||||
|
return _boneList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static float _dragForceRate = 1f;
|
private void Awake() {
|
||||||
|
Create();
|
||||||
|
}
|
||||||
|
|
||||||
private static float _gravityRate = 1f;
|
private void Start() {
|
||||||
|
_cachedTransform = base.gameObject.transform;
|
||||||
|
SetCollision();
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
private bool _bCollisionSwitch = true;
|
public void Bind(CySpringParamDataAsset springData) {
|
||||||
|
_springData = springData;
|
||||||
|
Create();
|
||||||
|
SetCollision();
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
[SerializeField]
|
public void SetSpecificSpringRatio(float fTargetFPS, float fSpringFactor, float fGravityFactor) {
|
||||||
private CySpringParamDataAsset _springData;
|
float num = 1f / fTargetFPS;
|
||||||
|
num = 1f / num;
|
||||||
|
num = (float) (int) (num + 0.5f);
|
||||||
|
num = 1f / num;
|
||||||
|
float f = num / 0.0166666675f;
|
||||||
|
_isUseSpecificValue = true;
|
||||||
|
_specificStiffnessForceRate = Mathf.Pow(f, 1f / fSpringFactor);
|
||||||
|
_specificDragForceRate = 1f / _specificStiffnessForceRate;
|
||||||
|
_specificGravityRate = Mathf.Pow(f, fGravityFactor);
|
||||||
|
}
|
||||||
|
|
||||||
private bool _bUseUnionCollision;
|
public void GatherSpring(float deltaTime) {
|
||||||
|
if (_boneList != null) {
|
||||||
private CySpringCollisionComponent _unionCollision;
|
_sqartDeltaTime = deltaTime;
|
||||||
|
for (int i = 0; i < CollisionList.Count; i++) {
|
||||||
private CySpringCollisionComponent[] _unionCollisionList;
|
switch (CollisionList[i].CollisionType) {
|
||||||
|
case CySpringCollisionData.CollisionType.Sphere:
|
||||||
private CySpringCollisionComponent[] _collisionList;
|
_nativeCollisions[i]._position = CollisionList[i].cacheTransform.position;
|
||||||
|
break;
|
||||||
public NativeClothCollision[] _nativeCollisions;
|
case CySpringCollisionData.CollisionType.Capsule:
|
||||||
|
_nativeCollisions[i]._position = CollisionList[i].cacheTransform.TransformPoint(CollisionList[i].Offset);
|
||||||
private CollisionParent[] _collisionParentTable;
|
_nativeCollisions[i]._position2 = CollisionList[i].cacheTransform.TransformPoint(CollisionList[i].Offset2);
|
||||||
|
break;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
for (int j = 0; j < _boneList.Length; j++) {
|
||||||
|
_boneList[j].GathreAllSpring();
|
||||||
|
_boneList[j]._natives[0]._isSkip = _boneList[j]._isSkip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static float dragForceRate
|
public void UpdateSpring() {
|
||||||
{
|
if (boneList != null) {
|
||||||
set
|
for (int i = 0; i < boneList.Length; i++) {
|
||||||
{
|
CySpringNative.UpdateNativeCloth(_boneList[i]._natives, _boneList[i]._natives.Length, _nativeCollisions, _stiffnessForceRate, _dragForceRate, _gravityRate, _bCollisionSwitch);
|
||||||
_dragForceRate = value;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PostSpring() {
|
||||||
|
if (_boneList != null) {
|
||||||
|
for (int i = 0; i < _boneList.Length; i++) {
|
||||||
|
_boneList[i].PostAllSpring();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Create() {
|
||||||
|
_sqartDeltaTime = 0f;
|
||||||
|
if (_collisionList == null) {
|
||||||
|
_collisionList = new List<CySpringCollisionComponent>(GetComponentsInChildren<CySpringCollisionComponent>());
|
||||||
|
}
|
||||||
|
if (!(_springData == null)) {
|
||||||
|
List<CySpringRootBone> list = new List<CySpringRootBone>();
|
||||||
|
for (int i = 0; i < _springData._elements.Count; i++) {
|
||||||
|
CySpringRootBone cySpringRootBone = new CySpringRootBone();
|
||||||
|
cySpringRootBone.CreateRoot(_springData._elements[i], this, cySpringRootBone, null);
|
||||||
|
if (cySpringRootBone.Exist) {
|
||||||
|
list.Add(cySpringRootBone);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
_boneList = list.ToArray();
|
||||||
|
_nativeCollisions = new NativeClothCollision[_collisionList.Count];
|
||||||
|
for (int j = 0; j < _collisionList.Count; j++) {
|
||||||
|
_nativeCollisions[j]._radius = _collisionList[j].Radius;
|
||||||
|
_nativeCollisions[j]._type = (int) _collisionList[j].CollisionType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static float gravityRate
|
private void SetCollision() {
|
||||||
{
|
if (_boneList != null) {
|
||||||
set
|
for (int i = 0; i < _boneList.Length; i++) {
|
||||||
{
|
_boneList[i].SetCollision();
|
||||||
_gravityRate = value;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool CollisionSwitch
|
public void Reset(bool bForceReset = true) {
|
||||||
{
|
if (_boneList != null && _boneList.Length > 0) {
|
||||||
get
|
if (_cachedTransform == null) {
|
||||||
{
|
|
||||||
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;
|
_cachedTransform = base.gameObject.transform;
|
||||||
SetCollision();
|
}
|
||||||
Reset();
|
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;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSuppression(bool enable, float length)
|
public static GameObject FindGameObject(GameObject rootObject, string objectName) {
|
||||||
{
|
if (!objectName.Contains("/")) {
|
||||||
CySpringRootBone[] array = _boneList;
|
return FindGameObjectLoop(rootObject, objectName);
|
||||||
foreach (CySpringRootBone obj in array)
|
|
||||||
{
|
|
||||||
obj.IsSuppression = enable;
|
|
||||||
obj.SuppressionLength = length * length;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
string[] array = objectName.Split('/');
|
||||||
public void GetContext(ref BindContext context)
|
if (array.Length == 0) {
|
||||||
{
|
return null;
|
||||||
context.commonNativeCollisions = _nativeCollisions;
|
|
||||||
context.commonCollisionParentTable = _collisionParentTable;
|
|
||||||
context.commonUnionCollisionList = _unionCollisionList;
|
|
||||||
context.commonCollisionParentWorldPosition = _collisionParentWorldPosition;
|
|
||||||
context.commonCoollisionParentWorldRotation = _collisionParentWorldRotation;
|
|
||||||
}
|
}
|
||||||
|
GameObject gameObject = rootObject;
|
||||||
public void Bind(CySpringParamDataAsset springData, CySpringCollisionComponent groundCollision, CySpringCollisionComponent unionCollision, bool bUseUnionCollision, string oftenAccessedParent, ref BindContext context)
|
for (int i = 0; i < array.Length; i++) {
|
||||||
{
|
gameObject = FindGameObjectLoop(gameObject, array[i]);
|
||||||
_springData = springData;
|
if (gameObject == null) {
|
||||||
_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;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return gameObject;
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetAttenuationFactor(float fTargetFPS, float fSpringFactor, float fGravityFactor)
|
private static GameObject FindGameObjectLoop(GameObject rootObject, string objectName) {
|
||||||
{
|
if (rootObject == null) {
|
||||||
float num = 1f / fTargetFPS;
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
foreach (Transform item in rootObject.transform) {
|
||||||
public static void ClearUnionCollision()
|
if (item.name.Contains(objectName)) {
|
||||||
{
|
return item.gameObject;
|
||||||
if (_lstUnionCollision != null)
|
}
|
||||||
{
|
|
||||||
_lstUnionCollision.Clear();
|
|
||||||
}
|
|
||||||
_lstUnionCollision = null;
|
|
||||||
}
|
}
|
||||||
|
foreach (Transform item2 in rootObject.transform) {
|
||||||
public static void AddUnionCollision(CySpringCollisionComponent comp)
|
GameObject gameObject = FindGameObjectLoop(item2.gameObject, objectName);
|
||||||
{
|
if (gameObject != null) {
|
||||||
if (comp != null)
|
return gameObject;
|
||||||
{
|
}
|
||||||
if (_lstUnionCollision == null)
|
|
||||||
{
|
|
||||||
_lstUnionCollision = new List<CySpringCollisionComponent>();
|
|
||||||
}
|
|
||||||
if (_lstUnionCollision != null)
|
|
||||||
{
|
|
||||||
_lstUnionCollision.Add(comp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
//private static void RequestUnionCollision(CySpringCollisionComponent comp, Action<CharacterObject> fn)
|
public static void SetAttenuationFactor(float fTargetFPS, float fSpringFactor, float fGravityFactor) {
|
||||||
//{
|
float num = 1f / fTargetFPS;
|
||||||
// Director instance = Director.instance;
|
num = 1f / num;
|
||||||
// if (comp != null && instance != null)
|
num = (float) (int) (num + 0.5f);
|
||||||
// {
|
num = 1f / num;
|
||||||
// List<CharacterObject> characterObjects = instance.characterObjects;
|
float f = num / 0.0166666675f;
|
||||||
// for (int i = 0; i < characterObjects.Count; i++)
|
_stiffnessForceRate = Mathf.Pow(f, 1f / fSpringFactor);
|
||||||
// {
|
_dragForceRate = 1f / _stiffnessForceRate;
|
||||||
// fn(characterObjects[i]);
|
_gravityRate = Mathf.Pow(f, fGravityFactor);
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public static void RemoveUnionCollision(CySpringCollisionComponent comp)
|
public static void ClearUnionCollision() {
|
||||||
//{
|
if (_lstUnionCollision != null) {
|
||||||
// RequestUnionCollision(comp, delegate (CharacterObject obj)
|
_lstUnionCollision.Clear();
|
||||||
// {
|
_lstUnionCollision = null;
|
||||||
// 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)
|
public static void AddUnionCollision(CySpringCollisionComponent comp) {
|
||||||
{
|
if (_lstUnionCollision == null) {
|
||||||
if (_collisionList == null || !(comp != null))
|
_lstUnionCollision = new List<CySpringCollisionComponent>();
|
||||||
{
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
if (_lstUnionCollision != null) {
|
||||||
|
_lstUnionCollision.Add(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0e3dc5c6665128d41a5cea73c711768c
|
guid: 0541e5904daeb65468ed1c36718747fd
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -1,387 +1,263 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CySpringBoneBase
|
public class CySpringBoneBase {
|
||||||
{
|
protected string _boneName;
|
||||||
protected string _boneName;
|
|
||||||
|
|
||||||
protected CySpring _root;
|
protected CySpring _root;
|
||||||
|
|
||||||
protected CySpringRootBone _rootBone;
|
protected CySpringRootBone _rootBone;
|
||||||
|
|
||||||
protected CySpringBoneBase _parentBone;
|
protected CySpringBoneBase _parentBone;
|
||||||
|
|
||||||
protected GameObject _gameObject;
|
protected GameObject _gameObject;
|
||||||
|
|
||||||
protected Transform _transform;
|
protected Transform _transform;
|
||||||
|
|
||||||
protected Transform _parentTransform;
|
protected bool _exist;
|
||||||
|
|
||||||
protected bool _exist;
|
public int _index;
|
||||||
|
|
||||||
public int _index;
|
private List<int> _collisionIndexList;
|
||||||
|
|
||||||
public CySpringParamDataChildElement _element;
|
public string BoneName {
|
||||||
|
get {
|
||||||
private List<int> _collisionIndexList;
|
return _boneName;
|
||||||
|
|
||||||
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
|
public GameObject GameObject {
|
||||||
{
|
get {
|
||||||
get
|
return _gameObject;
|
||||||
{
|
|
||||||
return _rootBone._natives[_index]._boneAxis;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_rootBone._natives[_index]._boneAxis = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool Exist
|
public float StiffnessForce {
|
||||||
{
|
get {
|
||||||
get
|
return _rootBone._natives[_index]._stiffnessForce;
|
||||||
{
|
|
||||||
return _exist;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_exist = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsWind
|
public float DragForce {
|
||||||
{
|
get {
|
||||||
get
|
return _rootBone._natives[_index]._dragForce;
|
||||||
{
|
|
||||||
return (_rootBone._natives[_index]._wind & 1) != 0;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
_rootBone._natives[_index]._wind |= 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_rootBone._natives[_index]._wind &= -2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public float WindGroupIndex
|
public Vector3 SpringForce {
|
||||||
{
|
get {
|
||||||
get
|
return _rootBone._natives[_index]._springForce;
|
||||||
{
|
|
||||||
return _rootBone._natives[_index]._windGroupIndex;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_rootBone._natives[_index]._windGroupIndex = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<int> CollisionIndexList => _collisionIndexList;
|
public float CollisionRadius {
|
||||||
|
get {
|
||||||
public CySpringBoneBase()
|
return _rootBone._natives[_index]._collisionRadius;
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CySpringBoneBase(string name)
|
public float Gravity {
|
||||||
{
|
get {
|
||||||
_boneName = name;
|
return _rootBone._natives[_index]._gravity;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Create(CySpring root, CySpringRootBone rootBone, CySpringBoneBase parentBone)
|
public float InitBoneDistance {
|
||||||
{
|
get {
|
||||||
_root = root;
|
return _rootBone._natives[_index]._initBoneDistance;
|
||||||
_rootBone = rootBone;
|
}
|
||||||
_parentBone = parentBone;
|
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 List<int> CollisionIndexList {
|
||||||
|
get {
|
||||||
|
return _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;
|
_exist = false;
|
||||||
if (!(_root == null) && _rootBone != null)
|
} else {
|
||||||
{
|
_transform = _gameObject.transform;
|
||||||
if (_parentBone != null)
|
_exist = true;
|
||||||
{
|
}
|
||||||
_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)
|
public void CreateChild(CySpring root, CySpringRootBone rootBone, CySpringBoneBase parentBone) {
|
||||||
{
|
Create(root, rootBone, parentBone);
|
||||||
Create(root, rootBone, parentBone);
|
foreach (Transform item in _transform) {
|
||||||
foreach (Transform item in _transform)
|
if (!(item == _transform) && !(item.GetComponent<CySpringCollisionComponent>() != null)) {
|
||||||
{
|
CySpringBoneBase cySpringBoneBase = new CySpringBoneBase(item.name);
|
||||||
if (!(item == _transform) && !(item.GetComponent<CySpringCollisionComponent>() != null))
|
_rootBone.ChildBoneList.Add(cySpringBoneBase);
|
||||||
{
|
cySpringBoneBase.CreateChild(_root, _rootBone, this);
|
||||||
CySpringBoneBase cySpringBoneBase = new CySpringBoneBase(item.name);
|
}
|
||||||
_rootBone.TmpChildBoneList.Add(cySpringBoneBase);
|
|
||||||
cySpringBoneBase.CreateChild(_root, _rootBone, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Initialize(int idx)
|
public virtual void Initialize(int idx) {
|
||||||
{
|
_index = idx;
|
||||||
_index = idx;
|
_rootBone._natives[_index]._initLocalRotation = _transform.localRotation;
|
||||||
_rootBone._natives[_index]._initLocalRotation = _transform.localRotation;
|
_rootBone._natives[_index]._currentPosition = _transform.position;
|
||||||
_rootBone._natives[_index]._currentPosition = _transform.position;
|
_rootBone._natives[_index]._prevPosition = _rootBone._natives[_index]._currentPosition;
|
||||||
_rootBone._natives[_index]._prevPosition = _rootBone._natives[_index]._currentPosition;
|
_rootBone._natives[_index]._existCollision = _rootBone.ApplyCollision;
|
||||||
_rootBone._natives[_index]._existCollision = _rootBone.ApplyCollision;
|
if (_parentBone != null) {
|
||||||
if (_parentBone != null)
|
_parentBone.InitBoneDistance = Vector3.Distance(_transform.position, _parentBone.GameObject.transform.position);
|
||||||
{
|
if (_parentBone.InitBoneDistance == 0f) {
|
||||||
_parentBone.InitBoneDistance = Vector3.Distance(_transform.position, _parentBone.GameObject.transform.position);
|
_parentBone.Exist = false;
|
||||||
if (_parentBone.InitBoneDistance == 0f)
|
_exist = false;
|
||||||
{
|
} else {
|
||||||
_parentBone.Exist = false;
|
_parentBone.BoneAxis = (_gameObject.transform.position - _parentBone.GameObject.transform.position).normalized;
|
||||||
_exist = false;
|
}
|
||||||
}
|
if (_transform.childCount == 0) {
|
||||||
else
|
_rootBone._natives[_index]._boneAxis = _parentBone.BoneAxis;
|
||||||
{
|
_rootBone._natives[_index]._initBoneDistance = _parentBone.InitBoneDistance;
|
||||||
_parentBone.BoneAxis = (_gameObject.transform.position - _parentBone.GameObject.transform.position).normalized;
|
}
|
||||||
}
|
} else {
|
||||||
if (_transform.childCount == 0)
|
_rootBone._natives[_index]._boneAxis = Vector3.down;
|
||||||
{
|
_rootBone._natives[_index]._initBoneDistance = 1f;
|
||||||
_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()
|
public void CreateCollisionIndexList() {
|
||||||
{
|
_collisionIndexList = new List<int>();
|
||||||
_collisionIndexList = new List<int>();
|
_rootBone._natives[_index]._activeCollision = 0;
|
||||||
_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;
|
||||||
}
|
}
|
||||||
|
_rootBone._natives[_index]._activeCollision++;
|
||||||
|
}
|
||||||
|
|
||||||
protected void AddCollisionIndex(int i)
|
public void GatherSpring() {
|
||||||
{
|
if (_root.sqartDeltaTime == 0f) {
|
||||||
CollisionIndexList.Add(i);
|
_transform.localRotation = _rootBone._natives[_index]._initLocalRotation;
|
||||||
switch (_rootBone._natives[_index]._activeCollision)
|
} else {
|
||||||
{
|
_rootBone._natives[_index]._existCollision = _rootBone.ApplyCollision;
|
||||||
case 0:
|
if (_index == 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]._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 * _transform.parent.rotation;
|
||||||
_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()
|
public void PostSpring() {
|
||||||
{
|
if (_root.sqartDeltaTime != 0f) {
|
||||||
_rootBone._natives[_index]._existCollision = _rootBone.ApplyCollision;
|
_transform.rotation = _rootBone._natives[_index]._finalRotation;
|
||||||
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()
|
public virtual bool Reset(bool bForceReset = true) {
|
||||||
{
|
if (_transform == null || (_rootBone._natives[_index]._gravity != 0f && !bForceReset)) {
|
||||||
if (_element == null)
|
return false;
|
||||||
{
|
|
||||||
_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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
_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 * _transform.parent.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) ? _rootBone.ChildBoneList[_index - 1].BoneName : _boneName;
|
||||||
|
CySpringParamDataChildElement cySpringParamDataChildElement = _rootBone.ChildElements.Find((CySpringParamDataChildElement child) => child._boneName == 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) {
|
||||||
|
foreach (string collisionName in cySpringParamDataChildElement._collisionNameList) {
|
||||||
|
for (int i = 0; i < _root.CollisionList.Count; i++) {
|
||||||
|
CySpringCollisionComponent cySpringCollisionComponent = _root.CollisionList[i];
|
||||||
|
if (!(collisionName != cySpringCollisionComponent.name)) {
|
||||||
|
AddCollisionIndex((short) i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 52288e519468a4348829dd3d858d92f2
|
guid: f72cf3c1db1c25c4da188511e7a185d4
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -1,56 +1,32 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CySpringCollision : MonoBehaviour
|
public class CySpringCollision : MonoBehaviour {
|
||||||
{
|
[SerializeField]
|
||||||
[SerializeField]
|
private CySpringCollisionDataAsset _collisionData;
|
||||||
private CySpringCollisionDataAsset _collisionData;
|
|
||||||
|
|
||||||
private float _collisionScale = 1f;
|
public void Create(CySpringCollisionDataAsset data, HashSet<string> setUsableCollision) {
|
||||||
|
_collisionData = data;
|
||||||
public float CollisionScale
|
if (!(_collisionData == null)) {
|
||||||
{
|
foreach (CySpringCollisionData data2 in _collisionData._dataList) {
|
||||||
get
|
if (setUsableCollision.Contains(data2.collisionName)) {
|
||||||
{
|
data2.Create(this);
|
||||||
return _collisionScale;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_collisionScale = value;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Create(CySpringCollisionDataAsset data, HashSet<string> setUsableCollision)
|
public void Create(CySpringCollisionDataAsset data) {
|
||||||
{
|
_collisionData = data;
|
||||||
_collisionData = data;
|
if (!(_collisionData == null)) {
|
||||||
if (_collisionData == null)
|
foreach (CySpringCollisionData data2 in _collisionData._dataList) {
|
||||||
{
|
data2.Create(this);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
foreach (CySpringCollisionData data2 in _collisionData.dataList)
|
|
||||||
{
|
|
||||||
if (setUsableCollision.Contains(data2.collisionName))
|
|
||||||
{
|
|
||||||
data2.Create(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Create(CySpringCollisionDataAsset data)
|
public CySpringCollisionComponent CreateCollision(string targetName, string collisionName, float radius) {
|
||||||
{
|
CySpringCollisionData data = new CySpringCollisionData(collisionName, targetName, Vector3.zero, radius);
|
||||||
_collisionData = data;
|
return data.Create(this);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: afc6a4ef6252e2a459183f023b76a243
|
guid: c64329c27c4704f4ba12ba8bc036e2d7
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
+77
-165
@@ -1,187 +1,99 @@
|
|||||||
using System;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CySpringCollisionComponent : MonoBehaviour
|
public class CySpringCollisionComponent : MonoBehaviour {
|
||||||
{
|
public enum ePurpose {
|
||||||
public enum ePurpose
|
None = 0,
|
||||||
{
|
Generic = 1,
|
||||||
None = 0,
|
Union = 2,
|
||||||
Generic = 1,
|
Ground = 4
|
||||||
Union = 2,
|
}
|
||||||
Ground = 4
|
|
||||||
|
[SerializeField]
|
||||||
|
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;
|
||||||
|
|
||||||
|
public float Radius {
|
||||||
|
get {
|
||||||
|
return _radius;
|
||||||
}
|
}
|
||||||
|
set {
|
||||||
[NonSerialized]
|
_radius = value;
|
||||||
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
|
public CySpringCollisionData.CollisionType CollisionType {
|
||||||
{
|
get {
|
||||||
get
|
return _collisionType;
|
||||||
{
|
|
||||||
return _collisionType;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_collisionType = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
set {
|
||||||
public Vector3 Offset
|
_collisionType = value;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _offset;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_offset = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3 Offset2
|
public Vector3 Offset {
|
||||||
{
|
get {
|
||||||
get
|
return _offset;
|
||||||
{
|
|
||||||
return _offset2;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_offset2 = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
set {
|
||||||
public Vector3 Rotation
|
_offset = value;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _offset2;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_offset2 = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Transform cacheTransform => _cacheTransform;
|
public Vector3 Offset2 {
|
||||||
|
get {
|
||||||
public Vector3 unionCollisionPosition => _unionCollisionPosition;
|
return _offset2;
|
||||||
|
|
||||||
public ePurpose purpose
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _purpose;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_purpose = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
set {
|
||||||
private void Awake()
|
_offset2 = value;
|
||||||
{
|
|
||||||
_cacheTransform = GetComponent<Transform>();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateUnionCollision()
|
public ePurpose purpose {
|
||||||
{
|
get {
|
||||||
_unionCollisionPosition = _cacheTransform.position;
|
return _purpose;
|
||||||
}
|
}
|
||||||
|
set {
|
||||||
|
_purpose = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void EnableUnionCollision(bool bEnable)
|
public Vector3 unionCollisionPosition {
|
||||||
{
|
get {
|
||||||
_collisionType = ((!bEnable) ? CySpringCollisionData.CollisionType.None : CySpringCollisionData.CollisionType.Sphere);
|
return _unionCollisionPosition;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateNativeParameter()
|
public Transform cacheTransform {
|
||||||
{
|
get {
|
||||||
if (_nativeClothCollision == null)
|
return _cacheTransform;
|
||||||
{
|
|
||||||
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)
|
private void Awake() {
|
||||||
{
|
_cacheTransform = GetComponent<Transform>();
|
||||||
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)
|
public void UpdateUnionCollision() {
|
||||||
{
|
_unionCollisionPosition = _cacheTransform.position;
|
||||||
_nativeIndex = index;
|
}
|
||||||
_nativeClothCollision = collision;
|
|
||||||
_nativeClothCollision[index]._radius = Radius;
|
public void EnableUnionCollision(bool bEnable) {
|
||||||
_nativeClothCollision[index]._type = (int)CollisionType;
|
if (bEnable) {
|
||||||
_nativeClothCollision[index]._purpose = (int)purpose;
|
_collisionType = CySpringCollisionData.CollisionType.Sphere;
|
||||||
_nativeClothCollision[index]._parentIndex = parentIndex;
|
} else {
|
||||||
UpdateNativeParameter();
|
_collisionType = CySpringCollisionData.CollisionType.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a4eeb268d14c0f145b33f7bebd4a513f
|
guid: 7ff0dd5461bcc0d4ca7a1faa9c28269d
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -9,59 +9,38 @@ public class CySpringCollisionData
|
|||||||
Sphere,
|
Sphere,
|
||||||
None,
|
None,
|
||||||
Capsule,
|
Capsule,
|
||||||
Plane,
|
Plane
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string CollisionScaleTargetName = "S_Col";
|
[SerializeField]
|
||||||
|
public string _collisionName;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private string _collisionName;
|
public string _targetObjectName;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private string _targetObjectName;
|
public Vector3 _offset;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Vector3 _offset;
|
public Vector3 _offset2;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Vector3 _offset2;
|
public float _radius;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private float _radius;
|
public CollisionType _type;
|
||||||
|
|
||||||
[SerializeField]
|
public Transform _transform;
|
||||||
private CollisionType _type;
|
|
||||||
|
|
||||||
private Transform _transform;
|
|
||||||
|
|
||||||
public bool _isOtherTarget;
|
|
||||||
public float _distance;
|
public float _distance;
|
||||||
public Vector3 _normal;
|
public Vector3 _normal;
|
||||||
public bool _isInner;
|
public bool _isInner;
|
||||||
|
|
||||||
public string collisionName
|
public string collisionName
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _collisionName;
|
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)
|
public CySpringCollisionData(string collisionName, string targetObjectName, Vector3 offset, float radius)
|
||||||
@@ -89,7 +68,7 @@ public class CySpringCollisionData
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (_collisionName == "")
|
if (_collisionName == string.Empty)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -104,24 +83,19 @@ public class CySpringCollisionData
|
|||||||
}
|
}
|
||||||
GameObject gameObject2 = new GameObject();
|
GameObject gameObject2 = new GameObject();
|
||||||
_transform = gameObject2.transform;
|
_transform = gameObject2.transform;
|
||||||
_transform.SetParent(gameObject.transform, worldPositionStays: false);
|
_transform.SetParent(gameObject.transform, false);
|
||||||
float num = 1f;
|
|
||||||
if (_collisionName.IndexOf("S_Col", StringComparison.Ordinal) == 0)
|
|
||||||
{
|
|
||||||
num = root.CollisionScale;
|
|
||||||
}
|
|
||||||
switch (_type)
|
switch (_type)
|
||||||
{
|
{
|
||||||
case CollisionType.Sphere:
|
case CollisionType.Sphere:
|
||||||
_transform.position += _offset * num;
|
_transform.position += _offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_transform.name = _collisionName;
|
_transform.name = _collisionName;
|
||||||
CySpringCollisionComponent cySpringCollisionComponent = gameObject2.AddComponent<CySpringCollisionComponent>();
|
CySpringCollisionComponent cySpringCollisionComponent = gameObject2.AddComponent<CySpringCollisionComponent>();
|
||||||
cySpringCollisionComponent.CollisionType = _type;
|
cySpringCollisionComponent.CollisionType = _type;
|
||||||
cySpringCollisionComponent.Radius = _radius * num;
|
cySpringCollisionComponent.Radius = _radius;
|
||||||
cySpringCollisionComponent.Offset = _offset * num;
|
cySpringCollisionComponent.Offset = _offset;
|
||||||
cySpringCollisionComponent.Offset2 = _offset2 * num;
|
cySpringCollisionComponent.Offset2 = _offset2;
|
||||||
return cySpringCollisionComponent;
|
return cySpringCollisionComponent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: b8adb6395b4ed9e4fb0e4ab25dc6b4e9
|
guid: 3aa601d889d2e614ea2105b8c1af029a
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -1,56 +1,13 @@
|
|||||||
// CySpringCollisionDataAsset
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CySpringCollisionDataAsset : ScriptableObject
|
// public class CySpringCollisionDataAsset : ScriptableObject {
|
||||||
{
|
// [SerializeField]
|
||||||
[SerializeField]
|
// public List<CySpringCollisionData> _dataList;
|
||||||
private List<CySpringCollisionData> _dataList;
|
// }
|
||||||
|
|
||||||
[SerializeField]
|
[Serializable]
|
||||||
private List<CySpringPartsCollisionData> _partsDataList = new List<CySpringPartsCollisionData>();
|
public class CySpringCollisionDataAsset {
|
||||||
|
public List<CySpringCollisionData> _dataList;
|
||||||
[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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: bb6ffe81e81ab0440af942441a44e1d7
|
guid: 36e9e120714863e4f8665e51c85c9434
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -2,212 +2,127 @@ using System;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public struct CySpringNative
|
public struct CySpringNative {
|
||||||
{
|
private const string LibraryName = "cyspringandroid";
|
||||||
private const string LibraryName = "CySpringPlugin";
|
|
||||||
|
|
||||||
public static bool isNative = true;
|
public static bool isNative = true;
|
||||||
|
|
||||||
public NativeClothWorking _clothWorking;
|
public NativeClothWorking _clothWorking;
|
||||||
|
|
||||||
[DllImport("CySpringPlugin")]
|
[DllImport("cyspringandroid")]
|
||||||
private static extern void NativeClothUpdate(IntPtr cond, int nCond, IntPtr collisions, IntPtr clothParams, IntPtr parentWorldPosition, IntPtr parentWorldRotation);
|
private static extern void NativeClothUpdate(IntPtr cond, int nCond, IntPtr collisions, float stiffnessForceRate, float dragForceRate, float gravityRate, bool bCollisionSwitch);
|
||||||
/*
|
|
||||||
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)による物理演算は無効化
|
//private unsafe static void UpdateNativeClothInternal(NativeClothWorking[] clothWorking, int nClothWorking, NativeClothCollision[] collisions, float stiffnessForceRate, float dragForceRate, float gravityRate, bool bCollisionSwitch)
|
||||||
if (isNative)
|
//{
|
||||||
{
|
/*
|
||||||
UpdateNativeClothInternal(clothWorkings, collisions, clothParam, parentCollisionWorldPosition, _collisionParentWorldRotation);
|
//IL_001f: Incompatible stack types: I vs Ref
|
||||||
return;
|
fixed (NativeClothWorking* value = &clothWorking[0])
|
||||||
}
|
{
|
||||||
|
fixed (NativeClothCollision* value2 = &((collisions != null && collisions.Length != 0) ? ref collisions[0] : ref *(NativeClothCollision*)null))
|
||||||
|
{
|
||||||
|
NativeClothUpdate((IntPtr)(void*)value, nClothWorking, (IntPtr)(void*)value2, stiffnessForceRate, dragForceRate, gravityRate, bCollisionSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
//}
|
||||||
|
|
||||||
for (int i = 1; i < num; i++)
|
public static void UpdateNativeCloth(NativeClothWorking[] clothWorkings, int clothWorkingCount, NativeClothCollision[] collisions, float stiffnessForceRate, float dragForceRate, float gravityRate, bool bCollisionSwitch) {
|
||||||
{
|
if (!clothWorkings[0]._isSkip) {
|
||||||
clothWorkings[i]._oldPosition = clothWorkings[i - 1]._currentPosition;
|
/*
|
||||||
clothWorkings[i]._oldRotation = clothWorkings[i]._initLocalRotation * clothWorkings[i - 1]._finalRotation;
|
if (isNative)
|
||||||
}
|
{
|
||||||
for (int j = 0; j < num; j++)
|
UpdateNativeClothInternal(clothWorkings, clothWorkingCount, collisions, stiffnessForceRate, dragForceRate, gravityRate, bCollisionSwitch);
|
||||||
{
|
}
|
||||||
UpdateNativeClothInternalMono(ref clothWorkings[j], collisions, ref clothParam[0], parentCollisionWorldPosition, _collisionParentWorldRotation);
|
else
|
||||||
}
|
{
|
||||||
|
*/
|
||||||
|
for (int i = 1; i < clothWorkingCount; i++) {
|
||||||
|
clothWorkings[i]._oldPosition = clothWorkings[i - 1]._currentPosition;
|
||||||
|
clothWorkings[i]._oldRotation = clothWorkings[i]._initLocalRotation * clothWorkings[i - 1]._finalRotation;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < clothWorkingCount; j++) {
|
||||||
|
UpdateNativeClothInternalMono(ref clothWorkings[j], collisions, stiffnessForceRate, dragForceRate, gravityRate, bCollisionSwitch);
|
||||||
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UpdateNativeClothInternalMono(ref NativeClothWorking clothWorking, NativeClothCollision[] collisions, float stiffnessForceRate, float dragForceRate, float gravityRate, bool bCollisionSwitch) {
|
||||||
|
clothWorking._diff = clothWorking._prevPosition - clothWorking._currentPosition;
|
||||||
|
clothWorking._prevPosition = clothWorking._currentPosition;
|
||||||
|
clothWorking._aimVector = clothWorking._oldRotation * clothWorking._boneAxis;
|
||||||
|
clothWorking._force = clothWorking._aimVector * clothWorking._stiffnessForce * stiffnessForceRate;
|
||||||
|
clothWorking._force += clothWorking._diff * clothWorking._dragForce * dragForceRate;
|
||||||
|
clothWorking._force += clothWorking._springForce;
|
||||||
|
clothWorking._force.y -= clothWorking._gravity * gravityRate;
|
||||||
|
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 && bCollisionSwitch) {
|
||||||
|
int[] array = new int[16] {
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
private static void UpdateNativeClothInternalMono(ref NativeClothWorking clothWorking, NativeClothCollision[] collisions, ref NativeClothParameter clothParam, Vector3[] parentWorldPosition, Quaternion[] parentWorldRotation)
|
for (int i = 0; i < clothWorking._activeCollision; i++) {
|
||||||
{
|
int num = array[i];
|
||||||
clothWorking._diff = clothWorking._prevPosition - clothWorking._currentPosition;
|
NativeClothCollision nativeClothCollision = collisions[num];
|
||||||
clothWorking._prevPosition = clothWorking._currentPosition;
|
switch (nativeClothCollision._type) {
|
||||||
clothWorking._aimVector = clothWorking._oldRotation * clothWorking._boneAxis;
|
case 0:
|
||||||
clothWorking._force = clothWorking._aimVector * clothWorking._stiffnessForce * clothParam._stiffnessForceRate;
|
if (Vector3.Distance(clothWorking._currentPosition, nativeClothCollision._position) <= clothWorking._collisionRadius + nativeClothCollision._radius) {
|
||||||
clothWorking._force += clothWorking._diff * clothWorking._dragForce * clothParam._dragForceRate;
|
Vector3 normalized3 = (clothWorking._currentPosition - nativeClothCollision._position).normalized;
|
||||||
clothWorking._force += clothWorking._springForce;
|
clothWorking._currentPosition = nativeClothCollision._position + normalized3 * (clothWorking._collisionRadius + nativeClothCollision._radius);
|
||||||
if ((clothWorking._capability & CySpring.eCapability.GravityControl) != 0)
|
clothWorking._currentPosition = (clothWorking._currentPosition - clothWorking._oldPosition).normalized * clothWorking._initBoneDistance + clothWorking._oldPosition;
|
||||||
{
|
|
||||||
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)
|
break;
|
||||||
|
case 2:
|
||||||
{
|
{
|
||||||
float num = clothWorking._gravity * clothParam._gravityRate;
|
Vector3 a = nativeClothCollision._position2 - nativeClothCollision._position;
|
||||||
vector = clothWorking._oldRotation * vector * num;
|
float magnitude = a.magnitude;
|
||||||
clothWorking._force -= vector;
|
a /= magnitude;
|
||||||
}
|
Vector3 vector = clothWorking._currentPosition - nativeClothCollision._position;
|
||||||
}
|
float num2 = Vector3.Dot(vector, a);
|
||||||
else
|
bool flag = false;
|
||||||
{
|
if (0f <= num2 && num2 < magnitude) {
|
||||||
clothWorking._force.y -= clothWorking._gravity * clothParam._gravityRate;
|
Vector3 b = a * num2;
|
||||||
}
|
Vector3 a2 = vector - b;
|
||||||
if (((uint)clothWorking._wind & (true ? 1u : 0u)) != 0)
|
float magnitude2 = a2.magnitude;
|
||||||
{
|
if (magnitude2 < clothWorking._collisionRadius + nativeClothCollision._radius) {
|
||||||
clothWorking._force = Vector3.Scale(clothWorking._force, clothParam._forceScale);
|
clothWorking._currentPosition = nativeClothCollision._position + b + a2 * ((clothWorking._collisionRadius + nativeClothCollision._radius) / magnitude2);
|
||||||
clothWorking._force += clothWorking._windPower;
|
clothWorking._currentPosition = (clothWorking._currentPosition - clothWorking._oldPosition).normalized * clothWorking._initBoneDistance + clothWorking._oldPosition;
|
||||||
}
|
flag = true;
|
||||||
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;
|
}
|
||||||
|
if (!flag) {
|
||||||
|
if (Vector3.Distance(clothWorking._currentPosition, nativeClothCollision._position) <= clothWorking._collisionRadius + nativeClothCollision._radius) {
|
||||||
|
Vector3 normalized = (clothWorking._currentPosition - nativeClothCollision._position).normalized;
|
||||||
|
clothWorking._currentPosition = nativeClothCollision._position + normalized * (clothWorking._collisionRadius + nativeClothCollision._radius);
|
||||||
|
clothWorking._currentPosition = (clothWorking._currentPosition - clothWorking._oldPosition).normalized * clothWorking._initBoneDistance + clothWorking._oldPosition;
|
||||||
|
} else if (Vector3.Distance(clothWorking._currentPosition, nativeClothCollision._position2) <= clothWorking._collisionRadius + nativeClothCollision._radius) {
|
||||||
|
Vector3 normalized2 = (clothWorking._currentPosition - nativeClothCollision._position2).normalized;
|
||||||
|
clothWorking._currentPosition = nativeClothCollision._position2 + normalized2 * (clothWorking._collisionRadius + nativeClothCollision._radius);
|
||||||
|
clothWorking._currentPosition = (clothWorking._currentPosition - clothWorking._oldPosition).normalized * clothWorking._initBoneDistance + clothWorking._oldPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clothWorking._finalRotation = Quaternion.FromToRotation(clothWorking._aimVector, clothWorking._diff) * clothWorking._oldRotation;
|
}
|
||||||
}
|
}
|
||||||
|
clothWorking._finalRotation = Quaternion.FromToRotation(clothWorking._aimVector, clothWorking._diff) * clothWorking._oldRotation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 4a68b14e3f18fc348a25777b6947480d
|
guid: d724f99a9f07aab4d97fd9c4f08d8b9a
|
||||||
timeCreated: 1534933219
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -2,54 +2,12 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CySpringParamDataAsset : ScriptableObject
|
// public class CySpringParamDataAsset : ScriptableObject {
|
||||||
{
|
// [SerializeField]
|
||||||
[SerializeField]
|
// public List<CySpringParamDataElement> _elements;
|
||||||
private List<CySpringParamDataElement> _elements;
|
// }
|
||||||
|
|
||||||
[SerializeField]
|
[Serializable]
|
||||||
private List<CySpringPartsParamDataElement> _partsElements = new List<CySpringPartsParamDataElement>();
|
public class CySpringParamDataAsset {
|
||||||
|
public List<CySpringParamDataElement> _elements;
|
||||||
[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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: b1e00a451c86371438af181589f578b3
|
guid: fbe6e2f0ac5d93f4999cf9f445570edc
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
+2
-3
@@ -3,8 +3,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CySpringParamDataChildElement
|
public class CySpringParamDataChildElement {
|
||||||
{
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
public string _boneName;
|
public string _boneName;
|
||||||
|
|
||||||
@@ -41,4 +40,4 @@ public class CySpringParamDataChildElement
|
|||||||
public Vector3 _limitAngleMin;
|
public Vector3 _limitAngleMin;
|
||||||
public Vector3 _limitAngleMax;
|
public Vector3 _limitAngleMax;
|
||||||
public float MoveSpringApplyRate;
|
public float MoveSpringApplyRate;
|
||||||
}
|
}
|
||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 47e7f41f75eab62468171e3df8977325
|
guid: c7204d0fc9ac4dc41bdf2abd261f749b
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CySpringParamDataElement
|
public class CySpringParamDataElement {
|
||||||
{
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
public string _boneName;
|
public string _boneName;
|
||||||
|
|
||||||
@@ -45,4 +44,4 @@ public class CySpringParamDataElement
|
|||||||
public float _horizontalWindRateSlow;
|
public float _horizontalWindRateSlow;
|
||||||
public float _verticalWindRateFast;
|
public float _verticalWindRateFast;
|
||||||
public float _horizontalWindRateFast;
|
public float _horizontalWindRateFast;
|
||||||
}
|
}
|
||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 155f1045b454be546a9be77add067068
|
guid: 2456307e22521d741b68138639d9c3ac
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
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
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e325b7e40ac15f04da8aff7ec7f1ac54
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,357 +1,140 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CySpringRootBone : CySpringBoneBase
|
public class CySpringRootBone : CySpringBoneBase {
|
||||||
{
|
public List<string> _collisionNameList;
|
||||||
public struct OverrideParameter
|
|
||||||
{
|
|
||||||
public bool enableGravity;
|
|
||||||
|
|
||||||
public float gravity;
|
private List<CySpringParamDataChildElement> _childElements;
|
||||||
|
|
||||||
public bool enableStiffness;
|
private int _depth;
|
||||||
|
|
||||||
public float stiffness;
|
private List<CySpringBoneBase> _childBoneList;
|
||||||
|
|
||||||
public bool enableDragForce;
|
private bool _applyCollision = true;
|
||||||
|
|
||||||
public float dragForce;
|
public NativeClothWorking[] _natives;
|
||||||
|
|
||||||
|
public bool _isSkip;
|
||||||
|
|
||||||
|
public bool ApplyCollision {
|
||||||
|
get {
|
||||||
|
return _applyCollision;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public const float DefaultSuppressionLength = 1f;
|
public List<CySpringParamDataChildElement> ChildElements {
|
||||||
|
get {
|
||||||
public List<string> _collisionNameList;
|
return _childElements;
|
||||||
|
|
||||||
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
|
public List<CySpringBoneBase> ChildBoneList {
|
||||||
{
|
get {
|
||||||
get
|
return _childBoneList;
|
||||||
{
|
|
||||||
return _suppressionLength;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_suppressionLength = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<CySpringBoneBase> TmpChildBoneList => _tmpChildBoneList;
|
public void CreateRoot(CySpringParamDataElement element, CySpring root, CySpringRootBone rootBone, CySpringBoneBase parentBone) {
|
||||||
|
_boneName = element._boneName;
|
||||||
public void CreateRoot(CySpringParamDataElement element, CySpring root, CySpringRootBone rootBone, CySpringBoneBase parentBone)
|
_collisionNameList = element._collisionNameList;
|
||||||
{
|
_childElements = element._childElements;
|
||||||
_boneName = element._boneName;
|
Transform transform = root.gameObject.transform;
|
||||||
_collisionNameList = element._collisionNameList;
|
Vector3 position = transform.position;
|
||||||
_childElements = element._childElements;
|
Quaternion rotation = transform.rotation;
|
||||||
_rootElement = element;
|
transform.position = Vector3.zero;
|
||||||
_isRootElement = _rootElement != null;
|
transform.rotation = Quaternion.identity;
|
||||||
Transform transform = root.gameObject.transform;
|
Create(root, rootBone, parentBone);
|
||||||
Vector3 position = transform.position;
|
if (_exist) {
|
||||||
Quaternion rotation = transform.rotation;
|
_childBoneList = new List<CySpringBoneBase>();
|
||||||
transform.position = Vector3.zero;
|
foreach (Transform item in _transform) {
|
||||||
transform.rotation = Quaternion.identity;
|
if (!(item == _transform) && !(item.GetComponent<CySpringCollisionComponent>() != null)) {
|
||||||
Create(root, rootBone, parentBone);
|
CySpringBoneBase cySpringBoneBase = new CySpringBoneBase(item.name);
|
||||||
if (!_exist)
|
_childBoneList.Add(cySpringBoneBase);
|
||||||
{
|
cySpringBoneBase.CreateChild(_root, _rootBone, this);
|
||||||
transform.position = position;
|
|
||||||
transform.rotation = rotation;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
_tmpChildBoneList = new List<CySpringBoneBase>();
|
}
|
||||||
foreach (Transform item in _transform)
|
_depth = _childBoneList.Count;
|
||||||
{
|
_natives = new NativeClothWorking[_childBoneList.Count + 1];
|
||||||
if (!(item == _transform) && !(item.GetComponent<CySpringCollisionComponent>() != null))
|
for (int i = 0; i < _natives.Length; i++) {
|
||||||
{
|
_natives[i]._stiffnessForce = 0.0001f;
|
||||||
CySpringBoneBase cySpringBoneBase = new CySpringBoneBase(item.name);
|
_natives[i]._dragForce = 0.05f;
|
||||||
_tmpChildBoneList.Add(cySpringBoneBase);
|
_natives[i]._springForce = new Vector3(0f, 0f, 0f);
|
||||||
cySpringBoneBase.CreateChild(_root, _rootBone, this);
|
_natives[i]._collisionRadius = 0.01f;
|
||||||
}
|
_natives[i]._boneAxis = new Vector3(0f, 1f, 0f);
|
||||||
}
|
_natives[i]._gravity = 0f;
|
||||||
_childBoneList = _tmpChildBoneList.ToArray();
|
}
|
||||||
_tmpChildBoneList = null;
|
Initialize(0);
|
||||||
_depth = _childBoneList.Length;
|
for (int j = 0; j < _childBoneList.Count; j++) {
|
||||||
_natives = new NativeClothWorking[_childBoneList.Length + 1];
|
_childBoneList[j].Initialize(j + 1);
|
||||||
for (int i = 0; i < _natives.Length; i++)
|
}
|
||||||
{
|
_natives[0]._stiffnessForce = element._stiffnessForce;
|
||||||
_natives[i]._stiffnessForce = 0.0001f;
|
_natives[0]._dragForce = element._dragForce;
|
||||||
_natives[i]._dragForce = 0.05f;
|
_natives[0]._springForce = element._springForce;
|
||||||
_natives[i]._springForce = new Vector3(0f, 0f, 0f);
|
_natives[0]._collisionRadius = element._collisionRadius;
|
||||||
_natives[i]._collisionRadius = 0.01f;
|
_natives[0]._gravity = element._gravity;
|
||||||
_natives[i]._boneAxis = new Vector3(0f, 1f, 0f);
|
transform.position = position;
|
||||||
_natives[i]._gravity = 0f;
|
transform.rotation = rotation;
|
||||||
_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)
|
private void UpdateCollisionIndexList() {
|
||||||
{
|
if (_collisionNameList != null && _collisionNameList.Count != 0 && _root.CollisionList != null && _root.CollisionList.Count != 0) {
|
||||||
_hasOftenAccessedParent = false;
|
CreateCollisionIndexList();
|
||||||
if (_parentTransform != null && _parentTransform.name.Equals(oftenAccessedParent))
|
foreach (string collisionName in _collisionNameList) {
|
||||||
{
|
for (int i = 0; i < _root.CollisionList.Count; i++) {
|
||||||
_hasOftenAccessedParent = true;
|
CySpringCollisionComponent cySpringCollisionComponent = _root.CollisionList[i];
|
||||||
|
if (!(collisionName != cySpringCollisionComponent.name)) {
|
||||||
|
AddCollisionIndex(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _hasOftenAccessedParent;
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateCollisionIndexList()
|
public void SetCollision() {
|
||||||
{
|
UpdateCollisionIndexList();
|
||||||
if (_collisionNameList == null || _collisionNameList.Count == 0 || _root.CollisionList == null || _root.CollisionList.Length == 0)
|
ChangeRootValue();
|
||||||
{
|
}
|
||||||
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()
|
public void GathreAllSpring() {
|
||||||
{
|
if (_depth < 0) {
|
||||||
UpdateCollisionIndexList();
|
_isSkip = true;
|
||||||
ChangeRootValue();
|
} else {
|
||||||
|
_isSkip = false;
|
||||||
|
GatherSpring();
|
||||||
|
for (int i = 0; i < _childBoneList.Count; i++) {
|
||||||
|
_childBoneList[i].GatherSpring();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void DoGatherAllSpring(ref Quaternion oftenAccessedParentRot)
|
public void PostAllSpring() {
|
||||||
{
|
if (!_isSkip) {
|
||||||
if (_depth < 0)
|
PostSpring();
|
||||||
{
|
for (int i = 0; i < _childBoneList.Count; i++) {
|
||||||
_isSkip = true;
|
_childBoneList[i].PostSpring();
|
||||||
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)
|
public override bool Reset(bool bForceReset = true) {
|
||||||
{
|
if (base.Reset(bForceReset)) {
|
||||||
if (_depth < 0)
|
if (_childBoneList == null) {
|
||||||
{
|
return false;
|
||||||
_isSkip = true;
|
}
|
||||||
return;
|
foreach (CySpringBoneBase childBone in _childBoneList) {
|
||||||
}
|
childBone.Reset(bForceReset);
|
||||||
_isSkip = false;
|
}
|
||||||
UpdateNativeOldTransform(ref oftenAccessedParentRot);
|
|
||||||
DoGatherSpringReset();
|
|
||||||
CySpringBoneBase[] childBoneList = _childBoneList;
|
|
||||||
for (int i = 0; i < childBoneList.Length; i++)
|
|
||||||
{
|
|
||||||
childBoneList[i].DoGatherSpringReset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateNativeOldTransform(ref Quaternion oftenAccessedParentRot)
|
public void ChangeRootValue() {
|
||||||
{
|
if (_childBoneList != null) {
|
||||||
Vector3 position = _transform.position;
|
_rootBone._natives[_index]._existCollision = _rootBone._applyCollision;
|
||||||
if (_hasOftenAccessedParent)
|
foreach (CySpringBoneBase childBone in _childBoneList) {
|
||||||
{
|
childBone.ChangeValue();
|
||||||
_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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 068d2ea4974c10b469f8b880d2eac4c8
|
guid: 5eae7a625f67160458b202535df3f4f7
|
||||||
timeCreated: 1534933097
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct NativeClothCollision
|
public struct NativeClothCollision {
|
||||||
{
|
[FieldOffset(0)]
|
||||||
[FieldOffset(0)]
|
public Vector3 _position;
|
||||||
public Vector3 _position;
|
[FieldOffset(16)]
|
||||||
|
public Vector3 _position2;
|
||||||
[FieldOffset(16)]
|
[FieldOffset(32)]
|
||||||
public Vector3 _position2;
|
public int _type;
|
||||||
|
[FieldOffset(36)]
|
||||||
[FieldOffset(32)]
|
public float _radius;
|
||||||
public int _type;
|
[FieldOffset(40)]
|
||||||
|
private int _padding1;
|
||||||
[FieldOffset(36)]
|
[FieldOffset(44)]
|
||||||
public float _radius;
|
private int _padding2;
|
||||||
|
}
|
||||||
[FieldOffset(40)]
|
|
||||||
public int _parentIndex;
|
|
||||||
|
|
||||||
[FieldOffset(44)]
|
|
||||||
public int _purpose;
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 374df1be538ee244b9897d3c967d8a1b
|
guid: d995c2b9aa7543246804848ccbf82b1c
|
||||||
timeCreated: 1530511089
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
|
|||||||
@@ -1,138 +1,79 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct NativeClothWorking
|
public struct NativeClothWorking {
|
||||||
{
|
[FieldOffset(0)]
|
||||||
[FieldOffset(0)]
|
public Quaternion _initLocalRotation;
|
||||||
public Quaternion _initLocalRotation;
|
[FieldOffset(16)]
|
||||||
|
public Quaternion _oldRotation;
|
||||||
[FieldOffset(16)]
|
[FieldOffset(32)]
|
||||||
public Quaternion _oldRotation;
|
public Quaternion _finalRotation;
|
||||||
|
[FieldOffset(48)]
|
||||||
[FieldOffset(32)]
|
public Vector3 _boneAxis;
|
||||||
public Quaternion _finalRotation;
|
[FieldOffset(64)]
|
||||||
|
public Vector3 _currentPosition;
|
||||||
[FieldOffset(48)]
|
[FieldOffset(80)]
|
||||||
public Vector3 _boneAxis;
|
public Vector3 _prevPosition;
|
||||||
|
[FieldOffset(96)]
|
||||||
[FieldOffset(64)]
|
public Vector3 _force;
|
||||||
public Vector3 _currentPosition;
|
[FieldOffset(112)]
|
||||||
|
public Vector3 _aimVector;
|
||||||
[FieldOffset(80)]
|
[FieldOffset(128)]
|
||||||
public Vector3 _prevPosition;
|
public Vector3 _diff;
|
||||||
|
[FieldOffset(144)]
|
||||||
[FieldOffset(96)]
|
public Vector3 _oldPosition;
|
||||||
public Vector3 _force;
|
[FieldOffset(160)]
|
||||||
|
public Vector3 _springForce;
|
||||||
[FieldOffset(112)]
|
[FieldOffset(176)]
|
||||||
public Vector3 _aimVector;
|
public float _initBoneDistance;
|
||||||
|
[FieldOffset(180)]
|
||||||
[FieldOffset(128)]
|
public float _stiffnessForce;
|
||||||
public Vector3 _diff;
|
[FieldOffset(184)]
|
||||||
|
public float _dragForce;
|
||||||
[FieldOffset(144)]
|
[FieldOffset(188)]
|
||||||
public Vector3 _oldPosition;
|
public float _collisionRadius;
|
||||||
|
[FieldOffset(192)]
|
||||||
[FieldOffset(160)]
|
public float _gravity;
|
||||||
public Vector3 _springForce;
|
[FieldOffset(196)]
|
||||||
|
public int _activeCollision;
|
||||||
[FieldOffset(176)]
|
[FieldOffset(200)]
|
||||||
public Vector3 _windPower;
|
public short _cIndex0;
|
||||||
|
[FieldOffset(202)]
|
||||||
[FieldOffset(192)]
|
public short _cIndex1;
|
||||||
public float _initBoneDistance;
|
[FieldOffset(204)]
|
||||||
|
public short _cIndex2;
|
||||||
[FieldOffset(196)]
|
[FieldOffset(206)]
|
||||||
public float _stiffnessForce;
|
public short _cIndex3;
|
||||||
|
[FieldOffset(208)]
|
||||||
[FieldOffset(200)]
|
public short _cIndex4;
|
||||||
public float _dragForce;
|
[FieldOffset(210)]
|
||||||
|
public short _cIndex5;
|
||||||
[FieldOffset(204)]
|
[FieldOffset(212)]
|
||||||
public float _collisionRadius;
|
public short _cIndex6;
|
||||||
|
[FieldOffset(214)]
|
||||||
[FieldOffset(208)]
|
public short _cIndex7;
|
||||||
public float _gravity;
|
[FieldOffset(216)]
|
||||||
|
public short _cIndex8;
|
||||||
[FieldOffset(212)]
|
[FieldOffset(218)]
|
||||||
public int _activeCollision;
|
public short _cIndex9;
|
||||||
|
[FieldOffset(220)]
|
||||||
[FieldOffset(216)]
|
public short _cIndex10;
|
||||||
public short _cIndex0;
|
[FieldOffset(222)]
|
||||||
|
public short _cIndex11;
|
||||||
[FieldOffset(218)]
|
[FieldOffset(224)]
|
||||||
public short _cIndex1;
|
public short _cIndex12;
|
||||||
|
[FieldOffset(226)]
|
||||||
[FieldOffset(220)]
|
public short _cIndex13;
|
||||||
public short _cIndex2;
|
[FieldOffset(228)]
|
||||||
|
public short _cIndex14;
|
||||||
[FieldOffset(222)]
|
[FieldOffset(230)]
|
||||||
public short _cIndex3;
|
public short _cIndex15;
|
||||||
|
[FieldOffset(232)]
|
||||||
[FieldOffset(224)]
|
public bool _existCollision;
|
||||||
public short _cIndex4;
|
[FieldOffset(226)]
|
||||||
|
public bool _isSkip;
|
||||||
[FieldOffset(226)]
|
[FieldOffset(230)]
|
||||||
public short _cIndex5;
|
private int _padding2;
|
||||||
|
}
|
||||||
[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;
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 9f6d46425af01d84ca3f68f91412489b
|
guid: 17492b14ce1aebe4ab62f7b5f995e0b3
|
||||||
timeCreated: 1530511089
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 94a19af2ebcc39448a7265778a585f83
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 11d7967b797cf2b4e8360b069ecb9f01
|
guid: 15077261ef938f4468a4c4a0ce4e972a
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public class CySpringDataBucket<T> where T : class
|
||||||
|
{
|
||||||
|
private Dictionary<string, List<T>> _mapDataList = new Dictionary<string, List<T>>();
|
||||||
|
|
||||||
|
public Dictionary<string, List<T>> mapDataList => _mapDataList;
|
||||||
|
|
||||||
|
public List<T> GetDataList(string partsCode)
|
||||||
|
{
|
||||||
|
List<T> value = null;
|
||||||
|
if (_mapDataList != null && !_mapDataList.TryGetValue(partsCode, out value))
|
||||||
|
{
|
||||||
|
value = new List<T>();
|
||||||
|
_mapDataList.Add(partsCode, value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 08bcd0f94a23d314e8b3600575b57e65
|
guid: 83d21d2b7a517b24c8dd4460fad2cc16
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a14147a7a11a95048a6802aaa0f1f09e
|
guid: b02b24920ab38e147aa08bd55598aa16
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ca01b287ca68a7f48bc613d156008c9f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Binary file not shown.
+27
@@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 369718b89f259f64bb8530151f3d9cc1
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user