Bläddra i källkod

Created Entity class

Thomas Buck 11 år sedan
förälder
incheckning
6f15905676
14 ändrade filer med 167 tillägg och 81 borttagningar
  1. 23
    18
      CMakeLists.txt
  2. 6
    0
      ChangeLog.md
  3. 6
    0
      TODO.md
  4. 56
    0
      include/Entity.h
  5. 0
    2
      include/Render.h
  6. 0
    4
      include/SkeletalModel.h
  7. 1
    0
      include/TombRaider.h
  8. 20
    18
      include/World.h
  9. 0
    3
      include/WorldData.h
  10. 1
    1
      src/CMakeLists.txt
  11. 37
    0
      src/Entity.cpp
  12. 15
    9
      src/Game.cpp
  13. 0
    20
      src/Render.cpp
  14. 2
    6
      src/SkeletalModel.cpp

+ 23
- 18
CMakeLists.txt Visa fil

38
     set (WARNINGS "${WARNINGS} -Wno-missing-prototypes -Wno-missing-variable-declarations")
38
     set (WARNINGS "${WARNINGS} -Wno-missing-prototypes -Wno-missing-variable-declarations")
39
     set (WARNINGS "${WARNINGS} -Wno-disabled-macro-expansion")
39
     set (WARNINGS "${WARNINGS} -Wno-disabled-macro-expansion")
40
     set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32 -Wno-sign-conversion")
40
     set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32 -Wno-sign-conversion")
41
+    set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
42
+    set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0")
43
+    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2 -fomit-frame-pointer")
44
+    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -ffast-math -funroll-loops")
41
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
45
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
42
     set (WARNINGS "${WARNINGS} -Wall -Wextra -Wpedantic")
46
     set (WARNINGS "${WARNINGS} -Wall -Wextra -Wpedantic")
47
+    set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
48
+    set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0")
49
+    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2 -fomit-frame-pointer")
50
+    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -ffast-math -funroll-loops")
43
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
51
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
44
     # TODO Visual C++ compiler flags?
52
     # TODO Visual C++ compiler flags?
45
 endif()
53
 endif()
46
 
54
 
47
 # Flags for all builds
55
 # Flags for all builds
48
-set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11 ${WARNINGS}")
56
+set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} ${WARNINGS}")
49
 
57
 
50
 # Flags for Debug build
58
 # Flags for Debug build
51
-set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0")
52
 set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -DDEBUG")
59
 set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -DDEBUG")
53
 set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -DEXPERIMENTAL")
60
 set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -DEXPERIMENTAL")
54
 # set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -DMULTITEXTURE")
61
 # set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -DMULTITEXTURE")
55
 
62
 
56
 # Flags for Releasae builds
63
 # Flags for Releasae builds
57
-set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
58
-set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -ffast-math -funroll-loops")
59
-set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
64
+set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -DNDEBUG")
60
 
65
 
61
 #################################################################
66
 #################################################################
62
 
67
 
65
 
70
 
66
 #################################################################
71
 #################################################################
67
 
72
 
68
-# Target for running the setup
69
-add_custom_target (setup "${PROJECT_SOURCE_DIR}/cmake/setup.sh"
70
-    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
71
-)
73
+if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
72
 
74
 
73
-#################################################################
75
+    # Target for running the setup
76
+    add_custom_target (setup "${PROJECT_SOURCE_DIR}/cmake/setup.sh"
77
+        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
78
+    )
74
 
79
 
75
-# Target for running cppcheck
76
-if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
80
+    #################################################################
81
+
82
+    # Target for running cppcheck
77
     set (CHECK_STD "--std=c++11" "--std=posix")
83
     set (CHECK_STD "--std=c++11" "--std=posix")
78
     set (CHECK_FLAGS "--quiet" "--force")
84
     set (CHECK_FLAGS "--quiet" "--force")
79
     set (CHECK_NORMAL "--enable=information,warning,performance,portability")
85
     set (CHECK_NORMAL "--enable=information,warning,performance,portability")
