Merge branch 'issue_150'
This commit is contained in:
commit
a3b98ddcfa
@ -258,6 +258,7 @@ enum OOScanClass
|
||||
|
||||
- (BOOL) canCollide;
|
||||
- (GLfloat) collisionRadius;
|
||||
- (GLfloat) frustumRadius;
|
||||
- (void) setCollisionRadius:(GLfloat)amount;
|
||||
- (NSMutableArray *)collisionArray;
|
||||
|
||||
|
@ -612,12 +612,12 @@ static NSString * const kOOLogEntityVerificationError = @"entity.linkedList.ver
|
||||
|
||||
- (GLfloat) cameraRangeFront
|
||||
{
|
||||
return magnitude(cameraRelativePosition) - [self collisionRadius];
|
||||
return magnitude(cameraRelativePosition) - [self frustumRadius];
|
||||
}
|
||||
|
||||
- (GLfloat) cameraRangeBack
|
||||
{
|
||||
return magnitude(cameraRelativePosition) + [self collisionRadius];
|
||||
return magnitude(cameraRelativePosition) + [self frustumRadius];
|
||||
}
|
||||
|
||||
|
||||
@ -899,6 +899,12 @@ static NSString * const kOOLogEntityVerificationError = @"entity.linkedList.ver
|
||||
}
|
||||
|
||||
|
||||
- (GLfloat) frustumRadius
|
||||
{
|
||||
return collision_radius;
|
||||
}
|
||||
|
||||
|
||||
- (void) setCollisionRadius:(GLfloat) amount
|
||||
{
|
||||
collision_radius = amount;
|
||||
|
@ -110,7 +110,7 @@ static OOTexture *sPlumeTexture = nil;
|
||||
|
||||
- (double)findCollisionRadius
|
||||
{
|
||||
return 0; // FIXME: something sensible. Where does plume length come from anyway?
|
||||
return collision_radius;
|
||||
}
|
||||
|
||||
|
||||
@ -131,6 +131,9 @@ static OOTexture *sPlumeTexture = nil;
|
||||
}
|
||||
|
||||
//GLfloat ex_emissive[4] = {0.7f, 0.9, 1.0f, 0.9f * kOverallAlpha}; // pale blue - old definition
|
||||
collision_radius = 0;
|
||||
GLfloat length;
|
||||
Vector vertex;
|
||||
GLfloat ex_emissive[4];
|
||||
[[ship exhaustEmissiveColor] getRed:&ex_emissive[0] green:&ex_emissive[1] blue:&ex_emissive[2] alpha:&ex_emissive[3]];
|
||||
const GLfloat s1[8] = { 0.0, M_SQRT1_2, 1.0, M_SQRT1_2, 0.0, -M_SQRT1_2, -1.0, -M_SQRT1_2};
|
||||
@ -218,9 +221,11 @@ static OOTexture *sPlumeTexture = nil;
|
||||
ex_emissive[3] = flare_factor * kOverallAlpha; // fade alpha towards rear of exhaust
|
||||
ex_emissive[1] = green_factor; // diminish green part towards rear of exhaust
|
||||
ex_emissive[0] = red_factor; // diminish red part towards rear of exhaust
|
||||
_vertices[iv++] = f01.position.x + b01.x;// + zero.k.x * flare_factor * 4.0;
|
||||
_vertices[iv++] = f01.position.y + b01.y;// + zero.k.y * flare_factor * 4.0;
|
||||
_vertices[iv++] = f01.position.z + b01.z;// + zero.k.z * flare_factor * 4.0;
|
||||
vertex = vector_add(HPVectorToVector(f01.position), b01);
|
||||
collision_radius = magnitude(vector_subtract(vertex, HPVectorToVector(currentPos)));
|
||||
_vertices[iv++] = vertex.x;// + zero.k.x * flare_factor * 4.0;
|
||||
_vertices[iv++] = vertex.y;// + zero.k.y * flare_factor * 4.0;
|
||||
_vertices[iv++] = vertex.z;// + zero.k.z * flare_factor * 4.0;
|
||||
_exhaustBaseColors[ci++] = ex_emissive[0];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[1];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[2];
|
||||
@ -234,9 +239,18 @@ static OOTexture *sPlumeTexture = nil;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
_vertices[iv++] = f01.position.x + b01.x + s1[i] * i1.x + c1[i] * j1.x;
|
||||
_vertices[iv++] = f01.position.y + b01.y + s1[i] * i1.y + c1[i] * j1.y;
|
||||
_vertices[iv++] = f01.position.z + b01.z + s1[i] * i1.z + c1[i] * j1.z;
|
||||
vertex = vector_add(HPVectorToVector(f01.position),
|
||||
vector_add(b01,
|
||||
vector_add(vector_multiply_scalar(i1,s1[i]),
|
||||
vector_multiply_scalar(j1,c1[i]))));
|
||||
length = magnitude(vector_subtract(vertex, HPVectorToVector(currentPos)));
|
||||
if (length > collision_radius)
|
||||
{
|
||||
collision_radius = length;
|
||||
}
|
||||
_vertices[iv++] = vertex.x;
|
||||
_vertices[iv++] = vertex.y;
|
||||
_vertices[iv++] = vertex.z;
|
||||
_exhaustBaseColors[ci++] = ex_emissive[0];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[1];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[2];
|
||||
@ -253,9 +267,19 @@ static OOTexture *sPlumeTexture = nil;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
r1 = randf();
|
||||
_vertices[iv++] = f03.position.x + b03.x + s1[i] * i1.x + c1[i] * j1.x + r1 * k1.x;
|
||||
_vertices[iv++] = f03.position.y + b03.y + s1[i] * i1.y + c1[i] * j1.y + r1 * k1.y;
|
||||
_vertices[iv++] = f03.position.z + b03.z + s1[i] * i1.z + c1[i] * j1.z + r1 * k1.z;
|
||||
vertex = vector_add(HPVectorToVector(f03.position),
|
||||
vector_add(b03,
|
||||
vector_add(vector_multiply_scalar(i1,s1[i]),
|
||||
vector_add(vector_multiply_scalar(j1,c1[i]),
|
||||
vector_multiply_scalar(k1,r1)))));
|
||||
length = magnitude(vector_subtract(vertex, HPVectorToVector(currentPos)));
|
||||
if (length > collision_radius)
|
||||
{
|
||||
collision_radius = length;
|
||||
}
|
||||
_vertices[iv++] = vertex.x;
|
||||
_vertices[iv++] = vertex.y;
|
||||
_vertices[iv++] = vertex.z;
|
||||
_exhaustBaseColors[ci++] = ex_emissive[0];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[1];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[2];
|
||||
@ -272,9 +296,19 @@ static OOTexture *sPlumeTexture = nil;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
r1 = randf();
|
||||
_vertices[iv++] = f06.position.x + b06.x + s1[i] * i1.x + c1[i] * j1.x + r1 * k1.x;
|
||||
_vertices[iv++] = f06.position.y + b06.y + s1[i] * i1.y + c1[i] * j1.y + r1 * k1.y;
|
||||
_vertices[iv++] = f06.position.z + b06.z + s1[i] * i1.z + c1[i] * j1.z + r1 * k1.z;
|
||||
vertex = vector_add(HPVectorToVector(f06.position),
|
||||
vector_add(b06,
|
||||
vector_add(vector_multiply_scalar(i1,s1[i]),
|
||||
vector_add(vector_multiply_scalar(j1,c1[i]),
|
||||
vector_multiply_scalar(k1,r1)))));
|
||||
length = magnitude(vector_subtract(vertex, HPVectorToVector(currentPos)));
|
||||
if (length > collision_radius)
|
||||
{
|
||||
collision_radius = length;
|
||||
}
|
||||
_vertices[iv++] = vertex.x;
|
||||
_vertices[iv++] = vertex.y;
|
||||
_vertices[iv++] = vertex.z;
|
||||
_exhaustBaseColors[ci++] = ex_emissive[0];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[1];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[2];
|
||||
@ -290,9 +324,19 @@ static OOTexture *sPlumeTexture = nil;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
r1 = randf();
|
||||
_vertices[iv++] = f08.position.x + b08.x + s1[i] * i1.x + c1[i] * j1.x + r1 * k1.x;
|
||||
_vertices[iv++] = f08.position.y + b08.y + s1[i] * i1.y + c1[i] * j1.y + r1 * k1.y;
|
||||
_vertices[iv++] = f08.position.z + b08.z + s1[i] * i1.z + c1[i] * j1.z + r1 * k1.z;
|
||||
vertex = vector_add(HPVectorToVector(f08.position),
|
||||
vector_add(b08,
|
||||
vector_add(vector_multiply_scalar(i1,s1[i]),
|
||||
vector_add(vector_multiply_scalar(j1,c1[i]),
|
||||
vector_multiply_scalar(k1,r1)))));
|
||||
length = magnitude(vector_subtract(vertex, HPVectorToVector(currentPos)));
|
||||
if (length > collision_radius)
|
||||
{
|
||||
collision_radius = length;
|
||||
}
|
||||
_vertices[iv++] = vertex.x;
|
||||
_vertices[iv++] = vertex.y;
|
||||
_vertices[iv++] = vertex.z;
|
||||
_exhaustBaseColors[ci++] = ex_emissive[0];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[1];
|
||||
_exhaustBaseColors[ci++] = ex_emissive[2];
|
||||
@ -302,6 +346,11 @@ static OOTexture *sPlumeTexture = nil;
|
||||
ex_emissive[3] = 0.0; // fade alpha towards rear of exhaust
|
||||
ex_emissive[1] = 0.0; // diminish green part towards rear of exhaust
|
||||
ex_emissive[0] = 0.0; // diminish red part towards rear of exhaust
|
||||
length = magnitude(vector_subtract(vertex, HPVectorToVector(currentPos)));
|
||||
if (length > collision_radius)
|
||||
{
|
||||
collision_radius = length;
|
||||
}
|
||||
_vertices[iv++] = f10.position.x;
|
||||
_vertices[iv++] = f10.position.y;
|
||||
_vertices[iv++] = f10.position.z;
|
||||
|
@ -860,7 +860,17 @@ static ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
|
||||
|
||||
- (GLfloat) frustumRadius
|
||||
{
|
||||
return _profileRadius;
|
||||
OOScalar exhaust_length = 0;
|
||||
NSEnumerator *exEnum = nil;
|
||||
OOExhaustPlumeEntity *exEnt = nil;
|
||||
for (exEnum = [self exhaustEnumerator]; (exEnt = [exEnum nextObject]); )
|
||||
{
|
||||
if ([exEnt findCollisionRadius] > exhaust_length)
|
||||
{
|
||||
exhaust_length = [exEnt findCollisionRadius];
|
||||
}
|
||||
}
|
||||
return _profileRadius + exhaust_length;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user