Coverage Report

Created: 2025-08-28 06:22

/src/ogre/OgreMain/include/OgrePose.h
Line
Count
Source (jump to first uncovered line)
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
9
Permission is hereby granted, free of charge, to any person obtaining a copy
10
of this software and associated documentation files (the "Software"), to deal
11
in the Software without restriction, including without limitation the rights
12
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
copies of the Software, and to permit persons to whom the Software is
14
furnished to do so, subject to the following conditions:
15
16
The above copyright notice and this permission notice shall be included in
17
all copies or substantial portions of the Software.
18
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
THE SOFTWARE.
26
-----------------------------------------------------------------------------
27
*/
28
#ifndef __OGRE_POSE_H
29
#define __OGRE_POSE_H
30
31
#include "OgrePrerequisites.h"
32
#include "OgreCommon.h"
33
#include "OgreHardwareVertexBuffer.h"
34
#include "OgreHeaderPrefix.h"
35
36
namespace Ogre {
37
38
    template <typename T> class MapIterator;
39
    template <typename T> class ConstMapIterator;
40
41
    /** \addtogroup Core
42
    *  @{
43
    */
44
    /** \addtogroup Animation
45
    *  @{
46
    */
47
    /** A pose is a linked set of vertex offsets applying to one set of vertex
48
        data. 
49
50
        The target index referred to by the pose has a meaning set by the user
51
        of this class; but for example when used by Mesh it refers to either the
52
        Mesh shared geometry (0) or a SubMesh dedicated geometry (1+).
53
        Pose instances can be referred to by keyframes in VertexAnimationTrack in
54
        order to animate based on blending poses together.
55
    */
56
    class _OgreExport Pose : public AnimationAlloc
57
    {
58
    public:
59
        /** Constructor
60
            @param target The target vertexdata index (0 for shared, 1+ for 
61
                dedicated at the submesh index + 1)
62
            @param name Optional name
63
        */
64
        Pose(ushort target, const String& name = BLANKSTRING);
65
        /// Return the name of the pose (may be blank)
66
0
        const String& getName(void) const { return mName; }
67
        /// Return the target geometry index of the pose
68
0
        ushort getTarget(void) const { return mTarget; }
69
        /// A collection of vertex offsets based on the vertex index
70
        typedef std::map<uint32, Vector3f> VertexOffsetMap;
71
        /// An iterator over the vertex offsets
72
        typedef MapIterator<VertexOffsetMap> VertexOffsetIterator;
73
        /// An iterator over the vertex offsets
74
        typedef ConstMapIterator<VertexOffsetMap> ConstVertexOffsetIterator;
75
        /// A collection of normals based on the vertex index
76
        typedef std::map<uint32, Vector3f> NormalsMap;
77
        /// An iterator over the vertex offsets
78
        typedef MapIterator<NormalsMap> NormalsIterator;
79
        /// An iterator over the vertex offsets
80
        typedef ConstMapIterator<NormalsMap> ConstNormalsIterator;
81
        /// Return whether the pose vertices include normals
82
0
        bool getIncludesNormals() const { return !mNormalsMap.empty(); }
83
84
        /** Adds an offset to a vertex for this pose. 
85
        @param index The vertex index
86
        @param offset The position offset for this pose
87
        */
88
        void addVertex(uint32 index, const Vector3f& offset);
89
90
        /** Adds an offset to a vertex and a new normal for this pose. 
91
        @param index The vertex index
92
        @param offset The position offset for this pose
93
        @param normal The new vertex normal
94
        */
95
        void addVertex(uint32 index, const Vector3f& offset, const Vector3f& normal);
96
97
        /** Remove a vertex offset. */
98
        void removeVertex(uint32 index);
99
100
        /** Clear all vertices. */
101
        void clearVertices(void);
102
103
        /// @deprecated use getVertexOffsets
104
        OGRE_DEPRECATED ConstVertexOffsetIterator getVertexOffsetIterator(void) const;
105
        /// @deprecated use getVertexOffsets
106
        OGRE_DEPRECATED VertexOffsetIterator getVertexOffsetIterator(void);
107
        /** Gets a const reference to the vertex offsets. */
108
0
        const VertexOffsetMap& getVertexOffsets(void) const { return mVertexOffsetMap; }
109
110
        /// @deprecated use getNormals
111
        OGRE_DEPRECATED ConstNormalsIterator getNormalsIterator(void) const;
112
        /// @deprecated use getNormals
113
        OGRE_DEPRECATED NormalsIterator getNormalsIterator(void);
114
        /** Gets a const reference to the vertex normals */
115
0
        const NormalsMap& getNormals(void) const { return mNormalsMap; }
116
117
        /** writable access to the vertex offsets for offline processing
118
         *
119
         * @attention does not invalidate the vertexbuffer
120
         */
121
0
        VertexOffsetMap& _getVertexOffsets() { return mVertexOffsetMap; }
122
123
        /** writable access to the vertex normals for offline processing
124
         *
125
         * @attention does not invalidate the vertexbuffer
126
         */
127
0
        NormalsMap& _getNormals() { return mNormalsMap; }
128
129
        /** Get a hardware vertex buffer version of the vertex offsets. */
130
        const HardwareVertexBufferSharedPtr& _getHardwareVertexBuffer(const VertexData* origData) const;
131
132
        /** Clone this pose and create another one configured exactly the same
133
            way (only really useful for cloning holders of this class).
134
        */
135
        Pose* clone(void) const OGRE_NODISCARD;
136
    private:
137
        /// Target geometry index
138
        ushort mTarget;
139
        /// Optional name
140
        String mName;
141
        /// Primary storage, sparse vertex use
142
        VertexOffsetMap mVertexOffsetMap;
143
        /// Primary storage, sparse vertex use
144
        NormalsMap mNormalsMap;
145
        /// Derived hardware buffer, covers all vertices
146
        mutable HardwareVertexBufferSharedPtr mBuffer;
147
    };
148
    typedef std::vector<Pose*> PoseList;
149
150
    /** @} */
151
    /** @} */
152
153
}
154
155
#include "OgreHeaderSuffix.h"
156
157
#endif