88
     add_custom_target (checkConfig echo "Checking cppcheck config..."
94
     add_custom_target (checkConfig echo "Checking cppcheck config..."
89
         COMMAND cppcheck ${CHECK_FLAGS} "-I${PROJECT_SOURCE_DIR}/include" ${CHECK_CONFIG} ${PROJECT_SOURCE_DIR}
95
         COMMAND cppcheck ${CHECK_FLAGS} "-I${PROJECT_SOURCE_DIR}/include" ${CHECK_CONFIG} ${PROJECT_SOURCE_DIR}
90
     )
96
     )
91
-endif (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
92
 
97
 
93
-#################################################################
98
+    #################################################################
94
 
99
 
95
-# Generate Doxygen Documentation
96
-if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
100
+    # Generate Doxygen Documentation
97
     find_package (Doxygen)
101
     find_package (Doxygen)
98
     if (DOXYGEN_FOUND)
102
     if (DOXYGEN_FOUND)
99
         # Configure the Template Doxyfile for our specific project
103
         # Configure the Template Doxyfile for our specific project
122
             COMMAND sed -i '' "s/CALL_GRAPH             = YES/CALL_GRAPH             = NO/g" Doxyfile
126
             COMMAND sed -i '' "s/CALL_GRAPH             = YES/CALL_GRAPH             = NO/g" Doxyfile
123
             COMMAND sed -i '' "s/CALLER_GRAPH           = YES/CALLER_GRAPH           = NO/g" Doxyfile
127
             COMMAND sed -i '' "s/CALLER_GRAPH           = YES/CALLER_GRAPH           = NO/g" Doxyfile
124
             SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
128
             SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
129
+
130
+        # Clean doc files
131
+        set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "doc")
125
     endif (DOXYGEN_FOUND)
132
     endif (DOXYGEN_FOUND)
