Browse Source

Work in progress

Thomas Buck 11 years ago
parent
commit
549374f4d4
9 changed files with 266 additions and 446 deletions
  1. 5
    4
      include/Entity.h
  2. 8
    5
      include/Game.h
  3. 47
    56
      include/SkeletalModel.h
  4. 13
    25
      include/World.h
  5. 0
    20
      include/WorldData.h
  6. 36
    0
      src/Entity.cpp
  7. 71
    174
      src/Game.cpp
  8. 47
    61
      src/SkeletalModel.cpp
  9. 39
    101
      src/World.cpp

+ 5
- 4
include/Entity.h View File

23
 
23
 
24
     Entity(TombRaider &tr);
24
     Entity(TombRaider &tr);
25
 
25
 
26
-    // Animation State
26
+    bool operator<(Entity &o);
27
+    void display();
28
+
29
+    void setSkeletalModel(unsigned int model);
27
 
30
 
31
+    // Animation State
28
     unsigned int getAnimationFrame();
32
     unsigned int getAnimationFrame();
29
     void setAnimationFrame(unsigned int index);
33
     void setAnimationFrame(unsigned int index);
30
-
31
     unsigned int getBoneFrame();
34
     unsigned int getBoneFrame();
32
     void setBoneFrame(unsigned int index);
35
     void setBoneFrame(unsigned int index);
33
-
34
     unsigned int getIdleAnimation();
36
     unsigned int getIdleAnimation();
35
     void setIdleAnimation(unsigned int index);
37
     void setIdleAnimation(unsigned int index);
36
 
38
 
46
     int objectId;
48
     int objectId;
47
 
49
 
48
     // Animation State
50
     // Animation State
49
-
50
     unsigned int boneFrame;
51
     unsigned int boneFrame;
51
     unsigned int animationFrame;
52
     unsigned int animationFrame;
52
     unsigned int idleAnimation;
53
     unsigned int idleAnimation;

+ 8
- 5
include/Game.h View File

11
 #include <vector>
11
 #include <vector>
12
 
12
 
13
 #include "Camera.h"
13
 #include "Camera.h"
14
+#include "Entity.h"
14
 #include "global.h"
15
 #include "global.h"
15
 #include "Render.h"
16
 #include "Render.h"
16
 #include "TombRaider.h"
17
 #include "TombRaider.h"
41
     unsigned int getTextureStart();
42
     unsigned int getTextureStart();
42
     unsigned int getTextureOffset();
43
     unsigned int getTextureOffset();
43
 
44
 
44
-    //! \fixme should be private
45
-    entity_t *mLara;
45
+    Entity &getLara();
46
 
46
 
47
 private:
47
 private:
48
 
48
 
50
     void processTextures();
50
     void processTextures();
51
     void processSprites();
51
     void processSprites();
52
     void processMoveables();
52
     void processMoveables();
53
-    void processMoveable(int index, int i, int *ent,
54
-                            std::vector<skeletal_model_t *> &cache2,
55
-                            std::vector<unsigned int> &cache, int object_id);
53
+    void processMoveable(int index, int i, int object_id);
56
     void processModels();
54
     void processModels();
57
     void processRooms();
55
     void processRooms();
56
+
57
+#ifdef EXPERIMENTAL
58
     void setupTextureColor(texture_tri_t *r_tri, float *colorf);
58
     void setupTextureColor(texture_tri_t *r_tri, float *colorf);
59
+#endif
59
 
60
 
60
     char *mName;
61
     char *mName;
61
     bool mLoaded;
62
     bool mLoaded;
64
 
65
 
65
     unsigned int mTextureStart;
66
     unsigned int mTextureStart;
66
     unsigned int mTextureOffset;
67
     unsigned int mTextureOffset;
68
+
69
+    unsigned int mLara;
67
 };
70
 };
68
 
71
 
69
 #endif
72
 #endif

+ 47
- 56
include/SkeletalModel.h View File

4
  *
4
  *
5
  * \author Mongoose
5
  * \author Mongoose
6
  * \author xythobuz
6
  * \author xythobuz
7
- *
8
- * \todo Start cutting off old hacks by simple force use of method interface.
9
- * Also move the publicly exposed attributes out  =)
10
- * Better animation system in general - this is memory wasteful
11
  */
7
  */
12
 
8
 
13
 #ifndef _SKELETALMODEL_H_
9
 #ifndef _SKELETALMODEL_H_
16
 #include <vector>
12
 #include <vector>
17
 
13
 
18
 #include "math/math.h"
14
 #include "math/math.h"
15
+#include "TombRaider.h"
16
+
17
+class BoneTag {
18
+public:
19
+    BoneTag();
19
 
20
 
20
-typedef struct {
21
+private:
21
     int mesh;
22
     int mesh;
22
     vec3_t off;
23
     vec3_t off;
23
     vec3_t rot;
24
     vec3_t rot;
24
     char flag;
25
     char flag;
25
-} bone_tag_t;
26
+};
26
 
27
 
27
-typedef struct {
28
-    std::vector<bone_tag_t *> tag;
28
+class BoneFrame {
29
+public:
30
+    BoneFrame();
31
+    ~BoneFrame();
32
+
33
+    unsigned int size();
34
+    BoneTag &get(unsigned int i);
35
+    void add(BoneTag &b);
36
+
37
+private:
29
     vec3_t pos;
38
     vec3_t pos;
30
-    float yaw;
31
-} bone_frame_t;
39
+    vec_t yaw;
40
+    std::vector<BoneTag *> tag;
41
+};
32
 
42
 
