Coverage Report

Created: 2026-02-14 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ogre/Components/RTShaderSystem/src/OgreShaderExDualQuaternionSkinning.cpp
Line
Count
Source
1
/*
2
-----------------------------------------------------------------------------
3
This source file is part of OGRE
4
(Object-oriented Graphics Rendering Engine)
5
For the latest info, see http://www.ogre3d.org
6
7
Copyright (c) 2000-2014 Torus Knot Software Ltd
8
Permission is hereby granted, free of charge, to any person obtaining a copy
9
of this software and associated documentation files (the "Software"), to deal
10
in the Software without restriction, including without limitation the rights
11
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
copies of the Software, and to permit persons to whom the Software is
13
furnished to do so, subject to the following conditions:
14
15
The above copyright notice and this permission notice shall be included in
16
all copies or substantial portions of the Software.
17
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
THE SOFTWARE.
25
-----------------------------------------------------------------------------
26
*/
27
28
#include "OgreShaderPrecompiledHeaders.h"
29
30
#ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
31
32
#define SGX_LIB_DUAL_QUATERNION                 "SGXLib_DualQuaternion"
33
0
#define SGX_FUNC_CALCULATE_BLEND_POSITION       "SGX_CalculateBlendPosition"
34
0
#define SGX_FUNC_CALCULATE_BLEND_NORMAL         "SGX_CalculateBlendNormal"
35
0
#define SGX_FUNC_ADJOINT_TRANSPOSE_MATRIX       "SGX_AdjointTransposeMatrix"
36
37
namespace Ogre {
38
39
namespace RTShader {
40
41
/************************************************************************/
42
/*                                                                      */
43
/************************************************************************/
44
bool DualQuaternionSkinning::resolveParameters(Program* vsProgram)
45
0
{
46
0
    Function* vsMain = vsProgram->getEntryPointFunction();
47
48
0
    mParamInWorldMatrices = vsProgram->resolveParameter(GpuProgramParameters::ACT_WORLD_DUALQUATERNION_ARRAY_2x4, mBoneCount);
49
0
    mParamBlendDQ = vsMain->resolveLocalParameter(GCT_MATRIX_2X4, "blendDQ");
50
51
0
    if(mScalingShearingSupport)
52
0
    {
53
0
        mParamInScaleShearMatrices = vsProgram->resolveParameter(GpuProgramParameters::ACT_WORLD_SCALE_SHEAR_MATRIX_ARRAY_3x4, mBoneCount);
54
0
        mParamBlendS = vsMain->resolveLocalParameter(GCT_MATRIX_3X4, "blendS");
55
0
        mParamTempFloat3x3 = vsMain->resolveLocalParameter(GCT_MATRIX_3X3, "TempVal3x3");
56
0
    }
57
0
    return true;
58
0
}
59
//-----------------------------------------------------------------------
60
void DualQuaternionSkinning::addPositionCalculations(const FunctionStageRef& stage)
61
0
{
62
0
    if (mScalingShearingSupport)
63
0
    {
64
        // Construct a scaling and shearing matrix based on the blend weights
65
0
        stage.callFunction("blendBonesMat3x4", {In(mParamInScaleShearMatrices), In(mParamInIndices),
66
0
                                                In(mParamInWeights), Out(mParamBlendS)});
67
        // Transform the position based by the scaling and shearing matrix
68
0
        stage.callFunction(FFP_FUNC_TRANSFORM, mParamBlendS, mParamInPosition, Out(mParamInPosition).xyz());
69
0
    }
70
71
    // Calculate the resultant dual quaternion based on the weights given
72
0
    stage.callFunction("blendBonesDQ",
73
0
                       {In(mParamInWorldMatrices), In(mParamInIndices), In(mParamInWeights), Out(mParamBlendDQ)});
74
75
    // Calculate the blend position
76
0
    stage.callFunction(SGX_FUNC_CALCULATE_BLEND_POSITION, In(mParamInPosition).xyz(), mParamBlendDQ, mParamInPosition);
77
0
}
78
79
//-----------------------------------------------------------------------
80
void DualQuaternionSkinning::addNormalRelatedCalculations(const FunctionStageRef& stage)
81
0
{
82
0
    if (mScalingShearingSupport)
83
0
    {
84
        // Calculate the adjoint transpose of the blended scaling and shearing matrix
85
0
        stage.callFunction(SGX_FUNC_ADJOINT_TRANSPOSE_MATRIX, mParamBlendS, mParamTempFloat3x3);
86
        // Transform the normal by the adjoint transpose of the blended scaling and shearing matrix
87
0
        stage.callBuiltin("mul", mParamTempFloat3x3, mParamInNormal, mParamInNormal);
88
        // Need to normalize again after transforming the normal
89
0
        stage.callBuiltin("normalize", mParamInNormal, mParamInNormal);
90
0
    }
91
    // Transform the normal according to the dual quaternion
92
0
    stage.callFunction(SGX_FUNC_CALCULATE_BLEND_NORMAL, mParamInNormal, mParamBlendDQ, mParamInNormal);
93
0
}
94
}
95
}
96
97
#endif
98
99
100