Compare commits

...

2 Commits

5 changed files with 24 additions and 35 deletions

View File

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

View File

@ -89,10 +89,8 @@ namespace ConformalDecals {
[KSPField] public Transform decalProjectorTransform;
[KSPField] public Transform decalColliderTransform;
[KSPField] public MeshRenderer boundsRenderer;
[KSPField] public MeshRenderer frontRenderer;
[KSPField] public Material backMaterial;
[KSPField] public Vector2 backTextureBaseScale;
[KSPField] public Material backMaterial;
[KSPField] public Vector2 backTextureBaseScale;
private const int DecalQueueMin = 2100;
private const int DecalQueueMax = 2400;
@ -103,8 +101,9 @@ namespace ConformalDecals {
private bool _isAttached;
private Matrix4x4 _orthoMatrix;
private Material _decalMaterial;
private Material _previewMaterial;
private Material _decalMaterial;
private Material _previewMaterial;
private MeshRenderer _boundsRenderer;
private int DecalQueue {
get {
@ -133,33 +132,24 @@ namespace ConformalDecals {
public override void OnLoad(ConfigNode node) {
try {
// 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);
if (decalFrontTransform == null) throw new FormatException($"Could not find decalFront transform: '{decalFront}'.");
frontRenderer = decalFrontTransform.GetComponent<MeshRenderer>();
decalBackTransform = part.FindModelTransform(decalBack);
if (decalBackTransform == null) throw new FormatException($"Could not find decalBack transform: '{decalBack}'.");
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}'.");
// 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
// SETUP BACK MATERIAL
if (updateBackScale) {
decalBackTransform = part.FindModelTransform(decalBack);
if (decalBackTransform == null) throw new FormatException($"Could not find decalBack transform: '{decalBack}'.");
var backRenderer = decalBackTransform.GetComponent<MeshRenderer>();
if (backRenderer == null) {
this.LogError($"Specified decalBack transform {decalBack} has no renderer attached! Setting updateBackScale to false.");
updateBackScale = false;
@ -254,8 +244,7 @@ namespace ConformalDecals {
public override void OnStart(StartState state) {
materialProperties.RenderQueue = DecalQueue;
boundsRenderer = decalProjectorTransform.GetComponent<MeshRenderer>();
frontRenderer = decalFrontTransform.GetComponent<MeshRenderer>();
_boundsRenderer = decalProjectorTransform.GetComponent<MeshRenderer>();
// handle tweakables
if (HighLogic.LoadedSceneIsEditor) {
@ -289,7 +278,7 @@ namespace ConformalDecals {
if (!selectableInFlight || !DecalConfig.SelectableInFlight) {
decalColliderTransform.GetComponent<Collider>().enabled = false;
boundsRenderer.enabled = false;
_boundsRenderer.enabled = false;
}
}
}
@ -451,7 +440,7 @@ namespace ConformalDecals {
// update projection
foreach (var target in _targets) {
target.Project(_orthoMatrix, decalProjectorTransform, boundsRenderer.bounds, useBaseNormal);
target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal);
}
}
else {
@ -476,7 +465,7 @@ namespace ConformalDecals {
_decalMaterial = materialProperties.DecalMaterial;
_previewMaterial = materialProperties.PreviewMaterial;
if (!_isAttached) frontRenderer.material = _previewMaterial;
if (!_isAttached) decalFrontTransform.GetComponent<MeshRenderer>().material = _previewMaterial;
}
protected void UpdateTargets() {

View File

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

View File

@ -1,10 +1,11 @@
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:
- Fixed certain non-ascii strings not rendering correctly under certain circumstances.
- Yet another attempted fix for the planet text glitch.
- Changes:
- Small optimizations and simplified text rendering.
v0.2.6
------