public bool Prepare()
{
_Prefix();
if( _isPrepared ) {
return false;
}
_isPrepared = true;
Assert( rootTransform != null );
if( rootTransform != null ) { // Failsafe.
internalValues.defaultRootPosition = rootTransform.position;
internalValues.defaultRootBasis = Matrix3x3.FromColumn( rootTransform.right, rootTransform.up, rootTransform.forward );
internalValues.defaultRootBasisInv = internalValues.defaultRootBasis.transpose;
internalValues.defaultRootRotation = rootTransform.rotation;
}
if( _bones != null ) {
int boneLength = _bones.Length;
for( int i = 0; i != boneLength; ++i ) {
Assert( _bones[i] != null );
if( _bones[i] != null ) {
_bones[i].Prepare( this );
}
}
for( int i = 0; i != boneLength; ++i ) {
if( _bones[i] != null ) {
_bones[i].PostPrepare();
}
}
}
boneCaches.Prepare( this );
if( _effectors != null ) {
int effectorLength = _effectors.Length;
for( int i = 0; i != effectorLength; ++i ) {
Assert( _effectors[i] != null );
if( _effectors[i] != null ) {
_effectors[i].Prepare( this );
}
}
}
if( _limbIK == null || _limbIK.Length != (int)LimbIKLocation.Max ) {
_limbIK = new LimbIK[(int)LimbIKLocation.Max];
}
for( int i = 0; i != (int)LimbIKLocation.Max; ++i ) {
_limbIK[i] = new LimbIK( this, (LimbIKLocation)i );
}
_bodyIK = new BodyIK( this, _limbIK );
_headIK = new HeadIK( this );
if( _fingerIK == null || _fingerIK.Length != (int)FingerIKType.Max ) {
_fingerIK = new FingerIK[(int)FingerIKType.Max];
}
for( int i = 0; i != (int)FingerIKType.Max; ++i ) {
_fingerIK[i] = new FingerIK( this, (FingerIKType)i );
}
{
Bone neckBone = headBones.neck;
Bone leftShoulder = leftArmBones.shoulder;
Bone rightShoulder = rightArmBones.shoulder;
if( leftShoulder != null && leftShoulder.transformIsAlive &&
rightShoulder != null && rightShoulder.transformIsAlive &&
neckBone != null && neckBone.transformIsAlive ) {
if( leftShoulder.transform.parent == neckBone.transform &&
rightShoulder.transform.parent == neckBone.transform ) {
_isNeedFixShoulderWorldTransform = true;
}
}
}
return true;
}