Better stretch (#584)

<!-- A new module or something else important -->
## Major features
-

<!-- A new parameter added to a module, or API feature -->
## Minor features
-

<!-- Some improvement that requires no action on the part of add-on
creators i.e., improved star graphics -->
## Improvements
- bump up detector shape limit 4x

<!-- Be sure to reference the existing issue if it exists -->
## Bug fixes
- stretch now behaves more intuitively (does not divide min/max height
by the largest stretch axis)

- [x] make ball pit mod work
This commit is contained in:
Will Corby 2023-05-01 20:44:04 -07:00 committed by GitHub
commit 4901d23db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 20 deletions

View File

@ -9,22 +9,6 @@ namespace NewHorizons.Builder.Body.Geometry
Mesh mesh = new Mesh();
mesh.name = "CubeSphere";
float max = 1;
if (stretch.x > stretch.y && stretch.x > stretch.z)
max = stretch.x;
else if (stretch.y > stretch.x && stretch.y > stretch.z)
max = stretch.y;
else if (stretch.z > stretch.x && stretch.z > stretch.y)
max = stretch.z;
else if (stretch.y == stretch.z && stretch.x > stretch.y)
max = stretch.x;
else if (stretch.x == stretch.z && stretch.y > stretch.x)
max = stretch.y;
else if (stretch.x == stretch.y && stretch.z > stretch.x)
max = stretch.z;
minHeight /= max;
maxHeight /= max;
CreateVertices(mesh, resolution, heightMap, minHeight, maxHeight);
StretchVertices(mesh, stretch);
CreateTriangles(mesh, resolution);

View File

@ -46,7 +46,8 @@ public class AddPhysics : MonoBehaviour
bodyGo.AddComponent<SphereCollider>().radius = Radius;
var shape = bodyGo.AddComponent<SphereShape>();
shape._collisionMode = Shape.CollisionMode.Detector;
shape.radius = Radius;
shape._layerMask = (int)(Shape.Layer.Default | Shape.Layer.Gravity);
shape._radius = Radius;
bodyGo.AddComponent<DynamicForceDetector>();
var fluidDetector = bodyGo.AddComponent<DynamicFluidDetector>();
fluidDetector._buoyancy = Locator.GetProbe().GetOWRigidbody()._attachedFluidDetector._buoyancy;

View File

@ -189,6 +189,8 @@ namespace NewHorizons
{
// Patches
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
// the campfire on the title screen calls this from RegisterShape before it gets patched, so we have to call it again. lol
ShapeManager.Initialize();
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded;

View File

@ -12,13 +12,13 @@ namespace NewHorizons.Patches
{
ShapeManager._exists = true;
ShapeManager._detectors = new ShapeManager.Layer(256);
for (int index = 0; index < 256; ++index)
ShapeManager._detectors = new ShapeManager.Layer(256 * 4);
for (int index = 0; index < 256 * 4; ++index)
ShapeManager._detectors[index].contacts = new List<ShapeManager.ContactData>(64);
ShapeManager._volumes = new ShapeManager.Layer[4];
for (int index = 0; index < 4; ++index)
ShapeManager._volumes[index] = new ShapeManager.Layer(2048);
ShapeManager._volumes[index] = new ShapeManager.Layer(1024 * 2);
ShapeManager._locked = false;
ShapeManager._frameFlag = false;