Behaviour change: ship clipping distance now takes flasher radius into account.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2473 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
3b1f0e97df
commit
d2d7bf66bc
@ -24,7 +24,7 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "OOSelfDrawingEntity.h"
|
#import "Entity.h"
|
||||||
|
|
||||||
#define DUST_SCALE 2000
|
#define DUST_SCALE 2000
|
||||||
#define DUST_N_PARTICLES 600
|
#define DUST_N_PARTICLES 600
|
||||||
|
@ -78,6 +78,12 @@ MA 02110-1301, USA.
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (double)findCollisionRadius
|
||||||
|
{
|
||||||
|
return 0; // FIXME: something sensible. Where does plume length come from anyway?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) update:(OOTimeDelta) delta_t
|
- (void) update:(OOTimeDelta) delta_t
|
||||||
{
|
{
|
||||||
OOTimeAbsolute now = [UNIVERSE getTime];
|
OOTimeAbsolute now = [UNIVERSE getTime];
|
||||||
@ -108,7 +114,7 @@ MA 02110-1301, USA.
|
|||||||
GLfloat flare_factor = flare_length * ex_emissive[3] * hyper_fade;
|
GLfloat flare_factor = flare_length * ex_emissive[3] * hyper_fade;
|
||||||
GLfloat red_factor = flare_length * ex_emissive[0] * (ranrot_rand() % 11) * 0.1; // random fluctuations
|
GLfloat red_factor = flare_length * ex_emissive[0] * (ranrot_rand() % 11) * 0.1; // random fluctuations
|
||||||
GLfloat green_factor = flare_length * ex_emissive[1] * hyper_fade;
|
GLfloat green_factor = flare_length * ex_emissive[1] * hyper_fade;
|
||||||
|
|
||||||
if (flare_length > 1.0) // afterburner!
|
if (flare_length > 1.0) // afterburner!
|
||||||
{
|
{
|
||||||
red_factor = 1.5;
|
red_factor = 1.5;
|
||||||
@ -121,7 +127,7 @@ MA 02110-1301, USA.
|
|||||||
green_factor = 0.0;
|
green_factor = 0.0;
|
||||||
if ((int)(ranrot_rand() % 25) < dam - 75)
|
if ((int)(ranrot_rand() % 25) < dam - 75)
|
||||||
flare_factor = 0.0;
|
flare_factor = 0.0;
|
||||||
|
|
||||||
if (flare_length < 0.1) { flare_length = 0.1;}
|
if (flare_length < 0.1) { flare_length = 0.1;}
|
||||||
Vector currentPos = ship->position;
|
Vector currentPos = ship->position;
|
||||||
Vector vfwd = vector_forward_from_quaternion(shipQrotation);
|
Vector vfwd = vector_forward_from_quaternion(shipQrotation);
|
||||||
|
@ -140,6 +140,13 @@ MA 02110-1301, USA.
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (double)findCollisionRadius
|
||||||
|
{
|
||||||
|
NSSize size = [self size];
|
||||||
|
return fmax(size.width, size.height);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (id) initWithSize:(NSSize)size;
|
- (id) initWithSize:(NSSize)size;
|
||||||
|
|
||||||
|
- (NSSize) size;
|
||||||
|
|
||||||
/* For subclasses that don't want the default blur texture.
|
/* For subclasses that don't want the default blur texture.
|
||||||
NOTE: such subclasses must deal with the OOGraphicsResetManager.
|
NOTE: such subclasses must deal with the OOGraphicsResetManager.
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +62,12 @@ static OOTexture *sBlobTexture = nil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (NSSize) size
|
||||||
|
{
|
||||||
|
return _size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) drawSubEntity:(BOOL)immediate :(BOOL)translucent
|
- (void) drawSubEntity:(BOOL)immediate :(BOOL)translucent
|
||||||
{
|
{
|
||||||
if (!translucent) return;
|
if (!translucent) return;
|
||||||
|
@ -305,6 +305,8 @@ MA 02110-1301, USA.
|
|||||||
OOShipGroup *_escortGroup;
|
OOShipGroup *_escortGroup;
|
||||||
uint8_t _maxEscortCount;
|
uint8_t _maxEscortCount;
|
||||||
uint8_t _pendingEscortCount;
|
uint8_t _pendingEscortCount;
|
||||||
|
|
||||||
|
GLfloat _profileRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ship brains
|
// ship brains
|
||||||
@ -344,6 +346,9 @@ MA 02110-1301, USA.
|
|||||||
|
|
||||||
- (void) clearSubEntities; // Releases and clears subentity array, after making sure subentities don't think ship is owner.
|
- (void) clearSubEntities; // Releases and clears subentity array, after making sure subentities don't think ship is owner.
|
||||||
|
|
||||||
|
- (Octree *) octree;
|
||||||
|
- (float) volume;
|
||||||
|
|
||||||
// octree collision hunting
|
// octree collision hunting
|
||||||
- (GLfloat)doesHitLine:(Vector) v0: (Vector) v1;
|
- (GLfloat)doesHitLine:(Vector) v0: (Vector) v1;
|
||||||
- (GLfloat)doesHitLine:(Vector) v0: (Vector) v1 :(ShipEntity**) hitEntity;
|
- (GLfloat)doesHitLine:(Vector) v0: (Vector) v1 :(ShipEntity**) hitEntity;
|
||||||
@ -615,8 +620,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
|
|||||||
|
|
||||||
- (Triangle) absoluteIJKForSubentity;
|
- (Triangle) absoluteIJKForSubentity;
|
||||||
|
|
||||||
- (void) addSolidSubentityToCollisionRadius:(ShipEntity *)subent;
|
|
||||||
|
|
||||||
ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
|
ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
|
||||||
|
|
||||||
- (NSComparisonResult) compareBeaconCodeWith:(ShipEntity *)other;
|
- (NSComparisonResult) compareBeaconCodeWith:(ShipEntity *)other;
|
||||||
|
@ -102,6 +102,8 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
|
|||||||
|
|
||||||
- (void) addSubEntity:(Entity *) subent;
|
- (void) addSubEntity:(Entity *) subent;
|
||||||
|
|
||||||
|
- (void) addSubentityToCollisionRadius:(Entity*) subent;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@ -433,6 +435,8 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
NSArray *plumes = [shipDict oo_arrayForKey:@"exhaust"];
|
NSArray *plumes = [shipDict oo_arrayForKey:@"exhaust"];
|
||||||
|
|
||||||
|
_profileRadius = collision_radius;
|
||||||
|
|
||||||
for (i = 0; i < [plumes count]; i++)
|
for (i = 0; i < [plumes count]; i++)
|
||||||
{
|
{
|
||||||
NSArray *definition = ScanTokensFromString([plumes oo_stringAtIndex:i]);
|
NSArray *definition = ScanTokensFromString([plumes oo_stringAtIndex:i]);
|
||||||
@ -446,6 +450,9 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
|
|||||||
{
|
{
|
||||||
[self setUpOneSubentity:[subs oo_dictionaryAtIndex:i]];
|
[self setUpOneSubentity:[subs oo_dictionaryAtIndex:i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
no_draw_distance = _profileRadius * _profileRadius * NO_DRAW_DISTANCE_FACTOR * NO_DRAW_DISTANCE_FACTOR * 2.0;
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,8 +537,6 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
|
|||||||
[subentity setStatus:STATUS_INACTIVE];
|
[subentity setStatus:STATUS_INACTIVE];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self addSolidSubentityToCollisionRadius:subentity];
|
|
||||||
|
|
||||||
[self addSubEntity:subentity];
|
[self addSubEntity:subentity];
|
||||||
[subentity release];
|
[subentity release];
|
||||||
|
|
||||||
@ -757,6 +762,18 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
- (Octree *) octree
|
||||||
|
{
|
||||||
|
return octree;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (float) volume
|
||||||
|
{
|
||||||
|
return [octree volume];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (GLfloat)doesHitLine:(Vector)v0: (Vector)v1;
|
- (GLfloat)doesHitLine:(Vector)v0: (Vector)v1;
|
||||||
{
|
{
|
||||||
Vector u0 = vector_between(position, v0); // relative to origin of model / octree
|
Vector u0 = vector_between(position, v0); // relative to origin of model / octree
|
||||||
@ -1263,16 +1280,24 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) addSolidSubentityToCollisionRadius:(ShipEntity*) subent
|
- (void) addSubentityToCollisionRadius:(Entity*)subent
|
||||||
{
|
{
|
||||||
if (!subent)
|
if (!subent) return;
|
||||||
return;
|
|
||||||
|
|
||||||
double distance = sqrt(magnitude2(subent->position)) + [subent findCollisionRadius];
|
|
||||||
if (distance > collision_radius)
|
|
||||||
collision_radius = distance;
|
|
||||||
|
|
||||||
mass += 20.0 * [subent->octree volume];
|
double distance = magnitude([subent position]) + [subent findCollisionRadius];
|
||||||
|
if ([subent isKindOfClass:[ShipEntity class]]) // Solid subentity
|
||||||
|
{
|
||||||
|
if (distance > collision_radius)
|
||||||
|
{
|
||||||
|
collision_radius = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
mass += 20.0 * [(ShipEntity *)subent volume];
|
||||||
|
}
|
||||||
|
if (distance > _profileRadius)
|
||||||
|
{
|
||||||
|
_profileRadius = distance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3323,6 +3348,8 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
// Order matters - need consistent state in setOwner:. -- Ahruman 2008-04-20
|
// Order matters - need consistent state in setOwner:. -- Ahruman 2008-04-20
|
||||||
[subEntities addObject:sub];
|
[subEntities addObject:sub];
|
||||||
[sub setOwner:self];
|
[sub setOwner:self];
|
||||||
|
|
||||||
|
[self addSubentityToCollisionRadius:sub];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user