33
-typedef struct {
34
-    int id;
43
+class AnimationFrame {
44
+public:
45
+    AnimationFrame();
46
+    ~AnimationFrame();
47
+
48
+    unsigned int size();
49
+    BoneFrame &get(unsigned int i);
50
+    void add(BoneFrame &b);
51
+
52
+private:
35
     char rate;
53
     char rate;
36
-    std::vector<bone_frame_t *> frame;
37
-} animation_frame_t;
54
+    std::vector<BoneFrame *> frame;
55
+};
56
+
57
+class SkeletalModel {
58
+public:
59
+    SkeletalModel(TombRaider &tr, );
60
+    ~SkeletalModel();
61
+    int getId();
38
 
62
 
39
-typedef struct {
63
+    unsigned int size();
64
+    AnimationFrame &get(unsigned int i);
65
+    void add(AnimationFrame &a);
66
+
67
+private:
40
     int id;
68
     int id;
41
     bool tr4Overlay;
69
     bool tr4Overlay;
42
     bool pigtails;
70
     bool pigtails;
44
     vec3_t ponytail;
72
     vec3_t ponytail;
45
     int ponytailMeshId;
73
     int ponytailMeshId;
46
     unsigned int ponytailNumMeshes;
74
     unsigned int ponytailNumMeshes;
47
-    float ponytailAngle;
48
-    float ponyOff;
49
-    float ponyOff2;
50
-    std::vector<animation_frame_t *> animation;
51
-} skeletal_model_t;
52
-
53
-/*!
54
- * \brief This is the factored out skeletal model class
55
- */
56
-class SkeletalModel {
57
-public:
58
-    /*!
59
-     * \brief Constructs an object of SkeletalModel
60
-     */
61
-    SkeletalModel();
62
-
63
-     /*!
64
-     * \brief Deconstructs an object of SkeletalModel
65
-     */
66
-    ~SkeletalModel();
67
-
68
-    int getAnimation();
69
-
70
-    int getFrame();
71
-
72
-    int getIdleAnimation();
73
-
74
-    void setModel(skeletal_model_t *mdl);
75
-
76
-    void setAnimation(int index);
77
-
78
-    void setFrame(int index);
79
-
80
-    void setIdleAnimation(int index);
81
-
82
-    skeletal_model_t *model; //!< World render model
83
-
84
-private:
85
-    int mBoneFrame;      //!< Bone frame
86
-    int mAnimationFrame; //!< Animation frame
87
-    int mIdleAnimation;  //!< Idle animation
75
+    vec_t ponytailAngle;
76
+    vec_t ponyOff;
77
+    vec_t ponyOff2;
78
+    std::vector<AnimationFrame *> animation;
88
 };
79
 };
89
 
80
 
90
 #endif
81
 #endif

+ 13
- 25
include/World.h View File

12
 #include <list>
12
 #include <list>
13
 #include <vector>
13
 #include <vector>
14
 
14
 
15
+#include "Entity.h"
15
 #include "Room.h"
16
 #include "Room.h"
17
+#include "SkeletalModel.h"
16
 #include "Sprite.h"
18
 #include "Sprite.h"
17
 
19
 
18
 #include "WorldData.h"
20
 #include "WorldData.h"
34
     void destroy();
36
     void destroy();
35
 
37
 
36
     void addRoom(Room &room);
38
     void addRoom(Room &room);
37
-
38
     unsigned int sizeRoom();
39
     unsigned int sizeRoom();
39
-
40
     Room &getRoom(unsigned int index);
40
     Room &getRoom(unsigned int index);
41
 
41
 
42
     void addSprite(SpriteSequence &sprite);
42
     void addSprite(SpriteSequence &sprite);
43
-
44
     unsigned int sizeSprite();
43
     unsigned int sizeSprite();
45
-
46
     SpriteSequence &getSprite(unsigned int index);
44
     SpriteSequence &getSprite(unsigned int index);
47
 
45
 
46
+    void addEntity(Entity &entity);
47
+    unsigned int sizeEntity();
48
+    Entity &getEntity(unsigned int index);
49
+
50
+    void addSkeletalModel(SkeletalModel &model);
51
+    unsigned int sizeSkeletalModel();
52
+    SkeletalModel &getSkeletalModel(unsigned int index);
53
+
48
     /*!
54
     /*!
49
      * \brief Adds mesh to world
55
      * \brief Adds mesh to world
50
      * \param model mesh to add
56
      * \param model mesh to add
51
      */
57
      */
52
     void addMesh(model_mesh_t *model);
58
     void addMesh(model_mesh_t *model);
53
 
59
 
54
-    /*!
55
-     * \brief Adds entity to world
56
-     * \param e entity to add
57
-     */
58
-    void addEntity(entity_t *e);
59
-
60
-    /*!
61
-     * \brief Adds model to world.
62
-     * \param model model to add
63
-     * \returns next model ID or -1 on error
64
-     */
65
-    int addModel(skeletal_model_t *model);
60
+    model_mesh_t *getMesh(int index);
66
 
61
 
67
     /*!
62
     /*!
68
      * \brief Move entity in given direction unless collision occurs
63
      * \brief Move entity in given direction unless collision occurs
71
      */
66
      */
72
     void moveEntity(entity_t *e, char movement);
67
     void moveEntity(entity_t *e, char movement);
73
 
68
 
