From fd44f97b5b981da5263b3464e9227921fd7138eb Mon Sep 17 00:00:00 2001 From: Jens Ayton Date: Sun, 26 Aug 2012 16:51:31 +0000 Subject: [PATCH] Deleted a bunch of #ifed-out and commented-out code that doesn't look likely to be reinstated. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5257 127b21dd-08f5-0310-b4b7-95ae10353056 --- src/Core/CollisionRegion.m | 40 --------- src/Core/Entities/Entity.h | 2 +- src/Core/Entities/OOEntityWithDrawable.m | 5 +- src/Core/Entities/OOPlanetEntity.m | 4 +- src/Core/Entities/PlayerEntity.h | 11 +-- src/Core/Entities/PlayerEntity.m | 13 --- src/Core/Entities/ShipEntity.h | 27 +++--- src/Core/Entities/StationEntity.h | 6 +- src/Core/Entities/StationEntity.m | 96 +++++++-------------- src/Core/Scripting/OOJSMission.m | 6 -- src/Core/Scripting/OOJavaScriptEngine.m | 42 +++------ src/Core/Universe.h | 18 ++-- src/Core/Universe.m | 103 +++++++++++------------ 13 files changed, 118 insertions(+), 255 deletions(-) diff --git a/src/Core/CollisionRegion.m b/src/Core/CollisionRegion.m index 58f69fc4..3e9bdce4 100644 --- a/src/Core/CollisionRegion.m +++ b/src/Core/CollisionRegion.m @@ -196,46 +196,6 @@ static BOOL positionIsWithinBorders(Vector position, CollisionRegion *region) } -#if 0 -// These were lying about unused when I found them, honest guv. -- Ahruman 2012-07-08 - -static BOOL positionIsOnBorders(Vector position, CollisionRegion *region) -{ - if (region == nil) return NO; - if (region->isUniverse) return NO; - - Vector loc = region->location; - GLfloat r2 = region->radius + region->border_radius; - - if ((position.x < loc.x - r2)||(position.x > loc.x + r2)|| - (position.y < loc.y - r2)||(position.y > loc.y + r2)|| - (position.z < loc.z - r2)||(position.z > loc.z + r2)) - { - return NO; - } - - return !positionIsWithinRegion(position, region); -} - - -static NSArray *subregionsContainingPosition(Vector position, CollisionRegion *region) -{ - NSArray *subs = region->subregions; - NSMutableArray *result = [NSMutableArray array]; // autoreleased - - int i, n_subs = [subs count]; - for (i = 0; i < n_subs; i++) - { - if (positionIsWithinBorders(position, (CollisionRegion *)[subs objectAtIndex:i])) - { - [result addObject:[subs objectAtIndex:i]]; - } - } - return result; -} -#endif - - // collision checking // - (void) clearEntityList diff --git a/src/Core/Entities/Entity.h b/src/Core/Entities/Entity.h index 6b5dd2ba..2d0b9b36 100644 --- a/src/Core/Entities/Entity.h +++ b/src/Core/Entities/Entity.h @@ -194,7 +194,7 @@ enum OOScanClass - (void) setOwner:(Entity *)ent; - (id) owner; -- (ShipEntity *) parentEntity; // owner if self is subentity of owner, otherwise nil. +- (ShipEntity *) parentEntity; // owner if self is subentity of owner, otherwise nil. - (ShipEntity *) rootShipEntity; // like parentEntity, but recursive. - (void) setPosition:(Vector)posn; diff --git a/src/Core/Entities/OOEntityWithDrawable.m b/src/Core/Entities/OOEntityWithDrawable.m index 3329bf57..fcdcd774 100644 --- a/src/Core/Entities/OOEntityWithDrawable.m +++ b/src/Core/Entities/OOEntityWithDrawable.m @@ -79,7 +79,7 @@ MA 02110-1301, USA. // Don't draw. return; } -#if FRUSTUM_CULL + if (no_draw_distance != INFINITY) { // (always draw sky!) @@ -103,8 +103,7 @@ MA 02110-1301, USA. return; } } - } -#endif + } if ([UNIVERSE wireframeGraphics]) GLDebugWireframeModeOn(); diff --git a/src/Core/Entities/OOPlanetEntity.m b/src/Core/Entities/OOPlanetEntity.m index 6bd3631c..f4dfa584 100644 --- a/src/Core/Entities/OOPlanetEntity.m +++ b/src/Core/Entities/OOPlanetEntity.m @@ -477,14 +477,12 @@ static OOColor *ColorWithHSBColor(Vector c) { if (translucent || [UNIVERSE breakPatternHide]) return; // DON'T DRAW if (_miniature && ![self isFinishedLoading]) return; // For responsiveness, don't block to draw as miniature. - -#if FRUSTUM_CULL + if (![UNIVERSE checkFrustum:position:([self radius] + ATMOSPHERE_DEPTH)]) { // Don't draw return; } -#endif if ([UNIVERSE wireframeGraphics]) GLDebugWireframeModeOn(); diff --git a/src/Core/Entities/PlayerEntity.h b/src/Core/Entities/PlayerEntity.h index 179f0335..11e4dbec 100644 --- a/src/Core/Entities/PlayerEntity.h +++ b/src/Core/Entities/PlayerEntity.h @@ -357,12 +357,6 @@ typedef enum OOCreditsQuantity credits; OOGalaxyID galaxy_number; - /* - OOWeaponType forward_weapon; // Is there a reason for having both this and forward_weapon_type? -- ahruman - OOWeaponType aft_weapon; // ditto - No good reason, and it could lead to some inconsistent state. Fixed. -- kaks - */ -/* OOWeaponType port_weapon_type; // now in ShipEntity -- cim - OOWeaponType starboard_weapon_type; */ NSMutableArray *shipCommodityData; @@ -487,7 +481,7 @@ typedef enum unsigned suppressTargetLost: 1, // smart target lst reports scoopsActive: 1, // smart fuelscoops - scoopOverride: 1, //scripted to just be on, ignoring normal rules + scoopOverride: 1, //scripted to just be on, ignoring normal rules game_over: 1, finished: 1, bomb_detonated: 1, @@ -652,7 +646,7 @@ typedef enum - (float) fuelLeakRate; - (void) setFuelLeakRate:(float)value; -- (double) clockTime; // Note that this is not an OOTimeAbsolute +- (double) clockTime; // Note that this is not an OOTimeAbsolute - (double) clockTimeAdjusted; // Note that this is not an OOTimeAbsolute - (BOOL) clockAdjusting; - (void) addToAdjustTime:(double) seconds ; @@ -829,7 +823,6 @@ typedef enum // *** World script events. // In general, script events should be sent through doScriptEvent:..., which // will forward to the world scripts. -//- (void) doWorldScriptEvent:(jsid)message withArguments:(NSArray *)arguments timeLimit:(OOTimeDelta)limit; - (BOOL) doWorldEventUntilMissionScreen:(jsid)message; - (void) doWorldScriptEvent:(jsid)message inContext:(JSContext *)context withArguments:(jsval *)argv count:(uintN)argc timeLimit:(OOTimeDelta)limit; diff --git a/src/Core/Entities/PlayerEntity.m b/src/Core/Entities/PlayerEntity.m index 5c2fa38a..8a5fd2cf 100644 --- a/src/Core/Entities/PlayerEntity.m +++ b/src/Core/Entities/PlayerEntity.m @@ -5131,20 +5131,7 @@ static GLfloat sBaseMass = 0.0; dockedStation = nil; suppressAegisMessages = YES; -#if 0 - // "Fix" for "simple" issue where space compass shows station with planet icon on launch. - // Has the slight unwanted side-effect of effectively giving the player an advanced compass. - if ([self checkForAegis] != AEGIS_NONE) - { - [self setCompassMode:COMPASS_MODE_STATION]; - } - else - { - [self setCompassMode:COMPASS_MODE_PLANET]; - } -#else [self checkForAegis]; -#endif suppressAegisMessages = NO; ident_engaged = NO; diff --git a/src/Core/Entities/ShipEntity.h b/src/Core/Entities/ShipEntity.h index c9672f92..f485b960 100644 --- a/src/Core/Entities/ShipEntity.h +++ b/src/Core/Entities/ShipEntity.h @@ -393,14 +393,14 @@ typedef enum OOEquipmentType *missile_list[SHIPENTITY_MAX_MISSILES]; // various types of target - OOWeakReference *_primaryTarget; // for combat or rendezvous - OOWeakReference *_primaryAggressor; // recorded after attack - OOWeakReference *_targetStation; // for docking - OOWeakReference *_foundTarget; // from scans - OOWeakReference *_lastEscortTarget; // last target an escort was deployed after - OOWeakReference *_thankedShip; // last ship thanked - OOWeakReference *_rememberedShip; // ship being remembered - OOWeakReference *_proximityAlert; // a ShipEntity within 2x collision_radius + OOWeakReference *_primaryTarget; // for combat or rendezvous + OOWeakReference *_primaryAggressor; // recorded after attack + OOWeakReference *_targetStation; // for docking + OOWeakReference *_foundTarget; // from scans + OOWeakReference *_lastEscortTarget; // last target an escort was deployed after + OOWeakReference *_thankedShip; // last ship thanked + OOWeakReference *_rememberedShip; // ship being remembered + OOWeakReference *_proximityAlert; // a ShipEntity within 2x collision_radius @@ -921,7 +921,6 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q - (GLfloat) rangeToDestination; - (double) trackDestination:(double) delta_t :(BOOL) retreat; -//- (double) trackPosition:(Vector) track_pos :(double) delta_t :(BOOL) retreat; - (void) setCoordinate:(Vector)coord; - (Vector) coordinates; @@ -1075,9 +1074,9 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q - (Entity *)entityForShaderProperties; /* *** Script events. - For NPC ships, these call doEvent: on the ship script. - For the player, they do that and also call doWorldScriptEvent:. - */ + For NPC ships, these call doEvent: on the ship script. + For the player, they do that and also call doWorldScriptEvent:. +*/ - (void) doScriptEvent:(jsid)message; - (void) doScriptEvent:(jsid)message withArgument:(id)argument; - (void) doScriptEvent:(jsid)message withArgument:(id)argument1 andArgument:(id)argument2; @@ -1086,8 +1085,8 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q - (void) doScriptEvent:(jsid)message inContext:(JSContext *)context withArguments:(jsval *)argv count:(uintN)argc; /* Convenience to send an event with raw JS values, for example: - ShipScriptEventNoCx(ship, "doSomething", INT_TO_JSVAL(42)); - */ + ShipScriptEventNoCx(ship, "doSomething", INT_TO_JSVAL(42)); +*/ #define ShipScriptEvent(context, ship, event, ...) do { \ jsval argv[] = { __VA_ARGS__ }; \ uintN argc = sizeof argv / sizeof *argv; \ diff --git a/src/Core/Entities/StationEntity.h b/src/Core/Entities/StationEntity.h index 2d139331..f2dea250 100644 --- a/src/Core/Entities/StationEntity.h +++ b/src/Core/Entities/StationEntity.h @@ -66,11 +66,7 @@ typedef enum OOTechLevelID equivalentTechLevel; float equipmentPriceFactor; - -/* Vector port_position; // these four now handled by DockEntity - Quaternion port_orientation; - ShipEntity *port_model; - double port_corridor; */ // corridor length inside station. + Vector port_dimensions; double port_radius; diff --git a/src/Core/Entities/StationEntity.m b/src/Core/Entities/StationEntity.m index ffff5312..1db32ac1 100644 --- a/src/Core/Entities/StationEntity.m +++ b/src/Core/Entities/StationEntity.m @@ -251,9 +251,9 @@ MA 02110-1301, USA. - (void) launchShip:(ShipEntity *)ship { NSEnumerator *subEnum = nil; - DockEntity* sub = nil; + DockEntity *sub = nil; -// try to find an unused dock first + // try to find an unused dock first for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); ) { if ([sub allowsLaunching] && [sub countOfShipsInLaunchQueue] == 0) @@ -262,7 +262,7 @@ MA 02110-1301, USA. return; } } -// otherwise any launchable dock will do + // otherwise any launchable dock will do for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); ) { if ([sub allowsLaunching]) @@ -272,13 +272,13 @@ MA 02110-1301, USA. } } -// ship has no launch docks specified; just use the last one + // ship has no launch docks specified; just use the last one if (sub != nil) { [sub launchShip:ship]; return; } -// guaranteed to always be a dock as virtual dock will suffice + // guaranteed to always be a dock as virtual dock will suffice } @@ -364,8 +364,8 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f } -// this routine does initial traffic control, before passing the ship -// to an appropriate dock for docking coordinates and instructions +// this method does initial traffic control, before passing the ship +// to an appropriate dock for docking coordinates and instructions. - (NSDictionary *) dockingInstructionsForShip:(ShipEntity *) ship { if (ship == nil) return nil; @@ -399,7 +399,8 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); ) { if ([sub shipIsInDockingQueue:ship]) - { // if already claimed a docking queue, use that one + { + // if already claimed a docking queue, use that one chosenDock = sub; alldockstoosmall = NO; break; @@ -431,7 +432,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f } if ([docking isEqualToString:@"DOCKING_POSSIBLE"] && [sub countOfShipsInDockingQueue] < queue) { -// try to select the dock with the fewest ships already enqueued + // try to select the dock with the fewest ships already enqueued chosenDock = sub; queue = [sub countOfShipsInDockingQueue]; alldockstoosmall = NO; @@ -913,7 +914,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f // quickest launch if we assign ships to those bays with no incoming ships // and spread the ships evenly around those bays - // much easier if the station has at least one launch-only dock + // much easier if the station has at least one launch-only dock while (threshold < 16) { for (subEnum = [self dockSubEntityEnumerator]; (sub = [subEnum nextObject]); ) @@ -938,8 +939,8 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f // if we get this far, all docks have at least some incoming traffic. // usually most efficient (since launching is far faster than docking) // to assign all ships to the *same* dock with the smallest incoming queue - // rather than to try spreading them out across several queues - // also stops escorts being launched before their mothership + // rather than to try spreading them out across several queues + // also stops escorts being launched before their mothership threshold = 0; while (threshold < 16) { @@ -947,11 +948,11 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f { if (sub != player_reserved_dock) { -// so this time as long as it allows launching only check the docking queue size -// so long as enumerator order is deterministic, this will assign -// every launch this update to the same dock -// (edge case where new docking ship appears in the middle, probably -// not a problem) + // so this time as long as it allows launching only check the docking queue size + // so long as enumerator order is deterministic, this will assign + // every launch this update to the same dock + // (edge case where new docking ship appears in the middle, probably + // not a problem) if ([sub allowsLaunching] && [sub countOfShipsInDockingQueue] <= threshold) { if ([sub allowsLaunchingOf:ship]) @@ -1010,7 +1011,8 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f PlayerEntity *player = PLAYER; // set last launch time to avoid clashes with outgoing ships if ([player getDockingClearanceStatus] != DOCKING_CLEARANCE_STATUS_GRANTED) - { // avoid interfering with docking clearance on another bay + { + // avoid interfering with docking clearance on another bay last_launch_time = [UNIVERSE getTime]; } [self addShipToStationCount: ship]; @@ -1030,7 +1032,8 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f [player getDockingClearanceStatus] == DOCKING_CLEARANCE_STATUS_REQUESTED) { if (![self hasClearDock]) - { // then say why + { + // then say why if ([self currentlyInDockingQueues]) { [self sendExpandedMessage:[NSString stringWithFormat: @@ -1088,9 +1091,13 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f - (BOOL) collideWithShip:(ShipEntity *)other { - // 2010.06.10 - Micha. Commented out as there doesn't appear to be a good - // reason for it and it interferes with docking clearance. - //[self abortAllDockings]; + /* + There used to be a [self abortAllDockings] here. Removed as there + doesn't appear to be a good reason for it and it interferes with + docking clearance. + -- Micha 2010-06-10 + Reformatted, Ahruman 2012-08-26 + */ return [super collideWithShip:other]; } @@ -1102,7 +1109,7 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f - (void) takeEnergyDamage:(double)amount from:(Entity *)ent becauseOf:(Entity *)other { - //stations must ignore friendly fire, otherwise the defenders' AI gets stuck. + // stations must ignore friendly fire, otherwise the defenders' AI gets stuck. BOOL isFriend = NO; OOShipGroup *group = [self group]; @@ -2277,46 +2284,3 @@ NSDictionary *OOMakeDockingInstructions(StationEntity *station, Vector coords, f } @end - - -#ifndef NDEBUG - -@implementation StationEntity (OOWireframeDockingBox) - -- (void)drawEntity:(BOOL)immediate :(BOOL)translucent -{ - [super drawEntity:immediate:translucent]; - -/* if (gDebugFlags & DEBUG_BOUNDING_BOXES) - { - Vector adjustedPosition; - Vector halfDimensions; - - OODebugDrawBasisAtOrigin(50.0f); - - OOMatrix matrix; - matrix = OOMatrixForQuaternionRotation(port_orientation); - OOGL(glPushMatrix()); - GLMultOOMatrix(matrix); - - halfDimensions = vector_multiply_scalar(port_dimensions, 0.5f); - adjustedPosition = port_position; - adjustedPosition.z -= halfDimensions.z; - - OODebugDrawColoredBoundingBoxBetween(vector_subtract(adjustedPosition, halfDimensions), vector_add(adjustedPosition, halfDimensions), [OOColor redColor]); - OODebugDrawBasisAtOrigin(30.0f); - - OOGL(glPopMatrix()); - } */ -} - - -// Added to test exception wrapping in JS engine. If this is an ancient issue, delete this method. -- Ahruman 2010-06-21 -- (void) TEMPExceptionTest -{ - [NSException raise:@"TestException" format:@"This is a test exception which shouldn't crash the game."]; -} - -@end - -#endif diff --git a/src/Core/Scripting/OOJSMission.m b/src/Core/Scripting/OOJSMission.m index d0ae1da0..672edd8a 100644 --- a/src/Core/Scripting/OOJSMission.m +++ b/src/Core/Scripting/OOJSMission.m @@ -304,13 +304,7 @@ static JSBool MissionAddMessageText(JSContext *context, uintN argc, jsval *vp) if (EXPECT_NOT(argc == 0)) { -#if 0 - // EMMSTRAN: fail. - OOJSReportBadArguments(context, @"Mission", @"addMessageText", argc, OOJS_ARGV, nil, @"string"); - return NO; -#else OOJS_RETURN_VOID; -#endif } // Found "FIXME: warning if no mission screen running.",,, diff --git a/src/Core/Scripting/OOJavaScriptEngine.m b/src/Core/Scripting/OOJavaScriptEngine.m index f7d7584f..f433c0d6 100644 --- a/src/Core/Scripting/OOJavaScriptEngine.m +++ b/src/Core/Scripting/OOJavaScriptEngine.m @@ -1877,38 +1877,24 @@ NSString *OOJSDescribeValue(JSContext *context, jsval value, BOOL abbreviateObje BOOL isFloat = NO; long long longLongValue; -#if 0 - /* Under GNUstep, it is not possible to distinguish between boolean - NSNumbers and integer NSNumbers - there is no such distinction. - It is better to convert booleans to integers than vice versa. - */ - if ([self oo_isBoolean]) + isFloat = [self oo_isFloatingPointNumber]; + if (!isFloat) { - if ([self boolValue]) result = JSVAL_TRUE; - else result = JSVAL_FALSE; + longLongValue = [self longLongValue]; + if (longLongValue < (long long)JSVAL_INT_MIN || (long long)JSVAL_INT_MAX < longLongValue) + { + // values outside JSVAL_INT range are returned as doubles. + isFloat = YES; + } + } + + if (isFloat) + { + if (!JS_NewNumberValue(context, [self doubleValue], &result)) result = JSVAL_VOID; } else -#endif { - isFloat = [self oo_isFloatingPointNumber]; - if (!isFloat) - { - longLongValue = [self longLongValue]; - if (longLongValue < (long long)JSVAL_INT_MIN || (long long)JSVAL_INT_MAX < longLongValue) - { - // values outside JSVAL_INT range are returned as doubles. - isFloat = YES; - } - } - - if (isFloat) - { - if (!JS_NewNumberValue(context, [self doubleValue], &result)) result = JSVAL_VOID; - } - else - { - result = INT_TO_JSVAL((int32_t)longLongValue); - } + result = INT_TO_JSVAL((int32_t)longLongValue); } return result; diff --git a/src/Core/Universe.h b/src/Core/Universe.h index bf5154a9..4531a76b 100644 --- a/src/Core/Universe.h +++ b/src/Core/Universe.h @@ -48,10 +48,6 @@ MA 02110-1301, USA. typedef BOOL (*EntityFilterPredicate)(Entity *entity, void *parameter); -#ifndef FRUSTUM_CULL -#define FRUSTUM_CULL 1 -#endif - #ifndef OO_SCANCLASS_TYPE #define OO_SCANCLASS_TYPE typedef enum OOScanClass OOScanClass; @@ -300,11 +296,9 @@ enum NSMutableArray *_preloadingPlanetMaterials; #endif BOOL doProcedurallyTexturedPlanets; - -#if FRUSTUM_CULL - GLfloat frustum[6][4]; -#endif - + + GLfloat frustum[6][4]; + NSMutableDictionary *conditionScripts; BOOL _pauseMessage; @@ -445,10 +439,10 @@ enum - (NSDictionary *) gameSettings; - (void) drawUniverse; -#if FRUSTUM_CULL + - (void) defineFrustum; -- (BOOL) checkFrustum:(Vector) position:(GLfloat) radius; -#endif +- (BOOL) checkFrustum:(Vector)position :(GLfloat)radius; + - (void) drawMessage; // Used to draw subentities. Should be getting this from camera. diff --git a/src/Core/Universe.m b/src/Core/Universe.m index e111adb7..ba35d558 100644 --- a/src/Core/Universe.m +++ b/src/Core/Universe.m @@ -937,7 +937,7 @@ GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOC /*- the dust particle system -*/ thing = [[DustEntity alloc] init]; // alloc retains! [thing setScanClass: CLASS_NO_DRAW]; - [self addEntity:thing]; // [entities addObject:thing]; + [self addEntity:thing]; [(DustEntity *)thing setDustColor:pale_bgcolor]; [thing release]; /*--*/ @@ -1015,8 +1015,6 @@ GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOC if (dict_object!=nil) [sun_dict setObject:dict_object forKey:@"corona_hues"]; dict_object=[systeminfo objectForKey: @"corona_flare"]; if (dict_object!=nil) [sun_dict setObject:dict_object forKey:@"corona_flare"]; - //dict_object=[systeminfo objectForKey: @"sun_texture"]; - //if (dict_object!=nil) [sun_dict setObject:dict_object forKey:@"sun_texture"]; a_sun = [[OOSunEntity alloc] initSunWithColor:pale_bgcolor andDictionary:sun_dict]; // alloc retains! @@ -3438,8 +3436,6 @@ static const OOMatrix starboard_matrix = } -#if FRUSTUM_CULL - /* Code adapted from http://www.crownandcutlass.com/features/technicaldetails/frustum.html * Original license is: "This page and its contents are Copyright 2000 by Mark Morley * Unless otherwise noted, you may use any and all code examples provided herein in any way you want." @@ -3448,62 +3444,62 @@ static const OOMatrix starboard_matrix = - (void) defineFrustum { GLfloat proj[16]; - GLfloat modl[16]; - GLfloat clip[16]; - GLfloat t; - + GLfloat modl[16]; + GLfloat clip[16]; + GLfloat rt; + /* Get the current PROJECTION matrix from OpenGL */ glGetFloatv( GL_PROJECTION_MATRIX, proj ); - + /* Get the current MODELVIEW matrix from OpenGL */ glGetFloatv( GL_MODELVIEW_MATRIX, modl ); - + /* Combine the two matrices (multiply projection by modelview) */ clip[ 0] = modl[ 0] * proj[ 0] + modl[ 1] * proj[ 4] + modl[ 2] * proj[ 8] + modl[ 3] * proj[12]; clip[ 1] = modl[ 0] * proj[ 1] + modl[ 1] * proj[ 5] + modl[ 2] * proj[ 9] + modl[ 3] * proj[13]; clip[ 2] = modl[ 0] * proj[ 2] + modl[ 1] * proj[ 6] + modl[ 2] * proj[10] + modl[ 3] * proj[14]; clip[ 3] = modl[ 0] * proj[ 3] + modl[ 1] * proj[ 7] + modl[ 2] * proj[11] + modl[ 3] * proj[15]; - + clip[ 4] = modl[ 4] * proj[ 0] + modl[ 5] * proj[ 4] + modl[ 6] * proj[ 8] + modl[ 7] * proj[12]; clip[ 5] = modl[ 4] * proj[ 1] + modl[ 5] * proj[ 5] + modl[ 6] * proj[ 9] + modl[ 7] * proj[13]; clip[ 6] = modl[ 4] * proj[ 2] + modl[ 5] * proj[ 6] + modl[ 6] * proj[10] + modl[ 7] * proj[14]; clip[ 7] = modl[ 4] * proj[ 3] + modl[ 5] * proj[ 7] + modl[ 6] * proj[11] + modl[ 7] * proj[15]; - + clip[ 8] = modl[ 8] * proj[ 0] + modl[ 9] * proj[ 4] + modl[10] * proj[ 8] + modl[11] * proj[12]; clip[ 9] = modl[ 8] * proj[ 1] + modl[ 9] * proj[ 5] + modl[10] * proj[ 9] + modl[11] * proj[13]; clip[10] = modl[ 8] * proj[ 2] + modl[ 9] * proj[ 6] + modl[10] * proj[10] + modl[11] * proj[14]; clip[11] = modl[ 8] * proj[ 3] + modl[ 9] * proj[ 7] + modl[10] * proj[11] + modl[11] * proj[15]; - + clip[12] = modl[12] * proj[ 0] + modl[13] * proj[ 4] + modl[14] * proj[ 8] + modl[15] * proj[12]; clip[13] = modl[12] * proj[ 1] + modl[13] * proj[ 5] + modl[14] * proj[ 9] + modl[15] * proj[13]; clip[14] = modl[12] * proj[ 2] + modl[13] * proj[ 6] + modl[14] * proj[10] + modl[15] * proj[14]; clip[15] = modl[12] * proj[ 3] + modl[13] * proj[ 7] + modl[14] * proj[11] + modl[15] * proj[15]; - + /* Extract the numbers for the RIGHT plane */ frustum[0][0] = clip[ 3] - clip[ 0]; frustum[0][1] = clip[ 7] - clip[ 4]; frustum[0][2] = clip[11] - clip[ 8]; frustum[0][3] = clip[15] - clip[12]; - + /* Normalize the result */ - t = sqrt( frustum[0][0] * frustum[0][0] + frustum[0][1] * frustum[0][1] + frustum[0][2] * frustum[0][2] ); - frustum[0][0] /= t; - frustum[0][1] /= t; - frustum[0][2] /= t; - frustum[0][3] /= t; - + rt = 1.0f / sqrt(frustum[0][0] * frustum[0][0] + frustum[0][1] * frustum[0][1] + frustum[0][2] * frustum[0][2]); + frustum[0][0] *= rt; + frustum[0][1] *= rt; + frustum[0][2] *= rt; + frustum[0][3] *= rt; + /* Extract the numbers for the LEFT plane */ frustum[1][0] = clip[ 3] + clip[ 0]; frustum[1][1] = clip[ 7] + clip[ 4]; frustum[1][2] = clip[11] + clip[ 8]; frustum[1][3] = clip[15] + clip[12]; - + /* Normalize the result */ - t = sqrt( frustum[1][0] * frustum[1][0] + frustum[1][1] * frustum[1][1] + frustum[1][2] * frustum[1][2] ); - frustum[1][0] /= t; - frustum[1][1] /= t; - frustum[1][2] /= t; - frustum[1][3] /= t; + rt = 1.0f / sqrt(frustum[1][0] * frustum[1][0] + frustum[1][1] * frustum[1][1] + frustum[1][2] * frustum[1][2]); + frustum[1][0] *= rt; + frustum[1][1] *= rt; + frustum[1][2] *= rt; + frustum[1][3] *= rt; /* Extract the BOTTOM plane */ frustum[2][0] = clip[ 3] + clip[ 1]; @@ -3512,11 +3508,11 @@ static const OOMatrix starboard_matrix = frustum[2][3] = clip[15] + clip[13]; /* Normalize the result */ - t = sqrt( frustum[2][0] * frustum[2][0] + frustum[2][1] * frustum[2][1] + frustum[2][2] * frustum[2][2] ); - frustum[2][0] /= t; - frustum[2][1] /= t; - frustum[2][2] /= t; - frustum[2][3] /= t; + rt = 1.0 / sqrt(frustum[2][0] * frustum[2][0] + frustum[2][1] * frustum[2][1] + frustum[2][2] * frustum[2][2]); + frustum[2][0] *= rt; + frustum[2][1] *= rt; + frustum[2][2] *= rt; + frustum[2][3] *= rt; /* Extract the TOP plane */ frustum[3][0] = clip[ 3] - clip[ 1]; @@ -3525,11 +3521,11 @@ static const OOMatrix starboard_matrix = frustum[3][3] = clip[15] - clip[13]; /* Normalize the result */ - t = sqrt( frustum[3][0] * frustum[3][0] + frustum[3][1] * frustum[3][1] + frustum[3][2] * frustum[3][2] ); - frustum[3][0] /= t; - frustum[3][1] /= t; - frustum[3][2] /= t; - frustum[3][3] /= t; + rt = 1.0 / sqrt(frustum[3][0] * frustum[3][0] + frustum[3][1] * frustum[3][1] + frustum[3][2] * frustum[3][2]); + frustum[3][0] *= rt; + frustum[3][1] *= rt; + frustum[3][2] *= rt; + frustum[3][3] *= rt; /* Extract the FAR plane */ frustum[4][0] = clip[ 3] - clip[ 2]; @@ -3538,11 +3534,11 @@ static const OOMatrix starboard_matrix = frustum[4][3] = clip[15] - clip[14]; /* Normalize the result */ - t = sqrt( frustum[4][0] * frustum[4][0] + frustum[4][1] * frustum[4][1] + frustum[4][2] * frustum[4][2] ); - frustum[4][0] /= t; - frustum[4][1] /= t; - frustum[4][2] /= t; - frustum[4][3] /= t; + rt = sqrt(frustum[4][0] * frustum[4][0] + frustum[4][1] * frustum[4][1] + frustum[4][2] * frustum[4][2]); + frustum[4][0] *= rt; + frustum[4][1] *= rt; + frustum[4][2] *= rt; + frustum[4][3] *= rt; /* Extract the NEAR plane */ frustum[5][0] = clip[ 3] + clip[ 2]; @@ -3551,27 +3547,26 @@ static const OOMatrix starboard_matrix = frustum[5][3] = clip[15] + clip[14]; /* Normalize the result */ - t = sqrt( frustum[5][0] * frustum[5][0] + frustum[5][1] * frustum[5][1] + frustum[5][2] * frustum[5][2] ); - frustum[5][0] /= t; - frustum[5][1] /= t; - frustum[5][2] /= t; - frustum[5][3] /= t; + rt = sqrt(frustum[5][0] * frustum[5][0] + frustum[5][1] * frustum[5][1] + frustum[5][2] * frustum[5][2]); + frustum[5][0] *= rt; + frustum[5][1] *= rt; + frustum[5][2] *= rt; + frustum[5][3] *= rt; } -- (BOOL) checkFrustum:(Vector) position:(GLfloat) radius +- (BOOL) checkFrustum:(Vector)position :(GLfloat)radius { int p; - for( p = 0; p < 6; p++ ) + for (p = 0; p < 6; p++) { - if( frustum[p][0] * position.x + frustum[p][1] * position.y + frustum[p][2] * position.z + frustum[p][3] <= -radius ) + if (frustum[p][0] * position.x + frustum[p][1] * position.y + frustum[p][2] * position.z + frustum[p][3] <= -radius) { return NO; } } return YES; } -#endif - (void) drawUniverse @@ -3690,9 +3685,8 @@ static const OOMatrix starboard_matrix = OOGL(glHint(GL_FOG_HINT, [self reducedDetail] ? GL_FASTEST : GL_NICEST)); -#if FRUSTUM_CULL [self defineFrustum]; // camera is set up for this frame -#endif + CheckOpenGLErrors(@"Universe after setting up for opaque pass"); // DRAW ALL THE OPAQUE ENTITIES for (i = furthest; i >= nearest; i--) @@ -9556,7 +9550,6 @@ static void PreloadOneSound(NSString *soundName) systeminfo = [self generateSystemData:system_seed]; sunGoneNova = [systeminfo oo_boolForKey:@"sun_gone_nova"]; -// OOTechLevelID techlevel = [systeminfo oo_unsignedCharForKey:KEY_TECHLEVEL]; // 0 .. 13 OOGovernmentID government = [systeminfo oo_unsignedCharForKey:KEY_GOVERNMENT]; // 0 .. 7 (0 anarchic .. 7 most stable) OOEconomyID economy = [systeminfo oo_unsignedCharForKey:KEY_ECONOMY]; // 0 .. 7 (0 richest .. 7 poorest)