Unify ship.roll and station.roll properties to use the same units (radians/second). station_roll in shipdata.plist will have to remain in right-angles/second for backward compatibility, odd unit that it is...

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5571 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Chris Morris 2012-12-11 20:03:35 +00:00
parent 6e407b3c17
commit 0e98304a6f
3 changed files with 15 additions and 3 deletions

View File

@ -762,6 +762,7 @@ typedef enum
- (GLfloat) fuelChargeRate;
- (void) setRoll:(double)amount;
- (void) setRawRoll:(double)amount; // does not multiply by PI/2
- (void) setPitch:(double)amount;
- (void) setThrust:(double)amount;
- (void) applySticks:(double)delta_t;

View File

@ -7066,6 +7066,12 @@ NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void* context)
}
- (void) setRawRoll:(double) amount
{
flightRoll = amount;
}
- (void) setPitch:(double) amount
{
flightPitch = amount * M_PI / 2.0;

View File

@ -216,7 +216,8 @@ static JSBool StationGetProperty(JSContext *context, JSObject *this, jsid propID
return YES;
case kStation_roll:
return JS_NewNumberValue(context, [entity flightRoll] * 2.0 / M_PI, value);
// same as in ship definition, but this time read/write below
return JS_NewNumberValue(context, [entity flightRoll], value);
case kStation_allowsFastDocking:
*value = OOJSValueFromBOOL([entity allowsFastDocking]);
@ -312,9 +313,13 @@ static JSBool StationSetProperty(JSContext *context, JSObject *this, jsid propID
case kStation_roll:
if (JS_ValueToNumber(context, *value, &fValue))
{
if (fValue < -2.0) fValue = -2.0;
/* if (fValue < -2.0) fValue = -2.0;
if (fValue > 2.0) fValue = 2.0; // clamping to -2.0...2.0 gives us ±M_PI actual maximum rotation
[entity setRoll:fValue];
[entity setRoll:fValue]; */
// use setRawRoll to make the units here equal to those in kShip_roll
if (fValue < -M_PI) fValue = -M_PI;
else if (fValue > M_PI) fValue = M_PI;
[entity setRawRoll:fValue];
return YES;
}
break;