Exemplo n.º 1
0
        /// <summary>
        /// Update를 끝내고 호출해야하는 함수
        /// 갱신된 정보를 RenderVertex 정보로 넣어준다.
        /// Child RenderUnit에 자동으로 호출한다.
        /// </summary>
        /// <param name="isUpdateAlways">Vertex 작업을 하는 상태에서는 True를 넣는다. 재생 전용이고 Gizmo가 안뜨면 False를 넣어주자</param>
        /// <param name="isMatrixCalculateForce">Matrix를 강제로 넣어야 한다. Force 옵션 또는 tDelta > bias일때 true 값을 넣자</param>
        //public void UpdateToRenderVert(float tDelta, bool isUpdateAlways, bool isMatrixCalculateForce, apMeshGroup.FUNC_IS_FORCE_UPDATE funcForceUpdate)
        //public void UpdateToRenderVert(float tDelta, bool isUpdateAlways, bool isMatrixCalculateForce, apMeshGroup.FUNC_IS_FORCE_UPDATE funcForceUpdate)
        public void UpdateToRenderVert(float tDelta, bool isUpdateAlways)
        {
            //강제로 업데이트해야하는지 결정한다.

            //Profiler.BeginSample("1. Func Check");
            //if(!isMatrixCalculateForce && funcForceUpdate != null)
            //{
            //	isMatrixCalculateForce = funcForceUpdate(this);
            //}
            //Profiler.EndSample();

            //Child까지 계산한 이후 Vertex를 계산해줘야 한다.
            if (_unitType == UNIT_TYPE.Mesh && (isUpdateAlways || _isVisible))
            {
                bool isRigging     = _calculatedStack.IsRigging;
                bool isVertexLocal = _calculatedStack.IsVertexLocal;
                bool isVertexWorld = _calculatedStack.IsVertexWorld;

                apRenderVertex rVert = null;

                for (int i = 0; i < _renderVerts.Count; i++)
                {
                    rVert = _renderVerts[i];

                    rVert.ReadyToCalculate();

                    //단계별로 처리하자

                    //1) Pivot 위치 적용
                    //rVert.SetMatrix_1_Static_Vert2Mesh(_meshTransform._mesh.Matrix_VertToLocal, _meshTransform._mesh.MatrixHashCode);
                    rVert.SetMatrix_1_Static_Vert2Mesh(_meshTransform._mesh.Matrix_VertToLocal);

                    if (isRigging)
                    {
                        rVert.SetRigging_0_LocalPosWeight(_calculatedStack.GetVertexRigging(i), _calculatedStack.GetRiggingWeight(), _calculatedStack.GetMatrixRigging(i));
                    }

                    if (isVertexLocal)
                    {
                        //Calculate - Vertex Local Morph (Vec2)
                        rVert.SetMatrix_2_Calculate_VertLocal(_calculatedStack.GetVertexLocalPos(i));
                    }

                    rVert.SetMatrix_3_Transform_Mesh(WorldMatrix);

                    if (isVertexWorld)
                    {
                        //Calculate - Vertex World Morph (Vec2)
                        rVert.SetMatrix_4_Calculate_VertWorld(_calculatedStack.GetVertexWorldPos(i));
                    }

                    rVert.Calculate(tDelta);
                }
            }

            if (_childRenderUnits.Count > 0)
            {
                apRenderUnit childRenderUnit = null;
                for (int i = 0; i < _childRenderUnits.Count; i++)
                {
                    childRenderUnit = _childRenderUnits[i];

                    //childRenderUnit.UpdateToRenderVert(tDelta, isUpdateAlways, isMatrixCalculateForce, funcForceUpdate);
                    childRenderUnit.UpdateToRenderVert(tDelta, isUpdateAlways);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update를 끝내고 호출해야하는 함수
        /// 갱신된 정보를 RenderVertex 정보로 넣어준다.
        /// Child RenderUnit에 자동으로 호출한다.
        /// </summary>
        /// <param name="isUpdateAlways">Vertex 작업을 하는 상태에서는 True를 넣는다. 재생 전용이고 Gizmo가 안뜨면 False를 넣어주자</param>
        /// <param name="isMatrixCalculateForce">Matrix를 강제로 넣어야 한다. Force 옵션 또는 tDelta > bias일때 true 값을 넣자</param>
        //public void UpdateToRenderVert(float tDelta, bool isUpdateAlways, bool isMatrixCalculateForce, apMeshGroup.FUNC_IS_FORCE_UPDATE funcForceUpdate)
        //public void UpdateToRenderVert(float tDelta, bool isUpdateAlways, bool isMatrixCalculateForce, apMeshGroup.FUNC_IS_FORCE_UPDATE funcForceUpdate)
        public void UpdateToRenderVert(float tDelta, bool isUpdateAlways)
        {
            //강제로 업데이트해야하는지 결정한다.

            //Profiler.BeginSample("1. Func Check");
            //if(!isMatrixCalculateForce && funcForceUpdate != null)
            //{
            //	isMatrixCalculateForce = funcForceUpdate(this);
            //}
            //Profiler.EndSample();

            //Child까지 계산한 이후 Vertex를 계산해줘야 한다.
            if (_unitType == UNIT_TYPE.Mesh && (isUpdateAlways || _isVisible))
            {
                bool isRigging     = _calculatedStack.IsRigging;
                bool isVertexLocal = _calculatedStack.IsVertexLocal;
                bool isVertexWorld = _calculatedStack.IsVertexWorld;

                apRenderVertex rVert = null;

                //Compute Shader를 써보자
                if (apComputeShader.I.IsComputable && _portrait._isGPUAccel)
                {
                    Profiler.BeginSample("2. Buffer Init");
                    int nVert = _renderVerts.Count;

                    if (_computedVerts_Input == null || _computedVerts_Input.Length != _renderVerts.Count)
                    {
                        _computedVerts_Input  = new ComputedVert_Input[nVert];
                        _computedVerts_Output = new ComputedVert_Output[nVert];
                    }

                    Profiler.EndSample();


                    float riggingWeight = 0.0f;
                    if (isRigging)
                    {
                        riggingWeight = _calculatedStack.GetRiggingWeight();
                    }


                    Profiler.BeginSample("3. Make Buffer");
                    for (int i = 0; i < nVert; i++)
                    {
                        rVert = _renderVerts[i];
                        //if (isMatrixCalculateForce)
                        //{
                        //	rVert.ResetMatrixHashCode();
                        //}
                        rVert.ReadyToCalculate();
                        //rVert.SetMatrix_1_Static_Vert2Mesh(_meshTransform._mesh.Matrix_VertToLocal, _meshTransform._mesh.MatrixHashCode);
                        rVert.SetMatrix_1_Static_Vert2Mesh(_meshTransform._mesh.Matrix_VertToLocal);

                        _computedVerts_Input[i]._posL = _renderVerts[i]._vertex._pos;
                        if (isRigging)
                        {
                            _computedVerts_Input[i]._posRigging = _calculatedStack.GetVertexRigging(i);
                        }
                        else
                        {
                            _computedVerts_Input[i]._posRigging = Vector2.zero;
                        }
                        if (isVertexLocal)
                        {
                            _computedVerts_Input[i]._calVertLocal = _calculatedStack.GetVertexLocalPos(i);
                        }
                        else
                        {
                            _computedVerts_Input[i]._calVertLocal = Vector2.zero;
                        }
                        if (isVertexWorld)
                        {
                            _computedVerts_Input[i]._calVertWorld = _calculatedStack.GetVertexWorldPos(i);
                        }
                        else
                        {
                            _computedVerts_Input[i]._calVertWorld = Vector2.zero;
                        }
                    }
                    Profiler.EndSample();

                    #region [미사용 코드]
                    //[ Compute Shader를 써보자 ]
                    //for (int i = 0; i < _renderVerts.Count; i++)
                    //{
                    //	rVert = _renderVerts[i];

                    //	//중복 처리 제거 코드를 리셋한다. (강제로 업데이트하기 위함)
                    //	if (isMatrixCalculateForce)
                    //	{
                    //		rVert.ResetMatrixHashCode();
                    //	}

                    //	rVert.ReadyToCalculate();

                    //	//단계별로 처리하자

                    //	//1) Pivot 위치 적용
                    //	rVert.SetMatrix_1_Static_Vert2Mesh(_meshTransform._mesh.Matrix_VertToLocal, _meshTransform._mesh.MatrixHashCode);


                    //	//추가) Rigging 정보를 넣자
                    //	if (isRigging)
                    //	{
                    //		rVert.SetRigging_0_LocalPosWeight(_calculatedStack.GetVertexRigging(i), _calculatedStack.GetRiggingWeight());
                    //	}

                    //	if (isVertexLocal)
                    //	{
                    //		//Calculate - Vertex Local Morph (Vec2)
                    //		rVert.SetMatrix_2_Calculate_VertLocal(_calculatedStack.GetVertexLocalPos(i));
                    //	}

                    //	rVert.SetMatrix_3_Transform_Mesh(WorldMatrix);

                    //	if (isVertexWorld)
                    //	{
                    //		//Calculate - Vertex World Morph (Vec2)
                    //		rVert.SetMatrix_4_Calculate_VertWorld(_calculatedStack.GetVertexWorldPos(i));
                    //	}
                    //}
                    #endregion


                    Profiler.BeginSample("4. Compute");
                    //apComputeShader.I.Compute_Editor_New(_computedVerts_Input, _computedVerts_Output, _renderVerts, _meshTransform._mesh.Matrix_VertToLocal, WorldMatrix, riggingWeight);
                    apComputeShader.I.AddRenderRequest(this,
                                                       _computedVerts_Input,
                                                       _renderVerts,
                                                       _meshTransform.
                                                       _mesh.Matrix_VertToLocal,
                                                       WorldMatrix,
                                                       riggingWeight);
                    Profiler.EndSample();
                }
                else
                {
                    for (int i = 0; i < _renderVerts.Count; i++)
                    {
                        rVert = _renderVerts[i];

                        //중복 처리 제거 코드를 리셋한다. (강제로 업데이트하기 위함)
                        //if (isMatrixCalculateForce)
                        //{
                        //	rVert.ResetMatrixHashCode();
                        //}

                        rVert.ReadyToCalculate();

                        //단계별로 처리하자



                        //1) Pivot 위치 적용
                        //rVert.SetMatrix_1_Static_Vert2Mesh(_meshTransform._mesh.Matrix_VertToLocal, _meshTransform._mesh.MatrixHashCode);
                        rVert.SetMatrix_1_Static_Vert2Mesh(_meshTransform._mesh.Matrix_VertToLocal);


                        #region [미사용 코드] 해시코드 사용 안한다.
                        //if (rVert.SetCalculateHashCode(_calculatedStack.CalculateHashCode))
                        //{
                        //	//추가) Rigging 정보를 넣자
                        //	if (isRigging)
                        //	{
                        //		rVert.SetRigging_0_LocalPosWeight(_calculatedStack.GetVertexRigging(i), _calculatedStack.GetRiggingWeight());
                        //	}

                        //	if (isVertexLocal)
                        //	{
                        //		//Calculate - Vertex Local Morph (Vec2)
                        //		rVert.SetMatrix_2_Calculate_VertLocal(_calculatedStack.GetVertexLocalPos(i));
                        //	}

                        //	rVert.SetMatrix_3_Transform_Mesh(WorldMatrix);

                        //	if (isVertexWorld)
                        //	{
                        //		//Calculate - Vertex World Morph (Vec2)
                        //		rVert.SetMatrix_4_Calculate_VertWorld(_calculatedStack.GetVertexWorldPos(i));
                        //	}
                        //}

                        #endregion

                        if (isRigging)
                        {
                            rVert.SetRigging_0_LocalPosWeight(_calculatedStack.GetVertexRigging(i), _calculatedStack.GetRiggingWeight());
                        }

                        if (isVertexLocal)
                        {
                            //Calculate - Vertex Local Morph (Vec2)
                            rVert.SetMatrix_2_Calculate_VertLocal(_calculatedStack.GetVertexLocalPos(i));
                        }

                        rVert.SetMatrix_3_Transform_Mesh(WorldMatrix);

                        if (isVertexWorld)
                        {
                            //Calculate - Vertex World Morph (Vec2)
                            rVert.SetMatrix_4_Calculate_VertWorld(_calculatedStack.GetVertexWorldPos(i));
                        }

                        rVert.Calculate(tDelta);
                    }
                }
            }

            if (_childRenderUnits.Count > 0)
            {
                apRenderUnit childRenderUnit = null;
                for (int i = 0; i < _childRenderUnits.Count; i++)
                {
                    childRenderUnit = _childRenderUnits[i];

                    //childRenderUnit.UpdateToRenderVert(tDelta, isUpdateAlways, isMatrixCalculateForce, funcForceUpdate);
                    childRenderUnit.UpdateToRenderVert(tDelta, isUpdateAlways);
                }
            }
        }