Compare commits

..

No commits in common. "3173dd914aa82b4add8b0476cf1fd4498d57f9af" and "6b7996fdd71d25c84f905dd17120b6524335e6aa" have entirely different histories.

5 changed files with 36 additions and 25 deletions

View File

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

View File

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

View File

@ -31,6 +31,7 @@ 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,11 +1,10 @@
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
------