126
 endif (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
133
 endif (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
127
 
134
 
128
-# Clean doc files
129
-set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "doc")

+ 6
- 0
ChangeLog.md Visa fil

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+    [ 20140515 ]
6
+    * Slight cmake script improvements
7
+    * Created Entity class that will also get animation state
8
+      from SkeletalModel
9
+    * Removed some unused old code parts
10
+
5
     [ 20140507 ]
11
     [ 20140507 ]
6
     * Prepared for Windows support using Visual C++
12
     * Prepared for Windows support using Visual C++
7
       - Wrote utils/time implementation for Windows
13
       - Wrote utils/time implementation for Windows

+ 6
- 0
TODO.md Visa fil

18
 
18
 
19
 * Using std::vector with [] is not bound checked. Segfaults were caused because the upper bound of the argument was never checked and garbage was returned... Do consistent checks, or use .at() as it throws an exception
19
 * Using std::vector with [] is not bound checked. Segfaults were caused because the upper bound of the argument was never checked and garbage was returned... Do consistent checks, or use .at() as it throws an exception
20
 
20
 
21
+## Cmake
22
+
23
+* Windows setup script needed, moving to AppData/Roaming
24
+* Support SSE with other compilers than Clang (src/CMakeLists.txt)
25
+* Visual C++ compiler flags? (CMakeLists.txt)
26
+
21
 ## Future Features
27
 ## Future Features
22
 
28
 
23
 * Use only assets from old TR games?
29
 * Use only assets from old TR games?

+ 56
- 0
include/Entity.h Visa fil

1
+/*!
2
+ * \file include/Entity.h
3
+ * \brief World Entities
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _ENTITY_H_
9
+#define _ENTITY_H_
10
+
11
+#include "math/math.h"
12
+#include "TombRaider.h"
13
+
14
+class Entity {
15
+public:
16
+    typedef enum {
17
+        MoveTypeWalkNoSwim = -1,
18
+        MoveTypeWalk       = 0,
19
+        MoveTypeNoClipping = 1,
20
+        MoveTypeFly        = 2,
21
+        MoveTypeSwim       = 3
22
+    } MoveType;
23
+
24
+    Entity(TombRaider &tr);
25
+
26
+    // Animation State
27
+
28
+    unsigned int getAnimationFrame();
29
+    void setAnimationFrame(unsigned int index);
30
+
31
+    unsigned int getBoneFrame();
32
+    void setBoneFrame(unsigned int index);
33
+
34
+    unsigned int getIdleAnimation();
35
+    void setIdleAnimation(unsigned int index);
36
+
37
+private:
38
+    vec3_t pos;
39
+    vec3_t angles;
40
+    int room;
41
+
42
+    unsigned int skeletalModel;
43
+    MoveType moveType;
44
+
45
+    int state;
46
+    int objectId;
47
+
48
+    // Animation State
49
+
50
+    unsigned int boneFrame;
51
+    unsigned int animationFrame;
52
+    unsigned int idleAnimation;
53
+};
54
+
55
+#endif
56
+

+ 0
- 2
include/Render.h Visa fil

121
 
121
 
122
     void setSkyMesh(int index, bool rot);
122
     void setSkyMesh(int index, bool rot);
123
 
123
 
124
-    void ViewModel(entity_t *ent, int index);
125
-
126
     void addSkeletalModel(SkeletalModel *mdl);
124
     void addSkeletalModel(SkeletalModel *mdl);
127
 
125
 
128
     unsigned int getFlags();
126
     unsigned int getFlags();

+ 0
- 4
include/SkeletalModel.h Visa fil

79
 
79
 
80
     void setIdleAnimation(int index);
80
     void setIdleAnimation(int index);
81
 
81
 
82
-    unsigned int flags;
83
     skeletal_model_t *model; //!< World render model
82
     skeletal_model_t *model; //!< World render model
84
-    float time;              //!< Interpolation use
85
-    float lastTime;
86
-    float rate;              //!< \fixme temp cache this here for old animation system use
87
 
83
 
88
 private:
84
 private:
89
     int mBoneFrame;      //!< Bone frame
85
     int mBoneFrame;      //!< Bone frame

+ 1
- 0
include/TombRaider.h Visa fil

10
 #define _TOMBRAIDER_H_
10
 #define _TOMBRAIDER_H_
11
 
11
 
12
 #include <cstdint>
12
 #include <cstdint>
13
+#include <cstdio>
13
 
14
 
14
 #ifdef WIN32
15
 #ifdef WIN32
15
 typedef uint8_t u_int8_t;
16
 typedef uint8_t u_int8_t;

+ 20
- 18
include/World.h Visa fil

29
     ~World();
29
     ~World();
30
 
30
 
31
     /*!
31
     /*!
32
+     * \brief Clears all data in world
33
+     */
34
+    void destroy();
35
+
36
+    void addRoom(Room &room);
37
+
38
+    unsigned int sizeRoom();
39
+
40
+    Room &getRoom(unsigned int index);
41
+
42
+    void addSprite(SpriteSequence &sprite);
43
+
44
+    unsigned int sizeSprite();
45
+
46
+    SpriteSequence &getSprite(unsigned int index);
47
+
48
+    /*!
32
      * \brief Adds mesh to world
49
      * \brief Adds mesh to world
33
      * \param model mesh to add
50
      * \param model mesh to add
34
      */
51
      */
58
     skeletal_model_t *getModel(int index);
75
     skeletal_model_t *getModel(int index);
59
     std::vector<entity_t *> *getEntities();
76
     std::vector<entity_t *> *getEntities();
60
 
77
 
61
-    void addRoom(Room &room);
62
-
63
-    unsigned int sizeRoom();
64
-
65
-    Room &getRoom(unsigned int index);
66
-
67
-    void addSprite(SpriteSequence &sprite);
68
-
69
-    unsigned int sizeSprite();
70
-
71
-    SpriteSequence &getSprite(unsigned int index);
72
-
73
     /*!
78
     /*!
74
      * \brief Find room a location is in.
79
      * \brief Find room a location is in.
75
      *
80
      *
117
      * \returns sector index of position in room
122
      * \returns sector index of position in room
118
      */
123
      */
119
     int getSector(int room, float x, float z);
124
     int getSector(int room, float x, float z);
125
+
120
     int getSector(int room, float x, float z, float *floor, float *ceiling);
126
     int getSector(int room, float x, float z, float *floor, float *ceiling);
121
 
127
 
122
     unsigned int getRoomInfo(int room);
128
     unsigned int getRoomInfo(int room);
138
      */
144
      */
139
     void getHeightAtPosition(int index, float x, float *y, float z);
145
     void getHeightAtPosition(int index, float x, float *y, float z);
140
 
146
 
141
-    /*!
142
-     * \brief Clears all data in world
143
-     * \todo in future will check if data is in use before clearing
144
-     */
145
-    void destroy();
146
-
147
 private:
147
 private:
148
 
148
 
149
     // Old World
149
     // Old World
155
     std::vector<Room *> mRooms;
155
     std::vector<Room *> mRooms;
156
     std::vector<SpriteSequence *> mSprites;
156
     std::vector<SpriteSequence *> mSprites;
157
 
157
 
158
+    //std::vector<Entity *> mEntities;
159
+    //std::vector<SkeletalModel *> mModels;
158
 };
