Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
CollisionRegion.h
Go to the documentation of this file.
1/*
2
3CollisionRegion.h
4
5Collision regions are used to group entities which may potentially collide, to
6reduce the number of collision checks required.
7
8Oolite
9Copyright (C) 2004-2013 Giles C Williams and contributors
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software
23Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24MA 02110-1301, USA.
25
26*/
27
28#import "OOCocoa.h"
29#import "OOMaths.h"
30
31
32#define COLLISION_REGION_BORDER_RADIUS 32000.0f
33#define COLLISION_MAX_ENTITIES 128
34#define MINIMUM_SHADOWING_ENTITY_RADIUS 75.0
35
36@class Entity, OOSunEntity;
37
38
39@interface CollisionRegion: NSObject
40{
41@private
42 BOOL isUniverse; // if YES location is origin and radius is 0.0f
43
44 int crid; // identifier
45 HPVector location; // center of the region
46 GLfloat radius; // inner radius of the region
47 GLfloat border_radius; // additiønal, border radius of the region (typically 32km or some value > the scanner range)
48
51
52 NSMutableArray *subregions;
53
55
56 Entity **entity_array; // entities within the region
57 unsigned n_entities; // number of entities
58 unsigned max_entities; // so storage can be expanded
59
61}
62
63- (id) initAsUniverse;
64- (id) initAtLocation:(HPVector) locn withRadius:(GLfloat) rad withinRegion:(CollisionRegion*) otherRegion;
65
66- (void) clearSubregions;
67- (void) addSubregionAtPosition:(HPVector) pos withRadius:(GLfloat) rad;
68
69// collision checking
70- (void) clearEntityList;
71- (void) addEntity:(Entity *)ent;
72- (BOOL) checkEntity:(Entity *)ent;
73
74- (void) findCollisions;
75- (void) findShadowedEntities;
76
77// Description for FPS HUD
78- (NSString *) collisionDescription;
79
80- (NSString *) debugOut;
81
82@end
83
84/* Given a region centred at e1pos with a radius of e1rad, the depth
85 * of shadowing cast by e2 from the_sun is recorded in outValue, with
86 * >1 = no shadow, <1 = shadow */
87BOOL shadowAtPointOcclusionToValue(HPVector e1pos, GLfloat e1rad, Entity *e2, OOSunEntity *the_sun, float *outValue);
BOOL shadowAtPointOcclusionToValue(HPVector e1pos, GLfloat e1rad, Entity *e2, OOSunEntity *the_sun, float *outValue)
NSMutableArray * subregions
CollisionRegion * parentRegion
Entity ** entity_array
unsigned checks_this_tick
unsigned checks_within_range