Cleaner obj_dump, now with range and visibility flag info.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3259 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2010-05-02 10:39:19 +00:00
parent b77bd31cea
commit 3b75e46988
7 changed files with 83 additions and 16 deletions

View File

@ -208,4 +208,13 @@ MA 02110-1301, USA.
}
}
#ifndef NDEBUG
- (NSString *) descriptionForObjDump
{
// Don't include range and visibility flag as they're irrelevant.
return [self descriptionForObjDumpBasic];
}
#endif
@end

View File

@ -238,10 +238,16 @@ extern size_t gTotalEntityMemory;
- (double) findCollisionRadius;
- (Geometry*) geometry;
- (void) drawEntity:(BOOL)immediate :(BOOL)translucent;
- (BOOL) isVisible;
// For shader bindings.
- (GLfloat) universalTime;
- (GLfloat) spawnTime;
- (GLfloat) timeElapsedSinceSpawn;
#ifndef NDEBUG
- (NSString *) descriptionForObjDumpBasic;
- (NSString *) descriptionForObjDump;
#endif
@end

View File

@ -122,7 +122,7 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
- (NSString *)descriptionComponents
{
return [NSString stringWithFormat:@"ID: %u position: %@ scanClass: %@ status: %@", [self universalID], VectorDescription([self position]), ScanClassToString([self scanClass]), EntityStatusToString([self status])];
return [NSString stringWithFormat:@"position: %@ scanClass: %@ status: %@", VectorDescription([self position]), ScanClassToString([self scanClass]), EntityStatusToString([self status])];
}
@ -984,4 +984,34 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
return [UNIVERSE getTime] - spawnTime;
}
#ifndef NDEBUG
- (NSString *) descriptionForObjDumpBasic
{
NSString *result = [self descriptionComponents];
if (result != nil) result = [NSString stringWithFormat:@"%@ %@", NSStringFromClass([self class]), result];
else result = [self description];
return result;
}
- (NSString *) descriptionForObjDump
{
NSString *result = [self descriptionForObjDumpBasic];
result = [result stringByAppendingFormat:@" range: %g (visible: %@)", distance([self position], [[PlayerEntity sharedPlayer] position]), [self isVisible] ? @"yes" : @"no"];
return result;
}
#endif
- (BOOL) isVisible
{
if ([self isSky] || [self isStellarObject]) return YES;
if (zero_distance > ABSOLUTE_NO_DRAW_DISTANCE2 || zero_distance > no_draw_distance) return NO;
return YES;
}
@end

View File

@ -175,7 +175,17 @@ MA 02110-1301, USA.
- (NSString*) descriptionComponents
{
return [NSString stringWithFormat:@"ID: %u position: %@ radius: %.3fkm", [self universalID], VectorDescription([self position]), 0.001 * [self radius]];
NSString *result = [NSString stringWithFormat:@"ID: %u position: %@ radius: %.3fkm", [self universalID], VectorDescription([self position]), 0.001 * [self radius]];
if ([self goneNova])
{
result = [result stringByAppendingString:@" (gone nova)"];
}
else if ([self willGoNova])
{
result = [result stringByAppendingString:@" (will go nova)"];
}
return result;
}

View File

@ -9658,6 +9658,20 @@ static BOOL AuthorityPredicate(Entity *entity, void *parameter)
}
#ifndef NDEBUG
- (NSString *) descriptionForObjDump
{
NSString *desc = [super descriptionForObjDump];
desc = [NSString stringWithFormat:@"%@ mass %g", desc, [self mass]];
if (![self isPlayer])
{
desc = [NSString stringWithFormat:@"%@ AI: %@", desc, [[self getAI] shortDescriptionComponents]];
}
return desc;
}
#endif
@end

View File

@ -184,6 +184,15 @@ MA 02110-1301, USA.
CheckOpenGLErrors(@"SkyEntity after drawing %@", self);
}
#ifndef NDEBUG
- (NSString *) descriptionForObjDump
{
// Don't include range and visibility flag as they're irrelevant.
return [self descriptionForObjDumpBasic];
}
#endif
@end

View File

@ -515,8 +515,7 @@ OOINLINE size_t class_getInstanceSize(Class cls)
OOLogIndent();
for (i = 0; i < show_count; i++)
{
ShipEntity* se = (sortedEntities[i]->isShip)? (id)sortedEntities[i]: nil;
OOLog(@"universe.objectDump", @"-> Ent:%d\t\t%@ mass %.2f %@", i, sortedEntities[i], [sortedEntities[i] mass], [[se getAI] shortDescription]);
OOLog(@"universe.objectDump", @"Ent:%4u %@", i, [sortedEntities[i] descriptionForObjDump]);
}
OOLogOutdent();
@ -3665,18 +3664,11 @@ static const OOMatrix starboard_matrix =
// use a non-mutable copy so this can't be changed under us.
for (i = 0; i < ent_count; i++)
{
// we check to see that we draw only the things that need to be drawn!
Entity *e = sortedEntities[i]; // ordered NEAREST -> FURTHEST AWAY
double zd2 = e->zero_distance;
if ([e isSky] || [e isStellarObject])
if ([e isVisible])
{
my_entities[draw_count++] = [e retain]; // planets and sky are always drawn!
continue;
my_entities[draw_count++] = [[e retain] autorelease];
}
if ((zd2 > ABSOLUTE_NO_DRAW_DISTANCE2)||((e->isShip)&&(zd2 > e->no_draw_distance)))
continue;
// it passed all drawing tests - and it's not a planet or the sky - we can add it to the list
my_entities[draw_count++] = [e retain]; // retained
}
position = [player viewpointPosition];
@ -3921,9 +3913,6 @@ static const OOMatrix starboard_matrix =
// clear errors - and announce them
CheckOpenGLErrors(@"Universe after all entity drawing is done.");
for (i = 0; i < draw_count; i++)
[my_entities[i] release]; // released
no_update = NO; // allow other attempts to draw
#if (defined (SNAPSHOT_BUILD) && defined (OOLITE_SNAPSHOT_VERSION))