74
-    model_mesh_t *getMesh(int index);
75
-    skeletal_model_t *getModel(int index);
76
-    std::vector<entity_t *> *getEntities();
77
-
78
     /*!
69
     /*!
79
      * \brief Find room a location is in.
70
      * \brief Find room a location is in.
80
      *
71
      *
147
 private:
138
 private:
148
 
139
 
149
     // Old World
140
     // Old World
150
-    std::vector<entity_t *> mEntities;       //!< World entities
151
     std::vector<model_mesh_t *> mMeshes;     //!< Unanimated meshes
141
     std::vector<model_mesh_t *> mMeshes;     //!< Unanimated meshes
152
-    std::vector<skeletal_model_t *> mModels; //!< Skeletal animation models
153
 
142
 
154
     // New World
143
     // New World
155
     std::vector<Room *> mRooms;
144
     std::vector<Room *> mRooms;
156
     std::vector<SpriteSequence *> mSprites;
145
     std::vector<SpriteSequence *> mSprites;
157
-
158
-    //std::vector<Entity *> mEntities;
159
-    //std::vector<SkeletalModel *> mModels;
146
+    std::vector<Entity *> mEntities;
147
+    std::vector<SkeletalModel *> mModels;
160
 };
148
 };
161
 
149
 
162
 #endif
150
 #endif

+ 0
- 20
include/WorldData.h View File

12
 #include "math/math.h"
12
 #include "math/math.h"
13
 #include "SkeletalModel.h"
13
 #include "SkeletalModel.h"
14
 
14
 
15
-typedef enum {
16
-    worldMoveType_walkNoSwim = -1,
17
-    worldMoveType_walk       = 0,
18
-    worldMoveType_noClipping = 1,
19
-    worldMoveType_fly        = 2,
20
-    worldMoveType_swim       = 3
21
-} worldMoveType;
22
-
23
 /*! \fixme For now shaders are textures on tex objects
15
 /*! \fixme For now shaders are textures on tex objects
24
  * and materials on color objects. If -1
16
  * and materials on color objects. If -1
25
  * then it doesn't have that information yet.
17
  * then it doesn't have that information yet.
50
     vec_t *normals;
42
     vec_t *normals;
51
 } model_mesh_t;
43
 } model_mesh_t;
52
 
44
 
53
-typedef struct {
54
-    float pos[3];            //!< World position
55
-    float angles[3];         //!< Euler angles (pitch, yaw, roll)
56
-    int room;                //!< Current room entity is in
57
-    worldMoveType moveType;  //!< Type of motion/clipping
58
-
59
-    int state;               //!< State of the Player, AI, or object
60
-    int objectId;            //!< What kind of entity?
61
-
62
-    SkeletalModel *tmpHook;
63
-} entity_t;
64
-
65
 #endif
45
 #endif
66
 
46
 

+ 36
- 0
src/Entity.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
+#ifdef __APPLE__
9
+#include <OpenGL/gl.h>
10
+#include <OpenGL/glu.h>
11
+#elif defined WIN32
12
+#include <gl/glew.h>
13
+#include <gl/wglew.h>
14
+#else
15
+#include <GL/gl.h>
16
+#include <GL/glu.h>
17
+#endif
18
+
8
 #include "Entity.h"
19
 #include "Entity.h"
20
+#include "main.h"
9
 
21
 
10
 Entity::Entity(TombRaider &tr) {
22
 Entity::Entity(TombRaider &tr) {
11
 
23
 
12
 }
24
 }
13
 
25
 
26
+bool Entity::operator<(Entity &o) {
27
+    vec_t distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0], pos[1], pos[2], 1.0f);
28
+    vec_t distB = getRender().mViewVolume.getDistToSphereFromNear(o.pos[0], o.pos[1], o.pos[2], 1.0f);
29
+    return (distA < distB);
30
+}
31
+
32
+void Entity::display() {
33
+    /*
34
+    glPushMatrix();
35
+    glTranslatef(pos[0], pos[1], pos[2]);
36
+    glRotatef(angles[1], 0, 1, 0);
37
+    getWorld().getSkeletalModel(skeletalModel).display();
38
+    glPopMatrix();
39
+    */
40
+}
41
+
42
+void Entity::setSkeletalModel(unsigned int model) {
43
+    skeletalModel = model;
44
+    animationFrame = 0;
45
+    boneFrame = 0;
46
+    idleAnimation = 0;
47
+}
48
+
14
 unsigned int Entity::getAnimationFrame() {
49
 unsigned int Entity::getAnimationFrame() {
15
     return animationFrame;
50
     return animationFrame;
16
 }
51
 }
17
 
52
 
18
 void Entity::setAnimationFrame(unsigned int index) {
53
 void Entity::setAnimationFrame(unsigned int index) {
19
     animationFrame = index;
54
     animationFrame = index;
55
+    boneFrame = 0;
20
 }
56
 }
21
 
57
 
22
 unsigned int Entity::getBoneFrame() {
58
 unsigned int Entity::getBoneFrame() {

+ 71
- 174
src/Game.cpp View File

36
 Game::Game() {
36
 Game::Game() {
37
     mLoaded = false;
37
     mLoaded = false;
38
     mName = NULL;
38
     mName = NULL;
39
-    mLara = NULL;
40
-
39
+    mLara = 0;
41
     mTextureStart = 0;
40
     mTextureStart = 0;
42
     mTextureOffset = 0;
41
     mTextureOffset = 0;
43
 }
42
 }
173
     }
172
     }
174
 }
173
 }
175
 
174
 