160
 };
159
 
161
 
160
 #endif
162
 #endif

+ 0
- 3
include/WorldData.h Visa fil

51
 } model_mesh_t;
51
 } model_mesh_t;
52
 
52
 
53
 typedef struct {
53
 typedef struct {
54
-    int id;                  //!< Unique identifier
55
     float pos[3];            //!< World position
54
     float pos[3];            //!< World position
56
     float angles[3];         //!< Euler angles (pitch, yaw, roll)
55
     float angles[3];         //!< Euler angles (pitch, yaw, roll)
57
     int room;                //!< Current room entity is in
56
     int room;                //!< Current room entity is in
60
     int state;               //!< State of the Player, AI, or object
59
     int state;               //!< State of the Player, AI, or object
61
     int objectId;            //!< What kind of entity?
60
     int objectId;            //!< What kind of entity?
62
 
61
 
63
-    int modelId;             //!< Animation model
64
     SkeletalModel *tmpHook;
62
     SkeletalModel *tmpHook;
65
-    bool animate;
66
 } entity_t;
63
 } entity_t;
67
 
64
 
68
 #endif
65
 #endif

+ 1
- 1
src/CMakeLists.txt Visa fil

42
 set (SRCS ${SRCS} "Camera.cpp")
42
 set (SRCS ${SRCS} "Camera.cpp")
43
 set (SRCS ${SRCS} "Command.cpp")
43
 set (SRCS ${SRCS} "Command.cpp")
44
 set (SRCS ${SRCS} "Console.cpp")
44
 set (SRCS ${SRCS} "Console.cpp")
45
+set (SRCS ${SRCS} "Entity.cpp")
45
 set (SRCS ${SRCS} "Game.cpp")
46
 set (SRCS ${SRCS} "Game.cpp")
46
 set (SRCS ${SRCS} "main.cpp")
47
 set (SRCS ${SRCS} "main.cpp")
47
 set (SRCS ${SRCS} "Menu.cpp")
48
 set (SRCS ${SRCS} "Menu.cpp")
141
     if (NOT "${SSE_FOUND_MSG}" STREQUAL "")
142
     if (NOT "${SSE_FOUND_MSG}" STREQUAL "")
142
         message (STATUS "Enabled${SSE_FOUND_MSG}...")
143
         message (STATUS "Enabled${SSE_FOUND_MSG}...")
143
     endif (NOT "${SSE_FOUND_MSG}" STREQUAL "")
144
     endif (NOT "${SSE_FOUND_MSG}" STREQUAL "")
144
-# TODO support SSE with other compilers than Clang
145
 endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
145
 endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
146
 
146
 
147
 # Apply Flags
147
 # Apply Flags

+ 37
- 0
src/Entity.cpp Visa fil

