Compare commits

...

2 Commits

5 changed files with 24 additions and 35 deletions

View File

@ -12,8 +12,8 @@
"KSP_VERSION": "KSP_VERSION":
{ {
"MAJOR":1, "MAJOR":1,
"MINOR":10, "MINOR":11,
"PATCH":1 "PATCH":0
}, },
"KSP_VERSION_MIN":{ "KSP_VERSION_MIN":{
"MAJOR":1, "MAJOR":1,
@ -22,7 +22,7 @@
}, },
"KSP_VERSION_MAX":{ "KSP_VERSION_MAX":{
"MAJOR":1, "MAJOR":1,
"MINOR":10, "MINOR":11,
"PATCH":99 "PATCH":99
} }
} }

View File

@ -89,8 +89,6 @@ namespace ConformalDecals {
[KSPField] public Transform decalProjectorTransform; [KSPField] public Transform decalProjectorTransform;
[KSPField] public Transform decalColliderTransform; [KSPField] public Transform decalColliderTransform;
[KSPField] public MeshRenderer boundsRenderer;
[KSPField] public MeshRenderer frontRenderer;
[KSPField] public Material backMaterial; [KSPField] public Material backMaterial;
[KSPField] public Vector2 backTextureBaseScale; [KSPField] public Vector2 backTextureBaseScale;
@ -105,6 +103,7 @@ namespace ConformalDecals {
private Material _decalMaterial; private Material _decalMaterial;
private Material _previewMaterial; private Material _previewMaterial;
private MeshRenderer _boundsRenderer;
private int DecalQueue { private int DecalQueue {
get { get {
@ -133,33 +132,24 @@ namespace ConformalDecals {
public override void OnLoad(ConfigNode node) { public override void OnLoad(ConfigNode node) {
try { try {
// SETUP TRANSFORMS // SETUP TRANSFORMS
// Projector transform, where the decal is projected from when attached
decalProjectorTransform = part.FindModelTransform(decalProjector);
if (decalProjectorTransform == null) throw new FormatException($"Could not find decalProjector transform: '{decalProjector}'.");
// Model transform, containing all visible elements of the decal when not attached
decalModelTransform = part.FindModelTransform(decalModel);
if (decalModelTransform == null) throw new FormatException($"Could not find decalModel transform: '{decalModel}'.");
// Front transform, shows a preview of the decal when unattached
decalFrontTransform = part.FindModelTransform(decalFront); decalFrontTransform = part.FindModelTransform(decalFront);
if (decalFrontTransform == null) throw new FormatException($"Could not find decalFront transform: '{decalFront}'."); if (decalFrontTransform == null) throw new FormatException($"Could not find decalFront transform: '{decalFront}'.");
frontRenderer = decalFrontTransform.GetComponent<MeshRenderer>();
// Collider transform, selectable area and shows where the decal is projecting onto
decalColliderTransform = part.FindModelTransform(decalCollider);
if (decalColliderTransform == null) throw new FormatException($"Could not find decalCollider transform: '{decalCollider}'.");
boundsRenderer = decalColliderTransform.GetComponent<MeshRenderer>();
// SETUP BACK
if (updateBackScale) {
decalBackTransform = part.FindModelTransform(decalBack); decalBackTransform = part.FindModelTransform(decalBack);
if (decalBackTransform == null) throw new FormatException($"Could not find decalBack transform: '{decalBack}'."); if (decalBackTransform == null) throw new FormatException($"Could not find decalBack transform: '{decalBack}'.");
var backRenderer = decalBackTransform.GetComponent<MeshRenderer>(); decalModelTransform = part.FindModelTransform(decalModel);
if (decalModelTransform == null) throw new FormatException($"Could not find decalModel transform: '{decalModel}'.");
decalProjectorTransform = part.FindModelTransform(decalProjector);
if (decalProjectorTransform == null) throw new FormatException($"Could not find decalProjector transform: '{decalProjector}'.");
decalColliderTransform = part.FindModelTransform(decalCollider);
if (decalColliderTransform == null) throw new FormatException($"Could not find decalCollider transform: '{decalCollider}'.");
// SETUP BACK MATERIAL
if (updateBackScale) {
var backRenderer = decalBackTransform.GetComponent<MeshRenderer>();
if (backRenderer == null) { if (backRenderer == null) {
this.LogError($"Specified decalBack transform {decalBack} has no renderer attached! Setting updateBackScale to false."); this.LogError($"Specified decalBack transform {decalBack} has no renderer attached! Setting updateBackScale to false.");
updateBackScale = false; updateBackScale = false;
@ -254,8 +244,7 @@ namespace ConformalDecals {
public override void OnStart(StartState state) { public override void OnStart(StartState state) {
materialProperties.RenderQueue = DecalQueue; materialProperties.RenderQueue = DecalQueue;
boundsRenderer = decalProjectorTransform.GetComponent<MeshRenderer>(); _boundsRenderer = decalProjectorTransform.GetComponent<MeshRenderer>();
frontRenderer = decalFrontTransform.GetComponent<MeshRenderer>();
// handle tweakables // handle tweakables
if (HighLogic.LoadedSceneIsEditor) { if (HighLogic.LoadedSceneIsEditor) {
@ -289,7 +278,7 @@ namespace ConformalDecals {
if (!selectableInFlight || !DecalConfig.SelectableInFlight) { if (!selectableInFlight || !DecalConfig.SelectableInFlight) {
decalColliderTransform.GetComponent<Collider>().enabled = false; decalColliderTransform.GetComponent<Collider>().enabled = false;
boundsRenderer.enabled = false; _boundsRenderer.enabled = false;
} }
} }
} }
@ -451,7 +440,7 @@ namespace ConformalDecals {
// update projection // update projection
foreach (var target in _targets) { foreach (var target in _targets) {
target.Project(_orthoMatrix, decalProjectorTransform, boundsRenderer.bounds, useBaseNormal); target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal);
} }
} }
else { else {
@ -476,7 +465,7 @@ namespace ConformalDecals {
_decalMaterial = materialProperties.DecalMaterial; _decalMaterial = materialProperties.DecalMaterial;
_previewMaterial = materialProperties.PreviewMaterial; _previewMaterial = materialProperties.PreviewMaterial;
if (!_isAttached) frontRenderer.material = _previewMaterial; if (!_isAttached) decalFrontTransform.GetComponent<MeshRenderer>().material = _previewMaterial;
} }
protected void UpdateTargets() { protected void UpdateTargets() {

View File

@ -31,7 +31,6 @@ namespace ConformalDecals.Text {
/// Update text immediately without using job queue /// Update text immediately without using job queue
public static TextRenderOutput UpdateText(DecalText oldText, DecalText newText) { public static TextRenderOutput UpdateText(DecalText oldText, DecalText newText) {
if (newText == null) throw new ArgumentNullException(nameof(newText)); if (newText == null) throw new ArgumentNullException(nameof(newText));
Logging.Log($"Rendering text {newText}");
if (!(oldText is null)) UnregisterText(oldText); if (!(oldText is null)) UnregisterText(oldText);

View File

@ -1,10 +1,11 @@
v0.2.7 v0.2.7
------ ------
- Supported KSP versions: 1.8.x to 1.11.x
- Notes:
- Attaching decal parts in flight using engineer kerbals is not supported.
- Fixes: - Fixes:
- Fixed certain non-ascii strings not rendering correctly under certain circumstances. - Fixed certain non-ascii strings not rendering correctly under certain circumstances.
- Yet another attempted fix for the planet text glitch. - Yet another attempted fix for the planet text glitch.
- Changes:
- Small optimizations and simplified text rendering.
v0.2.6 v0.2.6
------ ------