Re-enable frustum culling, fix display of planet atmosphere and flashers

This commit is contained in:
cim 2013-07-03 11:01:36 +01:00
parent 56761878a3
commit 814ef88f2b
8 changed files with 19 additions and 23 deletions

View File

@ -635,7 +635,7 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
- (void) updateCameraRelativePosition
{
cameraRelativePosition = HPVectorToVector(HPvector_subtract(position,[PLAYER viewpointPosition]));
cameraRelativePosition = HPVectorToVector(HPvector_subtract([self absolutePositionForSubentity],[PLAYER viewpointPosition]));
}
@ -901,7 +901,7 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
{
zero_distance = [[self owner] zeroDistance];
cam_zero_distance = [[self owner] camZeroDistance];
cameraRelativePosition = [[self owner] cameraRelativePosition];
[self updateCameraRelativePosition];
}
else
{

View File

@ -97,19 +97,19 @@ MA 02110-1301, USA.
// http://aegidian.org/bb/viewtopic.php?f=3&t=13619 - CIM
if (cam_zero_distance > (clipradius+1000)*(clipradius+1000))
{
if (![UNIVERSE viewFrustumIntersectsSphereAt:position withRadius:clipradius])
if (![UNIVERSE viewFrustumIntersectsSphereAt:cameraRelativePosition withRadius:clipradius])
{
return;
}
}
}
else
else // is subentity
{
// don't bother with frustum culling within 1km, as above - CIM
if (cam_zero_distance > (collision_radius+1000)*(collision_radius+1000))
{
// check correct sub-entity position
if (![UNIVERSE viewFrustumIntersectsSphereAt:[self absolutePositionForSubentity] withRadius:[self collisionRadius]])
if (![UNIVERSE viewFrustumIntersectsSphereAt:cameraRelativePosition withRadius:[self collisionRadius]])
{
return;
}

View File

@ -109,29 +109,26 @@ static OOTexture *sBlobTexture = nil;
OO_ENTER_OPENGL();
/*Entity *father = [self owner];
Entity *father = [self owner];
Entity *last = nil;
Vector abspos = position;
HPVector abspos = position;
while (father != nil && father != last && father != NO_TARGET)
{
OOMatrix rM = [father drawRotationMatrix];
abspos = vector_add(OOVectorMultiplyMatrix(abspos, rM), [father position]);
abspos = HPvector_add(OOHPVectorMultiplyMatrix(abspos, rM), [father position]);
last = father;
if (![father isSubEntity]) break;
father = [father owner];
}*/
HPVector abspos = [self absolutePositionForSubentity];
}
OOMatrix temp_matrix = OOMatrixLoadGLMatrix(GL_MODELVIEW_MATRIX);
OOGL(glPopMatrix()); OOGL(glPushMatrix()); // restore zero!
// HPVect: camera-relative
HPVector relpos = HPvector_subtract(abspos,[PLAYER viewpointPosition]);
GLTranslateOOVector(HPVectorToVector(relpos)); // move to camera-relative position
GLTranslateOOVector(HPVectorToVector(HPvector_subtract(abspos,[PLAYER viewpointPosition]))); // move to camera-relative position
[self drawImmediate:immediate translucent:translucent];
GLLoadOOMatrix(temp_matrix);
}

View File

@ -478,7 +478,7 @@ 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 (![UNIVERSE viewFrustumIntersectsSphereAt:position withRadius:([self radius] + ATMOSPHERE_DEPTH)])
if (![UNIVERSE viewFrustumIntersectsSphereAt:cameraRelativePosition withRadius:([self radius] + ATMOSPHERE_DEPTH)])
{
// Don't draw
return;

View File

@ -759,7 +759,7 @@ static const BaseFace kTexturedFaces[][3] =
// for some reason this check doesn't work when extremely close to
// the planet and with the horizon near the side of the frame (FP
// inaccuracy?)
if (![UNIVERSE viewFrustumIntersectsSphereAt:position withRadius:radWithAtmosphere])
if (![UNIVERSE viewFrustumIntersectsSphereAt:cameraRelativePosition withRadius:radWithAtmosphere])
{
// Don't draw
return;
@ -969,7 +969,7 @@ static const BaseFace kTexturedFaces[][3] =
{
OOGL(glPopMatrix()); // get old draw matrix back
OOGL(glPushMatrix()); // and store it again
OOGL(glTranslatef(position.x,position.y,position.z)); // centre on the planet
OOGL(glTranslatef(cameraRelativePosition.x,cameraRelativePosition.y,cameraRelativePosition.z)); // centre on the planet
// rotate
// GLMultOOMatrix([atmosphere rotationMatrix]);
// draw atmosphere entity

View File

@ -770,7 +770,7 @@ static ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
- (BOOL) setUpOneFlasher:(NSDictionary *) subentDict
{
OOFlasherEntity *flasher = [OOFlasherEntity flasherWithDictionary:subentDict];
[flasher setPosition:vectorToHPVector([subentDict oo_vectorForKey:@"position"])];
[flasher setPosition:[subentDict oo_hpvectorForKey:@"position"]];
[self addSubEntity:flasher];
return YES;
}

View File

@ -454,7 +454,7 @@ enum
- (void) drawUniverse;
- (void) defineFrustum;
- (BOOL) viewFrustumIntersectsSphereAt:(HPVector)position withRadius:(GLfloat)radius;
- (BOOL) viewFrustumIntersectsSphereAt:(Vector)position withRadius:(GLfloat)radius;
- (void) drawMessage;

View File

@ -3815,9 +3815,8 @@ static const OOMatrix starboard_matrix =
}
- (BOOL) viewFrustumIntersectsSphereAt:(HPVector)position withRadius:(GLfloat)radius
- (BOOL) viewFrustumIntersectsSphereAt:(Vector)position withRadius:(GLfloat)radius
{
return YES; // HPVect: temporarily, while rest of camera-relative is sorted out
int p;
for (p = 0; p < 6; p++)
{