-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Update PearlCalculatorLib.PearlCalculationLib to latest version
- Loading branch information
Showing
19 changed files
with
501 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System; | ||
using PearlCalculatorLib.PearlCalculationLib.MathLib; | ||
using PearlCalculatorLib.PearlCalculationLib.World; | ||
|
||
namespace PearlCalculatorLib.PearlCalculationLib.AABB | ||
{ | ||
[Serializable] | ||
public class AABBBox : IEquatable<AABBBox> | ||
{ | ||
public Space3D Min; | ||
public Space3D Max; | ||
|
||
public Space3D Extents => Max - Min; | ||
|
||
public Space3D Center => (Min + Max) * 0.5; | ||
|
||
public AABBBox() | ||
{ | ||
|
||
} | ||
|
||
public AABBBox(double x2 , double y2 , double z2) | ||
{ | ||
Min = Space3D.Zero; | ||
Max = new Space3D(x2 , y2 , z2); | ||
} | ||
|
||
public AABBBox(double x1 , double y1 , double z1 , double x2 , double y2 , double z2) | ||
{ | ||
Min = new Space3D(x1 , y1 , z1); | ||
Max = new Space3D(x2 , y2 , z2); | ||
} | ||
|
||
public AABBBox(Space3D min , Space3D max) | ||
{ | ||
Min = min; | ||
Max = max; | ||
} | ||
|
||
public AABBBox(Space3D max) : this(Space3D.Zero , max) { } | ||
|
||
public AABBBox ReSize(Space3D min , Space3D max) | ||
{ | ||
Min = min; | ||
Max = max; | ||
return this; | ||
} | ||
|
||
public bool Contains(Space3D point) | ||
{ | ||
return MathHelper.IsInside(Min.X , Max.X , point.X) && | ||
MathHelper.IsInside(Min.Y , Max.Y , point.Y) && | ||
MathHelper.IsInside(Min.Z , Max.Z , point.Z); | ||
} | ||
|
||
public bool Intersects(AABBBox bounds) | ||
{ | ||
return Equals(bounds) || ( | ||
Max.X >= bounds.Min.X && | ||
Max.Y >= bounds.Min.Y && | ||
Max.Z >= bounds.Min.Z && | ||
Min.X <= bounds.Max.X && | ||
Min.Y <= bounds.Max.Y && | ||
Min.Z <= bounds.Max.Z); | ||
} | ||
|
||
public override bool Equals(object obj) => obj is AABBBox s && Equals(s); | ||
|
||
public bool Equals(AABBBox other) | ||
{ | ||
if(other is null) | ||
return false; | ||
if(ReferenceEquals(this , other)) | ||
return true; | ||
return Min == other.Min && Max == other.Max; | ||
} | ||
|
||
public static bool operator ==(AABBBox left , AABBBox right) => left is { } && left.Equals(right); | ||
|
||
public static bool operator !=(AABBBox left , AABBBox right) => left is { } && !left.Equals(right); | ||
|
||
public override int GetHashCode() => Min.GetHashCode() ^ Max.GetHashCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 11 additions & 30 deletions
41
PearlCalculatorLib/PearlCalculationLib/Entity/PearlEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,39 @@ | ||
using PearlCalculatorLib.PearlCalculationLib.MathLib; | ||
using PearlCalculatorLib.PearlCalculationLib.World; | ||
using PearlCalculatorLib.PearlCalculationLib.World; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace PearlCalculatorLib.PearlCalculationLib.Entity | ||
{ | ||
[Serializable] | ||
public class PearlEntity : Entity, ICloneable | ||
public class PearlEntity : Entity, IDeepCloneable<PearlEntity> | ||
{ | ||
public override Space3D Size => new Space3D(0.25 , 0.25 , 0.25); | ||
public override Space3D Size => new Space3D(0.25, 0.25, 0.25); | ||
|
||
|
||
|
||
public PearlEntity(Space3D momemtum , Space3D position) | ||
public PearlEntity(Space3D momemtum, Space3D position) | ||
{ | ||
Motion = momemtum; | ||
Position = position; | ||
} | ||
|
||
public PearlEntity(PearlEntity pearl) : this(pearl.Motion , pearl.Position) { } | ||
public PearlEntity(PearlEntity pearl) : this(pearl.Motion, pearl.Position) { } | ||
|
||
public PearlEntity() | ||
{ | ||
|
||
} | ||
|
||
public PearlEntity WithPosition(double x , double y , double z) | ||
{ | ||
Position = new Space3D(x , y , z); | ||
return this; | ||
} | ||
|
||
public PearlEntity WithVector(double x , double y , double z) | ||
{ | ||
Motion = new Space3D(x , y , z); | ||
return this; | ||
} | ||
|
||
public override void Tick() | ||
{ | ||
Position += Motion; | ||
Motion *= 0.99; | ||
Motion.Y -= 0.03; | ||
} | ||
|
||
public object Clone() | ||
public PearlEntity DeepClone() => new PearlEntity | ||
{ | ||
PearlEntity pearl = new PearlEntity | ||
{ | ||
Position = Position , | ||
Motion = Motion | ||
}; | ||
return pearl; | ||
} | ||
Position = Position, | ||
Motion = Motion | ||
}; | ||
|
||
object IDeepCloneable.DeepClone() => DeepClone(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace PearlCalculatorLib.PearlCalculationLib | ||
{ | ||
public interface IDeepCloneable | ||
{ | ||
object DeepClone(); | ||
} | ||
|
||
public interface IDeepCloneable<T> : IDeepCloneable | ||
{ | ||
new T DeepClone(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 12 additions & 16 deletions
28
PearlCalculatorLib/PearlCalculationLib/Result/TNTCalculationResultSortComparer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.