Browse Source

Added comparison operator to static model

Thomas Buck 10 years ago
parent
commit
a119a9994c
5 changed files with 15 additions and 89 deletions
  1. 2
    2
      include/Render.h
  2. 3
    0
      include/Room.h
  3. 0
    65
      include/WorldData.h
  4. 0
    22
      src/Render.cpp
  5. 10
    0
      src/Room.cpp

+ 2
- 2
include/Render.h View File

@@ -223,7 +223,7 @@ private:
223 223
      * Texture must be initialized.
224 224
      * \param mesh Static model to render
225 225
      */
226
-    void drawRoomModel(static_model_t *mesh);
226
+    void drawRoomModel(StaticModel &mesh);
227 227
 
228 228
     /*!
229 229
      * \brief Renders a mesh.
@@ -240,7 +240,7 @@ private:
240 240
      * Texture must be initialized.
241 241
      * \param sprite sprite to render
242 242
      */
243
-    void drawSprite(sprite_t *sprite);
243
+    void drawSprite(Sprite &sprite);
244 244
 
245 245
     /*!
246 246
      * \brief Updates View Volume. Call once per render frame.

+ 3
- 0
include/Room.h View File

@@ -40,6 +40,9 @@ class StaticModel {
40 40
 public:
41 41
     StaticModel(int _index, vec_t _yaw, vec3_t _pos);
42 42
 
43
+    // Compares distance to ViewVolume for depth sorting
44
+    bool operator<(const StaticModel &other);
45
+
43 46
 private:
44 47
     int index;
45 48
     vec_t yaw;

+ 0
- 65
include/WorldData.h View File

@@ -33,22 +33,6 @@ typedef struct {
33 33
     vec2_t st;
34 34
 } texel_t;
35 35
 
36
-/*
37
-typedef struct {
38
-    int num_verts;      //!< 4 == Quad, 3 == Triangle, rendered as triangles
39
-    vertex_t vertex[4];
40
-    texel_t texel[4];
41
-    float pos[3];
42
-    float radius;       //!< \fixme yeah, I know (I don't? --xythobuz)
43
-    int texture;
44
-} sprite_t;
45
-
46
-typedef struct {
47
-    int num_sprites;
48
-    sprite_t *sprite;
49
-} sprite_seq_t;
50
-*/
51
-
52 36
 /*! \fixme For now shaders are textures on tex objects
53 37
  * and materials on color objects. If -1
54 38
  * then it doesn't have that information yet.
@@ -104,54 +88,5 @@ typedef struct entity_s {
104 88
     */
105 89
 } entity_t;
106 90
 
107
-/*
108
-typedef struct {
109
-    int index;    //!< model_mesh index
110
-    float yaw;    //!< angle of rotation on Y
111
-    float pos[3]; //!< position
112
-
113
-    //vec3_t bboxMax;
114
-    //vec3_t bboxMin;
115
-} static_model_t;
116
-
117
-typedef struct {
118
-    float vertices[4][3];
119
-    float normal[3];
120
-    int adjoining_room;
121
-} portal_t;
122
-
123
-typedef struct {
124
-    vertex_t a;
125
-    vertex_t b;
126
-    vertex_t c;
127
-    vertex_t d;
128
-} box_t;
129
-
130
-typedef struct {
131
-    vec_t floor;
132
-    vec_t ceiling;
133
-
134
-    bool wall;
135
-} sector_t;
136
-
137
-//! \fixme No room mesh list or sprites and etc
138
-typedef struct {
139
-    std::vector<int> adjacentRooms;
140
-    std::vector<portal_t *> portals;
141
-    std::vector<static_model_t *> models;
142
-    std::vector<sprite_t *> sprites;
143
-    std::vector<box_t *> boxes;
144
-    std::vector<sector_t *> sectors;
145
-
146
-    int id;
147
-    unsigned int flags;
148
-    unsigned int numXSectors;
149
-    unsigned int numZSectors;
150
-    float pos[3];
151
-    vec3_t bbox_min;
152
-    vec3_t bbox_max;
153
-} room_mesh_t;
154
-*/
155
-
156 91
 #endif
157 92
 

+ 0
- 22
src/Render.cpp View File

@@ -44,28 +44,6 @@ bool compareEntites(const void *voidA, const void *voidB)
44 44
     return (distA < distB);
45 45
 }
46 46
 
47
-
48
-bool compareStaticModels(const void *voidA, const void *voidB)
49
-{
50
-    static_model_t *a = (static_model_t *)voidA, *b = (static_model_t *)voidB;
51
-    vec_t distA, distB;
52
-
53
-    if (!a || !b)
54
-        return false; // error really
55
-
56
-    distA = getRender().mViewVolume.getDistToSphereFromNear(a->pos[0],
57
-            a->pos[1],
58
-            a->pos[2],
59
-            128.0f);
60
-    distB = getRender().mViewVolume.getDistToSphereFromNear(b->pos[0],
61
-            b->pos[1],
62
-            b->pos[2],
63
-            128.0f);
64
-
65
-    return (distA < distB);
66
-}
67
-
68
-
69 47
 bool compareRoomDist(const void *voidA, const void *voidB)
70 48
 {
71 49
     const RenderRoom *a = static_cast<const RenderRoom *>(voidA);

+ 10
- 0
src/Room.cpp View File

@@ -5,6 +5,7 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include "main.h"
8 9
 #include "Room.h"
9 10
 
10 11
 StaticModel::StaticModel(int _index, vec_t _yaw, vec3_t _pos) {
@@ -14,6 +15,15 @@ StaticModel::StaticModel(int _index, vec_t _yaw, vec3_t _pos) {
14 15
         pos[i] = _pos[i];
15 16
 }
16 17
 
18
+bool StaticModel::operator<(const StaticModel &other) {
19
+    vec_t distA, distB;
20
+    distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0],
21
+            pos[1], pos[2], 128.0f);
22
+    distB = getRender().mViewVolume.getDistToSphereFromNear(other.pos[0],
23
+            other.pos[1], other.pos[2], 128.0f);
24
+    return (distA < distB);
25
+}
26
+
17 27
 Portal::Portal(vec3_t _vertices[4], vec3_t _normal, int _adjoiningRoom) {
18 28
     for (unsigned int i = 0; i < 3; i++) {
19 29
         vertices[0][i] = _vertices[0][i];

Loading…
Cancel
Save