Skip to content

Commit

Permalink
Fix orientation of containers when attached to the container holders.
Browse files Browse the repository at this point in the history
The previous changes to fix rotations broke this case it seems, so
some fixes to the node directions are necessary. Note that the new
orientations are more consistent with stock parts.
  • Loading branch information
angavrilov committed Feb 8, 2014
1 parent 3cf9fc8 commit 56abd17
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Parts/container1/container1.cfg
Expand Up @@ -15,7 +15,7 @@ scale = 1
rescaleFactor = 0.50

// --- node definitions ---
node_stack_bottom = 0.0, -0.3968, 0.0, 0.0, -1.0, 0.0, 0
node_stack_bottom = 0.0, -0.3968, 0.0, 0.0, 1.0, 0.0, 0

// --- editor parameters ---
cost = 680
Expand Down
2 changes: 1 addition & 1 deletion Parts/container2/container2.cfg
Expand Up @@ -15,7 +15,7 @@ scale = 1
rescaleFactor = 0.50

// --- node definitions ---
node_stack_bottom = 0.0, -0.7596, 0.0, 0.0, -1.0, 0.0, 0
node_stack_bottom = 0.0, -0.7596, 0.0, 0.0, 1.0, 0.0, 0

// --- editor parameters ---
cost = 680
Expand Down
2 changes: 1 addition & 1 deletion Parts/containerBay1/containerBay1.cfg
Expand Up @@ -16,7 +16,7 @@ rescaleFactor = 0.50

// --- node definitions ---
node_stack_top = 0.0, -0.7125, 0.0, 0.0, 1.0, 0.0, 0
node_stack_bottom = 0.0, -0.8050, 0.0, 0.0, -1.0, 0.0, 0
node_stack_bottom = 0.0, -0.8050, 0.0, 0.0, 1.0, 0.0, 0
node_attach = 0.0, -0.8050, 0.0, 0.0, -1.0, 0.0

cost = 200
Expand Down
2 changes: 1 addition & 1 deletion Parts/hookSupport/hookSupport.cfg
Expand Up @@ -13,7 +13,7 @@ mesh = hookSupport.mu
//}

node_stack_top = 0.0, 0.0264, 0, 0.0, 1.0, 0.0, 0
node_stack_bottom = 0.0, -0.1493, 0, 0.0, -1.0, 0.0, 0
node_stack_bottom = 0.0, -0.1493, 0, 0.0, 1.0, 0.0, 0

cost = 200
category = Utility
Expand Down
2 changes: 1 addition & 1 deletion Parts/pipe1/pipe1.cfg
Expand Up @@ -13,7 +13,7 @@ mesh = pipe1.mu
//}


node_stack_bottom = 0.0, -0.0578, 0.0, 0.0, -1.0, 0.0, 0
node_stack_bottom = 0.0, -0.0578, 0.0, 0.0, 1.0, 0.0, 0
node_attach = 0.0, -0.0578, 0.0, 0.0, -1.0, 0.0

cost = 200
Expand Down
11 changes: 9 additions & 2 deletions Plugin/KAS_Shared.cs
Expand Up @@ -126,18 +126,25 @@ public static void MovePartWith(Part rootPart, List<Part> moveWithParts, Vector3

public static void AddNodeTransform(Part p, AttachNode attachNode)
{
Quaternion rotation = Quaternion.LookRotation(attachNode.orientation, Vector3.up);

if (attachNode.nodeType == AttachNode.NodeType.Surface)
{
rotation = Quaternion.Inverse(rotation);
}

if (attachNode.nodeTransform == null)
{
Transform nodeTransform = new GameObject("KASNodeTransf").transform;
nodeTransform.parent = p.transform;
nodeTransform.localPosition = attachNode.position;
nodeTransform.localRotation = Quaternion.Inverse(Quaternion.LookRotation(attachNode.orientation, Vector3.up));
nodeTransform.localRotation = rotation;
attachNode.nodeTransform = nodeTransform;
}
else
{
attachNode.nodeTransform.localPosition = attachNode.position;
attachNode.nodeTransform.localRotation = Quaternion.Inverse(Quaternion.LookRotation(attachNode.orientation, Vector3.up));
attachNode.nodeTransform.localRotation = rotation;
KAS_Shared.DebugLog("AddTransformToAttachNode - Node : " + attachNode.id + " already have a nodeTransform, only update");
}
}
Expand Down

0 comments on commit 56abd17

Please sign in to comment.