Skip to content

Commit

Permalink
Merge pull request #139 from ZiwKerman/develop
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
ZiwKerman authored Dec 15, 2016
2 parents 3f12964 + 230b3d6 commit 0c1e7f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 16 additions & 11 deletions InfernalRobotics/InfernalRobotics/Module/ModuleIRServo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ModuleIRServo : PartModule, IRescalable, IJointLockState

//BEGIN Mechanism related KSPFields
[KSPField(isPersistant = true)] public bool freeMoving = false;
[KSPField(isPersistant = true)] public bool isMotionLock;
[KSPField(isPersistant = true)] public bool isMotionLock = false;
[KSPField(isPersistant = true)] public bool limitTweakable = false;
[KSPField(isPersistant = true)] public bool limitTweakableFlag = false;

Expand Down Expand Up @@ -487,6 +487,8 @@ public void OnVesselGoOffRails (Vessel v)

Logger.Log ("[OnVesselGoOffRails] Started for "+ part.name, Logger.Level.Debug);

Logger.Log ("[OnVesselGoOffRails] Rebuilding Attachments", Logger.Level.Debug);
BuildAttachments ();

if (joint)
{
Expand Down Expand Up @@ -561,17 +563,14 @@ public override void OnLoad(ConfigNode config)
{
Logger.Log("[OnLoad] Start", Logger.Level.Debug);

base.OnLoad (config);
//base.OnLoad (config);

//save persistent rotation/translation data, because the joint will be initialized at current position.
rotationDelta = rotation;
translationDelta = translation;

InitModule();

Logger.Log ("[OnLoad] Rebuilding Attachments", Logger.Level.Debug);
BuildAttachments ();

Logger.Log("[OnLoad] End", Logger.Level.Debug);
}
/// <summary>
Expand Down Expand Up @@ -637,6 +636,12 @@ protected virtual void AttachToParent()
{
Transform fix = FixedMeshTransform;
//first revert position to part position
if (fix == null || part == null || part.transform == null || part.parent == null)
{
Logger.Log ("[AttachToParent] part, parent or transform is null", Logger.Level.Debug);
return;
}

fix.position = part.transform.position;
fix.rotation = part.transform.rotation;

Expand Down Expand Up @@ -704,10 +709,10 @@ protected virtual void BuildAttachments()
AttachToParent ();
}

var node = part.FindAttachNodeByPart (part.parent);
//var node = part.FindAttachNodeByPart (part.parent);

if(translateJoint && (node == null || !(node.id.Contains(bottomNode) || part.attachMode == AttachModes.SRF_ATTACH)))
translateAxis *= -1;
//if(translateJoint && (node == null || !(node.id.Contains(bottomNode) || part.attachMode == AttachModes.SRF_ATTACH)))
// translateAxis *= -1;

ReparentFriction(part.transform);
failedAttachment = false;
Expand Down Expand Up @@ -767,7 +772,7 @@ public override void OnStart(StartState state)
if (ModelTransform == null)
Logger.Log("[MMT] OnStart ModelTransform is null", Logger.Level.Warning);

BuildAttachments();
BuildAttachments();

if (limitTweakable)
{
Expand Down Expand Up @@ -1061,7 +1066,7 @@ public static float AngleSigned(Vector3 v1, Vector3 v2, Vector3 n)
/// </summary>
/// <returns>The real rotation.</returns>
public float GetRealRotation()
{
{
Vector3 v1, v2, n;
if(rotateAxis == Vector3.forward || rotateAxis == Vector3.back)
{
Expand Down Expand Up @@ -1149,7 +1154,7 @@ protected virtual void UpdatePosition()
Interpolator.Update(TimeWarp.fixedDeltaTime);

float targetPos = Interpolator.GetPosition();
float currentPos = rotateJoint ? GetRealRotation() : GetRealTranslation();
float currentPos = rotateJoint ? rotation : translation;//rotateJoint ? GetRealRotation() : GetRealTranslation();

if (lastRealPosition == 0f)
lastRealPosition = currentPos;
Expand Down
4 changes: 2 additions & 2 deletions InfernalRobotics/InfernalRobotics/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("2.0.4.0")]
[assembly: AssemblyFileVersion("2.0.4.0")]
[assembly: AssemblyVersion("2.0.9.0")]
[assembly: AssemblyFileVersion("2.0.9.0")]

0 comments on commit 0c1e7f1

Please sign in to comment.