175
+Entity &Game::getLara() {
176
+    assert(mLara < getWorld().sizeEntity());
177
+    return getWorld().getEntity(mLara);
178
+}
179
+
176
 void Game::processSprites() {
180
 void Game::processSprites() {
177
     printf("Processing sprites: ");
181
     printf("Processing sprites: ");
178
     for (int i = 0; i < (mTombRaider.NumItems() - 1); i++) {
182
     for (int i = 0; i < (mTombRaider.NumItems() - 1); i++) {
290
 
294
 
291
 void Game::processMoveables()
295
 void Game::processMoveables()
292
 {
296
 {
293
-    std::vector<unsigned int> cache;
294
-    std::vector<skeletal_model_t *> cache2;
295
-    tr2_mesh_t *mesh = NULL;
296
-    tr2_moveable_t *moveable = NULL;
297
-    tr2_meshtree_t *meshtree = NULL;
298
-    tr2_item_t *item = NULL;
299
-    tr2_animation_t *animation = NULL;
300
-    unsigned short *frame = NULL;
301
-    tr2_sprite_sequence_t *sprite_sequence = NULL;
302
-    tr2_object_texture_t *object_texture = NULL;
303
-    int i, j, object_id;
304
-    int ent = 0;
305
     unsigned int statCount = 0;
297
     unsigned int statCount = 0;
306
 
298
 
307
-    frame = mTombRaider.Frame();
308
-    moveable = mTombRaider.Moveable();
309
-    meshtree = mTombRaider.MeshTree();
310
-    mesh = mTombRaider.Mesh();
311
-    object_texture = mTombRaider.ObjectTextures();
312
-    item = mTombRaider.Item();
313
-    animation = mTombRaider.Animation();
314
-    sprite_sequence = mTombRaider.SpriteSequence();
299
+    tr2_moveable_t *moveable = mTombRaider.Moveable();
300
+    tr2_item_t *item = mTombRaider.Item();
301
+    tr2_sprite_sequence_t *sprite_sequence = mTombRaider.SpriteSequence();
315
 
302
 
316
     printf("Processing skeletal models: ");
303
     printf("Processing skeletal models: ");
317
 
304
 
318
-    for (i = 0; i < mTombRaider.NumItems(); ++i)
305
+    for (int i = 0; i < mTombRaider.NumItems(); ++i)
319
     {
306
     {
320
-        object_id = item[i].object_id;
307
+        int j;
308
+        int object_id = item[i].object_id;
321
 
309
 
322
         // It may not be a moveable, test for sprite
310
         // It may not be a moveable, test for sprite
323
-        if (!(mTombRaider.Engine() == TR_VERSION_1 && item[i].intensity1 == -1))
324
-        {
325
-            for (j = 0; j < (int)mTombRaider.NumSpriteSequences(); ++j)
326
-            {
311
+        if (!(mTombRaider.Engine() == TR_VERSION_1 && item[i].intensity1 == -1)) {
312
+            for (j = 0; j < (int)mTombRaider.NumSpriteSequences(); ++j) {
327
                 if (sprite_sequence[j].object_id == object_id)
313
                 if (sprite_sequence[j].object_id == object_id)
328
                     break;
314
                     break;
329
             }
315
             }
330
 
316
 
331
             // It's not a moveable, skip sprite
317
             // It's not a moveable, skip sprite
332
-            if (j != (int)mTombRaider.NumSpriteSequences())
333
-            {
334
-                //printf("s");
335
-                //fflush(stdout);
318
+            if (j < (int)mTombRaider.NumSpriteSequences())
336
                 continue;
319
                 continue;
337
-            }
338
         }
320
         }
339
 
321
 
340
-        for (j = 0; j < (int)mTombRaider.NumMoveables(); ++j)
341
-        {
322
+        for (j = 0; j < (int)mTombRaider.NumMoveables(); ++j) {
342
             if ((int)moveable[j].object_id == object_id)
323
             if ((int)moveable[j].object_id == object_id)
343
                 break;
324
                 break;
344
         }
325
         }
345
 
326
 
346
-        // It's not a moveable or even a sprite?, skip unknown
327
+        // It's not a moveable or even a sprite? Skip unknown
347
         if (j == (int)mTombRaider.NumMoveables())
328
         if (j == (int)mTombRaider.NumMoveables())
348
-        {
349
-            //printf("?"); // what the wolf?
350
-            //fflush(stdout);
351
             continue;
329
             continue;
352
-        }
353
 
330
 
354
-        processMoveable(j, i, &ent, cache2, cache, object_id);
331
+        processMoveable(j, i, object_id);
355
         statCount++;
332
         statCount++;
356
     }
333
     }
357
 
334
 
358
-    // Get models that aren't items
359
     /*
335
     /*
360
-    for (i = 0; i < mTombRaider.NumMoveables(); ++i)
336
+    // Get models that aren't items
337
+    for (int i = 0; i < mTombRaider.NumMoveables(); ++i)
361
     {
338
     {
362
         switch ((int)moveable[i].object_id)
339
         switch ((int)moveable[i].object_id)
363
         {
340
         {
364
             case 30:
341
             case 30:
365
             case 2: // Which tr needs this as model again?
342
             case 2: // Which tr needs this as model again?
366
-                processMoveable(i, i, &ent, cache2, cache,
367
-                        (int)moveable[i].object_id);
343
+                processMoveable(i, i, (int)moveable[i].object_id);
368
                 break;
344
                 break;
369
             default:
345
             default:
370
                 switch (mTombRaider.Engine())
346
                 switch (mTombRaider.Engine())
373
                         switch ((int)moveable[i].object_id)
349
                         switch ((int)moveable[i].object_id)
374
                         {
350
                         {
375
                             case TombRaider1::LaraMutant:
351
                             case TombRaider1::LaraMutant:
376
-                                processMoveable(i, i, &ent, cache2, cache,
377
-                                        (int)moveable[i].object_id);
352
+                                processMoveable(i, i, (int)moveable[i].object_id);
378
                                 break;
353
                                 break;
379
                         }
354
                         }
380
                         break;
355
                         break;
387
                             case TR4_CROSSBOW_ANIM:
362
                             case TR4_CROSSBOW_ANIM:
388
                             case TR4_GRENADE_GUN_ANIM:
363
                             case TR4_GRENADE_GUN_ANIM:
389
                             case TR4_SIXSHOOTER_ANIM:
364
                             case TR4_SIXSHOOTER_ANIM:
390
-                                processMoveable(i, i, &ent, cache2, cache,
391
-                                        (int)moveable[i].object_id);
365
+                                processMoveable(i, i, (int)moveable[i].object_id);
392
                                 break;
366
                                 break;
393
                         }
367
                         }
394
                         break;
368
                         break;
406
 }
380
 }
407
 
381
 
408
 // index moveable, i item, sometimes both moveable
382
 // index moveable, i item, sometimes both moveable
409
-void Game::processMoveable(int index, int i, int *ent,
410
-        std::vector<skeletal_model_t *> &cache2,
411
-        std::vector<unsigned int> &cache, int object_id)
383
+// object_id of item or moveable
384
+void Game::processMoveable(int index, int i, int object_id)
412
 {
385
 {
386
+    //std::vector<skeletal_model_t *> &cache2
387
+    //std::vector<unsigned int> &cache
388
+
389
+    bool cached = false;
390
+    for (unsigned int mod = 0; mod < getWorld().sizeSkeletalModel(); mod++) {
391
+        if (getWorld().getSkeletalModel(mod).getId() == moveable[index].object_id) {
392
+            cached = true;
393
+            break;
394
+        }
395
+    }
396
+
397
+    if (!cached) {
398
+        getWorld().addSkeletalModel(*new SkeletalModel(mTombRaider /* ... */));
399
+    }
400
+
401
+    getWorld().addEntity(*new Entity(mTombRaider, /* ... */ mod));
402
+
403
+
404
+
413
     // This creates both Entity and SkeletalModel
405
     // This creates both Entity and SkeletalModel
414
     // Basic Idea:
406
     // Basic Idea:
415
     // - Move animation state from SkeletalModel into Entity
407
     // - Move animation state from SkeletalModel into Entity
418
     // - Else store new skeletal model, tell new entity to use this one
410
     // - Else store new skeletal model, tell new entity to use this one
419
 
411
 
420
 
412
 
421
-    skeletal_model_t *r_model = NULL;
422
-    skeletal_model_t *c_model = NULL;
423
-    animation_frame_t *animation_frame = NULL;
424
-    tr2_mesh_t *mesh = NULL;
425
-    tr2_moveable_t *moveable = NULL;
426
-    tr2_meshtree_t *meshtree = NULL;
427
-    tr2_item_t *item = NULL;
428
-    tr2_animation_t *animation = NULL;
429
-    tr2_meshtree_t *mesh_tree = NULL;
430
-    bone_frame_t *bone = NULL;
431
-    bone_tag_t *tag = NULL;
432
-    entity_t *thing = NULL;
433
-    SkeletalModel *sModel = 0x0;
434
-    unsigned short *frame;
413
+
414
+
435
     int j, k, a, frame_step;
415
     int j, k, a, frame_step;
436
     unsigned int l, frame_offset, frame_count, f;
416
     unsigned int l, frame_offset, frame_count, f;
437
-    float pos[3];
438
-    float yaw;
439
-    bool lara = false;
440
-    int skyMesh;
441
-
442
-    skyMesh = mTombRaider.getSkyModelId();
443
-    frame = mTombRaider.Frame();
444
-    moveable = mTombRaider.Moveable();
445
-    meshtree = mTombRaider.MeshTree();
446
-    mesh = mTombRaider.Mesh();
447
-    item = mTombRaider.Item();
448
-    animation = mTombRaider.Animation();
449
-
450
-    pos[0] = item[i].x;
451
-    pos[1] = item[i].y;
452
-    pos[2] = item[i].z;
453
-
454
-    yaw = ((item[i].angle >> 14) & 0x03);
417
+
418
+    unsigned short *frame = mTombRaider.Frame();
419
+    tr2_moveable_t *moveable = mTombRaider.Moveable();
420
+    tr2_meshtree_t *meshtree = mTombRaider.MeshTree();
421
+    tr2_mesh_t *mesh = mTombRaider.Mesh();
422
+    tr2_item_t *item = mTombRaider.Item();
423
+    tr2_animation_t *animation = mTombRaider.Animation();
424
+
425
+    float yaw = ((item[i].angle >> 14) & 0x03);
455
     yaw *= 90;
426
     yaw *= 90;
456
 
427
 
457
-    thing = new entity_t;
458
-    //thing->id = (*ent)++;
428
+    entity_t *thing = new entity_t;
459
     thing->pos[0] = item[i].x;
429
     thing->pos[0] = item[i].x;
460
     thing->pos[1] = item[i].y;
430
     thing->pos[1] = item[i].y;
461
     thing->pos[2] = item[i].z;
431
     thing->pos[2] = item[i].z;
462
     thing->angles[1] = yaw;
432
     thing->angles[1] = yaw;
463
     thing->objectId = moveable[index].object_id;
433
     thing->objectId = moveable[index].object_id;
464
-    //thing->animate = false;
465
 
434
 
466
-    sModel = new SkeletalModel();
435
+    SkeletalModel *sModel = new SkeletalModel();
467
     getRender().addSkeletalModel(sModel);
436
     getRender().addSkeletalModel(sModel);
468
     thing->tmpHook = sModel; // temp hack to keep a running version during refactoring
437
     thing->tmpHook = sModel; // temp hack to keep a running version during refactoring
469
 
438
 
473
         {
442
         {
474
             case TombRaider1::Wolf:
443
             case TombRaider1::Wolf:
475
                 thing->state = TombRaider1::WolfState_Lying;
444
                 thing->state = TombRaider1::WolfState_Lying;
476
-                //thing->animate = true;
477
                 sModel->setAnimation(3);
445
                 sModel->setAnimation(3);
478
                 sModel->setFrame(0);
446
                 sModel->setFrame(0);
479
                 break;
447
                 break;
487
     //   return;
455
     //   return;
488
     // }
456
     // }
489
 
457
 
490
-    r_model = new skeletal_model_t;
458
+    skeletal_model_t *r_model = new skeletal_model_t;
491
     r_model->id = moveable[index].object_id;
459
     r_model->id = moveable[index].object_id;
492
 
460
 
493
     // Gather more info if this is lara
461
     // Gather more info if this is lara
494
     if (moveable[index].object_id == 0)
462
     if (moveable[index].object_id == 0)
495
     {
463
     {
496
-        lara = true;
497
         mLara = thing; // Mongoose 2002.03.22, Cheap hack for now
464
         mLara = thing; // Mongoose 2002.03.22, Cheap hack for now
498
 
465
 
499
-        switch (mTombRaider.Engine())
500
-        {
501
-            case TR_VERSION_3:
502
-                sModel->setAnimation(TR_ANIAMTION_RUN);
503
-                sModel->setIdleAnimation(TR_ANIAMTION_STAND);
504
-                r_model->tr4Overlay = false;
505
-                break;
506
-            case TR_VERSION_4:
507
-                sModel->setAnimation(TR_ANIAMTION_RUN);
508
-                sModel->setIdleAnimation(TR_ANIAMTION_STAND);
509
-                // Only TR4 lara has 2 layer bone tags/meshes per bone frame
510
-                r_model->tr4Overlay = true;
511
-                break;
512
-            case TR_VERSION_1:
513
-            case TR_VERSION_2:
514
-            case TR_VERSION_5:
515
-            case TR_VERSION_UNKNOWN:
516
-                sModel->setAnimation(TR_ANIAMTION_RUN);
517
-                sModel->setIdleAnimation(TR_ANIAMTION_STAND);
518
-                r_model->tr4Overlay = false;
519
-                break;
520
-        }
466
+        sModel->setAnimation(TR_ANIAMTION_RUN);
467
+        sModel->setIdleAnimation(TR_ANIAMTION_STAND);
521
 
468
 
469
+        // Only TR4 lara has 2 layer bone tags/meshes per bone frame
470
+        r_model->tr4Overlay = (mTombRaider.Engine() == TR_VERSION_4);
522
         r_model->ponytailId = 0;
471
         r_model->ponytailId = 0;
523
     }
472
     }
524
     else
473
     else
525
     {
474
     {
526
-        lara = false;
527
         r_model->ponytailId = -1;
475
         r_model->ponytailId = -1;
528
     }
476
     }
529
 
477
 
533
     frame_offset = animation[a].frame_offset / 2;
481
     frame_offset = animation[a].frame_offset / 2;
534
     frame_step = animation[a].frame_size;
482
     frame_step = animation[a].frame_size;
535
 
483
 
536
-    int frame_cycle = 0;
537
-
538
     if (a >= (int)mTombRaider.NumAnimations())
484
     if (a >= (int)mTombRaider.NumAnimations())
539
     {
485
     {
540
         a = mTombRaider.NumFrames() - frame_offset;
486
         a = mTombRaider.NumFrames() - frame_offset;
547
     if (frame_step != 0)  // prevent divide-by-zero errors
493
     if (frame_step != 0)  // prevent divide-by-zero errors
548
         a /= frame_step;
494
         a /= frame_step;
549
 
495
 
550
-    if (a != 0) // prevent divide-by-zero errors
551
-        frame_offset += frame_step * (frame_cycle % a);
552
-
553
     if (a < 0)
496
     if (a < 0)
554
     {
497
     {
555
         //continue;
498
         //continue;
556
         getConsole().print("Invalid animation data for model %d", index);
499
         getConsole().print("Invalid animation data for model %d", index);
557
         delete r_model;
500
         delete r_model;
558
-        return;
501
+        return; // leaking thing here!
559
     }
502
     }
560
 
503
 
561
     //! \fixme Might be better UID for each model, but this seems to work well
504
     //! \fixme Might be better UID for each model, but this seems to work well
637
     {
580
     {
638
         // Already cached
581
         // Already cached
639
         delete r_model;
582
         delete r_model;
640
-        c_model = cache2[foundIndex];
641
-        sModel->model = c_model;
583
+        r_model = cache2[foundIndex];
584
+        sModel->model = r_model;
642
         getWorld().addEntity(thing);
585
         getWorld().addEntity(thing);
643
-        getWorld().addModel(c_model);
586
+        getWorld().addModel(r_model);
644
         printf("c");
587
         printf("c");
645
         return;
588
         return;
646
     }
589
     }
647
 
590
 
648
     int aloop = mTombRaider.getNumAnimsForMoveable(index);
591
     int aloop = mTombRaider.getNumAnimsForMoveable(index);
649
 
592
 
650
-#ifdef DEBUG_MOVEABLE
651
-    printf("\nanimation = %i, num_animations = %i\n",
652
-            moveable[index].animation, aloop);
653
-    printf("\nitem[%i].flags = %i\nentity[%i]\n",
654
-            i, item[i].flags, thing->id);
655
-#endif
656
-
657
     //a = moveable[index].animation;
593
     //a = moveable[index].animation;
658
     //frame_offset = animation[a].frame_offset / 2;
594
     //frame_offset = animation[a].frame_offset / 2;
659
     //frame_step = animation[a].frame_size;
595
     //frame_step = animation[a].frame_size;
662
             frame_offset = animation[a].frame_offset / 2,
598
             frame_offset = animation[a].frame_offset / 2,
663
             frame_step = animation[a].frame_size)
599
             frame_step = animation[a].frame_size)
664
     {
600
     {
665
-        animation_frame = new animation_frame_t;
601
+        animation_frame_t *animation_frame = new animation_frame_t;
666
         r_model->animation.push_back(animation_frame);
602
         r_model->animation.push_back(animation_frame);
667
 
603
 
668
         frame_count = (animation[a].frame_end - animation[a].frame_start) + 1;
604
         frame_count = (animation[a].frame_end - animation[a].frame_start) + 1;
669
         animation_frame->rate = animation[a].frame_rate;
605
         animation_frame->rate = animation[a].frame_rate;
670
 
606
 
671
-#ifdef DEBUG_MOVEABLE
672
-        printf("animation[%i] state and unknowns = %i, %i, %i, %i, %i\n",
673
-                a, animation[a].state_id, animation[a].unknown1,
674
-                animation[a].unknown2, animation[a].unknown3,
675
-                animation[a].unknown4);
676
-        printf("animation[%i].frame_rate = %i\n",
677
-                a, animation[a].frame_rate);
678
-        printf("animation[%i].next_animation = %i\n",
679
-                a, animation[a].next_animation);
680
-        printf("animation[%i].frame_offset = %u\n",
681
-                a, animation[a].frame_offset);
682
-        printf("animation[%i].anim_command = %i\n",
683
-                a, animation[a].anim_command);
684
-        printf("animation[%i].num_anim_commands = %i\n",
685
-                a, animation[a].num_anim_commands);
686
-        printf("animation[%i].state_change_offset = %i\n",
687
-                a, animation[a].state_change_offset);
688
-        printf("              frame_offset = %u\n",
689
-                frame_offset);
690
-#endif
691
-
692
         // Get all the frames for aniamtion
607
         // Get all the frames for aniamtion
693
         for (f = 0; f < frame_count; ++f, frame_offset += frame_step)
608
         for (f = 0; f < frame_count; ++f, frame_offset += frame_step)
694
         {
609
         {
729
                 }
644
                 }
730
             }
645
             }
731
 
646
 
732
-#ifdef DEBUG_MOVEABLE
733
-            printf("animation[%i].boneframe[%u] = offset %u, step %i\n",
734
-                    a, f, frame_offset, frame_step);
735
-#endif
736
-
737
             // Mongoose 2002.08.15, Was
647
             // Mongoose 2002.08.15, Was
738
             //   if (frame_offset + 8 > _tombraider.NumFrames())
648
             //   if (frame_offset + 8 > _tombraider.NumFrames())
739
             if (frame_offset > mTombRaider.NumFrames())
649
             if (frame_offset > mTombRaider.NumFrames())
740
             {
650
             {
741
                 getConsole().print("WARNING: Bad animation frame %i > %i",
651
                 getConsole().print("WARNING: Bad animation frame %i > %i",
742
                         frame_offset, mTombRaider.NumFrames());
652
                         frame_offset, mTombRaider.NumFrames());
743
-
744
-                // Mongoose 2002.08.15, Attempt to skip more likely bad animation data
745
-                getConsole().print("WARNING: Handling bad animation data...");
746
                 return; //continue;
653
                 return; //continue;
747
             }
654
             }
748
 
655
 
749
             // Generate bone frames and tags per frame ////////////
656
             // Generate bone frames and tags per frame ////////////
750
-            bone = new bone_frame_t;
657
+            bone_frame_t *bone = new bone_frame_t;
751
             animation_frame->frame.push_back(bone);
658
             animation_frame->frame.push_back(bone);
752
 
659
 
753
             // Init translate for bone frame
660
             // Init translate for bone frame
763
             // Run through the tag and calculate the rotation and offset
670
             // Run through the tag and calculate the rotation and offset
764
             for (j = 0; j < (int)moveable[index].num_meshes; ++j)
671
             for (j = 0; j < (int)moveable[index].num_meshes; ++j)
765
             {
672
             {
766
-                tag = new bone_tag_t;
673
+                bone_tag_t *tag = new bone_tag_t;
767
                 bone->tag.push_back(tag);
674
                 bone->tag.push_back(tag);
768
                 tag->off[0] = 0.0;
675
                 tag->off[0] = 0.0;
769
                 tag->off[1] = 0.0;
676
                 tag->off[1] = 0.0;
777
                 // Setup offsets to produce skeletion
684
                 // Setup offsets to produce skeletion
778
                 if (j == 0)
685
                 if (j == 0)
779
                 {
686
                 {
780
-                    // Since we use bone's offset, these aren't used
781
-                    tag->off[0] = 0.0;
782
-                    tag->off[1] = 0.0;
783
-                    tag->off[2] = 0.0;
784
-
785
                     // Always push tag[0], this isn't really used either
687
                     // Always push tag[0], this isn't really used either
786
                     tag->flag = 0x02;
688
                     tag->flag = 0x02;
787
                 }
689
                 }
791
                     // Hack: moveable[index].mesh_tree is a byte offset
693
                     // Hack: moveable[index].mesh_tree is a byte offset
792
                     //       into mesh_tree[], so we have to convert to index
694
                     //       into mesh_tree[], so we have to convert to index
793
                     tree = (int *)(void *)meshtree;
695
                     tree = (int *)(void *)meshtree;
794
-                    mesh_tree = (tr2_meshtree_t *)&tree[moveable[index].mesh_tree
696
+                    tr2_meshtree_t *mesh_tree = (tr2_meshtree_t *)&tree[moveable[index].mesh_tree
795
                         + ((j - 1) * 4)];
697
                         + ((j - 1) * 4)];
796
 
698
 
797
                     tag->off[0] = mesh_tree->x;
699
                     tag->off[0] = mesh_tree->x;
807
         }
709
         }
808
     }
710
     }
809
 
711
 
810
-    if (i == skyMesh)
811
-    {
712
+    if (i == mTombRaider.getSkyModelId())
812
         getRender().setSkyMesh(i, //moveable[i].starting_mesh,
713
         getRender().setSkyMesh(i, //moveable[i].starting_mesh,
813
                 (mTombRaider.Engine() == TR_VERSION_2));
714
                 (mTombRaider.Engine() == TR_VERSION_2));
814
-    }
815
-
816
-    //printf(".");
817
-    //fflush(stdout);
818
 }
715
 }
819
 
716
 
820
 bool compareFaceTextureId(const void *voidA, const void *voidB)
717
 bool compareFaceTextureId(const void *voidA, const void *voidB)

+ 47
- 61
src/SkeletalModel.cpp View File

6
  * \author xythobuz
6
  * \author xythobuz
7
  */
7
  */
8
 
8
 
9
-#include <cstddef>
9
+#include <assert.h>
10
+
10
 #include "SkeletalModel.h"
11
 #include "SkeletalModel.h"
11
 
12
 
12
-SkeletalModel::SkeletalModel() {
13
-    model = NULL;
14
-    mBoneFrame = 0;
15
-    mAnimationFrame = 0;
16
-    mIdleAnimation = 0;
13
+BoneTag::BoneTag() {
14
+
17
 }
15
 }
18
 
16
 
19
-SkeletalModel::~SkeletalModel() {
20
-    // Model is really stored in World and deleted there
21
-    // Deleting it here causes EXEC_BAD_ACCESS...
22
-    /* if (model) {
23
-        for(std::vector<animation_frame_t>::size_type i = 0; i < model->animation.size(); i++) {
24
-            animation_frame_t *af = model->animation[i];
17
+BoneFrame::BoneFrame() {
25
 
18
 
26
-            if (!af)
27
-                continue;
19
+}
28
 
20
 
29
-            for(std::vector<bone_frame_t>::size_type j = 0; j < af->frame.size(); j++) {
30
-                bone_frame_t *bf = af->frame[j];
21
+BoneFrame::~BoneFrame() {
22
+    for (unsigned int i = 0; i < tag.size(); i++)
23
+        delete tag[i];
24
+}
31
 
25
 
32
-                if (!bf)
33
-                    continue;
26
+unsigned int BoneFrame::size() {
27
+    return tag.size();
28
+}
34
 
29
 
35
-                for(std::vector<bone_tag_t>::size_type k = 0; k < bf->tag.size(); k++) {
36
-                    if (bf->tag[i])
37
-                        delete bf->tag[i];
38
-                }
30
+BoneTag &BoneFrame::get(unsigned int i) {
31
+    assert(i < tag.size());
32
+    return *tag.at(i);
33
+}
39
 
34
 
40
-                delete bf;
41
-            }
35
+void BoneFrame::add(BoneTag &b) {
36
+    tag.push_back(&b);
37
+}
42
 
38
 
43
-            delete af;
44
-        }
39
+AnimationFrame::AnimationFrame() {
45
 
40
 
46
-        delete model;
47
-    } */
48
 }
41
 }
