Skip to content

Commit

Permalink
Fix #121
Browse files Browse the repository at this point in the history
Set render queue 4000 for pointer and target attach node icons.
  • Loading branch information
ihsoft committed Apr 27, 2016
1 parent 2af940e commit 4187eaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 3 additions & 10 deletions Plugins/Source/KISAddonPointer.cs
Expand Up @@ -581,22 +581,15 @@ public enum PointerState {
if (!pointer) {
throw new InvalidOperationException("Pointer doesn't exist");
}
var renderQueue = -1;
if (hoveredPart && hoveredPart.HighlightRendererCount > 0) {
// If highlight renderers are activated align pointer's renderer queue with them.
// Otherwise, the highlighted part mesh will be drawn over the pointer.
renderQueue = hoveredPart.HighlightRenderers[0].material.renderQueue;
}
foreach (var mr in pointer.GetComponentsInChildren<MeshRenderer>()) {
if (mr.enabled == isVisible
&& (renderQueue == -1 || mr.material.renderQueue == renderQueue)) {
&& mr.material.renderQueue == KIS_Shared.HighlighedPartRenderQueue) {
return; // Abort if current state is already up to date.
}
mr.enabled = isVisible;
mr.material.renderQueue = renderQueue;
mr.material.renderQueue = KIS_Shared.HighlighedPartRenderQueue;
}
Logger.logInfo("Pointer state set to: visibility={0}, renderer queue={1}",
isVisible, renderQueue);
Logger.logInfo("Pointer state set to: visibility={0}", isVisible);
}

/// <summary>Makes a game object to represent currently dragging assembly.</summary>
Expand Down
8 changes: 7 additions & 1 deletion Plugins/Source/KIS_Shared.cs
Expand Up @@ -66,7 +66,12 @@ public class KIS_UISoundPlayer : MonoBehaviour {
static public class KIS_Shared {
// TODO: Read it from the config.
private const float DefaultMessageTimeout = 5f; // Seconds.


/// <summary>Mesh render queue of the highlight part layer.</summary>
/// <remarks>When other renderers need to be drawn on the part they should have queue set to this
/// or higher value. Otherwise, the part's highliting will overwrite the output.</remarks>
public const int HighlighedPartRenderQueue = 4000; // As of KSP 1.1.1230

public static string bipWrongSndPath = "KIS/Sounds/bipwrong";
public delegate void OnPartCoupled(Part createdPart, Part tgtPart = null,
AttachNode tgtAttachNode = null);
Expand Down Expand Up @@ -571,6 +576,7 @@ public enum MessageAction {
iconRenderer.material = new Material(Shader.Find("Transparent/Diffuse"));
iconColor.a = 0.5f;
iconRenderer.material.color = iconColor;
iconRenderer.material.renderQueue = HighlighedPartRenderQueue;
}
node.icon.transform.parent = part.transform;
if (name != null)
Expand Down

0 comments on commit 4187eaa

Please sign in to comment.