Пример #1
0
        public bool RefreshSync()
        {
            if (_syncTransform_Mesh == null)
            {
                _syncTransform_Mesh = new List <apTransform_Mesh>();
            }
            _syncTransform_Mesh.Clear();

            if (_syncTransform_MeshGroup == null)
            {
                _syncTransform_MeshGroup = new List <apTransform_MeshGroup>();
            }
            _syncTransform_MeshGroup.Clear();

            if (_syncBone == null)
            {
                _syncBone = new List <apBone>();
            }
            _syncBone.Clear();

            //한번이라도 등장한 MeshTransform / MeshGroup Transform을 찾자
            for (int i = 0; i < _paramSetList.Count; i++)
            {
                apModifierParamSet paramSet = _paramSetList[i];

                for (int iModMesh = 0; iModMesh < paramSet._meshData.Count; iModMesh++)
                {
                    apModifiedMesh modMesh = paramSet._meshData[iModMesh];
                    if (modMesh._transform_Mesh != null)
                    {
                        //수정 4.1 : Mesh가 없는 MeshTransform
                        if (modMesh._transform_Mesh._mesh == null)
                        {
                            //Debug.Log("AnyPortrait : Mesh of [" + modMesh._transform_Mesh._nickName + "] is removed. Please check it.");
                        }
                        else
                        {
                            if (!_syncTransform_Mesh.Contains(modMesh._transform_Mesh))
                            {
                                _syncTransform_Mesh.Add(modMesh._transform_Mesh);
                            }
                        }

                        //이전 코드
                        //if (!_syncTransform_Mesh.Contains(modMesh._transform_Mesh))
                        //{
                        //	_syncTransform_Mesh.Add(modMesh._transform_Mesh);
                        //}
                    }
                    if (modMesh._transform_MeshGroup != null)
                    {
                        if (!_syncTransform_MeshGroup.Contains(modMesh._transform_MeshGroup))
                        {
                            _syncTransform_MeshGroup.Add(modMesh._transform_MeshGroup);
                        }
                    }
                }
                for (int iModBone = 0; iModBone < paramSet._boneData.Count; iModBone++)
                {
                    apModifiedBone modBone = paramSet._boneData[iModBone];

                    if (modBone._bone != null)
                    {
                        //>> 이건 Bone Set이 필요없다.
                        if (modBone._meshGroup_Bone != null &&
                            modBone._meshGroup_Bone._boneList_All.Contains(modBone._bone)                               //해당 MeshGroup에 Bone이 존재하는가.
                            )
                        {
                            if (!_syncBone.Contains(modBone._bone))
                            {
                                _syncBone.Add(modBone._bone);
                            }
                        }
                        else
                        {
                            //Modifier로 등록되었지만 Bone이 삭제되었다면 여기로 들어온다.
                            //Sync가 안됨
                        }
                    }
                }
            }

            //동기화 전용 Sync Transform을 모든 ParamSet에 넣자
            bool isAnyChanged = false;

            for (int iSync = 0; iSync < _syncTransform_Mesh.Count; iSync++)
            {
                apTransform_Mesh meshTransform = _syncTransform_Mesh[iSync];
                //bool isAdd = _parentModifier.AddMeshTransformToAllParamSet(_parentModifier._meshGroup, meshTransform, false);
                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddMeshTransformToParamSet(_paramSetList[iParamSet], meshTransform);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            for (int iSync = 0; iSync < _syncTransform_MeshGroup.Count; iSync++)
            {
                apTransform_MeshGroup meshGroupTransform = _syncTransform_MeshGroup[iSync];
                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddMeshGroupTransformToParamSet(_paramSetList[iParamSet], meshGroupTransform);
                    //bool isAdd = _parentModifier.AddMeshGroupTransformToAllParamSet(_parentModifier._meshGroup, meshGroupTransform, false);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            for (int iSync = 0; iSync < _syncBone.Count; iSync++)
            {
                apBone bone = _syncBone[iSync];

                apTransform_MeshGroup meshGroupTransform = null;
                if (_parentModifier._meshGroup == bone._meshGroup)
                {
                    meshGroupTransform = _parentModifier._meshGroup._rootMeshGroupTransform;
                }
                else
                {
                    meshGroupTransform = _parentModifier._meshGroup.FindChildMeshGroupTransform(bone._meshGroup);
                }

                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    //이전
                    //bool isAdd = AddBoneToParamSet(_paramSetList[iParamSet], bone._meshGroup._rootMeshGroupTransform, bone);
                    //변경 : ChildMeshGroup의 Root MGTF로 설정하는 코드는 잘못되었다.
                    bool isAdd = AddBoneToParamSet(_paramSetList[iParamSet], meshGroupTransform, bone);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            //추가 : Sync시 WeightedVertex도 같이 처리해주자
            // 동기화 안된건 자동 삭제
            for (int i = 0; i < _calculatedWeightedVertexList.Count; i++)
            {
                _calculatedWeightedVertexList[i]._isSync = false;
            }

            for (int iSync = 0; iSync < _syncTransform_Mesh.Count; iSync++)
            {
                apTransform_Mesh meshTransform            = _syncTransform_Mesh[iSync];
                apModifierParamSetGroupVertWeight existWV = _calculatedWeightedVertexList.Find(delegate(apModifierParamSetGroupVertWeight a)
                {
                    return(a._meshTransform_ID == meshTransform._transformUniqueID);
                });
                if (existWV != null)
                {
                    existWV._isSync = true;
                    existWV.LinkMeshTransform(meshTransform);
                }
                else
                {
                    //없다. 새로 만들자
                    apModifierParamSetGroupVertWeight newVW = new apModifierParamSetGroupVertWeight(meshTransform);
                    newVW._isSync = true;
                    _calculatedWeightedVertexList.Add(newVW);
                }
            }

            //동기화 되지 않은건 지운다.
            _calculatedWeightedVertexList.RemoveAll(delegate(apModifierParamSetGroupVertWeight a)
            {
                return(!a._isSync);
            });

            return(isAnyChanged);
        }
Пример #2
0
        public bool RefreshSync()
        {
            if (_syncTransform_Mesh == null)
            {
                _syncTransform_Mesh = new List <apTransform_Mesh>();
            }
            _syncTransform_Mesh.Clear();

            if (_syncTransform_MeshGroup == null)
            {
                _syncTransform_MeshGroup = new List <apTransform_MeshGroup>();
            }
            _syncTransform_MeshGroup.Clear();

            if (_syncBone == null)
            {
                _syncBone = new List <apBone>();
            }
            _syncBone.Clear();

            //한번이라도 등장한 MeshTransform / MeshGroup Transform을 찾자
            for (int i = 0; i < _paramSetList.Count; i++)
            {
                apModifierParamSet paramSet = _paramSetList[i];

                for (int iModMesh = 0; iModMesh < paramSet._meshData.Count; iModMesh++)
                {
                    apModifiedMesh modMesh = paramSet._meshData[iModMesh];
                    if (modMesh._transform_Mesh != null)
                    {
                        if (!_syncTransform_Mesh.Contains(modMesh._transform_Mesh))
                        {
                            _syncTransform_Mesh.Add(modMesh._transform_Mesh);
                        }
                    }
                    if (modMesh._transform_MeshGroup != null)
                    {
                        if (!_syncTransform_MeshGroup.Contains(modMesh._transform_MeshGroup))
                        {
                            _syncTransform_MeshGroup.Add(modMesh._transform_MeshGroup);
                        }
                    }
                }
                for (int iModBone = 0; iModBone < paramSet._boneData.Count; iModBone++)
                {
                    apModifiedBone modBone = paramSet._boneData[iModBone];

                    if (modBone._bone != null)
                    {
                        if (modBone._meshGroup_Bone != null && modBone._meshGroup_Bone._boneList_All.Contains(modBone._bone))
                        {
                            if (!_syncBone.Contains(modBone._bone))
                            {
                                _syncBone.Add(modBone._bone);
                            }
                        }
                        else
                        {
                            //Modifier로 등록되었지만 Bone이 삭제되었다면 여기로 들어온다.
                            //Sync가 안됨
                        }
                    }
                }
            }

            //동기화 전용 Sync Transform을 모든 ParamSet에 넣자
            bool isAnyChanged = false;

            for (int iSync = 0; iSync < _syncTransform_Mesh.Count; iSync++)
            {
                apTransform_Mesh meshTransform = _syncTransform_Mesh[iSync];
                //bool isAdd = _parentModifier.AddMeshTransformToAllParamSet(_parentModifier._meshGroup, meshTransform, false);
                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddMeshTransformToParamSet(_paramSetList[iParamSet], meshTransform);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            for (int iSync = 0; iSync < _syncTransform_MeshGroup.Count; iSync++)
            {
                apTransform_MeshGroup meshGroupTransform = _syncTransform_MeshGroup[iSync];
                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddMeshGroupTransformToParamSet(_paramSetList[iParamSet], meshGroupTransform);
                    //bool isAdd = _parentModifier.AddMeshGroupTransformToAllParamSet(_parentModifier._meshGroup, meshGroupTransform, false);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            for (int iSync = 0; iSync < _syncBone.Count; iSync++)
            {
                apBone bone = _syncBone[iSync];

                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddBoneToParamSet(_paramSetList[iParamSet], bone._meshGroup._rootMeshGroupTransform, bone);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            //추가 : Sync시 WeightedVertex도 같이 처리해주자
            // 동기화 안된건 자동 삭제
            for (int i = 0; i < _calculatedWeightedVertexList.Count; i++)
            {
                _calculatedWeightedVertexList[i]._isSync = false;
            }

            for (int iSync = 0; iSync < _syncTransform_Mesh.Count; iSync++)
            {
                apTransform_Mesh meshTransform            = _syncTransform_Mesh[iSync];
                apModifierParamSetGroupVertWeight existWV = _calculatedWeightedVertexList.Find(delegate(apModifierParamSetGroupVertWeight a)
                {
                    return(a._meshTransform_ID == meshTransform._transformUniqueID);
                });
                if (existWV != null)
                {
                    existWV._isSync = true;
                    existWV.LinkMeshTransform(meshTransform);
                }
                else
                {
                    //없다. 새로 만들자
                    apModifierParamSetGroupVertWeight newVW = new apModifierParamSetGroupVertWeight(meshTransform);
                    newVW._isSync = true;
                    _calculatedWeightedVertexList.Add(newVW);
                }
            }

            //동기화 되지 않은건 지운다.
            _calculatedWeightedVertexList.RemoveAll(delegate(apModifierParamSetGroupVertWeight a)
            {
                return(!a._isSync);
            });

            return(isAnyChanged);
        }