49
 
42
 
50
-int SkeletalModel::getAnimation() {
51
-    return mAnimationFrame;
43
+AnimationFrame::~AnimationFrame() {
44
+    for (unsigned int i = 0; i < frame.size(); i++)
45
+        delete frame[i];
52
 }
46
 }
53
 
47
 
54
-int SkeletalModel::getFrame() {
55
-    return mBoneFrame;
48
+unsigned int AnimationFrame::size() {
49
+    return frame.size();
56
 }
50
 }
57
 
51
 
58
-int SkeletalModel::getIdleAnimation() {
59
-    return mIdleAnimation;
52
+BoneFrame &AnimationFrame::get(unsigned int i) {
53
+    assert(i < frame.size());
54
+    return *frame.at(i);
60
 }
55
 }
61
 
56
 
62
-void SkeletalModel::setModel(skeletal_model_t *mdl) {
63
-    if (mdl)
64
-        model = mdl;
57
+void AnimationFrame::add(BoneFrame &b) {
58
+    frame.push_back(&b);
65
 }
59
 }
66
 
60
 
67
-void SkeletalModel::setAnimation(int index) {
68
-    if (!model) // index > (int)model->animation.size())
69
-        return;
70
-
71
-    animation_frame_t *a = model->animation[index];
61
+SkeletalModel::SkeletalModel() {
72
 
62
 
73
-    if (a) {
74
-        mAnimationFrame = index;
75
-        mBoneFrame = 0;
76
-    }
77
 }
63
 }
