Cube  Diff

Differences From Artifact [5a011dd2ea]:

To Artifact [7410504650]:


1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20












+







// physics.cpp: no physics books were hurt nor consulted in the construction of
// this code. All physics computations and constants were invented on the fly
// and simply tweaked until they "felt right", and have no basis in reality.
// Collision detection is simplistic but very robust (uses discrete steps at
// fixed fps).

#include "cube.h"

#import "DynamicEntity.h"
#import "Entity.h"
#import "MapModelInfo.h"
#import "Monster.h"
#import "Player.h"

// collide with player or monster
static bool
plcollide(
    DynamicEntity *d, DynamicEntity *o, float *headspace, float *hi, float *lo)
{
	if (o.state != CS_ALIVE)
175
176
177
178
179
180
181
182
183


184
185
186
187
188
189
190
176
177
178
179
180
181
182


183
184
185
186
187
188
189
190
191







-
-
+
+







	for (id player in players) {
		if (player == [OFNull null] || player == d)
			continue;
		if (!plcollide(d, player, &headspace, &hi, &lo))
			return false;
	}

	if (d != player1)
		if (!plcollide(d, player1, &headspace, &hi, &lo))
	if (d != Player.player1)
		if (!plcollide(d, Player.player1, &headspace, &hi, &lo))
			return false;

	// this loop can be a performance bottleneck with many monster on a slow
	// cpu, should replace with a blockmap but seems mostly fast enough
	for (Monster *monster in Monster.monsters)
		if (!vreject(d.origin, monster.origin, 7.0f) && d != monster &&
		    !plcollide(d, monster, &headspace, &hi, &lo))