Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
   Copyright (c) 2018 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

/*Code references:
    http://nolimitsdesigns.com/game-design/open-asset-import-library-animation-loader/
*/

#ifndef ANIMATION_EVALUATOR_H_
#define ANIMATION_EVALUATOR_H_

#include "Bone.h"
#include <assimp/anim.h>

struct aiAnimation;

namespace Divide {
class ByteBuffer;
class ShaderBuffer;

class AnimationChannel {
   public:
    AnimationChannel()
        : _nameKey(0ULL),
          _numPositionKeys(0U),
          _numRotationKeys(0U),
          _numScalingKeys(0U)
    {
    }

    U64 _nameKey;
    stringImpl _name;
    vectorImpl<aiVectorKey> _positionKeys;
    vectorImpl<aiQuatKey> _rotationKeys;
    vectorImpl<aiVectorKey> _scalingKeys;
    /** The number of position keys */
    U32 _numPositionKeys;
    U32 _numRotationKeys;
    U32 _numScalingKeys;
};

class GFXDevice;
class AnimEvaluator {
   public:
    AnimEvaluator();
    AnimEvaluator(const aiAnimation* pAnim, U32 idx);
    ~AnimEvaluator();

    void evaluate(const D64 dt, Bone* skeleton, bool rowMajor = false);

    I32 frameIndexAt(const D64 elapsedTime) const;

    
    inline U32 frameCount() const {
        return to_U32(_transforms.size());
    }

    inline vectorImpl<vectorImplBest<mat4<F32>>>& transforms() {
        return _transforms;
    }
    
    inline const vectorImpl<vectorImplBest<mat4<F32>>>& transforms() const {
        return _transforms;
    }

    inline vectorImplBest<mat4<F32>>& transforms(const U32 frameIndex) {
        assert(frameIndex < to_U32(_transforms.size()));
        return _transforms[frameIndex];
    }

    inline const vectorImplBest<mat4<F32>>& transforms(const U32 frameIndex) const {
        assert(frameIndex < to_U32(_transforms.size()));
        return _transforms[frameIndex];
    }

    inline vectorImplBest<mat4<F32>>& transforms(const D64 elapsedTime,
                                                    I32& resultingFrameIndex) {
        resultingFrameIndex = frameIndexAt(elapsedTime);
        return transforms(to_U32(resultingFrameIndex));
    }

    inline vectorImplBest<mat4<F32>>& transforms(const D64 elapsedTime) {
        I32 resultingFrameIndex = 0;
        return transforms(elapsedTime, resultingFrameIndex);
    }

    inline const vectorImplBest<mat4<F32>>& transforms(const D64 elapsedTime,
                                                          I32& resultingFrameIndex) const {
        resultingFrameIndex = frameIndexAt(elapsedTime);
        return transforms(to_U32(resultingFrameIndex));
    }

    inline const vectorImplBest<mat4<F32>>& transforms(const D64 elapsedTime) const {
        I32 resultingFrameIndex = 0;
        return transforms(elapsedTime, resultingFrameIndex);
    }

    inline void playAnimationForward(bool state) {
        _playAnimationForward = state;
    }

    inline bool playAnimationForward() const {
        return _playAnimationForward;
    }

    inline void ticksPerSecond(D64 tickCount) {
        _ticksPerSecond = tickCount;
    }

    inline D64 ticksPerSecond() const {
        return _ticksPerSecond;
    }

    inline const stringImpl& name() const {
        return _name;
    }

    inline D64 duration() const {
        return _duration;
    }

    bool initBuffers(GFXDevice& context);

    static void save(const AnimEvaluator& evaluator, ByteBuffer& dataOut);
    static void load(AnimEvaluator& evaluator, ByteBuffer& dataIn);

    ShaderBuffer& getBoneBuffer() const {
        return *_boneTransformBuffer;
    }

   protected:
    stringImpl _name;
    /// Array to return transformations results inside.
    vectorImpl<vectorImplBest<mat4<F32>>> _transforms;
    /// play forward == true, play backward == false
    bool _playAnimationForward;
    D64 _lastTime;
    D64 _duration;
    D64 _ticksPerSecond;

   private:
    vectorImpl<vec3<U32>> _lastPositions;
    /// vector that holds all bone channels
    vectorImpl<AnimationChannel> _channels;
    /// GPU buffer to hold bone transforms
    ShaderBuffer* _boneTransformBuffer;
};

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Geometry/Animations/Headers/AnimationEvaluator.h

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

833 Diff Diff IonutCava picture IonutCava Thu 26 Jan, 2017 22:04:33 +0000

[IonutCava]
- Fix most build errors. Divide-Server does not build for now.

804 Diff Diff IonutCava picture IonutCava Thu 01 Dec, 2016 17:20:59 +0000

[IonutCava]
- Singleton elimination update Part I: get it to compile
— The following classes are no longer Singletons: GFXDevice, GL_API, DX_API, SFXWrapper, FmodWrapper, SDLWrapper, ALWrapper, PXDevice, InputInterface, RenderPassManager, SceneManager and ResourceManager;
— Refactor system to a Context / Component based implementation (Pass relevant context to objects: e.g. GFXDevice object to Textures, GUI to GUIElements, etc)
— Make devices and managers components of the kernel
— Allow multiple Resource caches to co-exist. This may prove useful for later when a more fragmented memory model is need (per frame / per scene / global caches / etc)

  • next steps: part II – cleanup/refactor new code, part III – optimise code, part IV – remove remaining Singletons (e.g. Application, ParamHandler, FrameListenerManager, Recast, PostFX and DebugInterface)
795 Diff Diff IonutCava picture IonutCava Wed 23 Nov, 2016 17:14:33 +0000

[IonutCava]
- Remove ULL. Use U64 instead
- Various small bug fixes and typos.

788 Diff Diff IonutCava picture IonutCava Fri 21 Oct, 2016 16:11:37 +0000

[IonutCava]
- Added support for the Arena Allocator by Mamasha Knows (http://www.codeproject.com/Articles/44850/Arena-Allocator-DTOR-and-Embedded-Preallocated-Buf)
— Used for GFX Related objects: Textures, shaders, etc

680 Diff Diff IonutCava picture IonutCava Thu 14 Apr, 2016 16:15:38 +0000

[IonutCava]
- Added a mat2 class (untested)
- Added static asserts to matrices, vectors and quaternions to allow only arithmetic (sans bool) data types
- Added more vector unit tests
- Added unit tests for matrices
- D32 finally renamed to D64 as the VC++ compiler is considered as the reference compiler

674 Diff Diff IonutCava picture IonutCava Mon 11 Apr, 2016 16:17:10 +0000

[IonutCava]
- Some profile guided optimizations:
— Remove the task state hashmap and replace with flat array
— Allow PhysX to load collision meshes from a RAM cache first -> then file -> then recompute
- Improve memory logger output

671 IonutCava picture IonutCava Fri 08 Apr, 2016 16:26:49 +0000

[Ionut]
- Custom memory allocation system part 1:
— Add http://www.codeproject.com/Articles/1089905/A-Custom-STL-std-allocator-Replacement-Improves-Pe
— Add custom allocators to strings and vectors
— Add custom allocators to a few test classes
— No support for aligned memory yet, so vec4<F32> and mat4<F32> vectors use the old allocation system
- Replace more std::async call with our custom task system