78
 
64
 
79
-void SkeletalModel::setFrame(int index) {
80
-    if (!model)
81
-        return;
82
-
83
-    animation_frame_t *a = model->animation[mAnimationFrame];
65
+SkeletalModel::~SkeletalModel() {
66
+    for (unsigned int i = 0; i < animation.size(); i++)
67
+        delete animation[i];
68
+}
84
 
69
 
85
-    if (a) { // index > (int)a->frame.size())
86
-        bone_frame_t *b = a->frame[index];
70
+int SkeletalModel::getId() {
71
+    return id;
72
+}
87
 
73
 
88
-        if (b)
89
-            mBoneFrame = index;
90
-    }
74
+unsigned int SkeletalModel::size() {
75
+    return animation.size();
91
 }
76
 }
92
 
77
 
93
-void SkeletalModel::setIdleAnimation(int index) {
94
-    if (!model)
95
-        return;
78
+AnimationFrame &SkeletalModel::get(unsigned int i) {
79
+    assert(i < animation.size());
80
+    return *animation.at(i);
81
+}
96
 
82
 
97
-    if (model->animation[index])
98
-        mIdleAnimation = index;
83
+void SkeletalModel::add(AnimationFrame &a) {
84
+    animation.push_back(&a);
99
 }
85
 }
