Finish populator named locations (issue #36)
This commit is contained in:
parent
814ef88f2b
commit
4205ba932c
@ -320,7 +320,7 @@ this.systemWillPopulate = function()
|
||||
/* To ensure there's at least one hermit, for pirates to dock at */
|
||||
system.setPopulator("oolite-offlane-hermit",
|
||||
{
|
||||
priority: 11, // has to be after main asteroids
|
||||
priority: 99, // make sure all other core population is done
|
||||
location: "PLANET_ORBIT_HIGH",
|
||||
locationSeed: 71258,
|
||||
groupCount: 1,
|
||||
|
@ -75,6 +75,9 @@ HPVector OOHPVectorRandomSpatial(OOHPScalar maxLength); // Random vector uniform
|
||||
HPVector OOHPVectorRandomRadial(OOHPScalar maxLength); // Random vector with uniform distribution of direction and radius in radius-maxLength sphere. (Causes clustering at centre.)
|
||||
HPVector OORandomPositionInCylinder(HPVector centre1, OOHPScalar exclusion1, HPVector centre2, OOHPScalar exclusion2, OOHPScalar radius);
|
||||
HPVector OORandomPositionInShell(HPVector centre, OOHPScalar inner, OOHPScalar outer);
|
||||
/* returns the projection of 'point' to the plane defined by the point
|
||||
'plane' and the normal vector 'normal' */
|
||||
HPVector OOProjectHPVectorToPlane(HPVector point, HPVector plane, HPVector normal);
|
||||
#endif
|
||||
|
||||
/* Multiply vector by scalar (in place) */
|
||||
|
@ -129,4 +129,9 @@ HPVector OORandomPositionInShell(HPVector centre, OOHPScalar inner, OOHPScalar o
|
||||
return result;
|
||||
}
|
||||
|
||||
HPVector OOProjectHPVectorToPlane(HPVector point, HPVector plane, HPVector normal)
|
||||
{
|
||||
return HPvector_subtract(point,HPvector_multiply_scalar(normal,HPdot_product(HPvector_subtract(point, plane), normal)));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1434,11 +1434,29 @@ GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOC
|
||||
// make sure at least 3 radii from vertices
|
||||
while(HPdistance2(result,[sun position]) < [sun radius]*[sun radius]*9.0 || HPdistance2(result,[planet position]) < [planet radius]*[planet radius]*9.0 || HPmagnitude2(result) < SCANNER_MAX_RANGE2 * 9.0);
|
||||
}
|
||||
/* Some more, waiting for issue #22 */
|
||||
// INNER_SYSTEM
|
||||
// OUTER_SYSTEM
|
||||
// INNER_SYSTEM_OFFPLANE
|
||||
// OUTER_SYSTEM_OFFPLANE
|
||||
else if ([code isEqualToString:@"INNER_SYSTEM"])
|
||||
{
|
||||
do {
|
||||
result = OORandomPositionInShell([sun position],[sun radius]*3.0,HPdistance([sun position],[planet position]));
|
||||
result = OOProjectHPVectorToPlane(result,kZeroHPVector,HPcross_product([sun position],[planet position]));
|
||||
result = HPvector_add(result,OOHPVectorRandomSpatial([planet radius]));
|
||||
// projection to plane could bring back too close to sun
|
||||
} while (HPdistance2(result,[sun position]) < [sun radius]*[sun radius]*9.0);
|
||||
}
|
||||
else if ([code isEqualToString:@"INNER_SYSTEM_OFFPLANE"])
|
||||
{
|
||||
result = OORandomPositionInShell([sun position],[sun radius]*3.0,HPdistance([sun position],[planet position]));
|
||||
}
|
||||
else if ([code isEqualToString:@"OUTER_SYSTEM"])
|
||||
{
|
||||
result = OORandomPositionInShell([sun position],HPdistance([sun position],[planet position]),10000000); // no more than 10^7 metres from sun
|
||||
result = OOProjectHPVectorToPlane(result,kZeroHPVector,HPcross_product([sun position],[planet position]));
|
||||
result = HPvector_add(result,OOHPVectorRandomSpatial(0.01*HPdistance(result,[sun position]))); // within 1% of plane
|
||||
}
|
||||
else if ([code isEqualToString:@"OUTER_SYSTEM_OFFPLANE"])
|
||||
{
|
||||
result = OORandomPositionInShell([sun position],HPdistance([sun position],[planet position]),10000000); // no more than 10^7 metres from sun
|
||||
}
|
||||
else
|
||||
{
|
||||
OOLog(kOOLogUniversePopulateError,@"Named populator region %@ is not implemented, falling back to WITCHPOINT",code);
|
||||
|
Loading…
x
Reference in New Issue
Block a user