Update to 1.1.0

• Add support for multiple objects sharing the same name
• Add support for multiple Depth Mask modules on the same part
• Minor code cleanups
master v1.1.0
Andrew Cassidy 5 years ago
parent c45aef3d9a
commit 98777f5448
No known key found for this signature in database
GPG Key ID: 963017B38FD477A1

@ -25,8 +25,8 @@ namespace Restock
public int maskRenderQueue = 1999;
// depth mask object transform
public Transform maskTransformObject;
// depth mask object transforms
public Transform[] maskTransformObjects;
// body object transform
public Transform bodyTransformObject;
@ -38,7 +38,7 @@ namespace Restock
public override void OnStart(StartState state)
{
base.OnStart(state);
UpdatematerialQueue();
UpdateAllMaterials();
// the part variant system is implemented extremely stupidly
// so we have to make this whole module more complicated as a result
@ -58,14 +58,14 @@ namespace Restock
if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) return;
this.maskTransformObject = base.part.FindModelTransform(maskTransform);
if (this.maskTransformObject == null)
this.maskTransformObjects = base.part.FindModelTransforms(maskTransform);
if (this.maskTransformObjects.Length == 0 || this.maskTransformObjects == null)
{
this.LogError($"Can't find transform {maskTransform}");
return;
}
if (bodyTransform == "")
if (bodyTransform.Length == 0)
{
this.bodyTransformObject = base.part.partTransform;
}
@ -91,34 +91,27 @@ namespace Restock
public void OnVariantApplied(Part appliedPart, PartVariant variant)
{
// I dont know why changing part variants resets all the materials to their as-loaded state, but it does
if (appliedPart == this.part) UpdatematerialQueue();
if (appliedPart == this.part) UpdateAllMaterials();
}
private void UpdatematerialQueue()
private void UpdateAllMaterials()
{
var windowRenderer = maskTransformObject.GetComponent<MeshRenderer>();
var renderers = bodyTransformObject.GetComponentsInChildren<Renderer>(true);
windowRenderer.material.shader = depthShader;
windowRenderer.material.renderQueue = maskRenderQueue;
var meshRenderers = bodyTransformObject.GetComponentsInChildren<MeshRenderer>(true);
var skinnedMeshRenderers = bodyTransformObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
foreach (var renderer in meshRenderers)
foreach (var renderer in renderers)
{
if (renderer == windowRenderer) continue;
var queue = renderer.material.renderQueue;
if (queue <= maskRenderQueue) continue;
queue = meshRenderQueue + ((queue - 2000) / 2);
renderer.material.renderQueue = queue;
}
foreach (var renderer in skinnedMeshRenderers)
foreach (var maskObject in maskTransformObjects)
{
if (renderer == windowRenderer) continue;
var queue = renderer.material.renderQueue;
queue = meshRenderQueue + ((queue - 2000) / 2);
renderer.material.renderQueue = queue;
var renderer = maskObject.GetComponent<Renderer>();
renderer.material.shader = depthShader;
renderer.material.renderQueue = maskRenderQueue;
}
}

@ -1,13 +1,13 @@
# ModuleDepthMask
# ModuleDepthMask v1.1.0
This plugin allows for parts to have hollow insets that dont clip into other parts, ideal for engine nozzles, landing gear, air intakes, solar panel bays, and more. It is a standalone version of the depth mask module included in the [Restock](github.com/PorktoberRevolution/ReStocked) dll, which will be included in the next major Restock update along with the additon of depth masks to several stock parts
### Usage
1. Add a depth mask mesh to your part model. It should cover up the hollow area you want to prevent clipping in, without sticking out.
2. Mark the depth mask object with the `Icon_Hidden` tag to prevent it from showing in the VAB part picker
3. Add a new `ModuleDepthMask` to your part config
4. Add the name of your mask object in the `maskTransform` property
5. (Optional) Add the name of the object you want to restrict the mask effect to in the `bodyTransform` property
1. Add a depth mask mesh to your part model. It should cover up the hollow area you want to prevent clipping in, without sticking out. You can have multiple mask objects sharing the same name and they will all be used.
2. Mark the depth mask object with the `Icon_Hidden` tag to prevent it from showing in the VAB part picker.
3. Add a new `ModuleDepthMask` to your part config.
4. Add the name of your mask object in the `maskTransform` property.
5. (Optional) Add the name of the object you want to restrict the mask effect to in the `bodyTransform` property.
##### Creating the depth mask model
The depth mask will prevent any other parts from rendering behind it. Because of that, it should not be used on any kind of bay where other parts will be placed, or on any part you can look completely through. It also should "bubble" out above the hole you want to cover, otherwise it would be possible to see through it from the side. Also double check your normal direction, since the depth shader only works one way.

Loading…
Cancel
Save