mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
delete duplicate box shape fixer
This commit is contained in:
parent
d5ad5bf84b
commit
ed4e43a044
@ -295,39 +295,4 @@ namespace NewHorizons.Builder.Props
|
|||||||
return globalCorners.Select(globalCorner => relativeTo.transform.InverseTransformPoint(globalCorner)).ToArray();
|
return globalCorners.Select(globalCorner => relativeTo.transform.InverseTransformPoint(globalCorner)).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// for some reason mesh bounds are wrong unless we wait a bit
|
|
||||||
/// so this script contiously checks everything until it is correct
|
|
||||||
///
|
|
||||||
/// this actually only seems to be a problem with skinned renderers. normal ones work fine
|
|
||||||
/// TODO: at some point narrow this down to just skinned, instead of doing everything and checking every frame
|
|
||||||
/// </summary>
|
|
||||||
public class BoxShapeFixer : MonoBehaviour
|
|
||||||
{
|
|
||||||
public BoxShape shape;
|
|
||||||
public MeshFilter meshFilter;
|
|
||||||
public SkinnedMeshRenderer skinnedMeshRenderer;
|
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
if (meshFilter == null && skinnedMeshRenderer == null)
|
|
||||||
{
|
|
||||||
NHLogger.LogVerbose("Useless BoxShapeFixer, destroying");
|
|
||||||
DestroyImmediate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Mesh sharedMesh = null;
|
|
||||||
if (meshFilter != null) sharedMesh = meshFilter.sharedMesh;
|
|
||||||
if (skinnedMeshRenderer != null) sharedMesh = skinnedMeshRenderer.sharedMesh;
|
|
||||||
|
|
||||||
if (sharedMesh == null) return;
|
|
||||||
if (sharedMesh.bounds.size == Vector3.zero) return;
|
|
||||||
|
|
||||||
shape.size = sharedMesh.bounds.size;
|
|
||||||
shape.center = sharedMesh.bounds.center;
|
|
||||||
|
|
||||||
DestroyImmediate(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,14 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace NewHorizons.Utility.Geometry;
|
namespace NewHorizons.Utility.Geometry;
|
||||||
|
|
||||||
internal class BoxShapeFixer : MonoBehaviour
|
/// <summary>
|
||||||
|
/// for some reason mesh bounds are wrong unless we wait a bit
|
||||||
|
/// so this script contiously checks everything until it is correct
|
||||||
|
///
|
||||||
|
/// this actually only seems to be a problem with skinned renderers. normal ones work fine
|
||||||
|
/// TODO: at some point narrow this down to just skinned, instead of doing everything and checking every frame
|
||||||
|
/// </summary>
|
||||||
|
public class BoxShapeFixer : MonoBehaviour
|
||||||
{
|
{
|
||||||
public BoxShape shape;
|
public BoxShape shape;
|
||||||
public MeshFilter meshFilter;
|
public MeshFilter meshFilter;
|
||||||
@ -13,31 +20,20 @@ internal class BoxShapeFixer : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (meshFilter == null && skinnedMeshRenderer == null)
|
if (meshFilter == null && skinnedMeshRenderer == null)
|
||||||
{
|
{
|
||||||
NHLogger.LogVerbose("Useless BoxShapeFixer, destroying"); DestroyImmediate(this);
|
NHLogger.LogVerbose("Useless BoxShapeFixer, destroying");
|
||||||
|
DestroyImmediate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh sharedMesh = null;
|
Mesh sharedMesh = null;
|
||||||
if (meshFilter != null)
|
if (meshFilter != null) sharedMesh = meshFilter.sharedMesh;
|
||||||
{
|
if (skinnedMeshRenderer != null) sharedMesh = skinnedMeshRenderer.sharedMesh;
|
||||||
sharedMesh = meshFilter.sharedMesh;
|
|
||||||
}
|
|
||||||
if (skinnedMeshRenderer != null)
|
|
||||||
{
|
|
||||||
sharedMesh = skinnedMeshRenderer.sharedMesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sharedMesh == null)
|
if (sharedMesh == null) return;
|
||||||
{
|
if (sharedMesh.bounds.size == Vector3.zero) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sharedMesh.bounds.size == Vector3.zero)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
shape.size = sharedMesh.bounds.size;
|
shape.size = sharedMesh.bounds.size;
|
||||||
shape.center = sharedMesh.bounds.center;
|
shape.center = sharedMesh.bounds.center;
|
||||||
|
|
||||||
DestroyImmediate(this);
|
DestroyImmediate(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user