1
+/*!
2
+ * \file src/Entity.cpp
3
+ * \brief World Entities
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "Entity.h"
9
+
10
+Entity::Entity(TombRaider &tr) {
11
+
12
+}
13
+
14
+unsigned int Entity::getAnimationFrame() {
15
+    return animationFrame;
16
+}
17
+
18
+void Entity::setAnimationFrame(unsigned int index) {
19
+    animationFrame = index;
20
+}
21
+
22
+unsigned int Entity::getBoneFrame() {
23
+    return boneFrame;
24
+}
25
+
26
+void Entity::setBoneFrame(unsigned int index) {
27
+    boneFrame = index;
28
+}
29
+
30
+unsigned int Entity::getIdleAnimation() {
31
+    return idleAnimation;
32
+}
33
+
34
+void Entity::setIdleAnimation(unsigned int index) {
35
+    idleAnimation = index;
36
+}
37
+

+ 15
- 9
src/Game.cpp Visa fil

189
 
189
 
190
 void Game::processRooms() {
190
 void Game::processRooms() {
191
     printf("Processing rooms: ");
191
     printf("Processing rooms: ");
192
-    for (int index = 0; index < mTombRaider.NumRooms(); index++) {
193
-        Room &room = *new Room(mTombRaider, index);
194
-        getWorld().addRoom(room);
195
-    }
192
+    for (int index = 0; index < mTombRaider.NumRooms(); index++)
193
+        getWorld().addRoom(*new Room(mTombRaider, index));
196
     printf("Done! Found %d rooms.\n", mTombRaider.NumRooms());
194
     printf("Done! Found %d rooms.\n", mTombRaider.NumRooms());
197
 }
195
 }
198
 
196
 
358
     }
356
     }
359
 
357
 
360
     // Get models that aren't items
358
     // Get models that aren't items
359
+    /*
361
     for (i = 0; i < mTombRaider.NumMoveables(); ++i)
360
     for (i = 0; i < mTombRaider.NumMoveables(); ++i)
362
     {
361
     {
363
         switch ((int)moveable[i].object_id)
362
         switch ((int)moveable[i].object_id)
401
                 }
400
                 }
402
         }
401
         }
403
     }
402
     }
403
+    */
404
 
404
 
405
     printf("Done! Found %d models.\n", mTombRaider.NumMoveables() + statCount);
405
     printf("Done! Found %d models.\n", mTombRaider.NumMoveables() + statCount);
406
 }
406
 }
407
 
407
 
408
+// index moveable, i item, sometimes both moveable
408
 void Game::processMoveable(int index, int i, int *ent,
409
 void Game::processMoveable(int index, int i, int *ent,
409
         std::vector<skeletal_model_t *> &cache2,
410
         std::vector<skeletal_model_t *> &cache2,
410
         std::vector<unsigned int> &cache, int object_id)
411
         std::vector<unsigned int> &cache, int object_id)