100
 
86
 

+ 39
- 101
src/World.cpp View File

11
 
11
 
12
 #include "World.h"
12
 #include "World.h"
13
 
13
 
14
-World::~World()
15
-{
14
+World::~World() {
16
     destroy();
15
     destroy();
17
 }
16
 }
18
 
17
 
19
-
20
 // Temp methods for rendering use until more refactoring is done
18
 // Temp methods for rendering use until more refactoring is done
21
 model_mesh_t *World::getMesh(int index)
19
 model_mesh_t *World::getMesh(int index)
22
 {
20
 {
23
     return mMeshes[index];
21
     return mMeshes[index];
24
 }
22
 }
25
 
23
 
26
-skeletal_model_t *World::getModel(int index)
27
-{
28
-    return mModels[index];
29
-}
30
-
31
-std::vector<entity_t *> *World::getEntities()
32
-{
33
-    return &mEntities;
34
-}
35
-
36
 void World::addMesh(model_mesh_t *mesh)
24
 void World::addMesh(model_mesh_t *mesh)
37
 {
25
 {
38
     if (mesh)
26
     if (mesh)
39
         mMeshes.push_back(mesh);
27
         mMeshes.push_back(mesh);
40
 }
28
 }
41
 
29
 
42
-
43
-void World::addEntity(entity_t *e)
44
-{
45
-    if (e)
46
-    {
47
-        e->moveType = worldMoveType_walk; // Walk
48
-        e->room = getRoomByLocation(e->pos[0], e->pos[1], e->pos[2]);
49
-        mEntities.push_back(e);
50
-    }
51
-}
52
-
53
-
54
-int World::addModel(skeletal_model_t *model)
55
-{
56
-    if (model)
57
-    {
58
-        mModels.push_back(model);
59
-        return mModels.size() - 1;
60
-    }
61
-
62
-    return -1;
63
-}
64
-
65
-
66
 void World::moveEntity(entity_t *e, char movement)
