mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Revert changes to ModuleConformalDecal.cs
This commit is contained in:
parent
6b7996fdd7
commit
5f6712f476
Binary file not shown.
@ -89,10 +89,8 @@ namespace ConformalDecals {
|
|||||||
[KSPField] public Transform decalProjectorTransform;
|
[KSPField] public Transform decalProjectorTransform;
|
||||||
[KSPField] public Transform decalColliderTransform;
|
[KSPField] public Transform decalColliderTransform;
|
||||||
|
|
||||||
[KSPField] public MeshRenderer boundsRenderer;
|
[KSPField] public Material backMaterial;
|
||||||
[KSPField] public MeshRenderer frontRenderer;
|
[KSPField] public Vector2 backTextureBaseScale;
|
||||||
[KSPField] public Material backMaterial;
|
|
||||||
[KSPField] public Vector2 backTextureBaseScale;
|
|
||||||
|
|
||||||
private const int DecalQueueMin = 2100;
|
private const int DecalQueueMin = 2100;
|
||||||
private const int DecalQueueMax = 2400;
|
private const int DecalQueueMax = 2400;
|
||||||
@ -103,8 +101,9 @@ namespace ConformalDecals {
|
|||||||
private bool _isAttached;
|
private bool _isAttached;
|
||||||
private Matrix4x4 _orthoMatrix;
|
private Matrix4x4 _orthoMatrix;
|
||||||
|
|
||||||
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>();
|
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);
|
decalColliderTransform = part.FindModelTransform(decalCollider);
|
||||||
if (decalColliderTransform == null) throw new FormatException($"Could not find decalCollider transform: '{decalCollider}'.");
|
if (decalColliderTransform == null) throw new FormatException($"Could not find decalCollider transform: '{decalCollider}'.");
|
||||||
|
|
||||||
boundsRenderer = decalColliderTransform.GetComponent<MeshRenderer>();
|
// SETUP BACK MATERIAL
|
||||||
|
|
||||||
// SETUP BACK
|
|
||||||
if (updateBackScale) {
|
if (updateBackScale) {
|
||||||
decalBackTransform = part.FindModelTransform(decalBack);
|
|
||||||
if (decalBackTransform == null) throw new FormatException($"Could not find decalBack transform: '{decalBack}'.");
|
|
||||||
|
|
||||||
var backRenderer = decalBackTransform.GetComponent<MeshRenderer>();
|
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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user