|
@@ -11,25 +11,278 @@
|
11
|
11
|
|
12
|
12
|
#include "World.h"
|
13
|
13
|
|
|
14
|
+World::~World()
|
|
15
|
+{
|
|
16
|
+ destroy();
|
|
17
|
+}
|
14
|
18
|
|
15
|
|
-////////////////////////////////////////////////////////////
|
16
|
|
-// Constructors
|
17
|
|
-////////////////////////////////////////////////////////////
|
18
|
19
|
|
19
|
|
-World::World()
|
|
20
|
+// Temp methods for rendering use until more refactoring is done
|
|
21
|
+#ifdef BAD_BLOOD
|
|
22
|
+model_mesh_t *World::getMesh(int index)
|
20
|
23
|
{
|
|
24
|
+ return mMeshes[index];
|
21
|
25
|
}
|
22
|
26
|
|
|
27
|
+skeletal_model_t *World::getModel(int index)
|
|
28
|
+{
|
|
29
|
+ return mModels[index];
|
|
30
|
+}
|
23
|
31
|
|
24
|
|
-World::~World()
|
|
32
|
+room_mesh_t *World::getRoom(int index)
|
25
|
33
|
{
|
26
|
|
- destroy();
|
|
34
|
+ return mRooms[index];
|
|
35
|
+}
|
|
36
|
+
|
|
37
|
+std::vector<entity_t *> *World::getEntities()
|
|
38
|
+{
|
|
39
|
+ return &mEntities;
|
|
40
|
+}
|
|
41
|
+
|
|
42
|
+std::vector<sprite_seq_t *> *World::getSprites()
|
|
43
|
+{
|
|
44
|
+ return &mSprites;
|
|
45
|
+}
|
|
46
|
+
|
|
47
|
+std::vector<room_mesh_t *> *World::getRooms()
|
|
48
|
+{
|
|
49
|
+ return &mRooms;
|
|
50
|
+}
|
|
51
|
+
|
|
52
|
+void World::addRoom(room_mesh_t *room)
|
|
53
|
+{
|
|
54
|
+ mRooms.push_back(room);
|
|
55
|
+}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+void World::addMesh(model_mesh_t *mesh)
|
|
59
|
+{
|
|
60
|
+ if (mesh)
|
|
61
|
+ mMeshes.push_back(mesh);
|
|
62
|
+}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+void World::addEntity(entity_t *e)
|
|
66
|
+{
|
|
67
|
+ if (e)
|
|
68
|
+ {
|
|
69
|
+ e->master = 0x0;
|
|
70
|
+ e->moveType = worldMoveType_walk; // Walk
|
|
71
|
+ e->room = getRoomByLocation(e->pos[0], e->pos[1], e->pos[2]);
|
|
72
|
+ mEntities.push_back(e);
|
|
73
|
+ }
|
|
74
|
+}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+int World::addModel(skeletal_model_t *model)
|
|
78
|
+{
|
|
79
|
+ if (model)
|
|
80
|
+ {
|
|
81
|
+ mModels.push_back(model);
|
|
82
|
+ return mModels.size() - 1;
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ return -1;
|
|
86
|
+}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+void World::addSprite(sprite_seq_t *sprite)
|
|
90
|
+{
|
|
91
|
+ if (sprite)
|
|
92
|
+ mSprites.push_back(sprite);
|
|
93
|
+}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+void World::moveEntity(entity_t *e, char movement)
|
|
97
|
+{
|
|
98
|
+ const float moved = 180.0f;
|
|
99
|
+ const float testd = 220.0f;
|
|
100
|
+ const float camHeight = 8.0f;
|
|
101
|
+ float x, y, z, pitch, h, floor, ceiling;
|
|
102
|
+ int room, sector;
|
|
103
|
+ bool wall;
|
|
104
|
+ unsigned int roomFlags;
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+ if (!e)
|
|
108
|
+ {
|
|
109
|
+ return;
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ switch (e->moveType)
|
|
113
|
+ {
|
|
114
|
+ case worldMoveType_walkNoSwim:
|
|
115
|
+ case worldMoveType_walk:
|
|
116
|
+ pitch = 0.0f; // in the future pitch could control jump up blocks here
|
|
117
|
+ break;
|
|
118
|
+
|
|
119
|
+ case worldMoveType_noClipping:
|
|
120
|
+ case worldMoveType_fly:
|
|
121
|
+ case worldMoveType_swim:
|
|
122
|
+ pitch = e->angles[2];
|
|
123
|
+ break;
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ switch (movement)
|
|
127
|
+ {
|
|
128
|
+ case 'f':
|
|
129
|
+ x = e->pos[0] + (testd * sinf(e->angles[1]));
|
|
130
|
+ y = e->pos[1] + (testd * sinf(pitch));
|
|
131
|
+ z = e->pos[2] + (testd * cosf(e->angles[1]));
|
|
132
|
+ break;
|
|
133
|
+ case 'b':
|
|
134
|
+ x = e->pos[0] - (testd * sinf(e->angles[1]));
|
|
135
|
+ y = e->pos[1] - (testd * sinf(pitch));
|
|
136
|
+ z = e->pos[2] - (testd * cosf(e->angles[1]));
|
|
137
|
+ break;
|
|
138
|
+ case 'l':
|
|
139
|
+ x = e->pos[0] - (testd * sinf(e->angles[1] + 90.0f));
|
|
140
|
+ y = e->pos[1];
|
|
141
|
+ z = e->pos[2] - (testd * cosf(e->angles[1] + 90.0f));
|
|
142
|
+ break;
|
|
143
|
+ case 'r':
|
|
144
|
+ x = e->pos[0] + (testd * sinf(e->angles[1] + 90.0f));
|
|
145
|
+ y = e->pos[1];
|
|
146
|
+ z = e->pos[2] + (testd * cosf(e->angles[1] + 90.0f));
|
|
147
|
+ break;
|
|
148
|
+ default:
|
|
149
|
+ return;
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ //room = getRoomByLocation(x, y, z);
|
|
153
|
+ room = getRoomByLocation(e->room, x, y, z);
|
|
154
|
+
|
|
155
|
+ if (room == -1) // Will we hit a portal?
|
|
156
|
+ {
|
|
157
|
+ room = getAdjoiningRoom(e->room,
|
|
158
|
+ e->pos[0], e->pos[1], e->pos[2],
|
|
159
|
+ x, y, z);
|
|
160
|
+
|
|
161
|
+ if (room > -1)
|
|
162
|
+ {
|
|
163
|
+ printf("Crossing from room %i to %i\n", e->room, room);
|
|
164
|
+ } else {
|
|
165
|
+ //! \fixme mRooms, sectors, ... are now std::vector, but often upper bound checks are missing
|
|
166
|
+ return;
|
|
167
|
+ }
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ roomFlags = getRoomInfo(room);
|
|
171
|
+ sector = getSector(room, x, z, &floor, &ceiling);
|
|
172
|
+ wall = isWall(room, sector);
|
|
173
|
+
|
|
174
|
+ // If you're underwater you may want to swim =)
|
|
175
|
+ // ...if you're worldMoveType_walkNoSwim, you better hope it's shallow
|
|
176
|
+ if (roomFlags & roomFlag_underWater && e->moveType == worldMoveType_walk)
|
|
177
|
+ {
|
|
178
|
+ e->moveType = worldMoveType_swim;
|
|
179
|
+ }
|
|
180
|
+
|
|
181
|
+ // Don't swim on land
|
|
182
|
+ if (!(roomFlags & roomFlag_underWater) && e->moveType == worldMoveType_swim)
|
|
183
|
+ {
|
|
184
|
+ e->moveType = worldMoveType_walk;
|
|
185
|
+ }
|
|
186
|
+
|
|
187
|
+ // Mongoose 2002.09.02, Add check for room -> room transition
|
|
188
|
+ // ( Only allow by movement between rooms by using portals )
|
|
189
|
+ if (((e->moveType == worldMoveType_noClipping) ||
|
|
190
|
+ (e->moveType == worldMoveType_fly) ||
|
|
191
|
+ (e->moveType == worldMoveType_swim)) ||
|
|
192
|
+ ((room > -1) && (!wall)))
|
|
193
|
+ {
|
|
194
|
+ e->room = room;
|
|
195
|
+
|
|
196
|
+ switch (movement)
|
|
197
|
+ {
|
|
198
|
+ case 'f':
|
|
199
|
+ x = e->pos[0] + (moved * sinf(e->angles[1]));
|
|
200
|
+ y = e->pos[1] + (moved * sinf(pitch));
|
|
201
|
+ z = e->pos[2] + (moved * cosf(e->angles[1]));
|
|
202
|
+ break;
|
|
203
|
+ case 'b':
|
|
204
|
+ x = e->pos[0] - (moved * sinf(e->angles[1]));
|
|
205
|
+ y = e->pos[1] - (moved * sinf(pitch));
|
|
206
|
+ z = e->pos[2] - (moved * cosf(e->angles[1]));
|
|
207
|
+ break;
|
|
208
|
+ case 'l':
|
|
209
|
+ x = e->pos[0] - (moved * sinf(e->angles[1] + 90.0f));
|
|
210
|
+ z = e->pos[2] - (moved * cosf(e->angles[1] + 90.0f));
|
|
211
|
+ break;
|
|
212
|
+ case 'r':
|
|
213
|
+ x = e->pos[0] + (moved * sinf(e->angles[1] + 90.0f));
|
|
214
|
+ z = e->pos[2] + (moved * cosf(e->angles[1] + 90.0f));
|
|
215
|
+ break;
|
|
216
|
+ }
|
|
217
|
+
|
|
218
|
+ /*! \fixme Test for vector (move vector) / plane (portal) collision here
|
|
219
|
+ * to see if we need to switch rooms... man...
|
|
220
|
+ */
|
|
221
|
+
|
|
222
|
+ h = y;
|
|
223
|
+ getHeightAtPosition(room, x, &h, z);
|
|
224
|
+
|
|
225
|
+ switch (e->moveType)
|
|
226
|
+ {
|
|
227
|
+ case worldMoveType_fly:
|
|
228
|
+ case worldMoveType_swim:
|
|
229
|
+ // Don't fall out of world, avoid a movement that does
|
|
230
|
+ if (h > y - camHeight)
|
|
231
|
+ {
|
|
232
|
+ e->pos[0] = x;
|
|
233
|
+ e->pos[1] = y;
|
|
234
|
+ e->pos[2] = z;
|
|
235
|
+ }
|
|
236
|
+ break;
|
|
237
|
+ case worldMoveType_walk:
|
|
238
|
+ case worldMoveType_walkNoSwim:
|
|
239
|
+ y = e->pos[1]; // Override vector movement walking ( er, not pretty )
|
|
240
|
+
|
|
241
|
+ // Now fake gravity
|
|
242
|
+ // Mongoose 2002.08.14, Remember TR is upside down ( you fall 'up' )
|
|
243
|
+
|
|
244
|
+ //ddist = h - e->pos[1];
|
|
245
|
+
|
|
246
|
+ // This is to force false gravity, by making camera stay on ground
|
|
247
|
+ e->pos[1] = h; //roomFloor->bbox_min[1];
|
|
248
|
+
|
|
249
|
+ // Check for camera below terrian and correct
|
|
250
|
+ if (e->pos[1] < h - camHeight)
|
|
251
|
+ {
|
|
252
|
+ e->pos[1] = h - camHeight;
|
|
253
|
+ }
|
|
254
|
+
|
|
255
|
+ e->pos[0] = x;
|
|
256
|
+ e->pos[2] = z;
|
|
257
|
+ break;
|
|
258
|
+ case worldMoveType_noClipping:
|
|
259
|
+ e->pos[0] = x;
|
|
260
|
+ e->pos[1] = y;
|
|
261
|
+ e->pos[2] = z;
|
|
262
|
+ }
|
|
263
|
+ }
|
|
264
|
+ else
|
|
265
|
+ {
|
|
266
|
+ e->moving = false;
|
|
267
|
+ return;
|
|
268
|
+ }
|
|
269
|
+
|
|
270
|
+ e->room = room;
|
|
271
|
+ e->moving = true;
|
27
|
272
|
}
|
28
|
273
|
|
|
274
|
+#else
|
|
275
|
+
|
|
276
|
+void World::addRoom(Room &room) {
|
|
277
|
+ mRooms.push_back(&room);
|
|
278
|
+}
|
|
279
|
+
|
|
280
|
+void World::addSprite(SpriteSequence &sprite) {
|
|
281
|
+ mSprites.push_back(&sprite);
|
|
282
|
+}
|
|
283
|
+
|
|
284
|
+#endif
|
29
|
285
|
|
30
|
|
-////////////////////////////////////////////////////////////
|
31
|
|
-// Public Accessors
|
32
|
|
-////////////////////////////////////////////////////////////
|
33
|
286
|
|
34
|
287
|
int World::getRoomByLocation(int index, float x, float y, float z)
|
35
|
288
|
{
|
|
@@ -204,65 +457,31 @@ bool World::isWall(int room, int sector) {
|
204
|
457
|
}
|
205
|
458
|
|
206
|
459
|
|
207
|
|
-bool World::getHeightAtPosition(int index, float x, float *y, float z)
|
208
|
|
-{
|
209
|
|
- room_mesh_t *room = mRooms[index];
|
210
|
|
- int sector;
|
211
|
|
- sector_t *sect;
|
212
|
|
-
|
213
|
|
- if (!room)
|
214
|
|
- {
|
215
|
|
- return false;
|
216
|
|
- }
|
217
|
|
-
|
218
|
|
- // Mongoose 2002.08.14, Remember sector_z is width of sector array
|
219
|
|
- sector = getSector(index, x, z);
|
220
|
|
-
|
221
|
|
- sect = room->sectors[sector];
|
222
|
|
-
|
223
|
|
- if (!sect)
|
224
|
|
- {
|
225
|
|
- return true;
|
226
|
|
- }
|
227
|
|
-
|
228
|
|
- *y = sect->floor;
|
229
|
|
-
|
230
|
|
- return true;
|
231
|
|
-}
|
232
|
|
-
|
233
|
|
-
|
234
|
|
-// Temp methods for rendering use until more refactoring is done
|
235
|
|
-#ifdef BAD_BLOOD
|
236
|
|
-model_mesh_t *World::getMesh(int index)
|
237
|
|
-{
|
238
|
|
- return mMeshes[index];
|
239
|
|
-}
|
240
|
|
-
|
241
|
|
-skeletal_model_t *World::getModel(int index)
|
242
|
|
-{
|
243
|
|
- return mModels[index];
|
244
|
|
-}
|
245
|
|
-
|
246
|
|
-room_mesh_t *World::getRoom(int index)
|
247
|
|
-{
|
248
|
|
- return mRooms[index];
|
249
|
|
-}
|
250
|
|
-
|
251
|
|
-std::vector<entity_t *> *World::getEntities()
|
252
|
|
-{
|
253
|
|
- return &mEntities;
|
254
|
|
-}
|
255
|
|
-
|
256
|
|
-std::vector<sprite_seq_t *> *World::getSprites()
|
|
460
|
+bool World::getHeightAtPosition(int index, float x, float *y, float z)
|
257
|
461
|
{
|
258
|
|
- return &mSprites;
|
259
|
|
-}
|
|
462
|
+ room_mesh_t *room = mRooms[index];
|
|
463
|
+ int sector;
|
|
464
|
+ sector_t *sect;
|
260
|
465
|
|
261
|
|
-std::vector<room_mesh_t *> *World::getRooms()
|
262
|
|
-{
|
263
|
|
- return &mRooms;
|
|
466
|
+ if (!room)
|
|
467
|
+ {
|
|
468
|
+ return false;
|
|
469
|
+ }
|
|
470
|
+
|
|
471
|
+ // Mongoose 2002.08.14, Remember sector_z is width of sector array
|
|
472
|
+ sector = getSector(index, x, z);
|
|
473
|
+
|
|
474
|
+ sect = room->sectors[sector];
|
|
475
|
+
|
|
476
|
+ if (!sect)
|
|
477
|
+ {
|
|
478
|
+ return true;
|
|
479
|
+ }
|
|
480
|
+
|
|
481
|
+ *y = sect->floor;
|
|
482
|
+
|
|
483
|
+ return true;
|
264
|
484
|
}
|
265
|
|
-#endif
|
266
|
485
|
|
267
|
486
|
|
268
|
487
|
void World::destroy()
|
|
@@ -417,226 +636,3 @@ void World::destroy()
|
417
|
636
|
mModels.clear();
|
418
|
637
|
}
|
419
|
638
|
|
420
|
|
-
|
421
|
|
-void World::addRoom(room_mesh_t *room)
|
422
|
|
-{
|
423
|
|
- mRooms.push_back(room);
|
424
|
|
-}
|
425
|
|
-
|
426
|
|
-
|
427
|
|
-void World::addMesh(model_mesh_t *mesh)
|
428
|
|
-{
|
429
|
|
- if (mesh)
|
430
|
|
- mMeshes.push_back(mesh);
|
431
|
|
-}
|
432
|
|
-
|
433
|
|
-
|
434
|
|
-void World::addEntity(entity_t *e)
|
435
|
|
-{
|
436
|
|
- if (e)
|
437
|
|
- {
|
438
|
|
- e->master = 0x0;
|
439
|
|
- e->moveType = worldMoveType_walk; // Walk
|
440
|
|
- e->room = getRoomByLocation(e->pos[0], e->pos[1], e->pos[2]);
|
441
|
|
- mEntities.push_back(e);
|
442
|
|
- }
|
443
|
|
-}
|
444
|
|
-
|
445
|
|
-
|
446
|
|
-int World::addModel(skeletal_model_t *model)
|
447
|
|
-{
|
448
|
|
- if (model)
|
449
|
|
- {
|
450
|
|
- mModels.push_back(model);
|
451
|
|
- return mModels.size() - 1;
|
452
|
|
- }
|
453
|
|
-
|
454
|
|
- return -1;
|
455
|
|
-}
|
456
|
|
-
|
457
|
|
-
|
458
|
|
-void World::addSprite(sprite_seq_t *sprite)
|
459
|
|
-{
|
460
|
|
- if (sprite)
|
461
|
|
- mSprites.push_back(sprite);
|
462
|
|
-}
|
463
|
|
-
|
464
|
|
-
|
465
|
|
-void World::moveEntity(entity_t *e, char movement)
|
466
|
|
-{
|
467
|
|
- const float moved = 180.0f;
|
468
|
|
- const float testd = 220.0f;
|
469
|
|
- const float camHeight = 8.0f;
|
470
|
|
- float x, y, z, pitch, h, floor, ceiling;
|
471
|
|
- int room, sector;
|
472
|
|
- bool wall;
|
473
|
|
- unsigned int roomFlags;
|
474
|
|
-
|
475
|
|
-
|
476
|
|
- if (!e)
|
477
|
|
- {
|
478
|
|
- return;
|
479
|
|
- }
|
480
|
|
-
|
481
|
|
- switch (e->moveType)
|
482
|
|
- {
|
483
|
|
- case worldMoveType_walkNoSwim:
|
484
|
|
- case worldMoveType_walk:
|
485
|
|
- pitch = 0.0f; // in the future pitch could control jump up blocks here
|
486
|
|
- break;
|
487
|
|
-
|
488
|
|
- case worldMoveType_noClipping:
|
489
|
|
- case worldMoveType_fly:
|
490
|
|
- case worldMoveType_swim:
|
491
|
|
- pitch = e->angles[2];
|
492
|
|
- break;
|
493
|
|
- }
|
494
|
|
-
|
495
|
|
- switch (movement)
|
496
|
|
- {
|
497
|
|
- case 'f':
|
498
|
|
- x = e->pos[0] + (testd * sinf(e->angles[1]));
|
499
|
|
- y = e->pos[1] + (testd * sinf(pitch));
|
500
|
|
- z = e->pos[2] + (testd * cosf(e->angles[1]));
|
501
|
|
- break;
|
502
|
|
- case 'b':
|
503
|
|
- x = e->pos[0] - (testd * sinf(e->angles[1]));
|
504
|
|
- y = e->pos[1] - (testd * sinf(pitch));
|
505
|
|
- z = e->pos[2] - (testd * cosf(e->angles[1]));
|
506
|
|
- break;
|
507
|
|
- case 'l':
|
508
|
|
- x = e->pos[0] - (testd * sinf(e->angles[1] + 90.0f));
|
509
|
|
- y = e->pos[1];
|
510
|
|
- z = e->pos[2] - (testd * cosf(e->angles[1] + 90.0f));
|
511
|
|
- break;
|
512
|
|
- case 'r':
|
513
|
|
- x = e->pos[0] + (testd * sinf(e->angles[1] + 90.0f));
|
514
|
|
- y = e->pos[1];
|
515
|
|
- z = e->pos[2] + (testd * cosf(e->angles[1] + 90.0f));
|
516
|
|
- break;
|
517
|
|
- default:
|
518
|
|
- return;
|
519
|
|
- }
|
520
|
|
-
|
521
|
|
- //room = getRoomByLocation(x, y, z);
|
522
|
|
- room = getRoomByLocation(e->room, x, y, z);
|
523
|
|
-
|
524
|
|
- if (room == -1) // Will we hit a portal?
|
525
|
|
- {
|
526
|
|
- room = getAdjoiningRoom(e->room,
|
527
|
|
- e->pos[0], e->pos[1], e->pos[2],
|
528
|
|
- x, y, z);
|
529
|
|
-
|
530
|
|
- if (room > -1)
|
531
|
|
- {
|
532
|
|
- printf("Crossing from room %i to %i\n", e->room, room);
|
533
|
|
- } else {
|
534
|
|
- //! \fixme mRooms, sectors, ... are now std::vector, but often upper bound checks are missing
|
535
|
|
- return;
|
536
|
|
- }
|
537
|
|
- }
|
538
|
|
-
|
539
|
|
- roomFlags = getRoomInfo(room);
|
540
|
|
- sector = getSector(room, x, z, &floor, &ceiling);
|
541
|
|
- wall = isWall(room, sector);
|
542
|
|
-
|
543
|
|
- // If you're underwater you may want to swim =)
|
544
|
|
- // ...if you're worldMoveType_walkNoSwim, you better hope it's shallow
|
545
|
|
- if (roomFlags & roomFlag_underWater && e->moveType == worldMoveType_walk)
|
546
|
|
- {
|
547
|
|
- e->moveType = worldMoveType_swim;
|
548
|
|
- }
|
549
|
|
-
|
550
|
|
- // Don't swim on land
|
551
|
|
- if (!(roomFlags & roomFlag_underWater) && e->moveType == worldMoveType_swim)
|
552
|
|
- {
|
553
|
|
- e->moveType = worldMoveType_walk;
|
554
|
|
- }
|
555
|
|
-
|
556
|
|
- // Mongoose 2002.09.02, Add check for room -> room transition
|
557
|
|
- // ( Only allow by movement between rooms by using portals )
|
558
|
|
- if (((e->moveType == worldMoveType_noClipping) ||
|
559
|
|
- (e->moveType == worldMoveType_fly) ||
|
560
|
|
- (e->moveType == worldMoveType_swim)) ||
|
561
|
|
- ((room > -1) && (!wall)))
|
562
|
|
- {
|
563
|
|
- e->room = room;
|
564
|
|
-
|
565
|
|
- switch (movement)
|
566
|
|
- {
|
567
|
|
- case 'f':
|
568
|
|
- x = e->pos[0] + (moved * sinf(e->angles[1]));
|
569
|
|
- y = e->pos[1] + (moved * sinf(pitch));
|
570
|
|
- z = e->pos[2] + (moved * cosf(e->angles[1]));
|
571
|
|
- break;
|
572
|
|
- case 'b':
|
573
|
|
- x = e->pos[0] - (moved * sinf(e->angles[1]));
|
574
|
|
- y = e->pos[1] - (moved * sinf(pitch));
|
575
|
|
- z = e->pos[2] - (moved * cosf(e->angles[1]));
|
576
|
|
- break;
|
577
|
|
- case 'l':
|
578
|
|
- x = e->pos[0] - (moved * sinf(e->angles[1] + 90.0f));
|
579
|
|
- z = e->pos[2] - (moved * cosf(e->angles[1] + 90.0f));
|
580
|
|
- break;
|
581
|
|
- case 'r':
|
582
|
|
- x = e->pos[0] + (moved * sinf(e->angles[1] + 90.0f));
|
583
|
|
- z = e->pos[2] + (moved * cosf(e->angles[1] + 90.0f));
|
584
|
|
- break;
|
585
|
|
- }
|
586
|
|
-
|
587
|
|
- /*! \fixme Test for vector (move vector) / plane (portal) collision here
|
588
|
|
- * to see if we need to switch rooms... man...
|
589
|
|
- */
|
590
|
|
-
|
591
|
|
- h = y;
|
592
|
|
- getHeightAtPosition(room, x, &h, z);
|
593
|
|
-
|
594
|
|
- switch (e->moveType)
|
595
|
|
- {
|
596
|
|
- case worldMoveType_fly:
|
597
|
|
- case worldMoveType_swim:
|
598
|
|
- // Don't fall out of world, avoid a movement that does
|
599
|
|
- if (h > y - camHeight)
|
600
|
|
- {
|
601
|
|
- e->pos[0] = x;
|
602
|
|
- e->pos[1] = y;
|
603
|
|
- e->pos[2] = z;
|
604
|
|
- }
|
605
|
|
- break;
|
606
|
|
- case worldMoveType_walk:
|
607
|
|
- case worldMoveType_walkNoSwim:
|
608
|
|
- y = e->pos[1]; // Override vector movement walking ( er, not pretty )
|
609
|
|
-
|
610
|
|
- // Now fake gravity
|
611
|
|
- // Mongoose 2002.08.14, Remember TR is upside down ( you fall 'up' )
|
612
|
|
-
|
613
|
|
- //ddist = h - e->pos[1];
|
614
|
|
-
|
615
|
|
- // This is to force false gravity, by making camera stay on ground
|
616
|
|
- e->pos[1] = h; //roomFloor->bbox_min[1];
|
617
|
|
-
|
618
|
|
- // Check for camera below terrian and correct
|
619
|
|
- if (e->pos[1] < h - camHeight)
|
620
|
|
- {
|
621
|
|
- e->pos[1] = h - camHeight;
|
622
|
|
- }
|
623
|
|
-
|
624
|
|
- e->pos[0] = x;
|
625
|
|
- e->pos[2] = z;
|
626
|
|
- break;
|
627
|
|
- case worldMoveType_noClipping:
|
628
|
|
- e->pos[0] = x;
|
629
|
|
- e->pos[1] = y;
|
630
|
|
- e->pos[2] = z;
|
631
|
|
- }
|
632
|
|
- }
|
633
|
|
- else
|
634
|
|
- {
|
635
|
|
- e->moving = false;
|
636
|
|
- return;
|
637
|
|
- }
|
638
|
|
-
|
639
|
|
- e->room = room;
|
640
|
|
- e->moving = true;
|
641
|
|
-}
|
642
|
|
-
|