Skip to content

Commit

Permalink
Fix off-center spheres in the soft body demo to be created asymmetric…
Browse files Browse the repository at this point in the history
…al (#31)
  • Loading branch information
notgiven688 authored Oct 14, 2023
1 parent b622d0e commit 06be001
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/JitterDemo/Demos/SoftBody/PressurizedSphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using Jitter2;
using Jitter2.Collision;
using Jitter2.Collision.Shapes;
Expand All @@ -17,22 +18,18 @@ public class SoftBodySphere : SoftBodyCloth

private class UnitSphere : ISupportMap
{
public UnitSphere(JVector center)
{
GeometricCenter = center;
}

public void SupportMap(in JVector direction, out JVector result)
{
result = GeometricCenter + JVector.Normalize(direction);
result = JVector.Normalize(direction);
}

public JVector GeometricCenter { get; }
public JVector GeometricCenter => throw new NotImplementedException();
}

private static IEnumerable<JTriangle> GenSphereTriangles(JVector offset)
{
return ShapeHelper.MakeHull(new UnitSphere(offset));
return ShapeHelper.MakeHull(new UnitSphere())
.Select(t => new JTriangle(t.V0 + offset, t.V1 + offset, t.V2 + offset));
}

private static IEnumerable<JTriangle> GenSphereTrianglesFromMesh(JVector offset, string filename)
Expand Down

0 comments on commit 06be001

Please sign in to comment.