411
 {
412
 {
413
+    // This creates both Entity and SkeletalModel
414
+    // Basic Idea:
415
+    // - Move animation state from SkeletalModel into Entity
416
+    // - Check if skeletal model is already stored
417
+    // - If so tell new Entity to reuse
418
+    // - Else store new skeletal model, tell new entity to use this one
419
+
420
+
412
     skeletal_model_t *r_model = NULL;
421
     skeletal_model_t *r_model = NULL;
413
     skeletal_model_t *c_model = NULL;
422
     skeletal_model_t *c_model = NULL;
414
     animation_frame_t *animation_frame = NULL;
423
     animation_frame_t *animation_frame = NULL;
446
     yaw *= 90;
455
     yaw *= 90;
447
 
456
 
448
     thing = new entity_t;
457
     thing = new entity_t;
449
-    thing->id = (*ent)++;
458
+    //thing->id = (*ent)++;
450
     thing->pos[0] = item[i].x;
459
     thing->pos[0] = item[i].x;
451
     thing->pos[1] = item[i].y;
460
     thing->pos[1] = item[i].y;
452
     thing->pos[2] = item[i].z;
461
     thing->pos[2] = item[i].z;
453
     thing->angles[1] = yaw;
462
     thing->angles[1] = yaw;
454
     thing->objectId = moveable[index].object_id;
463
     thing->objectId = moveable[index].object_id;
455
-    thing->animate = false;
464
+    //thing->animate = false;
456
 
465
 
457
     sModel = new SkeletalModel();
466
     sModel = new SkeletalModel();
458
     getRender().addSkeletalModel(sModel);
467
     getRender().addSkeletalModel(sModel);
490
         switch (mTombRaider.Engine())
499
         switch (mTombRaider.Engine())
491
         {
500
         {
492
             case TR_VERSION_3:
501
             case TR_VERSION_3:
493
-                mLara->modelId = i;
494
                 sModel->setAnimation(TR_ANIAMTION_RUN);
502
                 sModel->setAnimation(TR_ANIAMTION_RUN);
495
                 sModel->setIdleAnimation(TR_ANIAMTION_STAND);
503
                 sModel->setIdleAnimation(TR_ANIAMTION_STAND);
496
                 r_model->tr4Overlay = false;
504
                 r_model->tr4Overlay = false;
497
                 break;
505
                 break;
498
             case TR_VERSION_4:
506
             case TR_VERSION_4:
499
-                mLara->modelId = i;
500
                 sModel->setAnimation(TR_ANIAMTION_RUN);
507
                 sModel->setAnimation(TR_ANIAMTION_RUN);
501
                 sModel->setIdleAnimation(TR_ANIAMTION_STAND);
508
                 sModel->setIdleAnimation(TR_ANIAMTION_STAND);
502
                 // Only TR4 lara has 2 layer bone tags/meshes per bone frame
509
                 // Only TR4 lara has 2 layer bone tags/meshes per bone frame
506
             case TR_VERSION_2:
513
             case TR_VERSION_2:
507
             case TR_VERSION_5:
514
             case TR_VERSION_5:
508
             case TR_VERSION_UNKNOWN:
515
             case TR_VERSION_UNKNOWN:
509
-                mLara->modelId = index;
510
                 sModel->setAnimation(TR_ANIAMTION_RUN);
516
                 sModel->setAnimation(TR_ANIAMTION_RUN);
511
                 sModel->setIdleAnimation(TR_ANIAMTION_STAND);
517
                 sModel->setIdleAnimation(TR_ANIAMTION_STAND);
512
                 r_model->tr4Overlay = false;
518
                 r_model->tr4Overlay = false;

+ 0
- 20
src/Render.cpp Visa fil

1111
 }
1111
 }
1112
 
1112
 
1113
 
1113
 
1114
-void Render::ViewModel(entity_t *ent, int index)
1115
-{
1116
-    skeletal_model_t *model;
1117
-
1118
-
1119
-    if (!ent)
1120
-    {
1121
-        return;
1122
-    }
1123
-
1124
-    model = getWorld().getModel(index);
1125
-
1126
-    if (model)
1127
-    {
1128
-        ent->modelId = index;
1129
-        printf("Viewmodel skeletal model %i\n", model->id);
1130
-    }
1131
-}
1132
-
1133
-
1134
 void Render::addSkeletalModel(SkeletalModel *mdl)
1114
 void Render::addSkeletalModel(SkeletalModel *mdl)
1135
 {
1115
 {
1136
     mModels.push_back(mdl);
1116
     mModels.push_back(mdl);

+ 2
- 6
src/SkeletalModel.cpp Visa fil

11
 
11
 
12
 SkeletalModel::SkeletalModel() {
12
 SkeletalModel::SkeletalModel() {
13
     model = NULL;
13
     model = NULL;
14
-    flags = 0;
15
     mBoneFrame = 0;
14
     mBoneFrame = 0;
16
     mAnimationFrame = 0;
15
     mAnimationFrame = 0;
17
     mIdleAnimation = 0;
16
     mIdleAnimation = 0;
18
-    time = 0.0f;
19
-    lastTime = 0.0f;
20
-    rate = 0.0f;
21
 }
17
 }
22
 
18
 
23
 SkeletalModel::~SkeletalModel() {
19
 SkeletalModel::~SkeletalModel() {
24
-    //! \fixme Causes "freeing already freed pointer" exceptions or EXEC_BAD_ACCESS
20
+    // Model is really stored in World and deleted there
21
+    // Deleting it here causes EXEC_BAD_ACCESS...
25
     /* if (model) {
22
     /* if (model) {
26
         for(std::vector<animation_frame_t>::size_type i = 0; i < model->animation.size(); i++) {
23
         for(std::vector<animation_frame_t>::size_type i = 0; i < model->animation.size(); i++) {
27
             animation_frame_t *af = model->animation[i];
24
             animation_frame_t *af = model->animation[i];
76
     if (a) {
73
     if (a) {
77
         mAnimationFrame = index;
74
         mAnimationFrame = index;
78
         mBoneFrame = 0;
75
         mBoneFrame = 0;
79
-        rate = a->rate;
80
     }
76
     }
81
 }
77
 }
82
 
78
 

Laddar…
Avbryt
Spara