コード例 #1
0
 public static void Add(Mesh mesh, SkinnedMeshRendererCache.RigInfo info)
 {
     if (!SkinnedMeshRendererCache.dictionary.ContainsKey(mesh))
     {
         SkinnedMeshRendererCache.dictionary.Add(mesh, info);
     }
 }
コード例 #2
0
 public static SkinnedMeshRendererCache.RigInfo Get(SkinnedMeshRenderer renderer)
 {
     SkinnedMeshRendererCache.RigInfo rigInfo;
     if (!SkinnedMeshRendererCache.dictionary.TryGetValue(renderer.sharedMesh, out rigInfo))
     {
         rigInfo = new SkinnedMeshRendererCache.RigInfo();
         Transform   transforms      = renderer.rootBone;
         Transform[] transformArrays = renderer.bones;
         if (transforms == null)
         {
             Debug.LogWarning(string.Concat("Renderer without a valid root bone: ", renderer.name, " ", renderer.sharedMesh.name), renderer.gameObject);
             return(rigInfo);
         }
         renderer.transform.position   = Vector3.zero;
         renderer.transform.rotation   = Quaternion.identity;
         renderer.transform.localScale = Vector3.one;
         rigInfo.root     = transforms.name;
         rigInfo.rootHash = rigInfo.root.GetHashCode();
         rigInfo.bones    = (
             from x in (IEnumerable <Transform>) transformArrays
             select x.name).ToArray <string>();
         rigInfo.boneHashes = (
             from x in rigInfo.bones
             select x.GetHashCode()).ToArray <int>();
         rigInfo.transforms = (
             from x in (IEnumerable <Transform>) transformArrays
             select x.transform.localToWorldMatrix).ToArray <Matrix4x4>();
         rigInfo.rootTransform = renderer.rootBone.transform.localToWorldMatrix;
         SkinnedMeshRendererCache.dictionary.Add(renderer.sharedMesh, rigInfo);
     }
     return(rigInfo);
 }
コード例 #3
0
 public static SkinnedMeshRendererCache.RigInfo Get(
     SkinnedMeshRenderer renderer)
 {
     SkinnedMeshRendererCache.RigInfo rigInfo;
     if (!SkinnedMeshRendererCache.dictionary.TryGetValue(renderer.get_sharedMesh(), out rigInfo))
     {
         rigInfo = new SkinnedMeshRendererCache.RigInfo();
         Transform   rootBone = renderer.get_rootBone();
         Transform[] bones    = renderer.get_bones();
         if (Object.op_Equality((Object)rootBone, (Object)null))
         {
             Debug.LogWarning((object)("Renderer without a valid root bone: " + ((Object)renderer).get_name() + " " + ((Object)renderer.get_sharedMesh()).get_name()), (Object)((Component)renderer).get_gameObject());
             return(rigInfo);
         }
         ((Component)renderer).get_transform().set_position(Vector3.get_zero());
         ((Component)renderer).get_transform().set_rotation(Quaternion.get_identity());
         ((Component)renderer).get_transform().set_localScale(Vector3.get_one());
         rigInfo.root          = ((Object)rootBone).get_name();
         rigInfo.rootHash      = rigInfo.root.GetHashCode();
         rigInfo.bones         = ((IEnumerable <Transform>)bones).Select <Transform, string>((Func <Transform, string>)(x => ((Object)x).get_name())).ToArray <string>();
         rigInfo.boneHashes    = ((IEnumerable <string>)rigInfo.bones).Select <string, int>((Func <string, int>)(x => x.GetHashCode())).ToArray <int>();
         rigInfo.transforms    = ((IEnumerable <Transform>)bones).Select <Transform, Matrix4x4>((Func <Transform, Matrix4x4>)(x => ((Component)x).get_transform().get_localToWorldMatrix())).ToArray <Matrix4x4>();
         rigInfo.rootTransform = ((Component)renderer.get_rootBone()).get_transform().get_localToWorldMatrix();
         SkinnedMeshRendererCache.dictionary.Add(renderer.get_sharedMesh(), rigInfo);
     }
     return(rigInfo);
 }
コード例 #4
0
 private void RefreshCache()
 {
     if (this.cachedMesh != this.component.sharedMesh)
     {
         if (this.cachedMesh != null)
         {
             SkinnedMeshRendererCache.Add(this.cachedMesh, this.cachedRig);
         }
         this.cachedMesh = this.component.sharedMesh;
         this.cachedRig  = SkinnedMeshRendererCache.Get(this.component);
     }
 }
コード例 #5
0
 private void RefreshCache()
 {
     if (!Object.op_Inequality((Object)this.cachedMesh, (Object)this.component.get_sharedMesh()))
     {
         return;
     }
     if (Object.op_Inequality((Object)this.cachedMesh, (Object)null))
     {
         SkinnedMeshRendererCache.Add(this.cachedMesh, this.cachedRig);
     }
     this.cachedMesh = this.component.get_sharedMesh();
     this.cachedRig  = SkinnedMeshRendererCache.Get(this.component);
 }