Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 274 vs 286 for /trunk/Source Code/Geometry/Animations/AnimationController.cpp

Diff revisions: vs.
  @@ -7,27 +7,12 @@
7 7 using namespace boost;
8 8
9 9 void SceneAnimator::Release(){// this should clean everything up
10 - FOR_EACH(pointCollection::value_type& it, _pointsA){
11 - FOR_EACH(pointMap::value_type& it2, it.second){
10 + FOR_EACH(LineCollection::value_type& it, _skeletonLines){
11 + FOR_EACH(LineMap::value_type& it2, it.second){
12 12 it2.second.clear();
13 13 }
14 14 }
15 -
16 - FOR_EACH(pointCollection::value_type& it, _pointsB){
17 - FOR_EACH(pointMap::value_type& it2, it.second){
18 - it2.second.clear();
19 - }
20 - }
21 -
22 - FOR_EACH(colorCollection::value_type& it, _colors){
23 - FOR_EACH(colorMap::value_type& it2, it.second){
24 - it2.second.clear();
25 - }
26 - }
27 -
28 - _pointsA.clear();
29 - _pointsB.clear();
30 - _colors.clear();
15 + _skeletonLines.clear();
31 16 _animations.clear();// clear all animations
32 17 _bonesByName.clear();
33 18 _bonesToIndex.clear();
  @@ -35,8 +20,6 @@
35 20 _transforms.clear();
36 21 // This node will delete all children recursivly
37 22 SAFE_DELETE(_skeleton);
38 - SAFE_DELETE(_boneTransformBuffer[0]);
39 - SAFE_DELETE(_boneTransformBuffer[1]);
40 23 }
41 24
42 25 bool SceneAnimator::Init(const aiScene* pScene, U8 meshPointer){// this will build the skeleton based on the scene passed to it and CLEAR EVERYTHING
  @@ -94,12 +77,6 @@
94 77 }
95 78 }
96 79
97 - _boneTransformBuffer[0] = GFX_DEVICE.newSB(true);
98 - _boneTransformBuffer[0]->Create(true, true, Config::MAX_INSTANCE_COUNT, _bones.size() * sizeof(mat4<F32>));
99 -
100 - _boneTransformBuffer[1] = GFX_DEVICE.newSB(true);
101 - _boneTransformBuffer[1]->Create(true, true, Config::MAX_INSTANCE_COUNT, _bones.size() * sizeof(mat4<F32>));
102 -
103 80 D_PRINT_FN(Locale::get("LOAD_ANIMATIONS_END"), _bones.size());
104 81 return !_transforms.empty();
105 82 }
  @@ -140,7 +117,7 @@
140 117 CalculateBoneToWorldTransform(internalNode);
141 118
142 119 // continue for all child nodes and assign the created internal nodes as our children
143 - // recursivly call this function on all children
120 + // recursively call this function on all children
144 121 for(uint32_t i = 0; i < pNode->mNumChildren; i++){
145 122 Bone* childNode = CreateBoneTree(pNode->mChildren[i], internalNode);
146 123 internalNode->_children.push_back(childNode);
  @@ -197,63 +174,43 @@
197 174 I32 SceneAnimator::RenderSkeleton(I32 animationIndex, const D32 dt){
198 175 I32 frameIndex = _animations[animationIndex].GetFrameIndexAt(dt);
199 176
200 - if (_pointsA.find(animationIndex) == _pointsA.end()){
201 - pointMap pointsA;
202 - pointMap pointsB;
203 - colorMap colors;
204 - _pointsA.insert(std::make_pair(animationIndex, pointsA));
205 - _pointsB.insert(std::make_pair(animationIndex, pointsB));
206 - _colors.insert(std::make_pair(animationIndex, colors));
207 - }
208 -
209 - if (_pointsA[animationIndex][frameIndex].empty()){
177 + if (_skeletonLines.find(animationIndex) == _skeletonLines.end())
178 + _skeletonLines.insert(std::make_pair(animationIndex, LineMap()));
179 +
180 + if (_skeletonLines[animationIndex][frameIndex].empty()){
210 181 // create all the needed points
211 - vectorImpl<vec3<F32> >& pA = _pointsA[animationIndex][frameIndex];
212 - vectorImpl<vec3<F32> >& pB = _pointsB[animationIndex][frameIndex];
213 - vectorImpl<vec4<U8> >& cl = _colors[animationIndex][frameIndex];
214 - pA.reserve(_bones.size());
215 - pB.reserve(_bones.size());
216 - cl.reserve(_bones.size());
182 + vectorImpl<Line >& lines = _skeletonLines[animationIndex][frameIndex];
183 + lines.reserve(_bones.size());
217 184 // Construct skeleton
218 185 Calculate(animationIndex, dt);
219 186 // Prepare global transform
220 187 aiMatrix4x4 rootTransform;
221 188 AnimUtils::TransformMatrix(rootTransform,_rootTransformRender);
222 - CreateSkeleton(_skeleton, rootTransform, pA, pB, cl);
189 + CreateSkeleton(_skeleton, rootTransform, lines);
223 190 }
224 191 // Submit skeleton to gpu
225 - return SubmitSkeletonToGPU(animationIndex, frameIndex);
192 + GFX_DEVICE.drawLines(_skeletonLines[animationIndex][frameIndex], _rootTransformRender, vec4<I32>(), false, true);
193 + return 1;
226 194 }
227 195
228 196 /// Create animation skeleton
229 - I32 SceneAnimator::CreateSkeleton(Bone* piNode, const aiMatrix4x4& parent, vectorImpl<vec3<F32> >& pointsA,
230 - vectorImpl<vec3<F32> >& pointsB,
231 - vectorImpl<vec4<U8> >& colors){
197 + I32 SceneAnimator::CreateSkeleton(Bone* piNode, const aiMatrix4x4& parent, vectorImpl<Line >& lines){
198 +
232 199 aiMatrix4x4 me = piNode->_globalTransform;
233 200 if(GFX_DEVICE.getApi() == Direct3D){
234 201 me.Transpose();
235 202 }
236 203
237 204 if (piNode->_parent) {
238 - colors.push_back(vec4<U8>(255,0,0,255));
239 - pointsA.push_back(vec3<F32>(parent.a4, parent.b4, parent.c4));
240 - pointsB.push_back(vec3<F32>(me.a4, me.b4, me.c4));
205 + lines.push_back(Line(vec3<F32>(parent.a4, parent.b4, parent.c4),
206 + vec3<F32>(me.a4, me.b4, me.c4),
207 + vec4<U8>(255,0,0,255)));
241 208 }
242 209
243 210 // render all child nodes
244 211 for(Bone* bone : piNode->_children){
245 - CreateSkeleton(bone, me, pointsA, pointsB, colors);
212 + CreateSkeleton(bone, me, lines);
246 213 }
247 214
248 215 return 1;
249 - }
250 -
251 - I32 SceneAnimator::SubmitSkeletonToGPU(I32 animationIndex, U32 frameIndex){
252 - GFX_DEVICE.drawLines(_pointsA[animationIndex][frameIndex],
253 - _pointsB[animationIndex][frameIndex],
254 - _colors[animationIndex][frameIndex],
255 - _rootTransformRender,
256 - false,
257 - true);
258 - return 1;
259 - }
216 + }