30
 void World::moveEntity(entity_t *e, char movement)
67
 {
31
 {
68
     const float moved = 180.0f;
32
     const float moved = 180.0f;
262
     return *mSprites.at(index);
226
     return *mSprites.at(index);
263
 }
227
 }
264
 
228
 
229
+void World::addEntity(Entity &entity) {
230
+    //e->moveType = worldMoveType_walk; // Walk
231
+    //e->room = getRoomByLocation(e->pos[0], e->pos[1], e->pos[2]);
232
+    mEntities.push_back(&entity);
233
+}
234
+
235
+unsigned int World::sizeEntity() {
236
+    return mEntities.size();
237
+}
238
+
239
+Entity &World::getEntity(unsigned int index) {
240
+    assert(index < mEntities.size());
241
+    return *mEntities.at(index);
242
+}
243
+
244
+void World::addSkeletalModel(SkeletalModel &model) {
245
+    mModels.push_back(&model);
246
+}
247
+
248
+unsigned int World::sizeSkeletalModel() {
249
+    return mModels.size();
250
+}
251
+
252
+SkeletalModel &World::getSkeletalModel(unsigned int index) {
253
+    assert(index < mModels.size());
254
+    return *mModels.at(index);
255
+}
256
+
265
 
257
 
266
 int World::getRoomByLocation(int index, float x, float y, float z)
258
 int World::getRoomByLocation(int index, float x, float y, float z)
267
 {
259
 {
377
 }
369
 }
378
 
370
 
379
 
371
 
380
-void World::destroy()
381
-{
372
+void World::destroy() {
382
     for (unsigned int i = 0; i != mRooms.size(); i++)
373
     for (unsigned int i = 0; i != mRooms.size(); i++)
383
         delete mRooms[i];
374
         delete mRooms[i];
375
+    mRooms.clear();
384
 
376
 
385
     for (unsigned int i = 0; i != mSprites.size(); i++)
377
     for (unsigned int i = 0; i != mSprites.size(); i++)
386
         delete mSprites[i];
378
         delete mSprites[i];
379
+    mSprites.clear();
387
 
380
 
388
-    model_mesh_t *mesh;
389
-    skeletal_model_t *model;
390
-    bone_frame_t *boneframe;
391
-    bone_tag_t *tag;
392
-    animation_frame_t *animation;
393
-    std::list<skeletal_model_t *> cache;
394
-
395
-    for (std::vector<int>::size_type i = 0; i != mEntities.size(); i++)
381
+    for (unsigned int i = 0; i != mEntities.size(); i++)
396
         delete mEntities[i];
382
         delete mEntities[i];
383
+    mEntities.clear();
384
+
385
+    for (unsigned int i = 0; i != mModels.size(); i++)
386
+        delete mModels[i];
387
+    mModels.clear();
397
 
388
 
398
     for (std::vector<int>::size_type i = 0; i != mMeshes.size(); i++) {
389
     for (std::vector<int>::size_type i = 0; i != mMeshes.size(); i++) {
399
-        mesh = mMeshes[i];
390
+        model_mesh_t *mesh = mMeshes[i];
400
 
391
 
401
         if (!mesh)
392
         if (!mesh)
402
             continue;
393
             continue;
432
 
423
 
433
         delete mesh;
424
         delete mesh;
434
     }
425
     }
435
-
436
     mMeshes.clear();
426
     mMeshes.clear();
437
-
438
-    for (std::vector<int>::size_type i = 0; i != mModels.size(); i++) {
439
-        model = mModels[i];
440
-
441
-        if (!model)
442
-            continue;
443
-
444
-        // No smart pointers, so skip if deleted once  =)
445
-        bool found = false;
446
-        for (std::list<skeletal_model_t *>::const_iterator iterator = cache.begin(), end = cache.end(); iterator != end; ++iterator) {
447
-            if (model == *iterator) {
448
-                found = true;
449
-                break;
450
-            }
451
-        }
452
-
453
-        if (!found)
454
-            cache.push_back(model);
455
-        else
456
-            continue;
457
-
458
-        for (std::vector<int>::size_type j = 0; j != model->animation.size(); j++) {
459
-            animation  = model->animation[j];
460
-
461
-            if (!animation)
462
-                continue;
463
-
464
-            for (std::vector<int>::size_type k = 0; k != animation->frame.size(); k++) {
465
-                boneframe = animation->frame[k];
466
-
467
-                if (!boneframe)
468
-                    continue;
469
-
470
-                for (std::vector<int>::size_type l = 0; l != boneframe->tag.size(); l++) {
471
-                    tag = boneframe->tag[l];
472
-
473
-                    if (!tag)
474
-                        continue;
475
-
476
-                    delete tag;
477
-                }
478
-
479
-                delete boneframe;
480
-            }
481
-
482
-            delete animation;
483
-        }
484
-
485
-        delete model;
486
-    }
487
-
488
-    mModels.clear();
489
 }
427
 }
490
 
428
 

Loading…
Cancel
Save